@tarojs/plugin-platform-harmony-ets 4.0.0-beta.53 → 4.0.0-beta.55

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.
@@ -72,6 +72,7 @@ export default struct TaroInput {
72
72
  .maxLength(Number(this.node._attrs?.maxlength) || null)
73
73
  .placeholderColor(getPlaceholderColor(this.node))
74
74
  .enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
75
+ .padding(0) // Note: 移出 Input 默认 padding 设置
75
76
  .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
76
77
  .styles(this.node?.hmStyle)
77
78
  .attrs(getAttributes(this.node))
@@ -1,7 +1,7 @@
1
1
  import type { TaroAny, HarmonyStyle, TaroElement, TaroStyleType, TaroTextElement } from '@tarojs/runtime'
2
2
  import { ObjectAssign } from '@tarojs/runtime'
3
3
  import { isUndefined } from '@tarojs/shared'
4
- import { computeBackgroundPosition } from './utils'
4
+ import { computeBackgroundPosition, convertVp2Px } from './utils'
5
5
  import { getNormalAttributes } from './utils/helper'
6
6
  import { isMaxWidthView } from './utils/styles'
7
7
  import { FlexManager } from './utils/flexManager.ets'
@@ -113,6 +113,7 @@ class PseudoStyleModify implements AttributeModifier<CommonAttribute> {
113
113
  applyNormalAttribute(instance: CommonAttribute): void {
114
114
  if (this.style) {
115
115
  setNormalAttributeIntoInstance(instance, this.style)
116
+ setTransformAttributeIntoInstance(instance, this.style || {})
116
117
  }
117
118
  }
118
119
  }
@@ -376,34 +377,15 @@ export function setNormalAttributeIntoInstance(instance: CommonAttribute, style:
376
377
  // 为了适应position不设置z-index也能高于同层级组件,估且让设置了z-index的会更高一级
377
378
  instance.zIndex(style.zIndex + 1)
378
379
  }
379
- // if (!isUndefined(style.transform)) {
380
- // if (style.transform.Translate) {
381
- // instance.translate({
382
- // x: style.transform.Translate.x || 0,
383
- // y: style.transform.Translate.y || 0,
384
- // z: style.transform.Translate.z || 0,
385
- // })
386
- // }
387
- // if (style.transform.Scale) {
388
- // instance.scale({
389
- // x: style.transform.Scale.x || 0,
390
- // y: style.transform.Scale.y || 0,
391
- // z: style.transform.Scale.z || 0,
392
- // centerX: style.transformOrigin?.x || 0,
393
- // centerY: style.transformOrigin?.y || 0,
394
- // })
395
- // }
396
- // if (style.transform.Rotate) {
397
- // instance.rotate({
398
- // x: style.transform.Rotate.x || 0,
399
- // y: style.transform.Rotate.y || 0,
400
- // z: style.transform.Rotate.z || 0,
401
- // centerX: style.transformOrigin?.x || 0,
402
- // centerY: style.transformOrigin?.y || 0,
403
- // angle: style.transform.Rotate.angle
404
- // })
405
- // }
406
- // }
380
+ if (!isUndefined(style.boxShadow)) {
381
+ instance.shadow({
382
+ radius: convertVp2Px(style.boxShadow.radius),
383
+ color: style.boxShadow.color,
384
+ offsetX: convertVp2Px(style.boxShadow.offsetX),
385
+ offsetY: convertVp2Px(style.boxShadow.offsetY),
386
+ fill: style.boxShadow.fill,
387
+ })
388
+ }
407
389
  }
408
390
 
409
391
  export const pseudoModify = new PseudoStyleModify()
@@ -77,5 +77,28 @@ export default struct TaroSwiper {
77
77
  this.node._nodeInfo.areaInfo = res[1]
78
78
  }))
79
79
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
80
+ .onGestureSwipe(shouldBindEvent((index: number, extraInfo: SwiperAnimationEvent) => {
81
+ const currentOffset = extraInfo.currentOffset || 0
82
+ // 判断设置的滚动方向
83
+ const isVertical = this.node._attrs.vertical || false
84
+ let event: TaroEvent
85
+ if (isVertical) {
86
+ event = createTaroEvent('transition', { detail: { dx: 0, dy: currentOffset } }, this.node)
87
+ } else {
88
+ event = createTaroEvent('transition', { detail: { dx: currentOffset, dy: 0 } }, this.node)
89
+ }
90
+ eventHandler(event, 'transition', this.node)
91
+ }, this.node, ['transition']))
92
+ .onTouch(shouldBindEvent((event: TouchEvent) => {
93
+ if (event.type === TouchType.Down) {
94
+ eventHandler(event, 'touchStart', this.node)
95
+ }
96
+ if (event.type === TouchType.Up) {
97
+ eventHandler(event, 'touchEnd', this.node)
98
+ }
99
+ if (event.type === TouchType.Move) {
100
+ eventHandler(event, 'touchMove', this.node)
101
+ }
102
+ }, this.node, ['touchstart', 'touchmove', 'touchend']))
80
103
  }
81
104
  }
@@ -1,7 +1,7 @@
1
1
  import { isString } from '@tarojs/shared'
2
2
  import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, NodeType } from '@tarojs/runtime'
3
3
 
4
- import commonStyleModify, { textModify, setNormalTextAttributeIntoInstance } from './style'
4
+ import { textModify, setNormalTextAttributeIntoInstance } from './style'
5
5
  import { getButtonColor } from './button'
6
6
  import { getImageMode } from './image'
7
7
  import { BUTTON_THEME_COLOR } from './utils/constant/style'
@@ -60,7 +60,7 @@ export default struct TaroText {
60
60
  // text 下还有标签
61
61
  if (this.node.childNodes.length > 1 || ((this.node.childNodes[0] && this.node.childNodes[0] as TaroElement)?.nodeType === NodeType.ELEMENT_NODE)) {
62
62
  ForEach(this.node.childNodes, (item: TaroElement) => {
63
- createTextChildNode(item, getSpanVerticalAlign(this.node.hmStyle?.verticalAlign))
63
+ createTextChildNode(item)
64
64
  }, (item: TaroElement) => item._nid)
65
65
  }
66
66
  }
@@ -75,12 +75,41 @@ export default struct TaroText {
75
75
  }
76
76
 
77
77
  @Builder
78
- function createTextChildNode (item: TaroElement, align: ImageSpanAlignment) {
78
+ function createTextChildNode (item: TaroElement) {
79
79
  if (item.tagName === 'IMAGE') {
80
80
  ImageSpan(item.getAttribute('src'))
81
- .attributeModifier(commonStyleModify.setNode(item))
81
+ // .attributeModifier(commonStyleModify.setNode(item))
82
82
  .objectFit(getImageMode(item.getAttribute('mode')))
83
- .verticalAlign(align)
83
+ // .verticalAlign(align)
84
+ .width(item._st.hmStyle.width)
85
+ .height(item._st.hmStyle.height)
86
+ .margin({
87
+ top: item._st.hmStyle.marginTop,
88
+ left: item._st.hmStyle.marginLeft,
89
+ right: item._st.hmStyle.marginRight,
90
+ bottom: item._st.hmStyle.marginBottom,
91
+ })
92
+ .padding({
93
+ top: item._st.hmStyle.paddingTop,
94
+ left: item._st.hmStyle.paddingLeft,
95
+ right: item._st.hmStyle.paddingRight,
96
+ bottom: item._st.hmStyle.paddingBottom,
97
+ })
98
+ .textBackgroundStyle({
99
+ color: item._st.hmStyle.backgroundColor,
100
+ radius: {
101
+ topLeft: item._st.hmStyle.borderTopLeftRadius,
102
+ topRight: item._st.hmStyle.borderTopRightRadius,
103
+ bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
104
+ bottomRight: item._st.hmStyle.borderBottomRightRadius,
105
+ }
106
+ })
107
+ .borderRadius({
108
+ topLeft: item._st.hmStyle.borderTopLeftRadius,
109
+ topRight: item._st.hmStyle.borderTopRightRadius,
110
+ bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
111
+ bottomRight: item._st.hmStyle.borderBottomRightRadius
112
+ })
84
113
  .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', item), item, ['click']))
85
114
  } else if (item.nodeType === NodeType.TEXT_NODE) {
86
115
  Span(item.textContent)
@@ -88,30 +117,39 @@ function createTextChildNode (item: TaroElement, align: ImageSpanAlignment) {
88
117
  Span(item.textContent)
89
118
  .attributeModifier(spanModify.setNode(item))
90
119
  .letterSpacing(item._st.hmStyle.letterSpacing)
120
+ .textBackgroundStyle({
121
+ color: item._st.hmStyle.backgroundColor,
122
+ radius: {
123
+ topLeft: item._st.hmStyle.borderTopLeftRadius,
124
+ topRight: item._st.hmStyle.borderTopRightRadius,
125
+ bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
126
+ bottomRight: item._st.hmStyle.borderBottomRightRadius,
127
+ }
128
+ })
91
129
  .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', item), item, ['click']))
92
130
  }
93
131
  }
94
132
 
95
- function getSpanVerticalAlign (verticalAlign?: Alignment) {
96
- switch (verticalAlign) {
97
- case Alignment.Start:
98
- case Alignment.TopStart:
99
- case Alignment.Top:
100
- case Alignment.TopEnd: {
101
- return ImageSpanAlignment.TOP
102
- }
103
- case Alignment.End:
104
- case Alignment.BottomStart:
105
- case Alignment.Bottom:
106
- case Alignment.BottomEnd: {
107
- return ImageSpanAlignment.BOTTOM
108
- }
109
- case Alignment.Center: {
110
- return ImageSpanAlignment.CENTER
111
- }
112
- }
113
- return ImageSpanAlignment.BASELINE
114
- }
133
+ // function getSpanVerticalAlign (verticalAlign?: Alignment) {
134
+ // switch (verticalAlign) {
135
+ // case Alignment.Start:
136
+ // case Alignment.TopStart:
137
+ // case Alignment.Top:
138
+ // case Alignment.TopEnd: {
139
+ // return ImageSpanAlignment.TOP
140
+ // }
141
+ // case Alignment.End:
142
+ // case Alignment.BottomStart:
143
+ // case Alignment.Bottom:
144
+ // case Alignment.BottomEnd: {
145
+ // return ImageSpanAlignment.BOTTOM
146
+ // }
147
+ // case Alignment.Center: {
148
+ // return ImageSpanAlignment.CENTER
149
+ // }
150
+ // }
151
+ // return ImageSpanAlignment.BASELINE
152
+ // }
115
153
 
116
154
 
117
155
  class SpanStyleModify implements AttributeModifier<SpanAttribute> {
@@ -80,3 +80,8 @@ export function computeBackgroundPosition(style) {
80
80
 
81
81
  return { offsetX, offsetY }
82
82
  }
83
+
84
+ export function convertVp2Px(val: string | number) {
85
+ const vp = parseFloat(`${val}`)
86
+ return vp2px(vp)
87
+ }
@@ -77,7 +77,7 @@ function depthTraversal(root: ReactElement) {
77
77
  // import { View } from '~/components'
78
78
  // hack:如果是taro节点,但是被赋予了__styleSheet,则走一下__styleSheet转__hmStyle
79
79
  if (tree.props.__styleSheet && typeof tree.type !== 'function') {
80
- tree.props.__hmStyle = tree.props.__styleSheet.value
80
+ tree.props.__hmStyle = Object.assign({}, tree.props.__hmStyle, tree.props.__styleSheet.value)
81
81
  }
82
82
 
83
83
  // 后代选择器
@@ -113,6 +113,15 @@ export interface TaroStyleType {
113
113
  animationDelay?: number
114
114
  animationIterationCount?: number
115
115
 
116
+ // shadow
117
+ boxShadow?: {
118
+ radius: number
119
+ color?: string
120
+ offsetX?: number
121
+ offsetY?: number
122
+ fill?: boolean
123
+ }
124
+
116
125
  // other
117
126
  opacity?: number | Resource
118
127
  zIndex?: number
@@ -55,6 +55,7 @@ export function parseClasses (classNames = ''): string[] {
55
55
 
56
56
  // 合并静态样式,从样式表里面找到对应的样式
57
57
  export function calcStaticStyle (styleSheet: Record<string, CSSProperties>, classNames = ''): CSSProperties {
58
+ classNames = classNames || '' // 兼容有些开发者传入了false/null等非字符串类型
58
59
  const obj: CSSProperties[] = []
59
60
 
60
61
  if (!styleSheet.cache) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/plugin-platform-harmony-ets",
3
- "version": "4.0.0-beta.53",
3
+ "version": "4.0.0-beta.55",
4
4
  "description": "OpenHarmony & 鸿蒙系统插件",
5
5
  "author": "O2Team",
6
6
  "homepage": "https://gitee.com/openharmony-sig/taro",
@@ -25,13 +25,13 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "webpack-sources": "^3.2.3",
28
- "@tarojs/components": "4.0.0-beta.53",
29
- "@tarojs/helper": "4.0.0-beta.53",
30
- "@tarojs/runner-utils": "4.0.0-beta.53",
31
- "@tarojs/service": "4.0.0-beta.53",
32
- "@tarojs/runtime": "4.0.0-beta.53",
33
- "@tarojs/taro": "4.0.0-beta.53",
34
- "@tarojs/shared": "4.0.0-beta.53"
28
+ "@tarojs/components": "4.0.0-beta.55",
29
+ "@tarojs/helper": "4.0.0-beta.55",
30
+ "@tarojs/runtime": "4.0.0-beta.55",
31
+ "@tarojs/runner-utils": "4.0.0-beta.55",
32
+ "@tarojs/service": "4.0.0-beta.55",
33
+ "@tarojs/shared": "4.0.0-beta.55",
34
+ "@tarojs/taro": "4.0.0-beta.55"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -44,7 +44,7 @@
44
44
  "solid-js": "^1.8.16",
45
45
  "tslib": "^2.4.0",
46
46
  "typescript": "^4.8.2",
47
- "rollup-plugin-copy": "4.0.0-beta.53"
47
+ "rollup-plugin-copy": "4.0.0-beta.55"
48
48
  },
49
49
  "scripts": {
50
50
  "prebuild": "rimraf ./dist",