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

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 (44) hide show
  1. package/dist/apis/base/system.ts +40 -22
  2. package/dist/components-harmony-ets/button.ets +34 -31
  3. package/dist/components-harmony-ets/checkbox.ets +5 -4
  4. package/dist/components-harmony-ets/form.ets +31 -28
  5. package/dist/components-harmony-ets/icon.ets +22 -18
  6. package/dist/components-harmony-ets/image.ets +15 -11
  7. package/dist/components-harmony-ets/innerHtml.ets +9 -5
  8. package/dist/components-harmony-ets/input.ets +1 -1
  9. package/dist/components-harmony-ets/label.ets +44 -40
  10. package/dist/components-harmony-ets/movableArea.ets +67 -0
  11. package/dist/components-harmony-ets/movableView.ets +66 -0
  12. package/dist/components-harmony-ets/picker.ets +7 -6
  13. package/dist/components-harmony-ets/progress.ets +45 -0
  14. package/dist/components-harmony-ets/radio.ets +5 -5
  15. package/dist/components-harmony-ets/richText.ets +14 -9
  16. package/dist/components-harmony-ets/scrollView.ets +40 -35
  17. package/dist/components-harmony-ets/slider.ets +1 -1
  18. package/dist/components-harmony-ets/swiper.ets +23 -19
  19. package/dist/components-harmony-ets/switch.ets +1 -1
  20. package/dist/components-harmony-ets/text.ets +28 -22
  21. package/dist/components-harmony-ets/textArea.ets +1 -1
  22. package/dist/components-harmony-ets/utils/styles.ets +2 -2
  23. package/dist/components-harmony-ets/video.ets +26 -21
  24. package/dist/components-harmony-ets/view.ets +34 -30
  25. package/dist/components-harmony-ets/webView.ets +37 -32
  26. package/dist/index.js +36 -16
  27. package/dist/index.js.map +1 -1
  28. package/dist/runtime-ets/dom/element/element.ts +0 -4
  29. package/dist/runtime-ets/dom/element/form.ts +11 -4
  30. package/dist/runtime-ets/dom/element/index.ts +9 -1
  31. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  32. package/dist/runtime-ets/dom/element/movableView.ts +12 -0
  33. package/dist/runtime-ets/dom/element/normal.ts +8 -2
  34. package/dist/runtime-ets/dom/element/progress.ts +13 -0
  35. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  36. package/dist/runtime-ets/dom/element/text.ts +1 -0
  37. package/dist/runtime-ets/dom/element/video.ts +1 -0
  38. package/dist/runtime-ets/dom/element/webView.ts +8 -0
  39. package/dist/runtime-ets/dom/node.ts +18 -17
  40. package/dist/runtime-utils.js +43 -21
  41. package/dist/runtime-utils.js.map +1 -1
  42. package/dist/runtime.js +43 -21
  43. package/dist/runtime.js.map +1 -1
  44. package/package.json +8 -8
@@ -1,25 +1,42 @@
1
+ import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'
1
2
  // 设备信息,从 API Version 6 开始支持
2
3
  import deviceInfo from '@ohos.deviceInfo'
3
4
  // 显示设备属性,从 API Version 7 开始支持
4
5
  import _display from '@ohos.display'
5
6
  // 从 API Version 7 开始支持
6
7
  import i18n from '@ohos.i18n'
7
- // 设备信息 从API Version 6开始,该接口不再维护,推荐使用新接口'@ohos.deviceInfo'进行设备信息查询
8
- import deviceMethod from '@system.device'
9
8
 
10
9
  import { callAsyncFail, callAsyncSuccess } from '../utils'
11
10
 
12
11
  import type Taro from '@tarojs/taro/types'
13
12
 
14
- const display = _display.getDefaultDisplaySync()
15
-
16
- let device
13
+ let display
14
+ let safeArea: TaroGeneral.SafeAreaResult | null = null
15
+ try {
16
+ display = _display.getDefaultDisplaySync()
17
+ // @ts-ignore
18
+ display.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} }: _display.CutoutInfo = {}) => {
19
+ if (err?.code) {
20
+ console.error('Failed to get cutout info', JSON.stringify(err))
21
+ return
22
+ }
17
23
 
18
- deviceMethod.getInfo({
19
- success: data => {
20
- device = data
21
- }
22
- })
24
+ const top = Math.max(...boundingRects.map(rect => rect.top * 2 + rect.height), waterfallDisplayAreaRects.top?.top + waterfallDisplayAreaRects.top?.height)
25
+ const bottom = (waterfallDisplayAreaRects.bottom?.top + waterfallDisplayAreaRects.bottom?.height) || display.height
26
+ const left = waterfallDisplayAreaRects.left?.left + waterfallDisplayAreaRects.left?.width
27
+ const right = (waterfallDisplayAreaRects.right?.left + waterfallDisplayAreaRects.right?.width) || display.width
28
+ safeArea = {
29
+ top,
30
+ bottom,
31
+ left,
32
+ right,
33
+ height: bottom - top,
34
+ width: right - left,
35
+ }
36
+ })
37
+ } catch (e) {
38
+ console.error('Failed to get display', e)
39
+ }
23
40
 
24
41
  /* 同步版本 */
25
42
  export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
@@ -32,7 +49,7 @@ export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
32
49
  res.cameraAuthorized = null // 允许使用摄像头的开关 boolean
33
50
  res.enableDebug = null // 是否已打开调试 boolean
34
51
  res.fontSizeSetting = null // 用户字体大小(单位px) number
35
- res.language = i18n && i18n.getSystemLanguage && i18n.getSystemLanguage() // string
52
+ res.language = i18n?.getSystemLanguage?.() // string
36
53
  res.locationAuthorized = null // 定位的开关 boolean
37
54
  res.locationEnabled = null // 地理位置的系统开关 boolean
38
55
  res.microphoneAuthorized = null // 麦克风的开关 boolean
@@ -43,17 +60,18 @@ export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
43
60
  res.notificationSoundAuthorized = false // 通知带有声音的开关(仅 iOS 有效)boolean
44
61
  res.phoneCalendarAuthorized = null // 使用日历的开关 boolean
45
62
  res.wifiEnabled = false // Wi-Fi 的系统开关 boolean
46
- res.pixelRatio = null // 设备像素比,number
47
- res.platform = 'android' // 客户端平台 string
48
- res.safeArea = null // 在竖屏正方向下的安全区域 General.SafeAreaResult
49
- res.screenHeight = display && display.height // 屏幕高度,单位px number
50
- res.screenWidth = display && display.width // 屏幕宽度,单位px number
51
- res.statusBarHeight = null // 状态栏的高度,单位px number
52
- res.system = deviceInfo && deviceInfo.osFullName // 操作系统及版本 string
53
- res.theme = null // 系统当前主题,取值为light或dark 'light' | 'dark'
54
- res.windowWidth = device && device.windowWidth // 可使用窗口宽度,单位px number
55
- res.windowHeight = device && device.windowHeight // 可使用窗口高度,单位px number
56
- res.version = deviceInfo && deviceInfo.displayVersion // 版本号 string
63
+ res.pixelRatio = display && (Math.round(display.xDPI / display.width * 100) / 100) // 设备像素比,number
64
+ res.platform = 'harmony' // 客户端平台 string
65
+ res.safeArea = safeArea // 在竖屏正方向下的安全区域 General.SafeAreaResult
66
+ res.screenHeight = display?.height // 屏幕高度,单位px number
67
+ res.screenWidth = display?.width // 屏幕宽度,单位px number
68
+ res.statusBarHeight = safeArea?.top // 状态栏的高度,单位px number
69
+ res.system = deviceInfo?.osFullName // 操作系统及版本 string
70
+ // Note: 更新配置时才能记录
71
+ res.theme = AppStorage.get('__TARO_APP_CONFIG')?.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK ? 'dark' : 'light' // 系统当前主题,取值为light或dark 'light' | 'dark'
72
+ res.windowHeight = display?.height // 可使用窗口高度,单位px number
73
+ res.windowWidth = display?.width // 可使用窗口宽度,单位px number
74
+ res.version = deviceInfo?.displayVersion // 版本号 string
57
75
 
58
76
  return res
59
77
  }
@@ -94,38 +94,41 @@ function getButtonMinHeight (node: TaroButtonElement): string | number | undefin
94
94
  return getButtonHeight(node)
95
95
  }
96
96
 
97
- @Builder
98
- export default function TaroButton (node: TaroButtonElement) {
99
- Button({ stateEffect: !node._attrs.disabled }) {
100
- Row() {
101
- if (node._attrs.loading) {
102
- LoadingProgress()
103
- .width(20).height(20)
104
- .color(getThemeAttributes(node).color)
97
+ @Component
98
+ export default struct TaroButton {
99
+ @ObjectLink node: TaroButtonElement
100
+ build() {
101
+ Button({ stateEffect: !this.node._attrs.disabled }) {
102
+ Row() {
103
+ if (this.node._attrs.loading) {
104
+ LoadingProgress()
105
+ .width(20).height(20)
106
+ .color(getThemeAttributes(this.node).color)
107
+ }
108
+ createLazyChildren(this.node)
105
109
  }
106
- createLazyChildren(node)
107
110
  }
111
+ .themeStyles(getThemeAttributes(this.node))
112
+ .attributeModifier(commonStyleModify.setNode(this.node))
113
+ .constraintSize({
114
+ minWidth: this.node.hmStyle?.minWidth || getButtonMinWidth(this.node),
115
+ minHeight: this.node.hmStyle?.minHeight || getButtonMinHeight(this.node),
116
+ maxWidth: this.node.hmStyle?.maxWidth,
117
+ maxHeight: this.node.hmStyle?.maxHeight,
118
+ })
119
+ .type(ButtonType.Normal)
120
+ .onClick((e: ClickEvent) => {
121
+ if (this.node._attrs.formType && ['submit', 'reset'].includes(this.node._attrs.formType)) {
122
+ const eventName = this.node._attrs.formType + '-btn'
123
+ const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
124
+ eventHandler(event, eventName, this.node)
125
+ }
126
+ eventHandler(e, 'click', this.node)
127
+ })
128
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
129
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
130
+ this.node._nodeInfo.areaInfo = res[1]
131
+ }))
132
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
108
133
  }
109
- .themeStyles(getThemeAttributes(node))
110
- .attributeModifier(commonStyleModify.setNode(node))
111
- .constraintSize({
112
- minWidth: node.hmStyle?.minWidth || getButtonMinWidth(node),
113
- minHeight: node.hmStyle?.minHeight || getButtonMinHeight(node),
114
- maxWidth: node.hmStyle?.maxWidth,
115
- maxHeight: node.hmStyle?.maxHeight,
116
- })
117
- .type(ButtonType.Normal)
118
- .onClick((e: ClickEvent) => {
119
- if (node._attrs.formType && ['submit', 'reset'].includes(node._attrs.formType)) {
120
- const eventName = node._attrs.formType + '-btn'
121
- const event: TaroEvent = createTaroEvent(eventName, {}, node)
122
- eventHandler(event, eventName, node)
123
- }
124
- eventHandler(e, 'click', node)
125
- })
126
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
127
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
128
- node._nodeInfo.areaInfo = res[1]
129
- }))
130
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
131
134
  }
@@ -2,7 +2,7 @@ import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_E
2
2
 
3
3
  import commonStyleModify from './style'
4
4
  import { createLazyChildren } from './render'
5
- import { FlexManager } from './utils/FlexManager'
5
+ import { FlexManager } from './utils/flexManager'
6
6
  import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
7
 
8
8
  import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
@@ -33,9 +33,10 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
33
33
  }
34
34
  }
35
35
 
36
+
36
37
  @Component
37
38
  export struct TaroCheckbox {
38
- node: TaroCheckboxElement | null = null
39
+ @ObjectLink node: TaroCheckboxElement
39
40
 
40
41
  aboutToAppear () {
41
42
  if (this.node && !this.node._isInit) {
@@ -59,7 +60,7 @@ export struct TaroCheckbox {
59
60
  this.node.updateComponent()
60
61
  } else {
61
62
  this.node.updateCheckedValue(value)
62
-
63
+
63
64
  if (value) {
64
65
  const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
65
66
  eventHandler(event, 'change', this.node)
@@ -94,7 +95,7 @@ interface ChangeEventDetail { value: string[] }
94
95
 
95
96
  @Component
96
97
  export struct TaroCheckboxGroup {
97
- node: TaroCheckboxGroupElement | null = null
98
+ @ObjectLink node: TaroCheckboxGroupElement
98
99
 
99
100
  @Styles visibleChangeEvent () {
100
101
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
@@ -3,38 +3,41 @@ import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBL
3
3
  import commonStyleModify from './style'
4
4
  import { createLazyChildren } from './render'
5
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
- import { FlexManager } from './utils/FlexManager'
6
+ import { FlexManager } from './utils/flexManager'
7
7
  import { shouldBindEvent, getNodeThresholds } from './utils/helper'
8
8
 
9
9
  import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
10
10
 
11
- @Builder
12
- export default function TaroForm (node: TaroFormElement) {
13
- if (FlexManager.isFlexNode(node) && FlexManager.flexOptions(node).direction !== FlexDirection.Column) {
14
- Row() {
15
- createLazyChildren(node)
11
+ @Component
12
+ export default struct TaroForm {
13
+ @ObjectLink node: TaroFormElement
14
+ build() {
15
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
16
+ Row() {
17
+ createLazyChildren(this.node)
18
+ }
19
+ .attributeModifier(commonStyleModify.setNode(this.node))
20
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
21
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
22
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
23
+ this.node._nodeInfo.areaInfo = res[1]
24
+ }))
25
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
26
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
27
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
28
+ } else {
29
+ Column() {
30
+ createLazyChildren(this.node)
31
+ }
32
+ .attributeModifier(commonStyleModify.setNode(this.node))
33
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
34
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
35
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
36
+ this.node._nodeInfo.areaInfo = res[1]
37
+ }))
38
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
39
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
40
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
16
41
  }
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)
39
42
  }
40
43
  }
@@ -48,22 +48,26 @@ function getIconData (node: TaroIconElement): Resource | null {
48
48
  }
49
49
  }
50
50
 
51
- @Builder
52
- export default function TaroIcon (node: TaroIconElement) {
53
- Image(getIconData(node))
54
- .objectFit(ImageFit.Contain)
55
- .fillColor(node._attrs.color || ICON_COLOR_MAP[node._attrs.type] || Color.Black)
56
- .attributeModifier(commonStyleModify.setNode(node))
57
- .size({
58
- width: convertNumber2VP(Number(node._attrs.size) || 23),
59
- height: convertNumber2VP(Number(node._attrs.size) || 23),
60
- })
61
- .width(getNormalAttributes(node).width || convertNumber2PX(23))
62
- .height(getNormalAttributes(node).height || convertNumber2PX(23))
63
- .onComplete(e => eventHandler(e, 'complete', node))
64
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
65
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
66
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
67
- node._nodeInfo.areaInfo = res[1]
68
- }))
51
+ @Component
52
+ export default struct TaroIcon {
53
+ @ObjectLink node: TaroIconElement
54
+ build() {
55
+ Image(getIconData(this.node))
56
+ .objectFit(ImageFit.Contain)
57
+ .fillColor(this.node._attrs.color || ICON_COLOR_MAP[this.node._attrs.type] || Color.Black)
58
+ .attributeModifier(commonStyleModify.setNode(this.node))
59
+ .size({
60
+ width: convertNumber2VP(Number(this.node._attrs.size) || 23),
61
+ height: convertNumber2VP(Number(this.node._attrs.size) || 23),
62
+ })
63
+ .width(getNormalAttributes(this.node).width || convertNumber2PX(23))
64
+ .height(getNormalAttributes(this.node).height || convertNumber2PX(23))
65
+ .onComplete(e => eventHandler(e, 'complete', this.node))
66
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
67
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
68
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
69
+ this.node._nodeInfo.areaInfo = res[1]
70
+ }))
71
+ }
69
72
  }
73
+
@@ -16,15 +16,19 @@ function getImageMode (mode: string): ImageFit {
16
16
  }
17
17
  }
18
18
 
19
- @Builder
20
- export default function TaroImage (node: TaroImageElement) {
21
- Image(node.getAttribute('src'))
22
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
23
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
24
- node._nodeInfo.areaInfo = res[1]
25
- }))
26
- .objectFit(getImageMode(node.getAttribute('mode')))
27
- .attributeModifier(commonStyleModify.setNode(node))
28
- .onComplete(e => eventHandler(e, 'complete', node))
29
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
19
+ @Component
20
+ export default struct TaroImage {
21
+ @ObjectLink node: TaroImageElement
22
+
23
+ build() {
24
+ Image(this.node.getAttribute('src'))
25
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
26
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
27
+ this.node._nodeInfo.areaInfo = res[1]
28
+ }))
29
+ .objectFit(getImageMode(this.node.getAttribute('mode')))
30
+ .attributeModifier(commonStyleModify.setNode(this.node))
31
+ .onComplete(e => eventHandler(e, 'complete', this.node))
32
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
33
+ }
30
34
  }
@@ -1,11 +1,15 @@
1
1
  import htmlParser from './utils/htmlParser'
2
2
  import { createChildItem } from './render'
3
3
 
4
- import type { TaroElement } from '@tarojs/runtime'
4
+ import type { TaroInnerHtmlElement } from '@tarojs/runtime'
5
5
 
6
- @Builder
7
- export default function TaroInnerHtml (node: TaroElement) {
8
- if (node.innerHTML) {
9
- createChildItem(htmlParser(node.innerHTML))
6
+ @Component
7
+ export default struct TaroInnerHtml {
8
+ @ObjectLink node: TaroInnerHtmlElement
9
+
10
+ build() {
11
+ if (this.node.innerHTML) {
12
+ createChildItem(htmlParser(this.node.innerHTML))
13
+ }
10
14
  }
11
15
  }
@@ -48,7 +48,7 @@ function getPlaceholderColor (node: TaroInputElement): string {
48
48
  export default struct TaroInput {
49
49
  @State value: string = ''
50
50
 
51
- node: TaroInputElement | null = null
51
+ @ObjectLink node: TaroInputElement
52
52
 
53
53
  aboutToAppear () {
54
54
  if (this.node) {
@@ -3,7 +3,7 @@ import { Current, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_
3
3
  import commonStyleModify from './style'
4
4
  import { createLazyChildren } from './render'
5
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
- import { FlexManager } from './utils/FlexManager'
6
+ import { FlexManager } from './utils/flexManager'
7
7
  import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
8
8
 
9
9
  import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
@@ -34,45 +34,49 @@ function handleTargetChange (id: string) {
34
34
  }
35
35
  }
36
36
 
37
- @Builder
38
- export default function TaroLabel (node: TaroLabelElement) {
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)
37
+
38
+ @Component
39
+ export default struct TaroLabel {
40
+ @ObjectLink node:TaroLabelElement
41
+ build() {
42
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
43
+ Row() {
44
+ createLazyChildren(this.node)
45
+ }
46
+ .attributeModifier(commonStyleModify.setNode(this.node))
47
+ .onClick((e: ClickEvent) => {
48
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
49
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
50
+
51
+ handleTargetChange(id)
52
+ eventHandler(e, 'click', this.node)
53
+ })
54
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
55
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
56
+ this.node._nodeInfo.areaInfo = res[1]
57
+ }))
58
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
59
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
60
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
61
+ } else {
62
+ Column() {
63
+ createLazyChildren(this.node)
64
+ }
65
+ .attributeModifier(commonStyleModify.setNode(this.node))
66
+ .onClick((e: ClickEvent) => {
67
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
68
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
69
+
70
+ handleTargetChange(id)
71
+ eventHandler(e, 'click', this.node)
72
+ })
73
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
74
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
75
+ this.node._nodeInfo.areaInfo = res[1]
76
+ }))
77
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
78
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
79
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
61
80
  }
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)
77
81
  }
78
82
  }
@@ -0,0 +1,67 @@
1
+ import type { TaroMovableAreaElement, TaroStyleType } from '@tarojs/runtime'
2
+ import commonStyleModify from './style'
3
+ import { createLazyChildren } from './render'
4
+
5
+ import { FlexManager } from './utils/flexManager'
6
+ import { getNormalAttributes } from './utils/helper'
7
+
8
+
9
+ @Extend(Row)
10
+ function rowAttrs(style: TaroStyleType) {
11
+ .constraintSize({
12
+ minWidth: style.minWidth || style.width,
13
+ maxWidth: style.maxWidth,
14
+ minHeight: style.minHeight,
15
+ maxHeight: style.maxHeight
16
+ })
17
+ }
18
+
19
+ @Extend(Column)
20
+ function columnAttrs(style: TaroStyleType) {
21
+ .constraintSize({
22
+ minWidth: style.minWidth,
23
+ maxWidth: style.maxWidth,
24
+ minHeight: style.minHeight || style.height,
25
+ maxHeight: style.maxHeight
26
+ })
27
+ }
28
+
29
+ @Component
30
+ export default struct TaroMovableArea {
31
+ @ObjectLink node: TaroMovableAreaElement
32
+
33
+ @Provide areaWidth: Length = 0
34
+ @Provide areaHeight: Length = 0
35
+
36
+ build() {
37
+ if (this.node) {
38
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
39
+ Row() {
40
+ createLazyChildren(this.node)
41
+ }
42
+ .attributeModifier(commonStyleModify.setNode(this.node))
43
+ .rowAttrs(getNormalAttributes(this.node))
44
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
45
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
46
+ .clip(true)
47
+ .onAreaChange((oldValue: Area, newValue: Area) => {
48
+ this.areaWidth = newValue.width
49
+ this.areaHeight = newValue.height
50
+ })
51
+ } else {
52
+ Column() {
53
+ createLazyChildren(this.node)
54
+ }
55
+ .attributeModifier(commonStyleModify.setNode(this.node))
56
+ .columnAttrs(getNormalAttributes(this.node))
57
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
58
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
59
+ .clip(true)
60
+ .onAreaChange((oldValue: Area, newValue: Area) => {
61
+ this.areaWidth = newValue.width
62
+ this.areaHeight = newValue.height
63
+ })
64
+ }
65
+ }
66
+ }
67
+ }
@@ -0,0 +1,66 @@
1
+ import type { TaroMovableViewElement, TaroStyleType } from '@tarojs/runtime'
2
+
3
+ import commonStyleModify from './style'
4
+ import { createLazyChildren } from './render'
5
+
6
+ import { FlexManager } from './utils/flexManager'
7
+ import { getNormalAttributes, } from './utils/helper'
8
+ @Extend(Row)
9
+ function rowAttrs(style: TaroStyleType) {
10
+ .constraintSize({
11
+ minWidth: style.minWidth || style.width,
12
+ maxWidth: style.maxWidth,
13
+ minHeight: style.minHeight,
14
+ maxHeight: style.maxHeight
15
+ })
16
+ }
17
+
18
+ @Extend(Column)
19
+ function columnAttrs(style: TaroStyleType) {
20
+ .constraintSize({
21
+ minWidth: style.minWidth,
22
+ maxWidth: style.maxWidth,
23
+ minHeight: style.minHeight || style.height,
24
+ maxHeight: style.maxHeight
25
+ })
26
+ }
27
+
28
+ @Component
29
+ export default struct TaroMovableArea {
30
+ @ObjectLink node: TaroMovableViewElement
31
+
32
+ @Provide areaWidth: Length = 0
33
+ @Provide areaHeight: Length = 0
34
+
35
+ build() {
36
+ if (this.node) {
37
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
38
+ Row() {
39
+ createLazyChildren(this.node)
40
+ }
41
+ .attributeModifier(commonStyleModify.setNode(this.node))
42
+ .rowAttrs(getNormalAttributes(this.node))
43
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
44
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
45
+ .clip(true)
46
+ .onAreaChange((oldValue: Area, newValue: Area) => {
47
+ this.areaWidth = newValue.width
48
+ this.areaHeight = newValue.height
49
+ })
50
+ } else {
51
+ Column() {
52
+ createLazyChildren(this.node)
53
+ }
54
+ .attributeModifier(commonStyleModify.setNode(this.node))
55
+ .columnAttrs(getNormalAttributes(this.node))
56
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
57
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
58
+ .clip(true)
59
+ .onAreaChange((oldValue: Area, newValue: Area) => {
60
+ this.areaWidth = newValue.width
61
+ this.areaHeight = newValue.height
62
+ })
63
+ }
64
+ }
65
+ }
66
+ }