@tarojs/plugin-platform-harmony-ets 4.0.0-beta.3 → 4.0.0-beta.4

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.
@@ -1,76 +1,10 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
-
4
- import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { getNodeThresholds, shouldBindEvent } from './utils/helper'
5
5
 
6
6
  import type { RichTextProps } from '@tarojs/components/types/RichText'
7
- import type { TaroAny, TaroStyleType, TaroRichTextElement } from '@tarojs/runtime'
8
-
9
- @Extend(RichText)
10
- function attrs (style: TaroStyleType) {
11
- .id(style.id)
12
- .key(style.id)
13
- .flexGrow(style.flexGrow)
14
- .flexShrink(style.flexShrink)
15
- .flexBasis(style.flexBasis)
16
- .alignSelf(style.alignSelf)
17
- .padding({
18
- top: style.paddingTop,
19
- right: style.paddingRight,
20
- bottom: style.paddingBottom,
21
- left: style.paddingLeft
22
- })
23
- .margin({
24
- top: style.marginTop,
25
- right: style.marginRight,
26
- bottom: style.marginBottom,
27
- left: style.marginLeft
28
- })
29
- .width(style.width)
30
- .height(style.height)
31
- .constraintSize({
32
- minWidth: style.minWidth,
33
- maxWidth: style.maxWidth,
34
- minHeight: style.minHeight,
35
- maxHeight: style.maxHeight
36
- })
37
- .backgroundColor(style.backgroundColor)
38
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
39
- .backgroundImageSize(style.backgroundSize)
40
- .backgroundImagePosition(style.backgroundPosition)
41
- .borderStyle({
42
- top: style.borderTopStyle,
43
- right: style.borderRightStyle,
44
- bottom: style.borderBottomStyle,
45
- left: style.borderLeftStyle
46
- })
47
- .borderWidth({
48
- top: style.borderTopWidth,
49
- right: style.borderRightWidth,
50
- bottom: style.borderBottomWidth,
51
- left: style.borderLeftWidth
52
- })
53
- .borderColor({
54
- top: style.borderTopColor,
55
- right: style.borderRightColor,
56
- bottom: style.borderBottomColor,
57
- left: style.borderLeftColor
58
- })
59
- .borderRadius({
60
- topLeft: style.borderTopLeftRadius,
61
- topRight: style.borderTopRightRadius,
62
- bottomLeft: style.borderBottomLeftRadius,
63
- bottomRight: style.borderBottomRightRadius
64
- })
65
- .zIndex(style.zIndex)
66
- .opacity(style.opacity)
67
- .linearGradient(style.linearGradient)
68
- .clip(style.overflow)
69
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
70
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
71
- .transform(style.transform)
72
- }
73
-
7
+ import type { TaroAny, TaroRichTextElement } from '@tarojs/runtime'
74
8
 
75
9
  function generateText (node: TaroRichTextElement): string {
76
10
  return parseHtmlNode(node._attrs.nodes || '')
@@ -79,7 +13,7 @@ function generateText (node: TaroRichTextElement): string {
79
13
  @Builder
80
14
  export default function TaroRichText (node: TaroRichTextElement) {
81
15
  RichText(generateText(node))
82
- .attrs(getNormalAttributes(node))
16
+ .attributeModifier(commonStyleModify.setNode(node))
83
17
  .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
84
18
  .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
85
19
  node._nodeInfo.areaInfo = res[1]
@@ -1,10 +1,11 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
+ import commonStyleModify from './style'
3
4
  import { createLazyChildren } from './render'
4
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
6
  import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
6
7
 
7
- import type { TaroAny, TaroStyleType, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
8
+ import type { TaroAny, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
8
9
 
9
10
  interface ScrollViewAttrs {
10
11
  scrollBar: BarState
@@ -22,135 +23,6 @@ interface ScrollViewEvent {
22
23
  scrollHeight: number
23
24
  }
24
25
 
25
- @Extend(Row)
26
- function rowAttrs (style: TaroStyleType) {
27
- .id(style.id)
28
- .key(style.id)
29
- .flexGrow(style.flexGrow)
30
- .flexShrink(style.flexShrink)
31
- .flexBasis(style.flexBasis)
32
- .alignSelf(style.alignSelf)
33
- .padding({
34
- top: style.paddingTop,
35
- right: style.paddingRight,
36
- bottom: style.paddingBottom,
37
- left: style.paddingLeft
38
- })
39
- .margin({
40
- top: style.marginTop,
41
- right: style.marginRight,
42
- bottom: style.marginBottom,
43
- left: style.marginLeft
44
- })
45
- .height(style.height)
46
- .constraintSize({
47
- minWidth: style.minWidth || style.width,
48
- maxWidth: style.maxWidth,
49
- minHeight: style.minHeight,
50
- maxHeight: style.maxHeight
51
- })
52
- .backgroundColor(style.backgroundColor)
53
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
54
- .backgroundImageSize(style.backgroundSize)
55
- .backgroundImagePosition(style.backgroundPosition)
56
- .borderStyle({
57
- top: style.borderTopStyle,
58
- right: style.borderRightStyle,
59
- bottom: style.borderBottomStyle,
60
- left: style.borderLeftStyle
61
- })
62
- .borderWidth({
63
- top: style.borderTopWidth,
64
- right: style.borderRightWidth,
65
- bottom: style.borderBottomWidth,
66
- left: style.borderLeftWidth
67
- })
68
- .borderColor({
69
- top: style.borderTopColor,
70
- right: style.borderRightColor,
71
- bottom: style.borderBottomColor,
72
- left: style.borderLeftColor
73
- })
74
- .borderRadius({
75
- topLeft: style.borderTopLeftRadius,
76
- topRight: style.borderTopRightRadius,
77
- bottomLeft: style.borderBottomLeftRadius,
78
- bottomRight: style.borderBottomRightRadius
79
- })
80
- .zIndex(style.zIndex)
81
- .opacity(style.opacity)
82
- .linearGradient(style.linearGradient)
83
- .clip(style.overflow)
84
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
85
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
86
- .transform(style.transform)
87
- }
88
-
89
- @Extend(Column)
90
- function columnAttrs (style: TaroStyleType) {
91
- .id(style.id)
92
- .key(style.id)
93
- .flexGrow(style.flexGrow)
94
- .flexShrink(style.flexShrink)
95
- .flexBasis(style.flexBasis)
96
- .alignSelf(style.alignSelf)
97
- .padding({
98
- top: style.paddingTop,
99
- right: style.paddingRight,
100
- bottom: style.paddingBottom,
101
- left: style.paddingLeft
102
- })
103
- .margin({
104
- top: style.marginTop,
105
- right: style.marginRight,
106
- bottom: style.marginBottom,
107
- left: style.marginLeft
108
- })
109
- .width(style.width)
110
- .constraintSize({
111
- minWidth: style.minWidth,
112
- maxWidth: style.maxWidth,
113
- minHeight: style.minHeight || style.height,
114
- maxHeight: style.maxHeight
115
- })
116
- .backgroundColor(style.backgroundColor)
117
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
118
- .backgroundImageSize(style.backgroundSize)
119
- .backgroundImagePosition(style.backgroundPosition)
120
- .borderStyle({
121
- top: style.borderTopStyle,
122
- right: style.borderRightStyle,
123
- bottom: style.borderBottomStyle,
124
- left: style.borderLeftStyle
125
- })
126
- .borderWidth({
127
- top: style.borderTopWidth,
128
- right: style.borderRightWidth,
129
- bottom: style.borderBottomWidth,
130
- left: style.borderLeftWidth
131
- })
132
- .borderColor({
133
- top: style.borderTopColor,
134
- right: style.borderRightColor,
135
- bottom: style.borderBottomColor,
136
- left: style.borderLeftColor
137
- })
138
- .borderRadius({
139
- topLeft: style.borderTopLeftRadius,
140
- topRight: style.borderTopRightRadius,
141
- bottomLeft: style.borderBottomLeftRadius,
142
- bottomRight: style.borderBottomRightRadius
143
- })
144
- .zIndex(style.zIndex)
145
- .opacity(style.opacity)
146
- .linearGradient(style.linearGradient)
147
- .clip(style.overflow)
148
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
149
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
150
- .transform(style.transform)
151
- }
152
-
153
-
154
26
  function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
155
27
  const _attrs = node._attrs
156
28
  const scrollAttrs: ScrollViewAttrs = {
@@ -192,7 +64,7 @@ export default function TaroScrollView (node: TaroScrollViewElement) {
192
64
  createLazyChildren(node)
193
65
  }
194
66
  .width(null)
195
- .rowAttrs(getNormalAttributes(node))
67
+ .attributeModifier(commonStyleModify.setNode(node))
196
68
  .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
197
69
  node._scroll = areaResult
198
70
  }, node, ['scroll', 'scrollstart', 'scrollend']))
@@ -201,7 +73,7 @@ export default function TaroScrollView (node: TaroScrollViewElement) {
201
73
  createLazyChildren(node)
202
74
  }
203
75
  .height(null)
204
- .columnAttrs(getNormalAttributes(node))
76
+ .attributeModifier(commonStyleModify.setNode(node))
205
77
  .alignItems(HorizontalAlign.Start)
206
78
  .onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
207
79
  node._scroll = areaResult
@@ -1,8 +1,9 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
- import { getNodeThresholds, shouldBindEvent, getNormalAttributes } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { getNodeThresholds, shouldBindEvent } from './utils/helper'
4
5
 
5
- import type { TaroAny, TaroSliderElement, TaroStyleType, TaroEvent } from '@tarojs/runtime'
6
+ import type { TaroAny, TaroSliderElement, TaroEvent } from '@tarojs/runtime'
6
7
 
7
8
  interface SliderAttrs {
8
9
  selectedColor?: ResourceColor
@@ -11,71 +12,6 @@ interface SliderAttrs {
11
12
  blockColor?: ResourceColor
12
13
  }
13
14
 
14
- @Extend(Slider)
15
- function style (style: TaroStyleType) {
16
- .id(style.id)
17
- .key(style.id)
18
- .flexGrow(style.flexGrow)
19
- .flexShrink(style.flexShrink)
20
- .flexBasis(style.flexBasis)
21
- .alignSelf(style.alignSelf)
22
- .padding({
23
- top: style.paddingTop,
24
- right: style.paddingRight,
25
- bottom: style.paddingBottom,
26
- left: style.paddingLeft
27
- })
28
- .margin({
29
- top: style.marginTop,
30
- right: style.marginRight,
31
- bottom: style.marginBottom,
32
- left: style.marginLeft
33
- })
34
- .width(style.width)
35
- .height(style.height)
36
- .constraintSize({
37
- minWidth: style.minWidth,
38
- maxWidth: style.maxWidth,
39
- minHeight: style.minHeight,
40
- maxHeight: style.maxHeight
41
- })
42
- .backgroundColor(style.backgroundColor)
43
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
44
- .backgroundImageSize(style.backgroundSize)
45
- .backgroundImagePosition(style.backgroundPosition)
46
- .borderStyle({
47
- top: style.borderTopStyle,
48
- right: style.borderRightStyle,
49
- bottom: style.borderBottomStyle,
50
- left: style.borderLeftStyle
51
- })
52
- .borderWidth({
53
- top: style.borderTopWidth,
54
- right: style.borderRightWidth,
55
- bottom: style.borderBottomWidth,
56
- left: style.borderLeftWidth
57
- })
58
- .borderColor({
59
- top: style.borderTopColor,
60
- right: style.borderRightColor,
61
- bottom: style.borderBottomColor,
62
- left: style.borderLeftColor
63
- })
64
- .borderRadius({
65
- topLeft: style.borderTopLeftRadius,
66
- topRight: style.borderTopRightRadius,
67
- bottomLeft: style.borderBottomLeftRadius,
68
- bottomRight: style.borderBottomRightRadius
69
- })
70
- .zIndex(style.zIndex)
71
- .opacity(style.opacity)
72
- .linearGradient(style.linearGradient)
73
- .clip(style.overflow)
74
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
75
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
76
- .transform(style.transform)
77
- }
78
-
79
15
  @Extend(Slider)
80
16
  function attrs (attr: SliderAttrs) {
81
17
  .selectedColor(attr.selectedColor)
@@ -126,7 +62,7 @@ export default struct TaroSlider {
126
62
  style: SliderStyle.OutSet,
127
63
  direction: Axis.Horizontal
128
64
  })
129
- .style(getNormalAttributes(node))
65
+ .attributeModifier(commonStyleModify.setNode(node))
130
66
  .attrs(getAttributes(node))
131
67
  .width(!!node._attrs.showValue ? '90%' : '100%')
132
68
  .themeStyles(!!node._attrs.disabled)
@@ -0,0 +1,154 @@
1
+ import type { TaroElement, TaroStyleType } from '@tarojs/runtime'
2
+ import { isUndefined } from '../shared'
3
+ import { getNormalAttributes } from './utils/helper'
4
+
5
+ function getTop (node: TaroElement): Length | number {
6
+ return node?.hmStyle?.top || 0
7
+ }
8
+
9
+ function getLeft (node: TaroElement): Length | number {
10
+ return node?.hmStyle?.left || 0
11
+ }
12
+
13
+ class CommonStyleModify implements AttributeModifier<CommonAttribute> {
14
+ node: TaroElement | null = null
15
+ style: TaroStyleType | null = null
16
+
17
+ setNode (node: TaroElement) {
18
+ this.node = node
19
+ this.style = getNormalAttributes(this.node)
20
+
21
+ return this
22
+ }
23
+
24
+ applyNormalAttribute(instance: CommonAttribute): void {
25
+ if (this.node && this.style) {
26
+
27
+ if (!isUndefined(this.style.id)) {
28
+ instance.id(this.style.id)
29
+ instance.key(this.style.id)
30
+ }
31
+ if (!isUndefined(this.style.flexGrow)) {
32
+ instance.flexGrow(this.style.flexGrow)
33
+ }
34
+ if (!isUndefined(this.style.flexShrink)) {
35
+ instance.flexShrink(this.style.flexShrink)
36
+ }
37
+ if (!isUndefined(this.style.flexBasis)) {
38
+ instance.flexBasis(this.style.flexBasis)
39
+ }
40
+ if (!isUndefined(this.style.alignSelf)) {
41
+ instance.alignSelf(this.style.alignSelf)
42
+ }
43
+ if (!isUndefined(this.style.paddingTop) || !isUndefined(this.style.paddingRight) || !isUndefined(this.style.paddingBottom) || !isUndefined(this.style.paddingLeft)) {
44
+ instance.padding({
45
+ top: this.style.paddingTop,
46
+ right: this.style.paddingRight,
47
+ bottom: this.style.paddingBottom,
48
+ left: this.style.paddingLeft
49
+ })
50
+ }
51
+ if (!isUndefined(this.style.marginTop) || !isUndefined(this.style.marginRight) || !isUndefined(this.style.marginBottom) || !isUndefined(this.style.marginLeft)) {
52
+ instance.margin({
53
+ top: this.style.marginTop,
54
+ right: this.style.marginRight,
55
+ bottom: this.style.marginBottom,
56
+ left: this.style.marginLeft
57
+ })
58
+ }
59
+ if (!isUndefined(this.style.width)) {
60
+ instance.width(this.style.width)
61
+ }
62
+ if (!isUndefined(this.style.height)) {
63
+ instance.height(this.style.height)
64
+ }
65
+ if (!isUndefined(this.style.minWidth) || !isUndefined(this.style.maxWidth) || !isUndefined(this.style.minHeight) || !isUndefined(this.style.maxHeight)) {
66
+ instance.constraintSize({
67
+ minWidth: this.style.minWidth,
68
+ maxWidth: this.style.maxWidth,
69
+ minHeight: this.style.minHeight,
70
+ maxHeight: this.style.maxHeight
71
+ })
72
+ }
73
+ if (!isUndefined(this.style.backgroundColor)) {
74
+ instance.backgroundColor(this.style.backgroundColor)
75
+ }
76
+ if (!isUndefined(this.style.backgroundImage)) {
77
+ instance.backgroundImage(this.style.backgroundImage?.src, this.style.backgroundRepeat)
78
+ }
79
+ if (!isUndefined(this.style.backgroundSize)) {
80
+ instance.backgroundImageSize(this.style.backgroundSize)
81
+ }
82
+ if (!isUndefined(this.style.backgroundPosition)) {
83
+ instance.backgroundImagePosition(this.style.backgroundPosition)
84
+ }
85
+ if (!isUndefined(this.style.borderTopStyle) || !isUndefined(this.style.borderRightStyle) || !isUndefined(this.style.borderBottomStyle) || !isUndefined(this.style.borderLeftStyle)) {
86
+ instance.borderStyle({
87
+ top: this.style.borderTopStyle,
88
+ right: this.style.borderRightStyle,
89
+ bottom: this.style.borderBottomStyle,
90
+ left: this.style.borderLeftStyle
91
+ })
92
+ }
93
+ if (!isUndefined(this.style.borderTopWidth) || !isUndefined(this.style.borderRightWidth) || !isUndefined(this.style.borderBottomWidth) || !isUndefined(this.style.borderLeftWidth)) {
94
+ instance.borderWidth({
95
+ top: this.style.borderTopWidth,
96
+ right: this.style.borderRightWidth,
97
+ bottom: this.style.borderBottomWidth,
98
+ left: this.style.borderLeftWidth
99
+ })
100
+ }
101
+ if (!isUndefined(this.style.borderTopColor) || !isUndefined(this.style.borderRightColor) || !isUndefined(this.style.borderBottomColor) || !isUndefined(this.style.borderLeftColor)) {
102
+ instance.borderColor({
103
+ top: this.style.borderTopColor,
104
+ right: this.style.borderRightColor,
105
+ bottom: this.style.borderBottomColor,
106
+ left: this.style.borderLeftColor
107
+ })
108
+ }
109
+ if (!isUndefined(this.style.borderTopLeftRadius) || !isUndefined(this.style.borderTopRightRadius) || !isUndefined(this.style.borderBottomLeftRadius) || !isUndefined(this.style.borderBottomRightRadius)) {
110
+ instance.borderRadius({
111
+ topLeft: this.style.borderTopLeftRadius,
112
+ topRight: this.style.borderTopRightRadius,
113
+ bottomLeft: this.style.borderBottomLeftRadius,
114
+ bottomRight: this.style.borderBottomRightRadius
115
+ })
116
+ }
117
+ if (!isUndefined(this.style.zIndex)) {
118
+ instance.zIndex(this.style.zIndex)
119
+ }
120
+ if (!isUndefined(this.style.opacity)) {
121
+ instance.opacity(this.style.opacity)
122
+ }
123
+ if (!isUndefined(this.style.linearGradient)) {
124
+ instance.linearGradient(this.style.linearGradient)
125
+ }
126
+ if (!isUndefined(this.style.overflow)) {
127
+ instance.clip(this.style.overflow)
128
+ }
129
+ if (!isUndefined(this.style.transformOrigin)) {
130
+ instance.rotate({ centerX: this.style.transformOrigin.x, centerY: this.style.transformOrigin.y, angle: 0 })
131
+ instance.scale({ centerX: this.style.transformOrigin.x, centerY: this.style.transformOrigin.y })
132
+ }
133
+ if (!isUndefined(this.style.transform)) {
134
+ instance.transform(this.style.transform)
135
+ }
136
+ if (this.node.hmStyle?.position === 'absolute' || this.node.hmStyle?.position === 'fixed') {
137
+ instance.position({
138
+ x: getLeft(this.node),
139
+ y: getTop(this.node)
140
+ })
141
+ }
142
+ if (this.node.hmStyle?.position === 'relative') {
143
+ instance.offset({
144
+ x: getLeft(this.node),
145
+ y: getTop(this.node)
146
+ })
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ const modify = new CommonStyleModify()
153
+
154
+ export default modify
@@ -1,9 +1,10 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
+ import commonStyleModify from './style'
3
4
  import { createLazyChildren } from './render'
4
- import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
5
+ import { getNodeThresholds, shouldBindEvent } from './utils/helper'
5
6
 
6
- import type { TaroStyleType, TaroSwiperElement, TaroEvent, TaroAny } from '@tarojs/runtime'
7
+ import type { TaroSwiperElement, TaroEvent, TaroAny } from '@tarojs/runtime'
7
8
 
8
9
  interface SwiperAttrs {
9
10
  index?: number
@@ -15,71 +16,6 @@ interface SwiperAttrs {
15
16
  indicator?: boolean
16
17
  }
17
18
 
18
- @Extend(Swiper)
19
- function swiperStyle (style: TaroStyleType) {
20
- .id(style.id)
21
- .key(style.id)
22
- .flexGrow(style.flexGrow)
23
- .flexShrink(style.flexShrink)
24
- .flexBasis(style.flexBasis)
25
- .alignSelf(style.alignSelf)
26
- .padding({
27
- top: style.paddingTop,
28
- right: style.paddingRight,
29
- bottom: style.paddingBottom,
30
- left: style.paddingLeft
31
- })
32
- .margin({
33
- top: style.marginTop,
34
- right: style.marginRight,
35
- bottom: style.marginBottom,
36
- left: style.marginLeft
37
- })
38
- .width(style.width)
39
- .height(style.height)
40
- .constraintSize({
41
- minWidth: style.minWidth,
42
- maxWidth: style.maxWidth,
43
- minHeight: style.minHeight,
44
- maxHeight: style.maxHeight
45
- })
46
- .backgroundColor(style.backgroundColor)
47
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
48
- .backgroundImageSize(style.backgroundSize)
49
- .backgroundImagePosition(style.backgroundPosition)
50
- .borderStyle({
51
- top: style.borderTopStyle,
52
- right: style.borderRightStyle,
53
- bottom: style.borderBottomStyle,
54
- left: style.borderLeftStyle
55
- })
56
- .borderWidth({
57
- top: style.borderTopWidth,
58
- right: style.borderRightWidth,
59
- bottom: style.borderBottomWidth,
60
- left: style.borderLeftWidth
61
- })
62
- .borderColor({
63
- top: style.borderTopColor,
64
- right: style.borderRightColor,
65
- bottom: style.borderBottomColor,
66
- left: style.borderLeftColor
67
- })
68
- .borderRadius({
69
- topLeft: style.borderTopLeftRadius,
70
- topRight: style.borderTopRightRadius,
71
- bottomLeft: style.borderBottomLeftRadius,
72
- bottomRight: style.borderBottomRightRadius
73
- })
74
- .zIndex(style.zIndex)
75
- .opacity(style.opacity)
76
- .linearGradient(style.linearGradient)
77
- .clip(style.overflow)
78
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
79
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
80
- .transform(style.transform)
81
- }
82
-
83
19
  @Extend(Swiper)
84
20
  function swiperAttr (attr: SwiperAttrs) {
85
21
  .index(attr.index)
@@ -109,7 +45,7 @@ export default function TaroSwiper (node: TaroSwiperElement) {
109
45
  Swiper(node.controller) {
110
46
  createLazyChildren(node)
111
47
  }
112
- .swiperStyle(getNormalAttributes(node))
48
+ .attributeModifier(commonStyleModify.setNode(node))
113
49
  .swiperAttr(getSwiperAttributes(node))
114
50
  .indicatorStyle({
115
51
  color: node.getAttribute('indicatorColor'),
@@ -1,78 +1,14 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
- import { getNodeThresholds, shouldBindEvent, getNormalAttributes } from './utils/helper'
3
+ import commonStyleModify from './style'
4
+ import { getNodeThresholds, shouldBindEvent } from './utils/helper'
4
5
 
5
- import type { TaroAny, TaroStyleType, TaroSwitchElement, TaroEvent } from '@tarojs/runtime'
6
+ import type { TaroAny, TaroSwitchElement, TaroEvent } from '@tarojs/runtime'
6
7
 
7
8
  interface SwitchAttrs {
8
9
  selectedColor?: ResourceColor
9
10
  }
10
11
 
11
- @Extend(Toggle)
12
- function styles (style: TaroStyleType) {
13
- .id(style.id)
14
- .key(style.id)
15
- .flexGrow(style.flexGrow)
16
- .flexShrink(style.flexShrink)
17
- .flexBasis(style.flexBasis)
18
- .alignSelf(style.alignSelf)
19
- .padding({
20
- top: style.paddingTop,
21
- right: style.paddingRight,
22
- bottom: style.paddingBottom,
23
- left: style.paddingLeft
24
- })
25
- .margin({
26
- top: style.marginTop,
27
- right: style.marginRight,
28
- bottom: style.marginBottom,
29
- left: style.marginLeft
30
- })
31
- .width(style.width)
32
- .height(style.height)
33
- .constraintSize({
34
- minWidth: style.minWidth,
35
- maxWidth: style.maxWidth,
36
- minHeight: style.minHeight,
37
- maxHeight: style.maxHeight
38
- })
39
- .backgroundColor(style.backgroundColor)
40
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
41
- .backgroundImageSize(style.backgroundSize)
42
- .backgroundImagePosition(style.backgroundPosition)
43
- .borderStyle({
44
- top: style.borderTopStyle,
45
- right: style.borderRightStyle,
46
- bottom: style.borderBottomStyle,
47
- left: style.borderLeftStyle
48
- })
49
- .borderWidth({
50
- top: style.borderTopWidth,
51
- right: style.borderRightWidth,
52
- bottom: style.borderBottomWidth,
53
- left: style.borderLeftWidth
54
- })
55
- .borderColor({
56
- top: style.borderTopColor,
57
- right: style.borderRightColor,
58
- bottom: style.borderBottomColor,
59
- left: style.borderLeftColor
60
- })
61
- .borderRadius({
62
- topLeft: style.borderTopLeftRadius,
63
- topRight: style.borderTopRightRadius,
64
- bottomLeft: style.borderBottomLeftRadius,
65
- bottomRight: style.borderBottomRightRadius
66
- })
67
- .zIndex(style.zIndex)
68
- .opacity(style.opacity)
69
- .linearGradient(style.linearGradient)
70
- .clip(style.overflow)
71
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
72
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
73
- .transform(style.transform)
74
- }
75
-
76
12
  @Extend(Toggle)
77
13
  function attrs(attr: SwitchAttrs) {
78
14
  .selectedColor(attr.selectedColor)
@@ -107,7 +43,7 @@ export default struct TaroSwitch {
107
43
  type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
108
44
  isOn: this.node.checked,
109
45
  })
110
- .styles(getNormalAttributes(this.node))
46
+ .attributeModifier(commonStyleModify.setNode(this.node))
111
47
  .attrs(getAttributes(this.node))
112
48
  .themeStyles(!!this.node._attrs.disabled)
113
49
  .onChange((isOn: boolean) => {