@tarojs/plugin-platform-harmony-ets 4.0.0-beta.79 → 4.0.0-beta.80

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.
@@ -6,6 +6,21 @@ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
6
6
 
7
7
  import type { TaroAny, TaroEvent, TaroButtonElement, TaroStyleType } from '@tarojs/runtime'
8
8
 
9
+ interface ButtonAttrs {
10
+ disabled?: boolean
11
+ }
12
+
13
+ @Extend(Button)
14
+ function attrs(attr: ButtonAttrs) {
15
+ .enabled(!attr.disabled)
16
+ }
17
+
18
+ function getAttributes(node: TaroButtonElement): ButtonAttrs {
19
+ return {
20
+ disabled: node._attrs.disabled || false,
21
+ }
22
+ }
23
+
9
24
  @Extend(Button)
10
25
  function themeStyles(style: TaroStyleType) {
11
26
  .fontColor(style.color)
@@ -121,6 +136,7 @@ export default struct TaroButton {
121
136
  }
122
137
  .themeStyles(getThemeAttributes(this.node))
123
138
  .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
139
+ .attrs(getAttributes(this.node))
124
140
  .constraintSize({
125
141
  minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
126
142
  minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
@@ -13,17 +13,20 @@ interface CheckboxOptions {
13
13
  }
14
14
  interface CheckboxAttrs {
15
15
  selectedColor?: ResourceColor
16
+ disabled?: boolean
16
17
  }
17
18
 
18
19
  @Extend(Checkbox)
19
20
  function checkboxAttr(attr: CheckboxAttrs) {
20
21
  .selectedColor(attr.selectedColor)
22
+ .enabled(!attr.disabled)
21
23
  }
22
24
 
23
25
  function getAttributes (node: TaroCheckboxElement): CheckboxAttrs {
24
26
  const _attrs = node._attrs
25
27
  const checkboxAttrs: CheckboxAttrs = {}
26
28
  checkboxAttrs.selectedColor = _attrs.color || '#1aad19'
29
+ checkboxAttrs.disabled = !!_attrs.disabled
27
30
  return checkboxAttrs
28
31
  }
29
32
 
@@ -1,7 +1,7 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
- import { parseStyles, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
+ import { parseStyles, shouldBindEvent, getNodeThresholds, getStyleAttr } from './utils/helper'
5
5
  import { INPUT_TYPE_MAP, INPUT_CONFIRM_MAP } from './utils/constant/style'
6
6
 
7
7
  import type { TaroStyleType, TaroAny, TaroInputElement, TaroEvent } from '@tarojs/runtime'
@@ -9,6 +9,7 @@ import type { TaroStyleType, TaroAny, TaroInputElement, TaroEvent } from '@taroj
9
9
  interface InputAttrs {
10
10
  textAlign?: TextAlign
11
11
  autoFocus?: boolean
12
+ disabled?: boolean
12
13
  }
13
14
 
14
15
  @Extend(TextInput)
@@ -24,12 +25,14 @@ function styles (style: TaroStyleType) {
24
25
  function attrs(attr: InputAttrs) {
25
26
  .textAlign(attr.textAlign)
26
27
  .defaultFocus(attr.autoFocus)
28
+ .enabled(!attr.disabled)
27
29
  }
28
30
 
29
31
  function getAttributes(node: TaroInputElement): InputAttrs {
30
32
  return {
31
33
  textAlign: node.hmStyle.textAlign,
32
34
  autoFocus: node._attrs.autoFocus || node._attrs.focus || false,
35
+ disabled: node._attrs.disabled || false,
33
36
  }
34
37
  }
35
38
 
@@ -75,6 +78,7 @@ export default struct TaroInput {
75
78
  .placeholderColor(getPlaceholderColor(this.node))
76
79
  .enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
77
80
  .padding(0) // Note: 移出 Input 默认 padding 设置
81
+ .backgroundColor(getStyleAttr(this.node, "backgroundColor"))//
78
82
  .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
79
83
  .styles(this.node?.hmStyle)
80
84
  .attrs(getAttributes(this.node))
@@ -1,5 +1,5 @@
1
1
  import type { TaroAny, TaroMovableAreaElement, TaroMovableViewElement } from '@tarojs/runtime'
2
-
2
+ import { isTaroMovableViewElement } from '@tarojs/runtime'
3
3
  import commonStyleModify, { rowModify, columnModify } from './style'
4
4
 
5
5
  import { FlexManager } from './utils/flexManager'
@@ -7,7 +7,10 @@ import { isUndefined } from '@tarojs/shared'
7
7
 
8
8
  @Component
9
9
  export default struct TaroMovableArea {
10
- @Builder customBuilder() {}
10
+ @Builder
11
+ customBuilder() {
12
+ }
13
+
11
14
  @BuilderParam createLazyChildren: (node: TaroMovableAreaElement) => void = this.customBuilder
12
15
  @ObjectLink node: TaroMovableAreaElement
13
16
  @State overwriteStyle: Record<string, TaroAny> = {}
@@ -18,6 +21,10 @@ export default struct TaroMovableArea {
18
21
  }
19
22
  }
20
23
 
24
+
25
+
26
+
27
+
21
28
  build() {
22
29
  if (FlexManager.useFlexLayout(this.node)) {
23
30
  Flex(FlexManager.flexOptions(this.node)) {
@@ -26,28 +33,21 @@ export default struct TaroMovableArea {
26
33
  .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
27
34
  .clip(true)
28
35
  .onAreaChange((oldValue: Area, newValue: Area) => {
29
- this.node.childNodes.forEach(item => {
30
- if(item.nodeName === 'MOVABLE-VIEW') {
31
- ;(item as TaroMovableViewElement).area = {
32
- w: Number( newValue.width),
33
- h: Number(newValue.height)
34
- }
35
- }
36
- })
36
+ areaChangeHandle(this.node, newValue)
37
37
  })
38
38
  .gesture(
39
39
  PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
40
40
  this.node.childNodes.forEach(item => {
41
- if(item.nodeName === 'MOVABLE-VIEW') {
42
- ;(item as TaroMovableViewElement).startScale()
41
+ if (isTaroMovableViewElement(item)) {
42
+ item.startScale()
43
43
  }
44
44
  })
45
45
  }).onActionUpdate((event) => {
46
46
  const scaleArea = this.node.getAttribute('scaleArea')
47
47
  if (scaleArea) {
48
48
  this.node.childNodes.forEach(item => {
49
- if(item.nodeName === 'MOVABLE-VIEW') {
50
- ;(item as TaroMovableViewElement).doScale(event.scale)
49
+ if (isTaroMovableViewElement(item)) {
50
+ item.doScale(event.scale)
51
51
  }
52
52
  })
53
53
  }
@@ -60,28 +60,21 @@ export default struct TaroMovableArea {
60
60
  .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
61
61
  .clip(true)
62
62
  .onAreaChange((oldValue: Area, newValue: Area) => {
63
- this.node.childNodes.forEach(item => {
64
- if(item.nodeName === 'MOVABLE-VIEW') {
65
- ;(item as TaroMovableViewElement).area = {
66
- w: Number( newValue.width),
67
- h: Number(newValue.height)
68
- }
69
- }
70
- })
63
+ areaChangeHandle(this.node, newValue)
71
64
  })
72
65
  .gesture(
73
66
  PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
74
67
  this.node.childNodes.forEach(item => {
75
- if(item.nodeName === 'MOVABLE-VIEW') {
76
- ;(item as TaroMovableViewElement).startScale()
68
+ if (isTaroMovableViewElement(item)) {
69
+ item.startScale()
77
70
  }
78
71
  })
79
72
  }).onActionUpdate((event) => {
80
73
  const scaleArea = this.node.getAttribute('scaleArea')
81
74
  if (scaleArea) {
82
75
  this.node.childNodes.forEach(item => {
83
- if(item.nodeName === 'MOVABLE-VIEW') {
84
- ;(item as TaroMovableViewElement).doScale(event.scale)
76
+ if (isTaroMovableViewElement(item)) {
77
+ item.doScale(event.scale)
85
78
  }
86
79
  })
87
80
  }
@@ -94,28 +87,21 @@ export default struct TaroMovableArea {
94
87
  .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
95
88
  .clip(true)
96
89
  .onAreaChange((oldValue: Area, newValue: Area) => {
97
- this.node.childNodes.forEach(item => {
98
- if(item.nodeName === 'MOVABLE-VIEW') {
99
- ;(item as TaroMovableViewElement).area = {
100
- w: Number( newValue.width),
101
- h: Number(newValue.height)
102
- }
103
- }
104
- })
90
+ areaChangeHandle(this.node, newValue)
105
91
  })
106
92
  .gesture(
107
93
  PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
108
94
  this.node.childNodes.forEach(item => {
109
- if(item.nodeName === 'MOVABLE-VIEW') {
110
- ;(item as TaroMovableViewElement).startScale()
95
+ if (isTaroMovableViewElement(item)) {
96
+ item.startScale()
111
97
  }
112
98
  })
113
99
  }).onActionUpdate((event) => {
114
100
  const scaleArea = this.node.getAttribute('scaleArea')
115
101
  if (scaleArea) {
116
102
  this.node.childNodes.forEach(item => {
117
- if(item.nodeName === 'MOVABLE-VIEW') {
118
- ;(item as TaroMovableViewElement).doScale(event.scale)
103
+ if (isTaroMovableViewElement(item)) {
104
+ item.doScale(event.scale)
119
105
  }
120
106
  })
121
107
  }
@@ -124,3 +110,15 @@ export default struct TaroMovableArea {
124
110
  }
125
111
  }
126
112
  }
113
+ function areaChangeHandle(node: TaroMovableAreaElement,newValue: Area) {
114
+ node.childNodes.forEach(item => {
115
+ if (isTaroMovableViewElement(item)) {
116
+ if (item.area?.w !== Number(newValue.width) || item.area?.h !== Number(newValue.height)) {
117
+ item.area = {
118
+ w: Number(newValue.width),
119
+ h: Number(newValue.height)
120
+ }
121
+ }
122
+ }
123
+ })
124
+ }
@@ -42,7 +42,9 @@ export default struct TaroMovableView {
42
42
  .translate({ x: this.node.position.x, y: this.node.position.y })
43
43
  .scale({ x: this.node.scaleValue, y: this.node.scaleValue })
44
44
  .onAreaChange((oldValue: Area, newValue: Area) => {
45
- this.node.selfSize = { w: Number(newValue.width), h: Number(newValue.height) }
45
+ if (this.node.selfSize?.w !== Number(newValue.width) || this.node.selfSize?.h !== Number(newValue.height)) {
46
+ this.node.selfSize = { w: Number(newValue.width), h: Number(newValue.height) }
47
+ }
46
48
  })
47
49
  .visibility(this.node.visibility)
48
50
  .gesture(
@@ -11,12 +11,14 @@ import { isUndefined } from '@tarojs/shared'
11
11
  interface RadioAttrs {
12
12
  radioStyle?: HarmonyType.RadioStyle
13
13
  themeStyles?: boolean
14
+ disabled?: boolean
14
15
  }
15
16
 
16
17
  @Extend(Radio)
17
18
  function radioAttr (attr: RadioAttrs) {
18
19
  .radioStyle(attr.radioStyle)
19
20
  .themeStyles(attr.themeStyles)
21
+ .enabled(!attr.disabled)
20
22
  }
21
23
 
22
24
  function getAttributes (node: TaroRadioElement): RadioAttrs {
@@ -25,6 +27,7 @@ function getAttributes (node: TaroRadioElement): RadioAttrs {
25
27
  checkedBackgroundColor: node._attrs.color || '#1aad19'
26
28
  }
27
29
  radioAttrs.themeStyles = !!node._attrs.disabled
30
+ radioAttrs.disabled = !!node._attrs.disabled
28
31
  return radioAttrs
29
32
  }
30
33
 
@@ -10,6 +10,7 @@ interface SliderAttrs {
10
10
  trackColor?: ResourceColor
11
11
  trackThickness?: Length
12
12
  blockColor?: ResourceColor
13
+ disabled?: boolean
13
14
  }
14
15
 
15
16
  @Extend(Slider)
@@ -18,6 +19,7 @@ function attrs (attr: SliderAttrs) {
18
19
  .trackColor(attr.trackColor)
19
20
  .trackThickness(attr.trackThickness)
20
21
  .blockColor(attr.blockColor)
22
+ .enabled(!attr.disabled)
21
23
  }
22
24
 
23
25
  function getAttributes (node: TaroSliderElement): SliderAttrs {
@@ -27,6 +29,7 @@ function getAttributes (node: TaroSliderElement): SliderAttrs {
27
29
  sliderAttrs.trackColor = _attrs.backgroundColor || _attrs.color || '#e9e9e9'
28
30
  sliderAttrs.trackThickness = _attrs.blockSize
29
31
  sliderAttrs.blockColor = _attrs.blockColor || '#ffffff'
32
+ sliderAttrs.disabled = !!_attrs.disabled
30
33
  return sliderAttrs
31
34
  }
32
35
 
@@ -7,18 +7,20 @@ import type { TaroAny, TaroSwitchElement, TaroEvent } from '@tarojs/runtime'
7
7
 
8
8
  interface SwitchAttrs {
9
9
  selectedColor?: ResourceColor
10
+ disabled?: boolean
10
11
  }
11
12
 
12
13
  @Extend(Toggle)
13
14
  function attrs(attr: SwitchAttrs) {
14
15
  .selectedColor(attr.selectedColor)
16
+ .enabled(!attr.disabled)
15
17
  }
16
18
 
17
19
  function getAttributes (node: TaroSwitchElement): SwitchAttrs {
18
- const _attrs = node._attrs
19
- const switchStyle: SwitchAttrs = {}
20
- switchStyle.selectedColor = _attrs.color || '#04BE02'
21
- return switchStyle
20
+ const attr: SwitchAttrs = {}
21
+ attr.selectedColor = node._attrs.color || '#04BE02'
22
+ attr.disabled = !!node._attrs.disabled
23
+ return attr
22
24
  }
23
25
 
24
26
  @Extend(Toggle)
@@ -7,6 +7,7 @@ import type { TaroAny, TaroStyleType, TaroTextStyleType, TaroTextAreaElement, Ta
7
7
 
8
8
  interface TextareaAttrs extends TaroTextStyleType {
9
9
  autoFocus?: boolean
10
+ disabled?: boolean
10
11
  }
11
12
 
12
13
  @Extend(TextArea)
@@ -23,11 +24,13 @@ function textAttr(attr: TextareaAttrs) {
23
24
  .textAlign(attr.textAlign)
24
25
  .maxLines(attr.WebkitLineClamp)
25
26
  .defaultFocus(attr.autoFocus)
27
+ .enabled(!attr.disabled)
26
28
  }
27
29
 
28
30
  function getAttributes(node: TaroTextAreaElement): TextareaAttrs {
29
31
  const attrs: TaroAny = getFontAttributes(node)
30
32
  attrs.autoFocus = node._attrs.autoFocus || node._attrs.focus || false
33
+ attrs.disabled = node._attrs.disabled || false
31
34
  return attrs
32
35
  }
33
36
 
@@ -16,7 +16,7 @@ import {
16
16
  TaroTextAreaElement
17
17
  } from './form'
18
18
  import { TaroMovableAreaElement } from './movableArea'
19
- import { TaroMovableViewElement } from './movableView'
19
+ import { TaroMovableViewElement, isTaroMovableViewElement } from './movableView'
20
20
  import {
21
21
  TaroButtonElement,
22
22
  TaroIconElement,
@@ -113,3 +113,8 @@ export {
113
113
  TaroViewElement,
114
114
  TaroWebViewElement
115
115
  }
116
+
117
+
118
+ export {
119
+ isTaroMovableViewElement
120
+ }
@@ -1,6 +1,7 @@
1
1
  import { TaroElement } from './element'
2
2
 
3
3
  import type { MovableViewProps } from '@tarojs/components/types'
4
+ import type { TaroAny } from '../../utils'
4
5
 
5
6
  type Tsize = {
6
7
  w: number
@@ -21,6 +22,9 @@ function calcPosition(postion: number, start: number, end: number) {
21
22
  }
22
23
  }
23
24
 
25
+ export function isTaroMovableViewElement (item: TaroAny): item is TaroMovableViewElement {
26
+ return item instanceof TaroMovableViewElement
27
+ }
24
28
  @Observed
25
29
  export class TaroMovableViewElement extends TaroElement<MovableViewProps & { animation: undefined }> {
26
30
  _scaleValue = 1
@@ -55,17 +59,6 @@ export class TaroMovableViewElement extends TaroElement<MovableViewProps & { ani
55
59
  return 0
56
60
  }
57
61
 
58
- set area(val: Tsize) {
59
- if (this._area === undefined) {
60
- this._areaInited = true
61
- }
62
- this._area = val
63
- }
64
-
65
- get area(): Tsize | undefined {
66
- return this._area
67
- }
68
-
69
62
  startScale() {
70
63
  this._scalevalueTemp = this._scaleValue
71
64
  }
@@ -160,7 +153,7 @@ export class TaroMovableViewElement extends TaroElement<MovableViewProps & { ani
160
153
  }
161
154
 
162
155
  set area(val: Tsize) {
163
-
156
+ if (val.w === this._area?.w && val.h === this._area?.h) return
164
157
  this._area = val
165
158
  if (!this._areaInited) {
166
159
  this._areaInited = true
@@ -173,6 +166,7 @@ export class TaroMovableViewElement extends TaroElement<MovableViewProps & { ani
173
166
  }
174
167
 
175
168
  set selfSize(val: Tsize) {
169
+ if (val.w === this._selfSize?.w && val.h === this._selfSize?.h) return
176
170
  this._selfSize = val
177
171
  if (!this._selfSizeInited) {
178
172
  this._selfSizeInited = true
@@ -186,7 +180,7 @@ export class TaroMovableViewElement extends TaroElement<MovableViewProps & { ani
186
180
 
187
181
  initPositionFromAttribute () {
188
182
  if (!this.area || !this.selfSize) {
189
- return
183
+ return
190
184
  }
191
185
  const x = this.getAttribute('x') ? Number(this.getAttribute('x')) : 0
192
186
  const y = this.getAttribute('y') ? Number(this.getAttribute('y')) : 0
@@ -238,6 +232,8 @@ export class TaroMovableViewElement extends TaroElement<MovableViewProps & { ani
238
232
  const touchFns = (this?.__listeners?.[eventName] || []) as Function[]
239
233
  touchFns.forEach(fn => {
240
234
  fn({
235
+ _hmEvent: gestureEvent,
236
+ target: this,
241
237
  changedTouches: gestureEvent.fingerList.map(finger => ({
242
238
  clientX: finger.globalX,
243
239
  clientY: finger.globalY
@@ -50,6 +50,9 @@ export function convertNumber2VP (value: number, unit = 'px'): string | number {
50
50
  }
51
51
 
52
52
  export function parseClasses (classNames = ''): string[] {
53
+ if (typeof classNames !== 'string') {
54
+ return []
55
+ }
53
56
  return classNames.includes(' ') ? classNames.split(' ') : [classNames]
54
57
  }
55
58
 
@@ -64,6 +67,7 @@ export function calcStaticStyle (styleSheet: Record<string, CSSProperties>, clas
64
67
  const cache: Record<string, CSSProperties> = styleSheet.cache as Record<string, CSSProperties>
65
68
 
66
69
  const classes = parseClasses(classNames)
70
+ if (!classes.length) return {}
67
71
  if (classes.length === 1) {
68
72
  // 同一个引用
69
73
  return styleSheet[classes[0]]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/plugin-platform-harmony-ets",
3
- "version": "4.0.0-beta.79",
3
+ "version": "4.0.0-beta.80",
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.79",
29
- "@tarojs/helper": "4.0.0-beta.79",
30
- "@tarojs/runner-utils": "4.0.0-beta.79",
31
- "@tarojs/service": "4.0.0-beta.79",
32
- "@tarojs/shared": "4.0.0-beta.79",
33
- "@tarojs/taro": "4.0.0-beta.79",
34
- "@tarojs/runtime": "4.0.0-beta.79"
28
+ "@tarojs/components": "4.0.0-beta.80",
29
+ "@tarojs/helper": "4.0.0-beta.80",
30
+ "@tarojs/runner-utils": "4.0.0-beta.80",
31
+ "@tarojs/service": "4.0.0-beta.80",
32
+ "@tarojs/runtime": "4.0.0-beta.80",
33
+ "@tarojs/shared": "4.0.0-beta.80",
34
+ "@tarojs/taro": "4.0.0-beta.80"
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.79"
47
+ "rollup-plugin-copy": "4.0.0-beta.80"
48
48
  },
49
49
  "scripts": {
50
50
  "prebuild": "rimraf ./dist",