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

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 (143) hide show
  1. package/dist/apis/base/system.ts +60 -25
  2. package/dist/apis/base/weapp/life-cycle.ts +1 -1
  3. package/dist/apis/canvas/index.ts +10 -1
  4. package/dist/apis/device/clipboard.ts +23 -8
  5. package/dist/apis/framework/index.ts +2 -6
  6. package/dist/apis/index.ts +25 -17
  7. package/dist/apis/media/image/index.ts +169 -17
  8. package/dist/apis/route/index.ts +1 -2
  9. package/dist/apis/storage/index.ts +135 -131
  10. package/dist/apis/ui/animation/animation.ts +71 -29
  11. package/dist/apis/ui/background.ts +3 -2
  12. package/dist/apis/ui/interaction/index.ts +58 -59
  13. package/dist/apis/ui/navigation-bar/index.ts +2 -2
  14. package/dist/apis/ui/pull-down-refresh.ts +9 -3
  15. package/dist/apis/ui/scroll/index.ts +6 -6
  16. package/dist/apis/ui/tab-bar.ts +4 -5
  17. package/dist/apis/utils/index.ts +20 -2
  18. package/dist/apis/utils/permissions.ts +6 -0
  19. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  20. package/dist/apis/wxml/selectorQuery.ts +26 -13
  21. package/dist/components-harmony-ets/button.ets +36 -9
  22. package/dist/components-harmony-ets/canvas.ets +51 -0
  23. package/dist/components-harmony-ets/checkbox.ets +69 -60
  24. package/dist/components-harmony-ets/form.ets +33 -15
  25. package/dist/components-harmony-ets/icon.ets +16 -8
  26. package/dist/components-harmony-ets/image.ets +22 -6
  27. package/dist/components-harmony-ets/index.ets +39 -0
  28. package/dist/components-harmony-ets/innerHtml.ets +6 -5
  29. package/dist/components-harmony-ets/input.ets +63 -37
  30. package/dist/components-harmony-ets/label.ets +43 -21
  31. package/dist/components-harmony-ets/listView.ets +32 -0
  32. package/dist/components-harmony-ets/movableArea.ets +110 -51
  33. package/dist/components-harmony-ets/movableView.ets +74 -47
  34. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  35. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  36. package/dist/components-harmony-ets/picker.ets +36 -33
  37. package/dist/components-harmony-ets/progress.ets +31 -24
  38. package/dist/components-harmony-ets/pseudo.ets +80 -0
  39. package/dist/components-harmony-ets/radio.ets +75 -66
  40. package/dist/components-harmony-ets/richText.ets +4 -25
  41. package/dist/components-harmony-ets/scrollList.ets +108 -0
  42. package/dist/components-harmony-ets/scrollView.ets +46 -42
  43. package/dist/components-harmony-ets/slider.ets +19 -15
  44. package/dist/components-harmony-ets/stickySection.ets +42 -0
  45. package/dist/components-harmony-ets/style.ets +386 -129
  46. package/dist/components-harmony-ets/swiper.ets +42 -5
  47. package/dist/components-harmony-ets/switch.ets +36 -32
  48. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  49. package/dist/components-harmony-ets/text.ets +102 -46
  50. package/dist/components-harmony-ets/textArea.ets +49 -34
  51. package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
  52. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
  53. package/dist/components-harmony-ets/utils/flexManager.ets +49 -19
  54. package/dist/components-harmony-ets/utils/helper.ets +20 -8
  55. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  56. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  57. package/dist/components-harmony-ets/utils/index.ts +54 -50
  58. package/dist/components-harmony-ets/utils/styles.ets +169 -91
  59. package/dist/components-harmony-ets/video.ets +28 -20
  60. package/dist/components-harmony-ets/view.ets +45 -39
  61. package/dist/components-harmony-ets/webView.ets +6 -5
  62. package/dist/index.d.ts +152 -0
  63. package/dist/index.js +73 -44
  64. package/dist/index.js.map +1 -1
  65. package/dist/runtime-ets/bom/URL.ts +2 -0
  66. package/dist/runtime-ets/bom/document.ts +5 -4
  67. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -3
  68. package/dist/runtime-ets/bom/history.ts +1 -0
  69. package/dist/runtime-ets/bom/location.ts +1 -0
  70. package/dist/runtime-ets/bom/navigator.ts +1 -21
  71. package/dist/runtime-ets/bom/raf.ts +1 -37
  72. package/dist/runtime-ets/bom/window.ts +10 -4
  73. package/dist/runtime-ets/constant.ts +17 -10
  74. package/dist/runtime-ets/current.ts +5 -2
  75. package/dist/runtime-ets/dom/bind.ts +28 -12
  76. package/dist/runtime-ets/dom/class-list.ts +2 -2
  77. package/dist/runtime-ets/dom/cssNesting.ts +419 -0
  78. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
  79. package/dist/runtime-ets/dom/document.ts +9 -12
  80. package/dist/runtime-ets/dom/element/canvas.ts +137 -0
  81. package/dist/runtime-ets/dom/element/element.ts +379 -55
  82. package/dist/runtime-ets/dom/element/form.ts +26 -22
  83. package/dist/runtime-ets/dom/element/index.ts +22 -2
  84. package/dist/runtime-ets/dom/element/movableArea.ts +0 -1
  85. package/dist/runtime-ets/dom/element/movableView.ts +238 -2
  86. package/dist/runtime-ets/dom/element/normal.ts +27 -6
  87. package/dist/runtime-ets/dom/element/progress.ts +0 -2
  88. package/dist/runtime-ets/dom/element/text.ts +0 -8
  89. package/dist/runtime-ets/dom/element/video.ts +4 -4
  90. package/dist/runtime-ets/dom/element/webView.ts +4 -5
  91. package/dist/runtime-ets/dom/event-source.ts +1 -0
  92. package/dist/runtime-ets/dom/event.ts +3 -5
  93. package/dist/runtime-ets/dom/eventTarget.ts +3 -4
  94. package/dist/runtime-ets/dom/node.ts +53 -22
  95. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
  96. package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
  97. package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
  98. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  99. package/dist/runtime-ets/emitter/emitter.ts +1 -0
  100. package/dist/runtime-ets/env.ts +1 -0
  101. package/dist/runtime-ets/index.ts +23 -7
  102. package/dist/runtime-ets/interface/event.ts +1 -1
  103. package/dist/runtime-ets/interface/index.ts +6 -0
  104. package/dist/runtime-ets/utils/index.ts +78 -19
  105. package/dist/runtime-ets/utils/info.ts +2 -2
  106. package/dist/runtime-ets/utils/router.ts +9 -0
  107. package/dist/runtime-framework/react/app.ts +15 -11
  108. package/dist/runtime-framework/react/hooks.ts +1 -2
  109. package/dist/runtime-framework/react/index.ts +0 -2
  110. package/dist/runtime-framework/react/native-page.ts +217 -81
  111. package/dist/runtime-framework/react/page.ts +4 -10
  112. package/dist/runtime-framework/react/utils/index.ts +3 -3
  113. package/dist/runtime-framework/solid/app.ts +29 -46
  114. package/dist/runtime-framework/solid/connect.ts +21 -3
  115. package/dist/runtime-framework/solid/hooks.ts +16 -11
  116. package/dist/runtime-framework/solid/index.ts +6 -2
  117. package/dist/runtime-framework/solid/page.ts +84 -31
  118. package/dist/runtime-framework/solid/reconciler/props.ts +73 -29
  119. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  120. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  121. package/dist/runtime-framework/solid/utils/index.ts +3 -5
  122. package/dist/runtime-utils.d.ts +827 -0
  123. package/dist/runtime-utils.js +574 -285
  124. package/dist/runtime-utils.js.map +1 -1
  125. package/dist/runtime.d.ts +1 -0
  126. package/dist/runtime.js +574 -285
  127. package/dist/runtime.js.map +1 -1
  128. package/index.js +3 -1
  129. package/package.json +14 -15
  130. package/static/media/cancel.svg +1 -1
  131. package/static/media/circle.svg +1 -1
  132. package/static/media/clear.svg +1 -1
  133. package/static/media/download.svg +1 -1
  134. package/static/media/info.svg +1 -1
  135. package/static/media/info_circle.svg +1 -1
  136. package/static/media/search.svg +1 -1
  137. package/static/media/success.svg +1 -1
  138. package/static/media/success_no_circle.svg +1 -1
  139. package/static/media/warn.svg +1 -1
  140. package/types/harmony.d.ts +5 -0
  141. package/types/index.d.ts +4 -0
  142. package/types/runtime.d.ts +1 -1
  143. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,18 +1,18 @@
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'
4
- import { createLazyChildren } from './render'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+
5
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
6
  import { FlexManager } from './utils/flexManager'
7
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
7
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
8
8
 
9
- import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
9
+ import type { TaroAny, TaroElement, TaroCheckboxElement, TaroLabelElement, TaroRadioElement } from '@tarojs/runtime'
10
10
 
11
11
  function handleTargetChange (id: string) {
12
12
  const taro: TaroAny = Current.taro
13
13
  const page: TaroAny = taro.getCurrentInstance().page
14
- const currentPageNode: TaroElement = getPageScrollerOrNode(page.node, page)
15
- const node: TaroElement | null = currentPageNode.getElementById(id)
14
+ const currentPageNode: TaroElement = getPageScrollerOrNode(page?.node, page)
15
+ const node: TaroElement | null = currentPageNode?.getElementById(id)
16
16
 
17
17
  if (!node) return
18
18
 
@@ -34,49 +34,71 @@ function handleTargetChange (id: string) {
34
34
  }
35
35
  }
36
36
 
37
-
38
37
  @Component
39
38
  export default struct TaroLabel {
40
- @ObjectLink node:TaroLabelElement
39
+ @Builder customBuilder() {}
40
+ @BuilderParam createLazyChildren: (node: TaroLabelElement, layer?: number) => void = this.customBuilder
41
+ @ObjectLink node: TaroLabelElement
42
+ @State overwriteStyle: Record<string, TaroAny> = {}
43
+
44
+ aboutToAppear(): void {
45
+ if (this.node) {
46
+ this.node._instance = this
47
+ }
48
+ }
49
+
41
50
  build() {
42
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
51
+ if (FlexManager.useFlexLayout(this.node)) {
52
+ Flex(FlexManager.flexOptions(this.node)) {
53
+ this.createLazyChildren(this.node, 0)
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.toString() || ''
59
+
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
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
43
69
  Row() {
44
- createLazyChildren(this.node)
70
+ this.createLazyChildren(this.node, 0)
45
71
  }
46
- .attributeModifier(commonStyleModify.setNode(this.node))
72
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
47
73
  .onClick((e: ClickEvent) => {
48
74
  const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
49
- const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
75
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid.toString() || ''
50
76
 
51
77
  handleTargetChange(id)
52
78
  eventHandler(e, 'click', this.node)
53
79
  })
54
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
80
+ .onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
55
81
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
56
82
  this.node._nodeInfo.areaInfo = res[1]
57
83
  }))
58
84
  .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
85
  } else {
62
86
  Column() {
63
- createLazyChildren(this.node)
87
+ this.createLazyChildren(this.node, 0)
64
88
  }
65
- .attributeModifier(commonStyleModify.setNode(this.node))
89
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
66
90
  .onClick((e: ClickEvent) => {
67
91
  const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
68
- const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
92
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid.toString() || ''
69
93
 
70
94
  handleTargetChange(id)
71
95
  eventHandler(e, 'click', this.node)
72
96
  })
73
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
97
+ .onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
74
98
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
75
99
  this.node._nodeInfo.areaInfo = res[1]
76
100
  }))
77
101
  .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)
80
102
  }
81
103
  }
82
104
  }
@@ -0,0 +1,32 @@
1
+ import commonStyleModify from './style'
2
+
3
+ import type { TaroAny, TaroViewElement } from '@tarojs/runtime'
4
+
5
+ @Reusable
6
+ @Component
7
+ export default struct TaroListView {
8
+ @Builder customBuilder() {}
9
+ @BuilderParam createLazyChildren: (node: TaroViewElement, layer?: number) => void = this.customBuilder
10
+ @ObjectLink node: TaroViewElement
11
+ @State overwriteStyle: Record<string, TaroAny> = {}
12
+
13
+ aboutToAppear(): void {
14
+ if (this.node) {
15
+ this.node._instance = this
16
+ }
17
+ }
18
+
19
+ aboutToReuse(params: TaroAny): void {
20
+ // this.node = params.node;
21
+ }
22
+
23
+ build() {
24
+ ListItem() {
25
+ Column() {
26
+ this.createLazyChildren(this.node, 0)
27
+ }
28
+ }
29
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
30
+ .zIndex(0)
31
+ }
32
+ }
@@ -1,67 +1,126 @@
1
- import type { TaroMovableAreaElement, TaroStyleType } from '@tarojs/runtime'
2
- import commonStyleModify from './style'
3
- import { createLazyChildren } from './render'
1
+ import { isTaroMovableViewElement } from '@tarojs/runtime'
2
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
3
 
5
4
  import { FlexManager } from './utils/flexManager'
6
- import { getNormalAttributes } from './utils/helper'
7
5
 
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
- }
6
+ import type { TaroAny, TaroMovableAreaElement } from '@tarojs/runtime'
28
7
 
29
8
  @Component
30
9
  export default struct TaroMovableArea {
10
+ @Builder
11
+ customBuilder() {
12
+ }
13
+
14
+ @BuilderParam createLazyChildren: (node: TaroMovableAreaElement, layer?: number) => void = this.customBuilder
31
15
  @ObjectLink node: TaroMovableAreaElement
16
+ @State overwriteStyle: Record<string, TaroAny> = {}
17
+
18
+ aboutToAppear(): void {
19
+ if (this.node) {
20
+ this.node._instance = this
21
+ }
22
+ }
23
+
24
+
25
+
32
26
 
33
- @Provide areaWidth: Length = 0
34
- @Provide areaHeight: Length = 0
35
27
 
36
28
  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
29
+ if (FlexManager.useFlexLayout(this.node)) {
30
+ Flex(FlexManager.flexOptions(this.node)) {
31
+ this.createLazyChildren(this.node, 0)
32
+ }
33
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
34
+ .clip(true)
35
+ .onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
36
+ sizeChangeHandle(this.node, newValue)
37
+ })
38
+ .gesture(
39
+ PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
40
+ this.node.childNodes.forEach(item => {
41
+ if (isTaroMovableViewElement(item)) {
42
+ item.startScale()
43
+ }
44
+ })
45
+ }).onActionUpdate((event) => {
46
+ const scaleArea = this.node.getAttribute('scaleArea')
47
+ if (scaleArea) {
48
+ this.node.childNodes.forEach(item => {
49
+ if (isTaroMovableViewElement(item)) {
50
+ item.doScale(event.scale)
51
+ }
52
+ })
53
+ }
50
54
  })
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
55
+ )
56
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
57
+ Row() {
58
+ this.createLazyChildren(this.node, 0)
59
+ }
60
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
61
+ .clip(true)
62
+ .onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
63
+ sizeChangeHandle(this.node, newValue)
64
+ })
65
+ .gesture(
66
+ PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
67
+ this.node.childNodes.forEach(item => {
68
+ if (isTaroMovableViewElement(item)) {
69
+ item.startScale()
70
+ }
71
+ })
72
+ }).onActionUpdate((event) => {
73
+ const scaleArea = this.node.getAttribute('scaleArea')
74
+ if (scaleArea) {
75
+ this.node.childNodes.forEach(item => {
76
+ if (isTaroMovableViewElement(item)) {
77
+ item.doScale(event.scale)
78
+ }
79
+ })
80
+ }
63
81
  })
82
+ )
83
+ } else {
84
+ Column() {
85
+ this.createLazyChildren(this.node, 0)
64
86
  }
87
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
88
+ .clip(true)
89
+ .onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
90
+ sizeChangeHandle(this.node, newValue)
91
+ })
92
+ .gesture(
93
+ PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
94
+ this.node.childNodes.forEach(item => {
95
+ if (isTaroMovableViewElement(item)) {
96
+ item.startScale()
97
+ }
98
+ })
99
+ }).onActionUpdate((event) => {
100
+ const scaleArea = this.node.getAttribute('scaleArea')
101
+ if (scaleArea) {
102
+ this.node.childNodes.forEach(item => {
103
+ if (isTaroMovableViewElement(item)) {
104
+ item.doScale(event.scale)
105
+ }
106
+ })
107
+ }
108
+ })
109
+ )
65
110
  }
66
111
  }
67
112
  }
113
+
114
+
115
+ function sizeChangeHandle(node: TaroMovableAreaElement, newValue: Area | SizeOptions) {
116
+ node.childNodes.forEach(item => {
117
+ if (isTaroMovableViewElement(item)) {
118
+ if (item.area?.w !== Number(newValue.width) || item.area?.h !== Number(newValue.height)) {
119
+ item.area = {
120
+ w: Number(newValue.width),
121
+ h: Number(newValue.height)
122
+ }
123
+ }
124
+ }
125
+ })
126
+ }
@@ -1,66 +1,93 @@
1
- import type { TaroMovableViewElement, TaroStyleType } from '@tarojs/runtime'
1
+ import type { TaroAny, TaroMovableViewElement, TaroElement } from '@tarojs/runtime'
2
2
 
3
- import commonStyleModify from './style'
4
- import { createLazyChildren } from './render'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
5
4
 
6
5
  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
6
 
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
- }
7
+
27
8
 
28
9
  @Component
29
- export default struct TaroMovableArea {
10
+ export default struct TaroMovableView {
11
+ @Builder customBuilder() {}
12
+ @BuilderParam createLazyChildren: (node: TaroMovableViewElement, layer?: number) => void = this.customBuilder
30
13
  @ObjectLink node: TaroMovableViewElement
14
+ @State overwriteStyle: Record<string, TaroAny> = {}
31
15
 
32
- @Provide areaWidth: Length = 0
33
- @Provide areaHeight: Length = 0
16
+ aboutToAppear(): void {
17
+ if (this.node) {
18
+ this.node._instance = this
19
+
20
+ }
21
+ }
34
22
 
35
23
  build() {
36
- if (this.node) {
37
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
24
+ Stack() {
25
+ if (FlexManager.useFlexLayout(this.node)) {
26
+ Flex(FlexManager.flexOptions(this.node)) {
27
+ this.createLazyChildren(this.node, 0)
28
+ }
29
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
30
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
38
31
  Row() {
39
- createLazyChildren(this.node)
32
+ this.createLazyChildren(this.node, 0)
40
33
  }
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
- })
34
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
50
35
  } else {
51
36
  Column() {
52
- createLazyChildren(this.node)
37
+ this.createLazyChildren(this.node, 0)
53
38
  }
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
- })
39
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
63
40
  }
64
41
  }
42
+ .translate({ x: this.node.position.x, y: this.node.position.y })
43
+ .scale({ x: this.node.scaleValue, y: this.node.scaleValue })
44
+ .onSizeChange((oldValue: SizeOptions, newValue: SizeOptions) => {
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
+ }
48
+ })
49
+ .visibility(this.node.visibility)
50
+ .gesture(
51
+ GestureGroup(GestureMode.Parallel,
52
+ PanGesture(getPanOption(this.node)).onActionStart((e: GestureEvent) => {
53
+
54
+ this.node.startMove()
55
+ this.node.callTouchEventFnFromGesture('touchstart', e)
56
+ }).onActionUpdate((e: GestureEvent) => {
57
+ this.node.callTouchEventFnFromGesture('touchmove', e)
58
+ this.node.doMove({
59
+ x: e.offsetX,
60
+ y: e.offsetY
61
+ })
62
+
63
+ }).onActionEnd((e: GestureEvent) => {
64
+ this.node.callTouchEventFnFromGesture('touchend', e)
65
+ this.node.checkPositionBoundary(this.node.position, this.node.scaleValue)
66
+ }),
67
+ PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
68
+ this.node.startScale()
69
+ }).onActionUpdate((event) => {
70
+ this.node.doScale(event.scale)
71
+ })
72
+ )
73
+ )
65
74
  }
66
75
  }
76
+
77
+
78
+ function getPanOption(node: TaroMovableViewElement) {
79
+ const attrDirection = node.getAttribute('direction')
80
+ let panDirection = PanDirection.All
81
+
82
+ if(node.getAttribute('disabled')) {
83
+ panDirection = PanDirection.None
84
+ } else if(attrDirection === 'horizontal') {
85
+ panDirection = PanDirection.Horizontal
86
+ } else if (attrDirection === 'vertical') {
87
+ panDirection = PanDirection.Vertical
88
+ }
89
+ return new PanGestureOptions({
90
+ direction: panDirection,
91
+ fingers: 1
92
+ })
93
+ }
@@ -0,0 +1,65 @@
1
+ import { eventCenter } from '@tarojs/runtime'
2
+
3
+ import { isTagFirstChild } from './utils/helper'
4
+
5
+ import type { TaroAny, TaroNavigationBarElement } from '@tarojs/runtime'
6
+ import type { IComponentAttributeUpdateEvents } from './pageMeta'
7
+
8
+ @Component
9
+ export default struct TaroNavigationBar {
10
+ @Builder customBuilder() {}
11
+ @BuilderParam createLazyChildren: (node: TaroNavigationBarElement, layer?: number) => void = this.customBuilder
12
+ @ObjectLink node: TaroNavigationBarElement
13
+
14
+ aboutToAppear(): void {
15
+ if (!isTagFirstChild(this.node, 'page-meta')) {
16
+ console.error('NavigationBar 只能是 PageMeta 内的第一个节点。')
17
+ }
18
+ if (this.node) {
19
+ this.node._instance = this
20
+ }
21
+
22
+ // FIXME 在 Harmony 提供 @Watch 文档后,根据 node 实际使用更细粒度的监听
23
+ eventCenter?.on('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
24
+ this.handleAttributes(this.node._attrs)
25
+ }
26
+
27
+ aboutToDisappear(): void {
28
+ eventCenter?.off('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
29
+ }
30
+
31
+ handleAttributeUpdate = (opt: IComponentAttributeUpdateEvents) => {
32
+ if (opt.id === this.node._nid.toString() && opt.tagName === 'NAVIGATION-BAR') {
33
+ const attrs: Record<string, TaroAny> = {}
34
+ attrs[opt.attribute] = opt.value
35
+ this.handleAttributes(attrs)
36
+ }
37
+ }
38
+
39
+ handleAttributes (attrs: Record<string, TaroAny>) {
40
+ const options: Record<string, TaroAny> = {}
41
+
42
+ if (attrs.title) {
43
+ options.title = attrs.title
44
+ }
45
+ if (attrs.loading) {
46
+ options.loading = attrs.loading
47
+ }
48
+ if (attrs.backgroundColor) {
49
+ options.backgroundColor = attrs.backgroundColor
50
+ }
51
+ if (attrs.frontColor) {
52
+ options.frontColor = attrs.frontColor
53
+ }
54
+ eventCenter?.trigger('__taroNavigationStyle', options)
55
+ // FIXME: 以下属性暂时不支持
56
+ // attrs.colorAnimationDuration
57
+ // attrs.colorAnimationTimingFunc
58
+ }
59
+
60
+ build() {
61
+ if (true) {
62
+ this.createLazyChildren(this.node, 0)
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,94 @@
1
+ import { APP, eventCenter } from '@tarojs/runtime'
2
+ import { getCurrentInstance, pageScrollTo } from '@tarojs/taro'
3
+
4
+ import { isTagFirstChild } from './utils/helper'
5
+
6
+ import type { TaroAny, TaroPageMetaElement } from '@tarojs/runtime'
7
+
8
+ export interface IComponentAttributeUpdateEvents {
9
+ id: string
10
+ tagName: string
11
+ attribute: string
12
+ value: TaroAny
13
+ }
14
+
15
+ @Component
16
+ export default struct TaroPageMeta {
17
+ @Builder customBuilder() {}
18
+ @BuilderParam createLazyChildren: (node: TaroPageMetaElement, layer?: number) => void = this.customBuilder
19
+ @ObjectLink node: TaroPageMetaElement
20
+
21
+ page: TaroAny = {}
22
+
23
+ aboutToAppear(): void {
24
+ if (!isTagFirstChild(this.node, APP, 2)) {
25
+ // PageMeta 只能是页面内的第一个元素
26
+ console.error('PageMeta 只能是页面内的第一个元素。')
27
+ }
28
+
29
+ this.page = getCurrentInstance().page
30
+ if (this.node) {
31
+ this.node._instance = this
32
+ }
33
+
34
+ // FIXME 在 Harmony 提供 @Watch 文档后,根据 node 实际使用更细粒度的监听
35
+ eventCenter?.on('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
36
+ this.handleAttributes(this.node._attrs)
37
+ }
38
+
39
+ aboutToDisappear(): void {
40
+ eventCenter?.off('__taroComponentAttributeUpdate', this.handleAttributeUpdate)
41
+ }
42
+
43
+ handleAttributeUpdate = (opt: IComponentAttributeUpdateEvents) => {
44
+ if (opt.id === this.node._nid.toString() && opt.tagName === 'PAGE-META') {
45
+ const attrs: Record<string, TaroAny> = {}
46
+ attrs[opt.attribute] = opt.value
47
+ this.handleAttributes(attrs)
48
+ }
49
+ }
50
+
51
+ handleAttributes (attrs: Record<string, TaroAny>) {
52
+ const options: Record<string, TaroAny> = {}
53
+ let triggerStyleEvent = false
54
+
55
+ // FIXME 更新类型支持度
56
+ if (attrs.backgroundColorTop || attrs.rootBackgroundColor || attrs.backgroundColor) {
57
+ options.backgroundColorContext = attrs.backgroundColorTop || attrs.rootBackgroundColor || attrs.backgroundColor
58
+ triggerStyleEvent = true
59
+ }
60
+ if (attrs.backgroundColorBottom || attrs.backgroundColor) {
61
+ options.backgroundColor = attrs.backgroundColorBottom || attrs.backgroundColor
62
+ triggerStyleEvent = true
63
+ }
64
+ if (attrs.backgroundTextStyle) {
65
+ options.backgroundTextStyle = attrs.backgroundTextStyle
66
+ triggerStyleEvent = true
67
+ }
68
+
69
+ if (this.page === getCurrentInstance().page) {
70
+ if (attrs.scrollTop || attrs.scrollDuration) {
71
+ pageScrollTo({
72
+ scrollTop: attrs.scrollTop || this.node._attrs.scrollTop,
73
+ duration: attrs.scrollDuration || this.node._attrs.scrollDuration,
74
+ } as TaroAny)
75
+ }
76
+ }
77
+ // pageStyle
78
+ // rootFontSize
79
+ // pageFontSize
80
+ // pageOrientation
81
+ if (triggerStyleEvent) {
82
+ eventCenter?.trigger('__taroPageStyle', options)
83
+ }
84
+ // onResize
85
+ // onScroll
86
+ // onScrollDone
87
+ }
88
+
89
+ build() {
90
+ if (true) {
91
+ this.createLazyChildren(this.node, 0)
92
+ }
93
+ }
94
+ }