@tarojs/plugin-platform-harmony-ets 4.0.0-beta.36 → 4.0.0-beta.37

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 (33) hide show
  1. package/dist/apis/index.ts +2 -1
  2. package/dist/components-harmony-ets/button.ets +30 -32
  3. package/dist/components-harmony-ets/checkbox.ets +52 -56
  4. package/dist/components-harmony-ets/form.ets +25 -27
  5. package/dist/components-harmony-ets/icon.ets +17 -19
  6. package/dist/components-harmony-ets/image.ets +9 -11
  7. package/dist/components-harmony-ets/input.ets +36 -38
  8. package/dist/components-harmony-ets/label.ets +36 -38
  9. package/dist/components-harmony-ets/movableArea.ets +55 -57
  10. package/dist/components-harmony-ets/movableView.ets +44 -46
  11. package/dist/components-harmony-ets/picker.ets +15 -17
  12. package/dist/components-harmony-ets/progress.ets +22 -24
  13. package/dist/components-harmony-ets/radio.ets +54 -58
  14. package/dist/components-harmony-ets/richText.ets +7 -9
  15. package/dist/components-harmony-ets/scrollView.ets +47 -49
  16. package/dist/components-harmony-ets/slider.ets +8 -10
  17. package/dist/components-harmony-ets/style.ets +8 -0
  18. package/dist/components-harmony-ets/swiper.ets +17 -19
  19. package/dist/components-harmony-ets/switch.ets +24 -26
  20. package/dist/components-harmony-ets/text.ets +13 -15
  21. package/dist/components-harmony-ets/textArea.ets +28 -30
  22. package/dist/components-harmony-ets/video.ets +19 -21
  23. package/dist/components-harmony-ets/view.ets +31 -33
  24. package/dist/components-harmony-ets/webView.ets +30 -32
  25. package/dist/runtime-ets/dom/document.ts +2 -0
  26. package/dist/runtime-ets/dom/element/element.ts +45 -1
  27. package/dist/runtime-ets/dom/node.ts +11 -7
  28. package/dist/runtime-ets/dom/stylesheet/type.ts +1 -0
  29. package/dist/runtime-utils.js +5 -46
  30. package/dist/runtime-utils.js.map +1 -1
  31. package/dist/runtime.js +5 -46
  32. package/dist/runtime.js.map +1 -1
  33. package/package.json +9 -9
@@ -112,7 +112,8 @@ export function pxTransform (size: number): number | string {
112
112
  const val = size
113
113
  switch (targetUnit) {
114
114
  case 'vp':
115
- return pxTransformHelper(size, 'px')
115
+ // return pxTransformHelper(size, 'px')
116
+ return `${size}lpx`
116
117
  default:
117
118
  // NOTE: 鸿蒙环境下 style 会自动完成设计稿转换,无需在方法内二次调整
118
119
  }
@@ -107,41 +107,39 @@ export default struct TaroButton {
107
107
  }
108
108
 
109
109
  build() {
110
- if (this.node?.hmStyle?.display !== 'none') {
111
- Button({ stateEffect: !this.node._attrs.disabled }) {
112
- if (this.node._attrs.loading) {
113
- Row() {
114
- LoadingProgress()
115
- .width(20).height(20)
116
- .color(getThemeAttributes(this.node).color)
117
- this.createLazyChildren(this.node)
118
- }
119
- } else {
110
+ Button({ stateEffect: !this.node._attrs.disabled }) {
111
+ if (this.node._attrs.loading) {
112
+ Row() {
113
+ LoadingProgress()
114
+ .width(20).height(20)
115
+ .color(getThemeAttributes(this.node).color)
120
116
  this.createLazyChildren(this.node)
121
117
  }
118
+ } else {
119
+ this.createLazyChildren(this.node)
122
120
  }
123
- .themeStyles(getThemeAttributes(this.node))
124
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
125
- .constraintSize({
126
- minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
127
- minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
128
- maxWidth: this.node.hmStyle?.maxWidth,
129
- maxHeight: this.node.hmStyle?.maxHeight,
130
- })
131
- .type(ButtonType.Normal)
132
- .onClick((e: ClickEvent) => {
133
- if (this.node._attrs.formType && ['submit', 'reset'].includes(this.node._attrs.formType)) {
134
- const eventName = this.node._attrs.formType + '-btn'
135
- const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
136
- eventHandler(event, eventName, this.node)
137
- }
138
- eventHandler(e, 'click', this.node)
139
- })
140
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
141
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
142
- this.node._nodeInfo.areaInfo = res[1]
143
- }))
144
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
145
121
  }
122
+ .themeStyles(getThemeAttributes(this.node))
123
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
124
+ .constraintSize({
125
+ minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
126
+ minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
127
+ maxWidth: this.node.hmStyle?.maxWidth,
128
+ maxHeight: this.node.hmStyle?.maxHeight,
129
+ })
130
+ .type(ButtonType.Normal)
131
+ .onClick((e: ClickEvent) => {
132
+ if (this.node._attrs.formType && ['submit', 'reset'].includes(this.node._attrs.formType)) {
133
+ const eventName = this.node._attrs.formType + '-btn'
134
+ const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
135
+ eventHandler(event, eventName, this.node)
136
+ }
137
+ eventHandler(e, 'click', this.node)
138
+ })
139
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
140
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
141
+ this.node._nodeInfo.areaInfo = res[1]
142
+ }))
143
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
146
144
  }
147
145
  }
@@ -49,47 +49,45 @@ export struct TaroCheckbox {
49
49
  }
50
50
 
51
51
  build () {
52
- if (this.node && this.node?.hmStyle?.display !== 'none') {
53
- Stack() {
54
- Row() {
55
- Checkbox(getOptions(this.node))
56
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
57
- .checkboxAttr(getAttributes(this.node))
58
- .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
59
- .select(this.node.checked)
60
- .onChange((value: boolean) => {
61
- if (this.node) {
62
- if (!!this.node?._attrs.disabled) {
63
- this.node.updateComponent()
64
- } else {
65
- this.node.updateCheckedValue(value)
66
-
67
- if (value) {
68
- const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
69
- eventHandler(event, 'change', this.node)
70
- }
52
+ Stack() {
53
+ Row() {
54
+ Checkbox(getOptions(this.node))
55
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
56
+ .checkboxAttr(getAttributes(this.node))
57
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
58
+ .select(this.node.checked)
59
+ .onChange((value: boolean) => {
60
+ if (this.node) {
61
+ if (!!this.node?._attrs.disabled) {
62
+ this.node.updateComponent()
63
+ } else {
64
+ this.node.updateCheckedValue(value)
65
+
66
+ if (value) {
67
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
68
+ eventHandler(event, 'change', this.node)
71
69
  }
72
70
  }
73
- })
74
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
75
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
76
- if (this.node) {
77
- this.node._nodeInfo.areaInfo = res[1]
78
- }
79
- }))
80
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
81
- Text(this.node.textContent)
82
- .textAlign(TextAlign.Center)
83
- .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
84
- }
85
- .onClick(() => {
86
- if (this.node) {
87
- if (!this.node?._attrs.disabled) {
88
- this.node.checked = !this.node.checked
89
71
  }
90
- }
91
- })
72
+ })
73
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
74
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
75
+ if (this.node) {
76
+ this.node._nodeInfo.areaInfo = res[1]
77
+ }
78
+ }))
79
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
80
+ Text(this.node.textContent)
81
+ .textAlign(TextAlign.Center)
82
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
92
83
  }
84
+ .onClick(() => {
85
+ if (this.node) {
86
+ if (!this.node?._attrs.disabled) {
87
+ this.node.checked = !this.node.checked
88
+ }
89
+ }
90
+ })
93
91
  }
94
92
  }
95
93
  }
@@ -128,26 +126,24 @@ export struct TaroCheckboxGroup {
128
126
  }
129
127
 
130
128
  build() {
131
- if (this.node && this.node?.hmStyle?.display !== 'none') {
132
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
133
- Row() {
134
- this.createLazyChildren(this.node)
135
- }
136
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
137
- .defaultEvent()
138
- .visibleChangeEvent()
139
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
140
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
141
- } else {
142
- Column() {
143
- this.createLazyChildren(this.node)
144
- }
145
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
146
- .defaultEvent()
147
- .visibleChangeEvent()
148
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
149
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
129
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
130
+ Row() {
131
+ this.createLazyChildren(this.node)
132
+ }
133
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
134
+ .defaultEvent()
135
+ .visibleChangeEvent()
136
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
137
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
138
+ } else {
139
+ Column() {
140
+ this.createLazyChildren(this.node)
150
141
  }
142
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
143
+ .defaultEvent()
144
+ .visibleChangeEvent()
145
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
146
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
151
147
  }
152
148
  }
153
149
  }
@@ -22,34 +22,32 @@ export default struct TaroForm {
22
22
  }
23
23
 
24
24
  build() {
25
- if (this.node?.hmStyle?.display !== 'none') {
26
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
27
- Row() {
28
- this.createLazyChildren(this.node)
29
- }
30
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
31
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
32
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
33
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
34
- this.node._nodeInfo.areaInfo = res[1]
35
- }))
36
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
37
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
38
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
39
- } else {
40
- Column() {
41
- this.createLazyChildren(this.node)
42
- }
43
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
44
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
45
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
46
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
47
- this.node._nodeInfo.areaInfo = res[1]
48
- }))
49
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
50
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
51
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
25
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
26
+ Row() {
27
+ this.createLazyChildren(this.node)
52
28
  }
29
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
30
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
31
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
32
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
33
+ this.node._nodeInfo.areaInfo = res[1]
34
+ }))
35
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
36
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
37
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
38
+ } else {
39
+ Column() {
40
+ this.createLazyChildren(this.node)
41
+ }
42
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
43
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
44
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
45
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
46
+ this.node._nodeInfo.areaInfo = res[1]
47
+ }))
48
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
49
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
50
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
53
51
  }
54
52
  }
55
53
  }
@@ -62,25 +62,23 @@ export default struct TaroIcon {
62
62
  }
63
63
 
64
64
  build() {
65
- if (this.node?.hmStyle?.display !== 'none') {
66
- Image(getIconData(this.node))
67
- .objectFit(ImageFit.Contain)
68
- .fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
69
- .attributeModifier(commonStyleModify.setNode(this.node, {
70
- width: convertNumber2PX(23),
71
- height: convertNumber2PX(23)
72
- }).setAnimationStyle(this.overwriteStyle))
73
- .size({
74
- width: convertNumber2VP(Number(this.node._attrs.size) || 23),
75
- height: convertNumber2VP(Number(this.node._attrs.size) || 23),
76
- })
77
- .onComplete(e => eventHandler(e, 'complete', this.node))
78
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
79
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
80
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
81
- this.node._nodeInfo.areaInfo = res[1]
82
- }))
83
- }
65
+ Image(getIconData(this.node))
66
+ .objectFit(ImageFit.Contain)
67
+ .fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
68
+ .attributeModifier(commonStyleModify.setNode(this.node, {
69
+ width: convertNumber2PX(23),
70
+ height: convertNumber2PX(23)
71
+ }).setAnimationStyle(this.overwriteStyle))
72
+ .size({
73
+ width: convertNumber2VP(Number(this.node._attrs.size) || 23),
74
+ height: convertNumber2VP(Number(this.node._attrs.size) || 23),
75
+ })
76
+ .onComplete(e => eventHandler(e, 'complete', this.node))
77
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
78
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
79
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
80
+ this.node._nodeInfo.areaInfo = res[1]
81
+ }))
84
82
  }
85
83
  }
86
84
 
@@ -30,16 +30,14 @@ export default struct TaroImage {
30
30
  }
31
31
 
32
32
  build() {
33
- if (this.node?.hmStyle?.display !== 'none') {
34
- Image(this.node.getAttribute('src'))
35
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
36
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
37
- this.node._nodeInfo.areaInfo = res[1]
38
- }))
39
- .objectFit(getImageMode(this.node.getAttribute('mode')))
40
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
41
- .onComplete(e => eventHandler(e, 'complete', this.node))
42
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
43
- }
33
+ Image(this.node.getAttribute('src'))
34
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
35
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
36
+ this.node._nodeInfo.areaInfo = res[1]
37
+ }))
38
+ .objectFit(getImageMode(this.node.getAttribute('mode')))
39
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
40
+ .onComplete(e => eventHandler(e, 'complete', this.node))
41
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
44
42
  }
45
43
  }
@@ -66,43 +66,41 @@ export default struct TaroInput {
66
66
  }
67
67
 
68
68
  build () {
69
- if (this.node && this.node?.hmStyle?.display !== 'none') {
70
- TextInput({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
71
- .key(this.node._nid)
72
- .type(getInputType(this.node))
73
- .maxLength(Number(this.node._attrs?.maxlength) || null)
74
- .placeholderColor(getPlaceholderColor(this.node))
75
- .enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
76
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
77
- .styles(this.node?.hmStyle)
78
- .attrs(getAttributes(this.node))
79
- .onChange((value: string) => {
80
- const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
81
-
82
- this.value = value
83
- this.node?.updateFormWidgetValue(value)
84
- eventHandler(event, 'input', this.node)
85
- })
86
- .onSubmit(() => {
87
- const event: TaroEvent = createTaroEvent('confirm', { detail: { value: this.value } }, this.node)
88
- eventHandler(event, 'confirm', this.node)
89
- })
90
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
91
- .onBlur(() => {
92
- const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
93
- eventHandler(event, 'blur', this.node)
94
- })
95
- .onFocus(() => {
96
- const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
97
-
98
- eventHandler(event, 'focus', this.node)
99
- })
100
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
101
- if (this.node) {
102
- this.node._nodeInfo.areaInfo = res[1]
103
- }
104
- }))
105
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
106
- }
69
+ TextInput({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
70
+ .key(this.node._nid)
71
+ .type(getInputType(this.node))
72
+ .maxLength(Number(this.node._attrs?.maxlength) || null)
73
+ .placeholderColor(getPlaceholderColor(this.node))
74
+ .enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
75
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
76
+ .styles(this.node?.hmStyle)
77
+ .attrs(getAttributes(this.node))
78
+ .onChange((value: string) => {
79
+ const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
80
+
81
+ this.value = value
82
+ this.node?.updateFormWidgetValue(value)
83
+ eventHandler(event, 'input', this.node)
84
+ })
85
+ .onSubmit(() => {
86
+ const event: TaroEvent = createTaroEvent('confirm', { detail: { value: this.value } }, this.node)
87
+ eventHandler(event, 'confirm', this.node)
88
+ })
89
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
90
+ .onBlur(() => {
91
+ const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
92
+ eventHandler(event, 'blur', this.node)
93
+ })
94
+ .onFocus(() => {
95
+ const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
96
+
97
+ eventHandler(event, 'focus', this.node)
98
+ })
99
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
100
+ if (this.node) {
101
+ this.node._nodeInfo.areaInfo = res[1]
102
+ }
103
+ }))
104
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
107
105
  }
108
106
  }
@@ -48,46 +48,44 @@ export default struct TaroLabel {
48
48
  }
49
49
 
50
50
  build() {
51
- if (this.node?.hmStyle?.display !== 'none') {
52
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
53
- Row() {
54
- this.createLazyChildren(this.node)
55
- }
56
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
57
- .onClick((e: ClickEvent) => {
58
- const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
59
- const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
60
-
61
- handleTargetChange(id)
62
- eventHandler(e, 'click', this.node)
63
- })
64
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
65
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
66
- this.node._nodeInfo.areaInfo = res[1]
67
- }))
68
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
69
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
70
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
71
- } else {
72
- Column() {
73
- this.createLazyChildren(this.node)
74
- }
75
- .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
76
- .onClick((e: ClickEvent) => {
77
- const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
78
- const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
51
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
52
+ Row() {
53
+ this.createLazyChildren(this.node)
54
+ }
55
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
56
+ .onClick((e: ClickEvent) => {
57
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
58
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
79
59
 
80
- handleTargetChange(id)
81
- eventHandler(e, 'click', this.node)
82
- })
83
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
84
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
85
- this.node._nodeInfo.areaInfo = res[1]
86
- }))
87
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
88
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
89
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
60
+ handleTargetChange(id)
61
+ eventHandler(e, 'click', this.node)
62
+ })
63
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
64
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
65
+ this.node._nodeInfo.areaInfo = res[1]
66
+ }))
67
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
68
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
69
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
70
+ } else {
71
+ Column() {
72
+ this.createLazyChildren(this.node)
90
73
  }
74
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
75
+ .onClick((e: ClickEvent) => {
76
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
77
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
78
+
79
+ handleTargetChange(id)
80
+ eventHandler(e, 'click', this.node)
81
+ })
82
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
83
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
84
+ this.node._nodeInfo.areaInfo = res[1]
85
+ }))
86
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
87
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
88
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
91
89
  }
92
90
  }
93
91
  }