@tarojs/plugin-platform-harmony-ets 4.0.0-beta.22 → 4.0.0-beta.23
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/index.ts +22 -12
- package/dist/apis/ui/animation/animation.ts +2 -1
- package/dist/apis/wxml/IntersectionObserver.ts +5 -1
- package/dist/components-harmony-ets/button.ets +8 -1
- package/dist/components-harmony-ets/canvas.ets +13 -5
- package/dist/components-harmony-ets/checkbox.ets +7 -3
- package/dist/components-harmony-ets/form.ets +10 -2
- package/dist/components-harmony-ets/icon.ets +8 -1
- package/dist/components-harmony-ets/image.ets +8 -1
- package/dist/components-harmony-ets/input.ets +2 -1
- package/dist/components-harmony-ets/label.ets +9 -2
- package/dist/components-harmony-ets/movableArea.ets +10 -3
- package/dist/components-harmony-ets/movableView.ets +10 -3
- package/dist/components-harmony-ets/picker.ets +1 -1
- package/dist/components-harmony-ets/progress.ets +8 -1
- package/dist/components-harmony-ets/radio.ets +7 -3
- package/dist/components-harmony-ets/scrollView.ets +9 -2
- package/dist/components-harmony-ets/slider.ets +2 -1
- package/dist/components-harmony-ets/style.ets +40 -4
- package/dist/components-harmony-ets/swiper.ets +8 -1
- package/dist/components-harmony-ets/switch.ets +3 -1
- package/dist/components-harmony-ets/text.ets +8 -1
- package/dist/components-harmony-ets/textArea.ets +2 -1
- package/dist/components-harmony-ets/utils/flexManager.ets +2 -2
- package/dist/components-harmony-ets/utils/helper.ets +1 -3
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +4 -59
- package/dist/components-harmony-ets/video.ets +9 -2
- package/dist/components-harmony-ets/view.ets +9 -2
- package/dist/runtime-ets/current.ts +1 -0
- package/dist/runtime-ets/dom/bind.ts +3 -3
- package/dist/runtime-ets/dom/cssNesting.ts +104 -22
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +2 -5
- package/dist/runtime-ets/dom/element/element.ts +1 -5
- package/dist/runtime-ets/dom/element/form.ts +4 -14
- package/dist/runtime-ets/dom/element/progress.ts +0 -1
- package/dist/runtime-ets/dom/element/text.ts +0 -8
- package/dist/runtime-ets/dom/element/video.ts +4 -3
- package/dist/runtime-ets/dom/node.ts +12 -11
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +5 -4
- package/dist/runtime-ets/dom/stylesheet/util.ts +12 -10
- package/dist/runtime-ets/utils/index.ts +16 -2
- package/dist/runtime-ets/utils/info.ts +1 -1
- package/dist/runtime-framework/react/native-page.ts +1 -0
- package/dist/runtime-framework/react/page.ts +1 -0
- package/dist/runtime-framework/solid/reconciler/props.ts +3 -8
- package/dist/runtime-utils.js +16 -10
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +16 -10
- package/dist/runtime.js.map +1 -1
- package/package.json +10 -9
- /package/dist/template/{container.js/container.js → container.js} +0 -0
package/dist/apis/index.ts
CHANGED
|
@@ -58,27 +58,37 @@ export function initPxTransform ({
|
|
|
58
58
|
|
|
59
59
|
const display = _display.getDefaultDisplaySync()
|
|
60
60
|
|
|
61
|
+
let displayWidth = display.width
|
|
62
|
+
let ratioCache: number | false = false
|
|
61
63
|
let designWidthFunc: (input: number) => number
|
|
64
|
+
let designWidth = defaultDesignWidth
|
|
65
|
+
let deviceRatio = defaultDesignRatio
|
|
62
66
|
function getRatio (value: number) {
|
|
63
|
-
|
|
64
|
-
if (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
// Note: 提前调用 display 可能无法获取正确值
|
|
68
|
+
if (ratioCache === false || displayWidth !== display.width) {
|
|
69
|
+
const config = (Current as any).taro?.config || {}
|
|
70
|
+
if (!isFunction(designWidthFunc)) {
|
|
71
|
+
designWidthFunc = isFunction(config.designWidth)
|
|
72
|
+
? config.designWidth
|
|
73
|
+
: () => config.designWidth
|
|
74
|
+
designWidth = designWidthFunc(value) || defaultDesignWidth
|
|
75
|
+
deviceRatio = config.deviceRatio || defaultDesignRatio
|
|
76
|
+
if (!(designWidth in deviceRatio)) {
|
|
77
|
+
throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
displayWidth = display.width
|
|
81
|
+
ratioCache = Math.min(display.width, display.height) / designWidth / deviceRatio[designWidth]
|
|
73
82
|
}
|
|
74
|
-
|
|
83
|
+
|
|
84
|
+
return ratioCache
|
|
75
85
|
}
|
|
76
86
|
|
|
77
87
|
// Note: 设置为 style 单位时会自动完成设计稿转换,设计开发者调用 API 时也许抹平差异,例如 pageScrollTo[option.offsetTop]
|
|
78
88
|
export function pxTransformHelper (size: number, unit?: string, isNumber = false): number | string {
|
|
79
89
|
const config = (Current as any).taro?.config || {}
|
|
80
90
|
const targetUnit = unit || config.targetUnit || defaultTargetUnit
|
|
81
|
-
|
|
91
|
+
|
|
82
92
|
if (targetUnit === 'PX') {
|
|
83
93
|
return px2vp(size * display.scaledDensity) + 'vp'
|
|
84
94
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import matrix4 from '@ohos.matrix4'
|
|
2
|
+
import { isUndefined } from '@tarojs/shared'
|
|
2
3
|
|
|
3
4
|
import { temporarilyNotSupport } from '../../utils'
|
|
4
5
|
|
|
@@ -110,7 +111,7 @@ export class Animation implements Taro.Animation {
|
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
scale (sx: number, sy?: number | undefined): Taro.Animation {
|
|
113
|
-
this.rule.scale = { x: sx, y: sy }
|
|
114
|
+
this.rule.scale = { x: sx, y: isUndefined(sy) ? sx : sy }
|
|
114
115
|
return this
|
|
115
116
|
}
|
|
116
117
|
|
|
@@ -45,7 +45,7 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
45
45
|
|
|
46
46
|
public observe (targetSelector: string, callback: Taro.IntersectionObserver.ObserveCallback): void {
|
|
47
47
|
if (!this._component) return
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
const { observeAll, thresholds } = this._options
|
|
50
50
|
const node = findChildNodeWithDFS(this._component, targetSelector, observeAll)
|
|
51
51
|
this._observerNodes = node
|
|
@@ -68,6 +68,10 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
68
68
|
callback(this.handleResult(isVisible, currentRatio))
|
|
69
69
|
})
|
|
70
70
|
}
|
|
71
|
+
} else {
|
|
72
|
+
callback({
|
|
73
|
+
errMsg: 'IntersectionObserver.observe:fail cannot find the node for selector.'
|
|
74
|
+
})
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
|
|
@@ -98,6 +98,13 @@ export default struct TaroButton {
|
|
|
98
98
|
@Builder customBuilder() {}
|
|
99
99
|
@BuilderParam createLazyChildren: (node: TaroButtonElement) => void = this.customBuilder
|
|
100
100
|
@ObjectLink node: TaroButtonElement
|
|
101
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
102
|
+
|
|
103
|
+
aboutToAppear(): void {
|
|
104
|
+
if (this.node) {
|
|
105
|
+
this.node._instance = this
|
|
106
|
+
}
|
|
107
|
+
}
|
|
101
108
|
|
|
102
109
|
build() {
|
|
103
110
|
if (this.node?.hmStyle?.display !== 'none') {
|
|
@@ -112,7 +119,7 @@ export default struct TaroButton {
|
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
121
|
.themeStyles(getThemeAttributes(this.node))
|
|
115
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
122
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
116
123
|
.constraintSize({
|
|
117
124
|
minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
|
|
118
125
|
minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type { TaroCanvasElement } from '@tarojs/runtime'
|
|
1
|
+
import type { TaroAny, TaroCanvasElement } from '@tarojs/runtime'
|
|
2
2
|
import { cancelAnimationFrame, requestAnimationFrame } from '@tarojs/runtime'
|
|
3
|
-
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
4
|
|
|
5
5
|
@Component
|
|
6
6
|
export default struct TaroCanvas {
|
|
7
7
|
@ObjectLink node: TaroCanvasElement
|
|
8
8
|
rafId: number = 0
|
|
9
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
9
10
|
|
|
11
|
+
aboutToAppear(): void {
|
|
12
|
+
if (this.node) {
|
|
13
|
+
this.node._instance = this
|
|
14
|
+
}
|
|
15
|
+
}
|
|
10
16
|
|
|
11
17
|
aboutToDisappear() {
|
|
12
18
|
if(this.rafId) {
|
|
@@ -16,9 +22,11 @@ export default struct TaroCanvas {
|
|
|
16
22
|
|
|
17
23
|
build() {
|
|
18
24
|
Canvas(this.node._context)
|
|
19
|
-
.
|
|
20
|
-
|
|
21
|
-
|
|
25
|
+
.attributeModifier(commonStyleModify.setNode(this.node as TaroAny, {
|
|
26
|
+
width: '100%',
|
|
27
|
+
height: '100%',
|
|
28
|
+
backgroundColor: '#ffff00'
|
|
29
|
+
}).setAnimationStyle(this.overwriteStyle))
|
|
22
30
|
.onReady(() => {
|
|
23
31
|
const context = this.node._context
|
|
24
32
|
|
|
@@ -38,10 +38,12 @@ export struct TaroCheckbox {
|
|
|
38
38
|
@Builder customBuilder() {}
|
|
39
39
|
@BuilderParam createLazyChildren: (node: TaroCheckboxElement) => void = this.customBuilder
|
|
40
40
|
@ObjectLink node: TaroCheckboxElement
|
|
41
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
41
42
|
|
|
42
43
|
aboutToAppear () {
|
|
43
44
|
if (this.node && !this.node._isInit) {
|
|
44
45
|
this.node._isInit = true
|
|
46
|
+
this.node._instance = this
|
|
45
47
|
this.node._reset = this.node.checked || false
|
|
46
48
|
}
|
|
47
49
|
}
|
|
@@ -51,7 +53,7 @@ export struct TaroCheckbox {
|
|
|
51
53
|
Stack() {
|
|
52
54
|
Row() {
|
|
53
55
|
Checkbox(getOptions(this.node))
|
|
54
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
56
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
55
57
|
.checkboxAttr(getAttributes(this.node))
|
|
56
58
|
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
57
59
|
.select(this.node.checked)
|
|
@@ -99,6 +101,7 @@ export struct TaroCheckboxGroup {
|
|
|
99
101
|
@Builder customBuilder() {}
|
|
100
102
|
@BuilderParam createLazyChildren: (node: TaroCheckboxGroupElement) => void = this.customBuilder
|
|
101
103
|
@ObjectLink node: TaroCheckboxGroupElement
|
|
104
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
102
105
|
|
|
103
106
|
@Styles visibleChangeEvent () {
|
|
104
107
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -106,6 +109,7 @@ export struct TaroCheckboxGroup {
|
|
|
106
109
|
|
|
107
110
|
aboutToAppear () {
|
|
108
111
|
if (this.node) {
|
|
112
|
+
this.node._instance = this
|
|
109
113
|
// 阻止事件冒泡传递上去
|
|
110
114
|
this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
|
|
111
115
|
e.stopPropagation()
|
|
@@ -129,7 +133,7 @@ export struct TaroCheckboxGroup {
|
|
|
129
133
|
Row() {
|
|
130
134
|
this.createLazyChildren(this.node)
|
|
131
135
|
}
|
|
132
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
136
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
133
137
|
.defaultEvent()
|
|
134
138
|
.visibleChangeEvent()
|
|
135
139
|
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
@@ -138,7 +142,7 @@ export struct TaroCheckboxGroup {
|
|
|
138
142
|
Column() {
|
|
139
143
|
this.createLazyChildren(this.node)
|
|
140
144
|
}
|
|
141
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
145
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
142
146
|
.defaultEvent()
|
|
143
147
|
.visibleChangeEvent()
|
|
144
148
|
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
@@ -13,13 +13,21 @@ export default struct TaroForm {
|
|
|
13
13
|
@BuilderParam createLazyChildren: (node: TaroFormElement) => void = this.customBuilder
|
|
14
14
|
@ObjectLink node: TaroFormElement
|
|
15
15
|
|
|
16
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
17
|
+
|
|
18
|
+
aboutToAppear(): void {
|
|
19
|
+
if (this.node) {
|
|
20
|
+
this.node._instance = this
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
build() {
|
|
17
25
|
if (this.node?.hmStyle?.display !== 'none') {
|
|
18
26
|
if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
|
|
19
27
|
Row() {
|
|
20
28
|
this.createLazyChildren(this.node)
|
|
21
29
|
}
|
|
22
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
30
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
23
31
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
24
32
|
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
25
33
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
@@ -32,7 +40,7 @@ export default struct TaroForm {
|
|
|
32
40
|
Column() {
|
|
33
41
|
this.createLazyChildren(this.node)
|
|
34
42
|
}
|
|
35
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
43
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
36
44
|
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
37
45
|
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
38
46
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
@@ -53,6 +53,13 @@ export default struct TaroIcon {
|
|
|
53
53
|
@Builder customBuilder() {}
|
|
54
54
|
@BuilderParam createLazyChildren: (node: TaroIconElement) => void = this.customBuilder
|
|
55
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
|
+
}
|
|
56
63
|
|
|
57
64
|
build() {
|
|
58
65
|
if (this.node?.hmStyle?.display !== 'none') {
|
|
@@ -62,7 +69,7 @@ export default struct TaroIcon {
|
|
|
62
69
|
.attributeModifier(commonStyleModify.setNode(this.node, {
|
|
63
70
|
width: convertNumber2PX(23),
|
|
64
71
|
height: convertNumber2PX(23)
|
|
65
|
-
}))
|
|
72
|
+
}).setAnimationStyle(this.overwriteStyle))
|
|
66
73
|
.size({
|
|
67
74
|
width: convertNumber2VP(Number(this.node._attrs.size) || 23),
|
|
68
75
|
height: convertNumber2VP(Number(this.node._attrs.size) || 23),
|
|
@@ -21,6 +21,13 @@ export default struct TaroImage {
|
|
|
21
21
|
@Builder customBuilder() {}
|
|
22
22
|
@BuilderParam createLazyChildren: (node: TaroImageElement) => void = this.customBuilder
|
|
23
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
|
+
}
|
|
24
31
|
|
|
25
32
|
build() {
|
|
26
33
|
if (this.node?.hmStyle?.display !== 'none') {
|
|
@@ -30,7 +37,7 @@ export default struct TaroImage {
|
|
|
30
37
|
this.node._nodeInfo.areaInfo = res[1]
|
|
31
38
|
}))
|
|
32
39
|
.objectFit(getImageMode(this.node.getAttribute('mode')))
|
|
33
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
40
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
34
41
|
.onComplete(e => eventHandler(e, 'complete', this.node))
|
|
35
42
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
36
43
|
}
|
|
@@ -51,6 +51,7 @@ export default struct TaroInput {
|
|
|
51
51
|
@Builder customBuilder() {}
|
|
52
52
|
@BuilderParam createLazyChildren: (node: TaroInputElement) => void = this.customBuilder
|
|
53
53
|
@ObjectLink node: TaroInputElement
|
|
54
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
54
55
|
|
|
55
56
|
aboutToAppear () {
|
|
56
57
|
if (this.node) {
|
|
@@ -72,7 +73,7 @@ export default struct TaroInput {
|
|
|
72
73
|
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
73
74
|
.placeholderColor(getPlaceholderColor(this.node))
|
|
74
75
|
.enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
|
|
75
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
76
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
76
77
|
.styles(this.node?.hmStyle)
|
|
77
78
|
.attrs(getAttributes(this.node))
|
|
78
79
|
.onChange((value: string) => {
|
|
@@ -39,6 +39,13 @@ export default struct TaroLabel {
|
|
|
39
39
|
@Builder customBuilder() {}
|
|
40
40
|
@BuilderParam createLazyChildren: (node:TaroLabelElement) => void = this.customBuilder
|
|
41
41
|
@ObjectLink node:TaroLabelElement
|
|
42
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
43
|
+
|
|
44
|
+
aboutToAppear(): void {
|
|
45
|
+
if (this.node) {
|
|
46
|
+
this.node._instance = this
|
|
47
|
+
}
|
|
48
|
+
}
|
|
42
49
|
|
|
43
50
|
build() {
|
|
44
51
|
if (this.node?.hmStyle?.display !== 'none') {
|
|
@@ -46,7 +53,7 @@ export default struct TaroLabel {
|
|
|
46
53
|
Row() {
|
|
47
54
|
this.createLazyChildren(this.node)
|
|
48
55
|
}
|
|
49
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
56
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
50
57
|
.onClick((e: ClickEvent) => {
|
|
51
58
|
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
52
59
|
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
@@ -65,7 +72,7 @@ export default struct TaroLabel {
|
|
|
65
72
|
Column() {
|
|
66
73
|
this.createLazyChildren(this.node)
|
|
67
74
|
}
|
|
68
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
75
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
69
76
|
.onClick((e: ClickEvent) => {
|
|
70
77
|
const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
|
|
71
78
|
const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TaroMovableAreaElement, TaroMovableViewElement} from '@tarojs/runtime'
|
|
1
|
+
import type { TaroAny, TaroMovableAreaElement, TaroMovableViewElement } from '@tarojs/runtime'
|
|
2
2
|
import { rowModify, columnModify } from './style'
|
|
3
3
|
|
|
4
4
|
import { FlexManager } from './utils/flexManager'
|
|
@@ -8,6 +8,13 @@ export default struct TaroMovableArea {
|
|
|
8
8
|
@Builder customBuilder() {}
|
|
9
9
|
@BuilderParam createLazyChildren: (node: TaroMovableAreaElement) => void = this.customBuilder
|
|
10
10
|
@ObjectLink node: TaroMovableAreaElement
|
|
11
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
12
|
+
|
|
13
|
+
aboutToAppear(): void {
|
|
14
|
+
if (this.node) {
|
|
15
|
+
this.node._instance = this
|
|
16
|
+
}
|
|
17
|
+
}
|
|
11
18
|
|
|
12
19
|
build() {
|
|
13
20
|
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
@@ -15,7 +22,7 @@ export default struct TaroMovableArea {
|
|
|
15
22
|
Row() {
|
|
16
23
|
this.createLazyChildren(this.node)
|
|
17
24
|
}
|
|
18
|
-
.attributeModifier(rowModify.setNode(this.node))
|
|
25
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
19
26
|
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
20
27
|
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
21
28
|
.clip(true)
|
|
@@ -51,7 +58,7 @@ export default struct TaroMovableArea {
|
|
|
51
58
|
Column() {
|
|
52
59
|
this.createLazyChildren(this.node)
|
|
53
60
|
}
|
|
54
|
-
.attributeModifier(columnModify.setNode(this.node))
|
|
61
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
55
62
|
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
56
63
|
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
57
64
|
.clip(true)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TaroMovableViewElement } from '@tarojs/runtime'
|
|
1
|
+
import type { TaroAny, TaroMovableViewElement } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import { rowModify, columnModify } from './style'
|
|
4
4
|
|
|
@@ -9,6 +9,13 @@ export default struct TaroMovableView {
|
|
|
9
9
|
@Builder customBuilder() {}
|
|
10
10
|
@BuilderParam createLazyChildren: (node: TaroMovableViewElement) => void = this.customBuilder
|
|
11
11
|
@ObjectLink node: TaroMovableViewElement
|
|
12
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
13
|
+
|
|
14
|
+
aboutToAppear(): void {
|
|
15
|
+
if (this.node) {
|
|
16
|
+
this.node._instance = this
|
|
17
|
+
}
|
|
18
|
+
}
|
|
12
19
|
|
|
13
20
|
build() {
|
|
14
21
|
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
@@ -18,14 +25,14 @@ export default struct TaroMovableView {
|
|
|
18
25
|
Row() {
|
|
19
26
|
this.createLazyChildren(this.node)
|
|
20
27
|
}
|
|
21
|
-
.attributeModifier(rowModify.setNode(this.node))
|
|
28
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
22
29
|
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
23
30
|
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
24
31
|
} else {
|
|
25
32
|
Column() {
|
|
26
33
|
this.createLazyChildren(this.node)
|
|
27
34
|
}
|
|
28
|
-
.attributeModifier(columnModify.setNode(this.node))
|
|
35
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
29
36
|
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
30
37
|
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
31
38
|
}
|
|
@@ -7,7 +7,7 @@ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
|
7
7
|
|
|
8
8
|
import type { TaroAny, TaroEvent } from '@tarojs/runtime'
|
|
9
9
|
|
|
10
|
-
import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from '
|
|
10
|
+
import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from '@tarojs/components/types'
|
|
11
11
|
|
|
12
12
|
interface TimeRange {
|
|
13
13
|
startHH: number
|
|
@@ -12,6 +12,13 @@ export default struct TaroProgress {
|
|
|
12
12
|
@Builder customBuilder() {}
|
|
13
13
|
@BuilderParam createLazyChildren: (node: TaroProgressElement) => void = this.customBuilder
|
|
14
14
|
@ObjectLink node: TaroProgressElement
|
|
15
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
16
|
+
|
|
17
|
+
aboutToAppear(): void {
|
|
18
|
+
if (this.node) {
|
|
19
|
+
this.node._instance = this
|
|
20
|
+
}
|
|
21
|
+
}
|
|
15
22
|
|
|
16
23
|
build() {
|
|
17
24
|
if (this.node && this.node.hmStyle?.display !== 'none') {
|
|
@@ -20,7 +27,7 @@ export default struct TaroProgress {
|
|
|
20
27
|
value: parseFloat(this.node.getAttribute('percent')),
|
|
21
28
|
type: ProgressType.Linear
|
|
22
29
|
})
|
|
23
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
30
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
24
31
|
.color(this.node.getAttribute('activeColor') ?? PROGRESS_ACTIVECOLOR)
|
|
25
32
|
.backgroundColor(this.node.getAttribute('backgroundColor') ?? PROGRESS_BACKGROUNDCOLOR)
|
|
26
33
|
.style({
|
|
@@ -37,10 +37,12 @@ export struct TaroRadio {
|
|
|
37
37
|
@Builder customBuilder() {}
|
|
38
38
|
@BuilderParam createLazyChildren: (node: TaroRadioElement) => void = this.customBuilder
|
|
39
39
|
@ObjectLink node: TaroRadioElement
|
|
40
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
40
41
|
|
|
41
42
|
aboutToAppear () {
|
|
42
43
|
if (this.node && !this.node._isInit) {
|
|
43
44
|
this.node._isInit = true
|
|
45
|
+
this.node._instance = this
|
|
44
46
|
this.node._reset = this.node.checked || false
|
|
45
47
|
}
|
|
46
48
|
}
|
|
@@ -54,7 +56,7 @@ export struct TaroRadio {
|
|
|
54
56
|
value: this.node.value || '',
|
|
55
57
|
})
|
|
56
58
|
.checked(this.node.checked)
|
|
57
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
59
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
58
60
|
.radioAttr(getAttributes(this.node))
|
|
59
61
|
.onChange((value: boolean) => {
|
|
60
62
|
if (this.node) {
|
|
@@ -99,6 +101,7 @@ export struct TaroRadioGroup {
|
|
|
99
101
|
@Builder customBuilder() {}
|
|
100
102
|
@BuilderParam createLazyChildren: (node: TaroRadioGroupElement) => void = this.customBuilder
|
|
101
103
|
@ObjectLink node: TaroRadioGroupElement
|
|
104
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
102
105
|
|
|
103
106
|
@Styles visibleChangeEvent () {
|
|
104
107
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -106,6 +109,7 @@ export struct TaroRadioGroup {
|
|
|
106
109
|
|
|
107
110
|
aboutToAppear () {
|
|
108
111
|
if (this.node) {
|
|
112
|
+
this.node._instance = this
|
|
109
113
|
const childList = this.node.getElementsByTagName<TaroRadioElement>('RADIO')
|
|
110
114
|
childList.forEach(element => {
|
|
111
115
|
element.group = this.node?._attrs.name || this.node?._nid
|
|
@@ -131,7 +135,7 @@ export struct TaroRadioGroup {
|
|
|
131
135
|
Row() {
|
|
132
136
|
this.createLazyChildren(this.node)
|
|
133
137
|
}
|
|
134
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
138
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
135
139
|
.defaultEvent()
|
|
136
140
|
.visibleChangeEvent()
|
|
137
141
|
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
@@ -140,7 +144,7 @@ export struct TaroRadioGroup {
|
|
|
140
144
|
Column() {
|
|
141
145
|
this.createLazyChildren(this.node)
|
|
142
146
|
}
|
|
143
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
147
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
144
148
|
.defaultEvent()
|
|
145
149
|
.visibleChangeEvent()
|
|
146
150
|
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
@@ -62,6 +62,13 @@ export default struct TaroScrollView {
|
|
|
62
62
|
@Builder customBuilder() {}
|
|
63
63
|
@BuilderParam createLazyChildren: (node: TaroScrollViewElement) => void = this.customBuilder
|
|
64
64
|
@ObjectLink node: TaroScrollViewElement
|
|
65
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
66
|
+
|
|
67
|
+
aboutToAppear(): void {
|
|
68
|
+
if (this.node) {
|
|
69
|
+
this.node._instance = this
|
|
70
|
+
}
|
|
71
|
+
}
|
|
65
72
|
|
|
66
73
|
build () {
|
|
67
74
|
if (this.node.hmStyle?.display !== 'none') {
|
|
@@ -74,7 +81,7 @@ export default struct TaroScrollView {
|
|
|
74
81
|
this.createLazyChildren(this.node)
|
|
75
82
|
}
|
|
76
83
|
}
|
|
77
|
-
.attributeModifier(rowModify.setNode(this.node))
|
|
84
|
+
.attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
78
85
|
.width(null)
|
|
79
86
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
80
87
|
this.node._nodeInfo._scroll = areaResult
|
|
@@ -90,7 +97,7 @@ export default struct TaroScrollView {
|
|
|
90
97
|
this.createLazyChildren(this.node)
|
|
91
98
|
}
|
|
92
99
|
}
|
|
93
|
-
.attributeModifier(columnModify.setNode(this.node))
|
|
100
|
+
.attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
94
101
|
.height(null)
|
|
95
102
|
.alignItems(HorizontalAlign.Start)
|
|
96
103
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
@@ -42,6 +42,7 @@ export default struct TaroSlider {
|
|
|
42
42
|
@ObjectLink node: TaroSliderElement
|
|
43
43
|
|
|
44
44
|
@State value: number = 0
|
|
45
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
45
46
|
|
|
46
47
|
aboutToAppear () {
|
|
47
48
|
if (this.node) {
|
|
@@ -64,7 +65,7 @@ export default struct TaroSlider {
|
|
|
64
65
|
style: SliderStyle.OutSet,
|
|
65
66
|
direction: Axis.Horizontal
|
|
66
67
|
})
|
|
67
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
68
|
+
.attributeModifier(commonStyleModify.setNode(node).setAnimationStyle(this.overwriteStyle))
|
|
68
69
|
.attrs(getAttributes(node))
|
|
69
70
|
.width(!!node._attrs.showValue ? '90%' : '100%')
|
|
70
71
|
.themeStyles(!!node._attrs.disabled)
|
|
@@ -1,13 +1,20 @@
|
|
|
1
|
-
import type { HarmonyStyle, TaroElement, TaroStyleType } from '@tarojs/runtime'
|
|
2
|
-
import { isUndefined } from '
|
|
1
|
+
import type { TaroAny, HarmonyStyle, TaroElement, TaroStyleType } from '@tarojs/runtime'
|
|
2
|
+
import { isUndefined } from '@tarojs/shared'
|
|
3
3
|
import { computeBackgroundPosition } from './utils'
|
|
4
4
|
import { getNormalAttributes } from './utils/helper'
|
|
5
5
|
import { isMaxWidthView } from './utils/styles'
|
|
6
6
|
|
|
7
7
|
class CommonStyleModify implements AttributeModifier<CommonAttribute> {
|
|
8
|
+
initStyle?: TaroStyleType
|
|
8
9
|
node: TaroElement | null = null
|
|
9
10
|
style: TaroStyleType | null = null
|
|
10
|
-
|
|
11
|
+
overwriteStyle: Record<string, TaroAny> = {}
|
|
12
|
+
|
|
13
|
+
setAnimationStyle (overwriteStyle: Record<string, TaroAny>) {
|
|
14
|
+
this.overwriteStyle = overwriteStyle
|
|
15
|
+
|
|
16
|
+
return this
|
|
17
|
+
}
|
|
11
18
|
|
|
12
19
|
setNode (node: TaroElement, initStyle?: TaroStyleType) {
|
|
13
20
|
this.node = node
|
|
@@ -28,6 +35,8 @@ class CommonStyleModify implements AttributeModifier<CommonAttribute> {
|
|
|
28
35
|
if (this.node && this.style) {
|
|
29
36
|
setNormalAttributeIntoInstance(instance, this.style, this.node)
|
|
30
37
|
}
|
|
38
|
+
|
|
39
|
+
setAnimationAttributeIntoInstance(instance, this.overwriteStyle)
|
|
31
40
|
}
|
|
32
41
|
}
|
|
33
42
|
|
|
@@ -59,6 +68,8 @@ class RowStyleModify extends CommonStyleModify {
|
|
|
59
68
|
maxHeight: this.style.maxHeight
|
|
60
69
|
})
|
|
61
70
|
}
|
|
71
|
+
|
|
72
|
+
setAnimationAttributeIntoInstance(instance, this.overwriteStyle)
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
75
|
|
|
@@ -73,9 +84,32 @@ class ColumnStyleModify extends CommonStyleModify {
|
|
|
73
84
|
maxHeight: this.style.maxHeight
|
|
74
85
|
})
|
|
75
86
|
}
|
|
87
|
+
|
|
88
|
+
setAnimationAttributeIntoInstance(instance, this.overwriteStyle)
|
|
76
89
|
}
|
|
77
90
|
}
|
|
78
91
|
|
|
92
|
+
function setAnimationAttributeIntoInstance(instance: CommonAttribute, overwriteStyle: Record<string, TaroAny>) {
|
|
93
|
+
// Animation 需要提前和 @State 变量绑定才能产生动画效果,因此不能做 if else 判断
|
|
94
|
+
instance.translate({
|
|
95
|
+
x: overwriteStyle.translate?.x,
|
|
96
|
+
y: overwriteStyle.translate?.y,
|
|
97
|
+
z: overwriteStyle.translate?.z,
|
|
98
|
+
}).scale({
|
|
99
|
+
x: overwriteStyle.scale?.x,
|
|
100
|
+
y: overwriteStyle.scale?.y,
|
|
101
|
+
z: overwriteStyle.scale?.z,
|
|
102
|
+
centerX: overwriteStyle.transformOrigin?.x,
|
|
103
|
+
centerY: overwriteStyle.transformOrigin?.y,
|
|
104
|
+
}).rotate({
|
|
105
|
+
x: overwriteStyle.rotate?.x,
|
|
106
|
+
y: overwriteStyle.rotate?.y,
|
|
107
|
+
z: overwriteStyle.rotate?.z,
|
|
108
|
+
centerX: overwriteStyle.transformOrigin?.x,
|
|
109
|
+
centerY: overwriteStyle.transformOrigin?.y,
|
|
110
|
+
angle: overwriteStyle.rotate?.angle,
|
|
111
|
+
})
|
|
112
|
+
}
|
|
79
113
|
|
|
80
114
|
function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroStyleType, node?: TaroElement | null) {
|
|
81
115
|
if (!isUndefined(style.id)) {
|
|
@@ -113,7 +147,9 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
|
|
|
113
147
|
if (node) {
|
|
114
148
|
instance.width(isMaxWidthView(node as TaroElement) && isUndefined(style.width) ? '100%' : style.width)
|
|
115
149
|
} else {
|
|
116
|
-
|
|
150
|
+
if (!isUndefined(style.width)) {
|
|
151
|
+
instance.width(style.width)
|
|
152
|
+
}
|
|
117
153
|
}
|
|
118
154
|
if (!isUndefined(style.height)) {
|
|
119
155
|
instance.height(style.height)
|
|
@@ -44,13 +44,20 @@ export default struct TaroSwiper {
|
|
|
44
44
|
@Builder customBuilder() {}
|
|
45
45
|
@BuilderParam createLazyChildren: (node: TaroSwiperElement) => void = this.customBuilder
|
|
46
46
|
@ObjectLink node: TaroSwiperElement
|
|
47
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
48
|
+
|
|
49
|
+
aboutToAppear(): void {
|
|
50
|
+
if (this.node) {
|
|
51
|
+
this.node._instance = this
|
|
52
|
+
}
|
|
53
|
+
}
|
|
47
54
|
|
|
48
55
|
build () {
|
|
49
56
|
if (this.node.hmStyle?.display !== 'none') {
|
|
50
57
|
Swiper(this.node.controller) {
|
|
51
58
|
this.createLazyChildren(this.node)
|
|
52
59
|
}
|
|
53
|
-
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
60
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
54
61
|
.swiperAttr(getSwiperAttributes(this.node))
|
|
55
62
|
.indicatorStyle({
|
|
56
63
|
color: this.node.getAttribute('indicatorColor'),
|