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

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 (78) hide show
  1. package/dist/apis/device/memory.ts +10 -3
  2. package/dist/apis/index.ts +2 -0
  3. package/dist/apis/media/video/VideoContext.ts +56 -7
  4. package/dist/apis/media/video/index.ts +3 -2
  5. package/dist/apis/network/request.ts +5 -5
  6. package/dist/apis/route/index.ts +15 -0
  7. package/dist/apis/storage/index.ts +124 -60
  8. package/dist/apis/wxml/index.ts +2 -0
  9. package/dist/components-harmony-ets/button.ets +26 -40
  10. package/dist/components-harmony-ets/checkbox.ets +70 -99
  11. package/dist/components-harmony-ets/form.ets +29 -42
  12. package/dist/components-harmony-ets/icon.ets +6 -34
  13. package/dist/components-harmony-ets/image.ets +2 -32
  14. package/dist/components-harmony-ets/innerHtml.ets +2 -2
  15. package/dist/components-harmony-ets/input.ets +7 -27
  16. package/dist/components-harmony-ets/label.ets +40 -47
  17. package/dist/components-harmony-ets/picker.ets +66 -73
  18. package/dist/components-harmony-ets/radio.ets +72 -101
  19. package/dist/components-harmony-ets/richText.ets +4 -36
  20. package/dist/components-harmony-ets/scrollView.ets +34 -74
  21. package/dist/components-harmony-ets/slider.ets +9 -34
  22. package/dist/components-harmony-ets/style.ets +154 -0
  23. package/dist/components-harmony-ets/swiper.ets +4 -34
  24. package/dist/components-harmony-ets/switch.ets +43 -56
  25. package/dist/components-harmony-ets/text.ets +7 -34
  26. package/dist/components-harmony-ets/textArea.ets +8 -28
  27. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
  28. package/dist/components-harmony-ets/utils/flexManager.ets +45 -7
  29. package/dist/components-harmony-ets/utils/helper.ets +2 -2
  30. package/dist/components-harmony-ets/utils/styles.ets +58 -20
  31. package/dist/components-harmony-ets/video.ets +4 -34
  32. package/dist/components-harmony-ets/view.ets +25 -67
  33. package/dist/components-harmony-ets/webView.ets +50 -0
  34. package/dist/index.js +103 -5
  35. package/dist/index.js.map +1 -1
  36. package/dist/runtime-ets/bom/window.ts +2 -2
  37. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -6
  38. package/dist/runtime-ets/dom/document.ts +21 -4
  39. package/dist/runtime-ets/dom/element/element.ts +1 -0
  40. package/dist/runtime-ets/dom/element/form.ts +11 -2
  41. package/dist/runtime-ets/dom/element/index.ts +4 -1
  42. package/dist/runtime-ets/dom/element/normal.ts +1 -0
  43. package/dist/runtime-ets/dom/element/webView.ts +61 -0
  44. package/dist/runtime-ets/dom/node.ts +29 -16
  45. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
  46. package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
  47. package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
  48. package/dist/runtime-ets/dom/stylesheet/util.ts +58 -6
  49. package/dist/runtime-ets/index.ts +1 -2
  50. package/dist/runtime-ets/interface/event.ts +2 -1
  51. package/dist/runtime-ets/utils/index.ts +6 -1
  52. package/dist/runtime-ets/utils/info.ts +3 -1
  53. package/dist/runtime-framework/react/app.ts +12 -22
  54. package/dist/runtime-framework/react/hooks.ts +3 -3
  55. package/dist/runtime-framework/react/index.ts +1 -0
  56. package/dist/runtime-framework/react/native-page.ts +344 -0
  57. package/dist/runtime-framework/react/page.ts +2 -2
  58. package/dist/runtime-framework/solid/hooks.ts +3 -3
  59. package/dist/runtime-utils.js +181 -80
  60. package/dist/runtime-utils.js.map +1 -1
  61. package/dist/runtime.js +181 -80
  62. package/dist/runtime.js.map +1 -1
  63. package/package.json +12 -11
  64. package/static/media/cancel.svg +1 -0
  65. package/static/media/circle.svg +1 -0
  66. package/static/media/clear.svg +1 -0
  67. package/static/media/download.svg +1 -0
  68. package/static/media/info.svg +1 -0
  69. package/static/media/info_circle.svg +1 -0
  70. package/static/media/search.svg +1 -0
  71. package/static/media/success.svg +1 -0
  72. package/static/media/success_no_circle.svg +1 -0
  73. package/static/media/taro_arrow_left.svg +1 -0
  74. package/static/media/taro_home.svg +1 -0
  75. package/static/media/waiting.svg +1 -0
  76. package/static/media/warn.svg +1 -0
  77. package/types/runtime.d.ts +2 -0
  78. package/dist/runtime-ets/utils/bind.ts +0 -24
@@ -1,10 +1,11 @@
1
1
  import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
+ import commonStyleModify from './style'
3
4
  import { createLazyChildren } from './render'
4
5
  import { FlexManager } from './utils/FlexManager'
5
- import { shouldBindEvent, getNormalAttributes, getNodeThresholds } from './utils/helper'
6
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
6
7
 
7
- import type { TaroStyleType, TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
8
+ import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
8
9
 
9
10
  interface CheckboxOptions {
10
11
  name?: string
@@ -14,37 +15,6 @@ interface CheckboxAttrs {
14
15
  selectedColor?: ResourceColor
15
16
  }
16
17
 
17
- @Extend(Checkbox)
18
- function checkboxStyle (style: TaroStyleType) {
19
- .id(style.id)
20
- .key(style.id)
21
- .padding(style.padding)
22
- .margin(style.margin)
23
- .width(style.width)
24
- .height(style.height)
25
- .constraintSize(style.constraintSize)
26
- .flexGrow(style.flexGrow)
27
- .flexShrink(style.flexShrink)
28
- .flexBasis(style.flexBasis)
29
- .alignSelf(style.alignSelf)
30
- .backgroundColor(style.backgroundColor)
31
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
32
- .backgroundImageSize(style.backgroundImageSize)
33
- .backgroundImagePosition(style.backgroundImagePosition)
34
- .rotate(style.rotate)
35
- .scale(style.scale)
36
- .translate(style.translate)
37
- .transform(style.transform)
38
- .borderStyle(style.borderStyle)
39
- .borderWidth(style.borderWidth)
40
- .borderColor(style.borderColor)
41
- .borderRadius(style.borderRadius)
42
- .linearGradient(style.linearGradient)
43
- .zIndex(style.zIndex)
44
- .opacity(style.opacity)
45
- .clip(style.clip)
46
- }
47
-
48
18
  @Extend(Checkbox)
49
19
  function checkboxAttr(attr: CheckboxAttrs) {
50
20
  .selectedColor(attr.selectedColor)
@@ -63,75 +33,63 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
63
33
  }
64
34
  }
65
35
 
66
- @Builder
67
- export function TaroCheckbox(node: TaroCheckboxElement) {
68
- Stack() {
69
- Row() {
70
- Checkbox(getOptions(node))
71
- .checkboxStyle(getNormalAttributes(node))
72
- .checkboxAttr(getAttributes(node))
73
- .opacity(!!node._attrs.disabled ? 0.4 : 1)
74
- .select(node.checked)
75
- .onChange((value: boolean) => {
76
- if (!!node?._attrs.disabled) {
77
- node.updateComponent()
78
- } else {
79
- node.updateCheckedValue(value)
36
+ @Component
37
+ export struct TaroCheckbox {
38
+ node: TaroCheckboxElement | null = null
80
39
 
81
- if (value) {
82
- const event: TaroEvent = createTaroEvent('change', { detail: { value: node?._attrs.value } }, node)
83
- eventHandler(event, 'change', node)
40
+ aboutToAppear () {
41
+ if (this.node && !this.node._isInit) {
42
+ this.node._isInit = true
43
+ this.node._reset = this.node.checked || false
44
+ }
45
+ }
46
+
47
+ build () {
48
+ if (this.node) {
49
+ Stack() {
50
+ Row() {
51
+ Checkbox(getOptions(this.node))
52
+ .attributeModifier(commonStyleModify.setNode(this.node))
53
+ .checkboxAttr(getAttributes(this.node))
54
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
55
+ .select(this.node.checked)
56
+ .onChange((value: boolean) => {
57
+ if (this.node) {
58
+ if (!!this.node?._attrs.disabled) {
59
+ this.node.updateComponent()
60
+ } else {
61
+ this.node.updateCheckedValue(value)
62
+
63
+ if (value) {
64
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
65
+ eventHandler(event, 'change', this.node)
66
+ }
67
+ }
68
+ }
69
+ })
70
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
71
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
72
+ if (this.node) {
73
+ this.node._nodeInfo.areaInfo = res[1]
74
+ }
75
+ }))
76
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
77
+ Text(this.node.textContent)
78
+ .textAlign(TextAlign.Center)
79
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
80
+ }
81
+ .onClick(() => {
82
+ if (this.node) {
83
+ if (!this.node?._attrs.disabled) {
84
+ this.node.checked = !this.node.checked
84
85
  }
85
86
  }
86
87
  })
87
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
88
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
89
- node._nodeInfo.areaInfo = res[1]
90
- }))
91
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
92
- Text(node.textContent)
93
- .textAlign(TextAlign.Center)
94
- .opacity(!!node._attrs.disabled ? 0.4 : 1)
95
- }
96
- .onClick(() => {
97
- if (!node?._attrs.disabled) {
98
- node.checked = !node.checked
99
88
  }
100
- })
89
+ }
101
90
  }
102
91
  }
103
92
 
104
- @Extend(Flex)
105
- function checkboxGroupAttrs (style: TaroStyleType) {
106
- .id(style.id)
107
- .key(style.id)
108
- .padding(style.padding)
109
- .margin(style.margin)
110
- .width(style.width)
111
- .height(style.height)
112
- .constraintSize(style.constraintSize)
113
- .flexGrow(style.flexGrow)
114
- .flexShrink(style.flexShrink)
115
- .flexBasis(style.flexBasis)
116
- .alignSelf(style.alignSelf)
117
- .backgroundColor(style.backgroundColor)
118
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
119
- .backgroundImageSize(style.backgroundImageSize)
120
- .backgroundImagePosition(style.backgroundImagePosition)
121
- .rotate(style.rotate)
122
- .scale(style.scale)
123
- .translate(style.translate)
124
- .transform(style.transform)
125
- .borderStyle(style.borderStyle)
126
- .borderWidth(style.borderWidth)
127
- .borderColor(style.borderColor)
128
- .borderRadius(style.borderRadius)
129
- .linearGradient(style.linearGradient)
130
- .zIndex(style.zIndex)
131
- .opacity(style.opacity)
132
- .clip(style.clip)
133
- }
134
-
135
93
  interface ChangeEventDetail { value: string[] }
136
94
 
137
95
  @Component
@@ -163,12 +121,25 @@ export struct TaroCheckboxGroup {
163
121
 
164
122
  build() {
165
123
  if (this.node) {
166
- Flex(FlexManager.flexOptions(this.node)) {
167
- createLazyChildren(this.node)
124
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
125
+ Row() {
126
+ createLazyChildren(this.node)
127
+ }
128
+ .attributeModifier(commonStyleModify.setNode(this.node))
129
+ .defaultEvent()
130
+ .visibleChangeEvent()
131
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
132
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
133
+ } else {
134
+ Column() {
135
+ createLazyChildren(this.node)
136
+ }
137
+ .attributeModifier(commonStyleModify.setNode(this.node))
138
+ .defaultEvent()
139
+ .visibleChangeEvent()
140
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
141
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
168
142
  }
169
- .checkboxGroupAttrs(getNormalAttributes(this.node))
170
- .defaultEvent()
171
- .visibleChangeEvent()
172
143
  }
173
144
  }
174
145
  }
@@ -1,53 +1,40 @@
1
1
  import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME } 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 { FlexManager } from './utils/FlexManager'
6
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
7
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
8
 
8
- import type { TaroAny, TaroFormElement, TaroStyleType } from '@tarojs/runtime'
9
-
10
- @Extend(Flex)
11
- function attrs (style: TaroStyleType) {
12
- .id(style.id)
13
- .key(style.id)
14
- .padding(style.padding)
15
- .margin(style.margin)
16
- .width(style.width)
17
- .height(style.height)
18
- .constraintSize(style.constraintSize)
19
- .flexGrow(style.flexGrow)
20
- .flexShrink(style.flexShrink)
21
- .flexBasis(style.flexBasis)
22
- .alignSelf(style.alignSelf)
23
- .backgroundColor(style.backgroundColor)
24
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
25
- .backgroundImageSize(style.backgroundImageSize)
26
- .backgroundImagePosition(style.backgroundImagePosition)
27
- .rotate(style.rotate)
28
- .scale(style.scale)
29
- .translate(style.translate)
30
- .transform(style.transform)
31
- .borderStyle(style.borderStyle)
32
- .borderWidth(style.borderWidth)
33
- .borderColor(style.borderColor)
34
- .borderRadius(style.borderRadius)
35
- .linearGradient(style.linearGradient)
36
- .zIndex(style.zIndex)
37
- .opacity(style.opacity)
38
- .clip(style.clip)
39
- }
9
+ import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
40
10
 
41
11
  @Builder
42
12
  export default function TaroForm (node: TaroFormElement) {
43
- Flex(FlexManager.flexOptions(node)) {
44
- createLazyChildren(node)
13
+ if (FlexManager.isFlexNode(node) && FlexManager.flexOptions(node).direction !== FlexDirection.Column) {
14
+ Row() {
15
+ createLazyChildren(node)
16
+ }
17
+ .attributeModifier(commonStyleModify.setNode(node))
18
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
19
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
20
+ .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
21
+ node._nodeInfo.areaInfo = res[1]
22
+ }))
23
+ .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
24
+ .alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
25
+ .justifyContent(FlexManager.flexOptions(node).justifyContent)
26
+ } else {
27
+ Column() {
28
+ createLazyChildren(node)
29
+ }
30
+ .attributeModifier(commonStyleModify.setNode(node))
31
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
32
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
33
+ .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
34
+ node._nodeInfo.areaInfo = res[1]
35
+ }))
36
+ .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
37
+ .alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
38
+ .justifyContent(FlexManager.flexOptions(node).justifyContent)
45
39
  }
46
- .attrs(getNormalAttributes(node))
47
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
48
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
49
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
50
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
51
- node._nodeInfo.areaInfo = res[1]
52
- }))
53
40
  }
@@ -1,39 +1,9 @@
1
- import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
1
+ import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, convertNumber2PX } from '@tarojs/runtime'
2
2
 
3
+ import commonStyleModify from './style'
3
4
  import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
5
 
5
- import type { TaroIconElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
6
-
7
- @Extend(Image)
8
- function attrs (style: TaroStyleType) {
9
- .id(style.id)
10
- .key(style.id)
11
- .padding(style.padding)
12
- .margin(style.margin)
13
- .width(style.width || convertNumber2VP(23))
14
- .height(style.height || convertNumber2VP(23))
15
- .constraintSize(style.constraintSize)
16
- .flexGrow(style.flexGrow)
17
- .flexShrink(style.flexShrink)
18
- .flexBasis(style.flexBasis)
19
- .alignSelf(style.alignSelf)
20
- .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)
33
- .zIndex(style.zIndex)
34
- .opacity(style.opacity)
35
- .clip(style.clip)
36
- }
6
+ import type { TaroIconElement, TaroAny } from '@tarojs/runtime'
37
7
 
38
8
  const ICON_COLOR_MAP: TaroAny = {
39
9
  success: Color.Green,
@@ -83,11 +53,13 @@ export default function TaroIcon (node: TaroIconElement) {
83
53
  Image(getIconData(node))
84
54
  .objectFit(ImageFit.Contain)
85
55
  .fillColor(node._attrs.color || ICON_COLOR_MAP[node._attrs.type] || Color.Black)
86
- .attrs(getNormalAttributes(node))
56
+ .attributeModifier(commonStyleModify.setNode(node))
87
57
  .size({
88
58
  width: convertNumber2VP(Number(node._attrs.size) || 23),
89
59
  height: convertNumber2VP(Number(node._attrs.size) || 23),
90
60
  })
61
+ .width(getNormalAttributes(node).width || convertNumber2PX(23))
62
+ .height(getNormalAttributes(node).height || convertNumber2PX(23))
91
63
  .onComplete(e => eventHandler(e, 'complete', node))
92
64
  .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
93
65
  .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
@@ -1,40 +1,10 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
+ import commonStyleModify from './style'
3
4
  import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
5
 
5
6
  import type { TaroImageElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
6
7
 
7
- @Extend(Image)
8
- function attrs (style: TaroStyleType) {
9
- .id(style.id)
10
- .key(style.id)
11
- .padding(style.padding)
12
- .margin(style.margin)
13
- .width(style.width)
14
- .height(style.height)
15
- .backgroundColor(style.backgroundColor)
16
- .constraintSize(style.constraintSize)
17
- .flexGrow(style.flexGrow)
18
- .flexShrink(style.flexShrink)
19
- .flexBasis(style.flexBasis)
20
- .alignSelf(style.alignSelf)
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)
33
- .zIndex(style.zIndex)
34
- .opacity(style.opacity)
35
- .clip(style.clip)
36
- }
37
-
38
8
  function getImageMode (mode: string): ImageFit {
39
9
  switch (mode) {
40
10
  case 'aspectFit': return ImageFit.Contain
@@ -54,7 +24,7 @@ export default function TaroImage (node: TaroImageElement) {
54
24
  node._nodeInfo.areaInfo = res[1]
55
25
  }))
56
26
  .objectFit(getImageMode(node.getAttribute('mode')))
57
- .attrs(getNormalAttributes(node))
27
+ .attributeModifier(commonStyleModify.setNode(node))
58
28
  .onComplete(e => eventHandler(e, 'complete', node))
59
29
  .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
60
30
  }
@@ -1,11 +1,11 @@
1
1
  import htmlParser from './utils/htmlParser'
2
- import { createChildItemWithPosition } from './render'
2
+ import { createChildItem } from './render'
3
3
 
4
4
  import type { TaroElement } from '@tarojs/runtime'
5
5
 
6
6
  @Builder
7
7
  export default function TaroInnerHtml (node: TaroElement) {
8
8
  if (node.innerHTML) {
9
- createChildItemWithPosition(htmlParser(node.innerHTML))
9
+ createChildItem(htmlParser(node.innerHTML))
10
10
  }
11
11
  }
@@ -1,5 +1,6 @@
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 { getNormalAttributes, parseStyles, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
5
  import { INPUT_TYPE_MAP, INPUT_CONFIRM_MAP } from './utils/constant/style'
5
6
 
@@ -11,33 +12,6 @@ interface InputAttrs {
11
12
 
12
13
  @Extend(TextInput)
13
14
  function styles (style: TaroStyleType) {
14
- .id(style.id)
15
- .key(style.id)
16
- .padding(style.padding)
17
- .margin(style.margin)
18
- .width(style.width)
19
- .height(style.height)
20
- .constraintSize(style.constraintSize)
21
- .flexGrow(style.flexGrow)
22
- .flexShrink(style.flexShrink)
23
- .flexBasis(style.flexBasis)
24
- .alignSelf(style.alignSelf)
25
- .backgroundColor(style.backgroundColor)
26
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
27
- .backgroundImageSize(style.backgroundImageSize)
28
- .backgroundImagePosition(style.backgroundImagePosition)
29
- .rotate(style.rotate)
30
- .scale(style.scale)
31
- .translate(style.translate)
32
- .transform(style.transform)
33
- .borderStyle(style.borderStyle)
34
- .borderWidth(style.borderWidth)
35
- .borderColor(style.borderColor)
36
- .borderRadius(style.borderRadius)
37
- .linearGradient(style.linearGradient)
38
- .zIndex(style.zIndex)
39
- .opacity(style.opacity)
40
- .clip(style.clip)
41
15
  .fontColor(style.color)
42
16
  .fontSize(style.fontSize)
43
17
  .fontWeight(style.fontWeight)
@@ -80,6 +54,11 @@ export default struct TaroInput {
80
54
  if (this.node) {
81
55
  this.value = this.node.value
82
56
  this.node._instance = this
57
+
58
+ if (!this.node._isInit) {
59
+ this.node._isInit = true
60
+ this.node._reset = this.node.value || ''
61
+ }
83
62
  }
84
63
  }
85
64
 
@@ -91,6 +70,7 @@ export default struct TaroInput {
91
70
  .maxLength(Number(this.node._attrs?.maxlength) || null)
92
71
  .placeholderColor(getPlaceholderColor(this.node))
93
72
  .enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
73
+ .attributeModifier(commonStyleModify.setNode(this.node))
94
74
  .styles(getNormalAttributes(this.node))
95
75
  .attrs(getAttributes(this.node))
96
76
  .onChange((value: string) => {
@@ -1,42 +1,12 @@
1
1
  import { Current, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, getPageScrollerOrNode, AREA_CHANGE_EVENT_NAME } 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 { FlexManager } from './utils/FlexManager'
6
7
  import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
7
8
 
8
- import type { TaroStyleType, TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
9
-
10
- @Extend(Flex)
11
- function attrs (style: TaroStyleType) {
12
- .id(style.id)
13
- .key(style.id)
14
- .padding(style.padding)
15
- .margin(style.margin)
16
- .width(style.width)
17
- .height(style.height)
18
- .constraintSize(style.constraintSize)
19
- .flexGrow(style.flexGrow)
20
- .flexShrink(style.flexShrink)
21
- .flexBasis(style.flexBasis)
22
- .alignSelf(style.alignSelf)
23
- .backgroundColor(style.backgroundColor)
24
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
25
- .backgroundImageSize(style.backgroundImageSize)
26
- .backgroundImagePosition(style.backgroundImagePosition)
27
- .rotate(style.rotate)
28
- .scale(style.scale)
29
- .translate(style.translate)
30
- .transform(style.transform)
31
- .borderStyle(style.borderStyle)
32
- .borderWidth(style.borderWidth)
33
- .borderColor(style.borderColor)
34
- .borderRadius(style.borderRadius)
35
- .linearGradient(style.linearGradient)
36
- .zIndex(style.zIndex)
37
- .opacity(style.opacity)
38
- .clip(style.clip)
39
- }
9
+ import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
40
10
 
41
11
  function handleTargetChange (id: string) {
42
12
  const taro: TaroAny = Current.taro
@@ -66,20 +36,43 @@ function handleTargetChange (id: string) {
66
36
 
67
37
  @Builder
68
38
  export default function TaroLabel (node: TaroLabelElement) {
69
- Flex(FlexManager.flexOptions(node)) {
70
- createLazyChildren(node)
39
+ if (FlexManager.isFlexNode(node) && FlexManager.flexOptions(node).direction !== FlexDirection.Column) {
40
+ Row() {
41
+ createLazyChildren(node)
42
+ }
43
+ .attributeModifier(commonStyleModify.setNode(node))
44
+ .onClick((e: ClickEvent) => {
45
+ const firstChild: TaroElement | null = node.childNodes[0] as TaroElement | null
46
+ const id: string = node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
47
+
48
+ handleTargetChange(id)
49
+ eventHandler(e, 'click', node)
50
+ })
51
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
52
+ .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
53
+ node._nodeInfo.areaInfo = res[1]
54
+ }))
55
+ .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
56
+ .alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
57
+ .justifyContent(FlexManager.flexOptions(node).justifyContent)
58
+ } else {
59
+ Column() {
60
+ createLazyChildren(node)
61
+ }
62
+ .attributeModifier(commonStyleModify.setNode(node))
63
+ .onClick((e: ClickEvent) => {
64
+ const firstChild: TaroElement | null = node.childNodes[0] as TaroElement | null
65
+ const id: string = node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
66
+
67
+ handleTargetChange(id)
68
+ eventHandler(e, 'click', node)
69
+ })
70
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
71
+ .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
72
+ node._nodeInfo.areaInfo = res[1]
73
+ }))
74
+ .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
75
+ .alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
76
+ .justifyContent(FlexManager.flexOptions(node).justifyContent)
71
77
  }
72
- .attrs(getNormalAttributes(node))
73
- .onClick((e: ClickEvent) => {
74
- const firstChild: TaroElement | null = node.childNodes[0] as TaroElement | null
75
- const id: string = node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
76
-
77
- handleTargetChange(id)
78
- eventHandler(e, 'click', node)
79
- })
80
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
81
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
82
- node._nodeInfo.areaInfo = res[1]
83
- }))
84
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
85
78
  }