@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.0 → 4.0.0-beta.1

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.
Files changed (54) hide show
  1. package/dist/apis/media/video/VideoContext.ts +56 -7
  2. package/dist/apis/media/video/index.ts +3 -2
  3. package/dist/components-harmony-ets/button.ets +58 -23
  4. package/dist/components-harmony-ets/checkbox.ets +154 -67
  5. package/dist/components-harmony-ets/form.ets +52 -18
  6. package/dist/components-harmony-ets/icon.ets +53 -19
  7. package/dist/components-harmony-ets/image.ets +53 -19
  8. package/dist/components-harmony-ets/input.ets +57 -18
  9. package/dist/components-harmony-ets/label.ets +52 -18
  10. package/dist/components-harmony-ets/picker.ets +139 -37
  11. package/dist/components-harmony-ets/radio.ets +157 -70
  12. package/dist/components-harmony-ets/richText.ets +52 -18
  13. package/dist/components-harmony-ets/scrollView.ets +102 -44
  14. package/dist/components-harmony-ets/slider.ets +57 -18
  15. package/dist/components-harmony-ets/swiper.ets +52 -18
  16. package/dist/components-harmony-ets/switch.ets +92 -41
  17. package/dist/components-harmony-ets/text.ets +57 -20
  18. package/dist/components-harmony-ets/textArea.ets +58 -19
  19. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
  20. package/dist/components-harmony-ets/utils/flexManager.ets +1 -1
  21. package/dist/components-harmony-ets/utils/styles.ets +46 -19
  22. package/dist/components-harmony-ets/video.ets +52 -18
  23. package/dist/components-harmony-ets/view.ets +100 -32
  24. package/dist/index.js +17 -4
  25. package/dist/index.js.map +1 -1
  26. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +7 -3
  27. package/dist/runtime-ets/dom/element/element.ts +1 -0
  28. package/dist/runtime-ets/dom/element/form.ts +11 -2
  29. package/dist/runtime-ets/dom/node.ts +29 -16
  30. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +551 -0
  31. package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
  32. package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
  33. package/dist/runtime-ets/dom/stylesheet/util.ts +55 -5
  34. package/dist/runtime-ets/interface/event.ts +2 -1
  35. package/dist/runtime-ets/utils/index.ts +3 -1
  36. package/dist/runtime-ets/utils/info.ts +3 -1
  37. package/dist/runtime-utils.js +48 -13
  38. package/dist/runtime-utils.js.map +1 -1
  39. package/dist/runtime.js +48 -13
  40. package/dist/runtime.js.map +1 -1
  41. package/package.json +10 -9
  42. package/static/media/cancel.svg +1 -0
  43. package/static/media/circle.svg +1 -0
  44. package/static/media/clear.svg +1 -0
  45. package/static/media/download.svg +1 -0
  46. package/static/media/info.svg +1 -0
  47. package/static/media/info_circle.svg +1 -0
  48. package/static/media/search.svg +1 -0
  49. package/static/media/success.svg +1 -0
  50. package/static/media/success_no_circle.svg +1 -0
  51. package/static/media/taro_arrow_left.svg +1 -0
  52. package/static/media/taro_home.svg +1 -0
  53. package/static/media/waiting.svg +1 -0
  54. package/static/media/warn.svg +1 -0
@@ -19,31 +19,65 @@ interface SwiperAttrs {
19
19
  function swiperStyle (style: TaroStyleType) {
20
20
  .id(style.id)
21
21
  .key(style.id)
22
- .padding(style.padding)
23
- .margin(style.margin)
24
- .width(style.width)
25
- .height(style.height)
26
- .constraintSize(style.constraintSize)
27
22
  .flexGrow(style.flexGrow)
28
23
  .flexShrink(style.flexShrink)
29
24
  .flexBasis(style.flexBasis)
30
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
+ })
31
46
  .backgroundColor(style.backgroundColor)
32
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
33
- .backgroundImageSize(style.backgroundImageSize)
34
- .backgroundImagePosition(style.backgroundImagePosition)
35
- .rotate(style.rotate)
36
- .scale(style.scale)
37
- .translate(style.translate)
38
- .transform(style.transform)
39
- .borderStyle(style.borderStyle)
40
- .borderWidth(style.borderWidth)
41
- .borderColor(style.borderColor)
42
- .borderRadius(style.borderRadius)
43
- .linearGradient(style.linearGradient)
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
+ })
44
74
  .zIndex(style.zIndex)
45
75
  .opacity(style.opacity)
46
- .clip(style.clip)
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)
47
81
  }
48
82
 
49
83
  @Extend(Swiper)
@@ -12,31 +12,65 @@ interface SwitchAttrs {
12
12
  function styles (style: TaroStyleType) {
13
13
  .id(style.id)
14
14
  .key(style.id)
15
- .padding(style.padding)
16
- .margin(style.margin)
17
- .width(style.width)
18
- .height(style.height)
19
- .constraintSize(style.constraintSize)
20
15
  .flexGrow(style.flexGrow)
21
16
  .flexShrink(style.flexShrink)
22
17
  .flexBasis(style.flexBasis)
23
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
+ })
24
39
  .backgroundColor(style.backgroundColor)
25
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
26
- .backgroundImageSize(style.backgroundImageSize)
27
- .backgroundImagePosition(style.backgroundImagePosition)
28
- .rotate(style.rotate)
29
- .scale(style.scale)
30
- .translate(style.translate)
31
- .transform(style.transform)
32
- .borderStyle(style.borderStyle)
33
- .borderWidth(style.borderWidth)
34
- .borderColor(style.borderColor)
35
- .borderRadius(style.borderRadius)
36
- .linearGradient(style.linearGradient)
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
+ })
37
67
  .zIndex(style.zIndex)
38
68
  .opacity(style.opacity)
39
- .clip(style.clip)
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)
40
74
  }
41
75
 
42
76
  @Extend(Toggle)
@@ -56,28 +90,45 @@ function themeStyles(isDisabled: boolean) {
56
90
  .opacity(isDisabled ? 0.4 : 1)
57
91
  }
58
92
 
59
- @Builder
60
- export default function TaroSwitch (node: TaroSwitchElement) {
61
- Toggle({
62
- type: node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
63
- isOn: node.checked,
64
- })
65
- .styles(getNormalAttributes(node))
66
- .attrs(getAttributes(node))
67
- .themeStyles(!!node._attrs.disabled)
68
- .onChange((isOn: boolean) => {
69
- if (!node?._attrs.disabled) {
70
- const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, node)
93
+ @Component
94
+ export default struct TaroSwitch {
95
+ node: TaroSwitchElement | null = null
96
+
97
+ aboutToAppear () {
98
+ if (this.node && !this.node._isInit) {
99
+ this.node._isInit = true
100
+ this.node._reset = this.node.checked || false
101
+ }
102
+ }
71
103
 
72
- node.updateCheckedValue(isOn)
73
- eventHandler(event, 'change', node)
74
- } else {
75
- node.updateComponent()
76
- }
77
- })
78
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
79
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
80
- node._nodeInfo.areaInfo = res[1]
81
- }))
82
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
104
+ build () {
105
+ if (this.node) {
106
+ Toggle({
107
+ type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
108
+ isOn: this.node.checked,
109
+ })
110
+ .styles(getNormalAttributes(this.node))
111
+ .attrs(getAttributes(this.node))
112
+ .themeStyles(!!this.node._attrs.disabled)
113
+ .onChange((isOn: boolean) => {
114
+ if (this.node) {
115
+ if (!this.node?._attrs.disabled) {
116
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, this.node)
117
+
118
+ this.node.updateCheckedValue(isOn)
119
+ eventHandler(event, 'change', this.node)
120
+ } else {
121
+ this.node.updateComponent()
122
+ }
123
+ }
124
+ })
125
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
126
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
127
+ if (this.node) {
128
+ this.node._nodeInfo.areaInfo = res[1]
129
+ }
130
+ }))
131
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
132
+ }
133
+ }
83
134
  }
@@ -8,30 +8,67 @@ import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, TaroText
8
8
 
9
9
  @Extend(Text)
10
10
  function textNormalStyle (style: TaroStyleType) {
11
- .padding(style.padding)
12
- .margin(style.margin)
13
- .width(style.width)
14
- .height(style.height)
15
- .constraintSize(style.constraintSize)
11
+ .id(style.id)
12
+ .key(style.id)
16
13
  .flexGrow(style.flexGrow)
17
14
  .flexShrink(style.flexShrink)
18
15
  .flexBasis(style.flexBasis)
19
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
+ })
20
37
  .backgroundColor(style.backgroundColor)
21
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
22
- .backgroundImageSize(style.backgroundImageSize)
23
- .backgroundImagePosition(style.backgroundImagePosition)
24
- .rotate(style.rotate)
25
- .scale(style.scale)
26
- .translate(style.translate)
27
- .transform(style.transform)
28
- .borderStyle(style.borderStyle)
29
- .borderWidth(style.borderWidth)
30
- .borderColor(style.borderColor)
31
- .borderRadius(style.borderRadius)
32
- .linearGradient(style.linearGradient)
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
+ })
33
65
  .zIndex(style.zIndex)
34
- .clip(style.clip)
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)
35
72
  }
36
73
 
37
74
  @Extend(Text)
@@ -46,7 +83,7 @@ function textNormalFontStyle (style: TaroStyleType) {
46
83
  .fontFamily(style.fontFamily)
47
84
  .lineHeight(style.lineHeight)
48
85
  .decoration({
49
- type: style.decoration,
86
+ type: style.textDecoration,
50
87
  color: style.color
51
88
  })
52
89
  }
@@ -55,7 +92,7 @@ function textNormalFontStyle (style: TaroStyleType) {
55
92
  function textSpecialFontStyle(attr: TaroTextStyleType) {
56
93
  .textAlign(attr.textAlign)
57
94
  .textOverflow(attr.textOverflow)
58
- .maxLines(attr.maxLines)
95
+ .maxLines(attr.WebkitLineClamp)
59
96
  .letterSpacing(attr.letterSpacing)
60
97
  }
61
98
 
@@ -8,31 +8,65 @@ import type { TaroAny, TaroStyleType, TaroTextStyleType, TaroTextAreaElement, Ta
8
8
  function textStyle (style: TaroStyleType) {
9
9
  .id(style.id)
10
10
  .key(style.id)
11
- .padding(style.padding)
12
- .margin(style.margin)
13
- .width(style.width)
14
- .height(style.height)
15
- .constraintSize(style.constraintSize)
16
11
  .flexGrow(style.flexGrow)
17
12
  .flexShrink(style.flexShrink)
18
13
  .flexBasis(style.flexBasis)
19
14
  .alignSelf(style.alignSelf)
15
+ .padding({
16
+ top: style.paddingTop,
17
+ right: style.paddingRight,
18
+ bottom: style.paddingBottom,
19
+ left: style.paddingLeft
20
+ })
21
+ .margin({
22
+ top: style.marginTop,
23
+ right: style.marginRight,
24
+ bottom: style.marginBottom,
25
+ left: style.marginLeft
26
+ })
27
+ .width(style.width)
28
+ .height(style.height)
29
+ .constraintSize({
30
+ minWidth: style.minWidth,
31
+ maxWidth: style.maxWidth,
32
+ minHeight: style.minHeight,
33
+ maxHeight: style.maxHeight
34
+ })
20
35
  .backgroundColor(style.backgroundColor)
21
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
22
- .backgroundImageSize(style.backgroundImageSize)
23
- .backgroundImagePosition(style.backgroundImagePosition)
24
- .rotate(style.rotate)
25
- .scale(style.scale)
26
- .translate(style.translate)
27
- .transform(style.transform)
28
- .borderStyle(style.borderStyle)
29
- .borderWidth(style.borderWidth)
30
- .borderColor(style.borderColor)
31
- .borderRadius(style.borderRadius)
32
- .linearGradient(style.linearGradient)
36
+ .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
37
+ .backgroundImageSize(style.backgroundSize)
38
+ .backgroundImagePosition(style.backgroundPosition)
39
+ .borderStyle({
40
+ top: style.borderTopStyle,
41
+ right: style.borderRightStyle,
42
+ bottom: style.borderBottomStyle,
43
+ left: style.borderLeftStyle
44
+ })
45
+ .borderWidth({
46
+ top: style.borderTopWidth,
47
+ right: style.borderRightWidth,
48
+ bottom: style.borderBottomWidth,
49
+ left: style.borderLeftWidth
50
+ })
51
+ .borderColor({
52
+ top: style.borderTopColor,
53
+ right: style.borderRightColor,
54
+ bottom: style.borderBottomColor,
55
+ left: style.borderLeftColor
56
+ })
57
+ .borderRadius({
58
+ topLeft: style.borderTopLeftRadius,
59
+ topRight: style.borderTopRightRadius,
60
+ bottomLeft: style.borderBottomLeftRadius,
61
+ bottomRight: style.borderBottomRightRadius
62
+ })
33
63
  .zIndex(style.zIndex)
34
64
  .opacity(style.opacity)
35
- .clip(style.clip)
65
+ .linearGradient(style.linearGradient)
66
+ .clip(style.overflow)
67
+ .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
68
+ .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
69
+ .transform(style.transform)
36
70
  .fontColor(style.color)
37
71
  .fontSize(style.fontSize)
38
72
  .fontWeight(style.fontWeight)
@@ -43,7 +77,7 @@ function textStyle (style: TaroStyleType) {
43
77
  @Extend(TextArea)
44
78
  function textAttr(attr: TaroTextStyleType) {
45
79
  .textAlign(attr.textAlign)
46
- .maxLines(attr.maxLines)
80
+ .maxLines(attr.WebkitLineClamp)
47
81
  }
48
82
 
49
83
  function getPlaceholderColor (node: TaroTextAreaElement): string {
@@ -62,6 +96,11 @@ export default struct TaroTextArea {
62
96
  if (this.node) {
63
97
  this.value = this.node.value
64
98
  this.node._instance = this
99
+
100
+ if (!this.node._isInit) {
101
+ this.node._isInit = true
102
+ this.node._reset = this.node.value || ''
103
+ }
65
104
  }
66
105
  }
67
106
 
@@ -1,9 +1,6 @@
1
- import { bindFocus, bindInstanceToNode, bindScrollTo, initComponentNodeInfo, TaroAny, TaroElement } from '@tarojs/runtime'
2
-
3
- import { bindAnimation } from './helper'
1
+ import { TaroAny, TaroElement } from '@tarojs/runtime'
4
2
 
5
3
  export class DynamicCenter {
6
-
7
4
  install (node: TaroElement, parentNode: TaroElement) {
8
5
  if (!parentNode._isCompileMode) return
9
6
 
@@ -25,13 +22,7 @@ export class DynamicCenter {
25
22
  const dynamicID = node._attrs?._dynamicID
26
23
 
27
24
  // dynamicID 只是为了更新到精准的 node
28
- // 而为了让半编译模板中每个 node 都能响应 api 的调用,因此 initComponentNodeInfo、bindInstanceToNode 和各种 bindAttribute 都需要执行
29
- initComponentNodeInfo(component, node)
30
- bindInstanceToNode(node, component)
31
- bindFocus(node)
32
- bindAnimation(node)
33
- bindScrollTo(node, component)
34
-
25
+ node._instance = component
35
26
  node._isCompileMode = true
36
27
 
37
28
  if (dynamicID) {
@@ -4,7 +4,7 @@ class FlexManager {
4
4
  static flexOptions (node: TaroElement): FlexOptions {
5
5
  const hmStyle = node.hmStyle
6
6
 
7
- let flexDirection = hmStyle.direction
7
+ let flexDirection = hmStyle.flexDirection
8
8
  if (!flexDirection && flexDirection !== 0) {
9
9
  flexDirection = hmStyle.display === 'flex' ? FlexDirection.Row : FlexDirection.Column
10
10
  }
@@ -2,14 +2,15 @@ import { ObjectAssign } from '@tarojs/runtime'
2
2
 
3
3
  import { TEXT_DEFAULT_STYLE } from './constant/style'
4
4
 
5
- import type { StandardProps } from '@tarojs/components/types'
5
+ import type { StandardProps, TextProps } from '@tarojs/components/types'
6
6
  import type { TaroAny, TaroElement, TaroStyleType, TaroTextStyleType, HarmonyType, HarmonyStyle } from '@tarojs/runtime'
7
7
 
8
8
  export function getFontAttributes (node: TaroElement): TaroTextStyleType {
9
9
  const hmStyle = node.hmStyle
10
+ const attrs: TextProps = node._attrs || {}
10
11
 
11
12
  const attributes: TaroAny = {
12
- maxLines: hmStyle.maxLines || Infinity,
13
+ WebkitLineClamp: attrs.maxLines || hmStyle.WebkitLineClamp || Infinity,
13
14
  // 已做处理的属性
14
15
  letterSpacing: hmStyle.letterSpacing,
15
16
  textAlign: hmStyle.textAlign,
@@ -25,11 +26,11 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
25
26
  const _nid = node._nid
26
27
  const _attrs: StandardProps = node._attrs || {}
27
28
 
28
- const transform: TaroAny = hmStyle.transform
29
- const transformRotate: HarmonyType.Transform.Rotate = transform?.rotate?.[0]
30
- const transformTranslate: HarmonyType.Transform.Translate = transform?.translate?.[0]
31
- const transformScale: HarmonyType.Transform.Scale = transform?.scale?.[0]
32
- const transformTransform: HarmonyType.Transform.Transform = transform?.transform?.[0]
29
+ let linearGradient: HarmonyType.LinearGradient | undefined = undefined
30
+ // 渐变
31
+ if (hmStyle.backgroundImage?.colors) {
32
+ linearGradient = hmStyle.backgroundImage
33
+ }
33
34
 
34
35
  let normalAttributes: HarmonyStyle = {
35
36
  // Flex相关
@@ -40,26 +41,52 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
40
41
  // 尺寸相关
41
42
  width: hmStyle.width,
42
43
  height: hmStyle.height,
43
- constraintSize: hmStyle.constraintSize,
44
- margin: hmStyle.margin,
45
- padding: hmStyle.padding,
44
+ minHeight: hmStyle.minHeight,
45
+ maxHeight: hmStyle.maxHeight,
46
+ minWidth: hmStyle.minWidth,
47
+ maxWidth: hmStyle.maxWidth,
48
+ marginTop: hmStyle.marginTop,
49
+ marginRight: hmStyle.marginRight,
50
+ marginBottom: hmStyle.marginBottom,
51
+ marginLeft: hmStyle.marginLeft,
52
+ paddingTop: hmStyle.paddingTop,
53
+ paddingRight: hmStyle.paddingRight,
54
+ paddingBottom: hmStyle.paddingBottom,
55
+ paddingLeft: hmStyle.paddingLeft,
46
56
  // 边框相关
47
57
  borderStyle: hmStyle.borderStyle,
58
+ borderTopStyle: hmStyle.borderTopStyle,
59
+ borderRightStyle: hmStyle.borderRightStyle,
60
+ borderBottomStyle: hmStyle.borderBottomStyle,
61
+ borderLeftStyle: hmStyle.borderLeftStyle,
48
62
  borderWidth: hmStyle.borderWidth,
63
+ borderTopWidth: hmStyle.borderTopWidth,
64
+ borderRightWidth: hmStyle.borderRightWidth,
65
+ borderBottomWidth: hmStyle.borderBottomWidth,
66
+ borderLeftWidth: hmStyle.borderLeftWidth,
49
67
  borderColor: hmStyle.borderColor,
68
+ borderTopColor: hmStyle.borderTopColor,
69
+ borderRightColor: hmStyle.borderRightColor,
70
+ borderBottomColor: hmStyle.borderBottomColor,
71
+ borderLeftColor: hmStyle.borderLeftColor,
50
72
  borderRadius: hmStyle.borderRadius,
73
+ borderTopLeftRadius: hmStyle.borderTopLeftRadius,
74
+ borderTopRightRadius: hmStyle.borderTopRightRadius,
75
+ borderBottomRightRadius: hmStyle.borderBottomRightRadius,
76
+ borderBottomLeftRadius: hmStyle.borderBottomLeftRadius,
51
77
  // 背景相关
52
78
  backgroundColor: hmStyle.backgroundColor,
53
79
  backgroundImage: hmStyle.backgroundImage,
54
- backgroundImageSize: hmStyle.backgroundImageSize,
80
+ backgroundSize: hmStyle.backgroundSize,
55
81
  backgroundRepeat: hmStyle.backgroundRepeat,
56
- backgroundImagePosition: hmStyle.backgroundImagePosition,
57
- linearGradient: hmStyle.linearGradient,
82
+ backgroundPosition: hmStyle.backgroundPosition,
83
+ linearGradient,
58
84
  // 变换相关
59
- rotate: transformRotate,
60
- translate: transformTranslate,
61
- scale: transformScale,
62
- transform: transformTransform,
85
+ transform: hmStyle.transform,
86
+ transformOrigin: {
87
+ x: hmStyle.transformOrigin?.x || 0,
88
+ y: hmStyle.transformOrigin?.y || 0
89
+ },
63
90
  // 通用文本相关
64
91
  color: hmStyle.color,
65
92
  fontSize: hmStyle.fontSize,
@@ -67,9 +94,9 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
67
94
  fontWeight: hmStyle.fontWeight,
68
95
  fontFamily: hmStyle.fontFamily || TEXT_DEFAULT_STYLE.FONT_FAMILY,
69
96
  lineHeight: hmStyle.lineHeight,
70
- decoration: hmStyle.decoration,
97
+ textDecoration: hmStyle.textDecoration,
71
98
  // 其他
72
- clip: hmStyle.clip,
99
+ overflow: hmStyle.overflow,
73
100
  id: _attrs.id || _nid,
74
101
  opacity: hmStyle.opacity,
75
102
  // focus: _attrs.focus || false,
@@ -25,31 +25,65 @@ export interface VideoUpdateEvent {
25
25
  function attrs (style: TaroStyleType) {
26
26
  .id(style.id)
27
27
  .key(style.id)
28
- .padding(style.padding)
29
- .margin(style.margin)
30
- .width(style.width)
31
- .height(style.height)
32
- .constraintSize(style.constraintSize)
33
28
  .flexGrow(style.flexGrow)
34
29
  .flexShrink(style.flexShrink)
35
30
  .flexBasis(style.flexBasis)
36
31
  .alignSelf(style.alignSelf)
32
+ .padding({
33
+ top: style.paddingTop,
34
+ right: style.paddingRight,
35
+ bottom: style.paddingBottom,
36
+ left: style.paddingLeft
37
+ })
38
+ .margin({
39
+ top: style.marginTop,
40
+ right: style.marginRight,
41
+ bottom: style.marginBottom,
42
+ left: style.marginLeft
43
+ })
44
+ .width(style.width)
45
+ .height(style.height)
46
+ .constraintSize({
47
+ minWidth: style.minWidth,
48
+ maxWidth: style.maxWidth,
49
+ minHeight: style.minHeight,
50
+ maxHeight: style.maxHeight
51
+ })
37
52
  .backgroundColor(style.backgroundColor)
38
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
39
- .backgroundImageSize(style.backgroundImageSize)
40
- .backgroundImagePosition(style.backgroundImagePosition)
41
- .rotate(style.rotate)
42
- .scale(style.scale)
43
- .translate(style.translate)
44
- .transform(style.transform)
45
- .borderStyle(style.borderStyle)
46
- .borderWidth(style.borderWidth)
47
- .borderColor(style.borderColor)
48
- .borderRadius(style.borderRadius)
49
- .linearGradient(style.linearGradient)
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
+ })
50
80
  .zIndex(style.zIndex)
51
81
  .opacity(style.opacity)
52
- .clip(style.clip)
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)
53
87
  }
54
88
 
55
89
  @Extend(Video)