@tarojs/plugin-platform-harmony-ets 4.0.0-beta.6 → 4.0.0-beta.61

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 (126) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +9 -0
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +27 -17
  6. package/dist/apis/network/request.ts +5 -5
  7. package/dist/apis/route/index.ts +15 -0
  8. package/dist/apis/storage/index.ts +148 -80
  9. package/dist/apis/ui/animation/animation.ts +71 -28
  10. package/dist/apis/ui/background.ts +2 -1
  11. package/dist/apis/ui/interaction/index.ts +42 -59
  12. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  13. package/dist/apis/ui/scroll/index.ts +1 -1
  14. package/dist/apis/utils/index.ts +1 -1
  15. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  16. package/dist/apis/wxml/index.ts +2 -0
  17. package/dist/apis/wxml/selectorQuery.ts +25 -12
  18. package/dist/components-harmony-ets/button.ets +48 -34
  19. package/dist/components-harmony-ets/canvas.ets +51 -0
  20. package/dist/components-harmony-ets/checkbox.ets +69 -61
  21. package/dist/components-harmony-ets/form.ets +51 -29
  22. package/dist/components-harmony-ets/icon.ets +31 -19
  23. package/dist/components-harmony-ets/image.ets +34 -14
  24. package/dist/components-harmony-ets/index.ets +92 -0
  25. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  26. package/dist/components-harmony-ets/input.ets +42 -40
  27. package/dist/components-harmony-ets/label.ets +69 -42
  28. package/dist/components-harmony-ets/listView.ets +26 -0
  29. package/dist/components-harmony-ets/movableArea.ets +126 -0
  30. package/dist/components-harmony-ets/movableView.ets +73 -0
  31. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  32. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  33. package/dist/components-harmony-ets/picker.ets +42 -38
  34. package/dist/components-harmony-ets/progress.ets +52 -0
  35. package/dist/components-harmony-ets/pseudo.ets +80 -0
  36. package/dist/components-harmony-ets/radio.ets +71 -64
  37. package/dist/components-harmony-ets/richText.ets +14 -30
  38. package/dist/components-harmony-ets/scrollList.ets +94 -0
  39. package/dist/components-harmony-ets/scrollView.ets +61 -57
  40. package/dist/components-harmony-ets/slider.ets +15 -14
  41. package/dist/components-harmony-ets/stickySection.ets +42 -0
  42. package/dist/components-harmony-ets/style.ets +372 -130
  43. package/dist/components-harmony-ets/swiper.ets +61 -20
  44. package/dist/components-harmony-ets/switch.ets +30 -28
  45. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  46. package/dist/components-harmony-ets/text.ets +159 -51
  47. package/dist/components-harmony-ets/textArea.ets +35 -34
  48. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  49. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  50. package/dist/components-harmony-ets/utils/flexManager.ets +47 -19
  51. package/dist/components-harmony-ets/utils/helper.ets +18 -5
  52. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  53. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  54. package/dist/components-harmony-ets/utils/index.ts +54 -50
  55. package/dist/components-harmony-ets/utils/styles.ets +170 -93
  56. package/dist/components-harmony-ets/video.ets +34 -20
  57. package/dist/components-harmony-ets/view.ets +63 -52
  58. package/dist/components-harmony-ets/webView.ets +40 -34
  59. package/dist/index.d.ts +152 -0
  60. package/dist/index.js +82 -39
  61. package/dist/index.js.map +1 -1
  62. package/dist/runtime-ets/bom/document.ts +6 -4
  63. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  64. package/dist/runtime-ets/bom/window.ts +7 -0
  65. package/dist/runtime-ets/current.ts +3 -0
  66. package/dist/runtime-ets/dom/bind.ts +30 -13
  67. package/dist/runtime-ets/dom/cssNesting.ts +411 -0
  68. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +27 -41
  69. package/dist/runtime-ets/dom/document.ts +22 -8
  70. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  71. package/dist/runtime-ets/dom/element/element.ts +334 -58
  72. package/dist/runtime-ets/dom/element/form.ts +23 -26
  73. package/dist/runtime-ets/dom/element/index.ts +25 -2
  74. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  75. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  76. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  77. package/dist/runtime-ets/dom/element/progress.ts +12 -0
  78. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  79. package/dist/runtime-ets/dom/element/text.ts +1 -8
  80. package/dist/runtime-ets/dom/element/video.ts +5 -3
  81. package/dist/runtime-ets/dom/element/webView.ts +11 -3
  82. package/dist/runtime-ets/dom/event.ts +0 -1
  83. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  84. package/dist/runtime-ets/dom/node.ts +46 -28
  85. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +416 -235
  86. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  87. package/dist/runtime-ets/dom/stylesheet/type.ts +49 -9
  88. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  89. package/dist/runtime-ets/index.ts +2 -2
  90. package/dist/runtime-ets/interface/event.ts +1 -1
  91. package/dist/runtime-ets/utils/index.ts +67 -11
  92. package/dist/runtime-ets/utils/info.ts +1 -1
  93. package/dist/runtime-framework/react/app.ts +7 -2
  94. package/dist/runtime-framework/react/index.ts +0 -2
  95. package/dist/runtime-framework/react/native-page.ts +32 -14
  96. package/dist/runtime-framework/react/page.ts +3 -8
  97. package/dist/runtime-framework/solid/app.ts +25 -45
  98. package/dist/runtime-framework/solid/connect.ts +21 -3
  99. package/dist/runtime-framework/solid/hooks.ts +16 -11
  100. package/dist/runtime-framework/solid/index.ts +6 -2
  101. package/dist/runtime-framework/solid/page.ts +84 -30
  102. package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
  103. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  104. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  105. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  106. package/dist/runtime-utils.d.ts +827 -0
  107. package/dist/runtime-utils.js +411 -200
  108. package/dist/runtime-utils.js.map +1 -1
  109. package/dist/runtime.d.ts +1 -0
  110. package/dist/runtime.js +411 -200
  111. package/dist/runtime.js.map +1 -1
  112. package/index.js +3 -1
  113. package/package.json +13 -13
  114. package/static/media/cancel.svg +1 -1
  115. package/static/media/circle.svg +1 -1
  116. package/static/media/clear.svg +1 -1
  117. package/static/media/download.svg +1 -1
  118. package/static/media/info.svg +1 -1
  119. package/static/media/info_circle.svg +1 -1
  120. package/static/media/search.svg +1 -1
  121. package/static/media/success.svg +1 -1
  122. package/static/media/success_no_circle.svg +1 -1
  123. package/static/media/warn.svg +1 -1
  124. package/types/harmony.d.ts +4 -0
  125. package/types/index.d.ts +4 -0
  126. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
- import { getNormalAttributes, parseStyles, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
+ import { parseStyles, shouldBindEvent, getNodeThresholds } from './utils/helper'
5
5
  import { INPUT_TYPE_MAP, INPUT_CONFIRM_MAP } from './utils/constant/style'
6
6
 
7
7
  import type { TaroStyleType, TaroAny, TaroInputElement, TaroEvent } from '@tarojs/runtime'
@@ -48,7 +48,10 @@ function getPlaceholderColor (node: TaroInputElement): string {
48
48
  export default struct TaroInput {
49
49
  @State value: string = ''
50
50
 
51
- node: TaroInputElement | null = null
51
+ @Builder customBuilder() {}
52
+ @BuilderParam createLazyChildren: (node: TaroInputElement) => void = this.customBuilder
53
+ @ObjectLink node: TaroInputElement
54
+ @State overwriteStyle: Record<string, TaroAny> = {}
52
55
 
53
56
  aboutToAppear () {
54
57
  if (this.node) {
@@ -63,43 +66,42 @@ export default struct TaroInput {
63
66
  }
64
67
 
65
68
  build () {
66
- if (this.node) {
67
- TextInput({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
68
- .key(this.node._nid)
69
- .type(getInputType(this.node))
70
- .maxLength(Number(this.node._attrs?.maxlength) || null)
71
- .placeholderColor(getPlaceholderColor(this.node))
72
- .enterKeyType(INPUT_CONFIRM_MAP.get(this.node._attrs?.confirmType) || EnterKeyType.Done)
73
- .attributeModifier(commonStyleModify.setNode(this.node))
74
- .styles(getNormalAttributes(this.node))
75
- .attrs(getAttributes(this.node))
76
- .onChange((value: string) => {
77
- const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
78
-
79
- this.value = value
80
- this.node?.updateFormWidgetValue(value)
81
- eventHandler(event, 'input', this.node)
82
- })
83
- .onSubmit(() => {
84
- const event: TaroEvent = createTaroEvent('confirm', { detail: { value: this.value } }, this.node)
85
- eventHandler(event, 'confirm', this.node)
86
- })
87
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
88
- .onBlur(() => {
89
- const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
90
- eventHandler(event, 'blur', this.node)
91
- })
92
- .onFocus(() => {
93
- const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
94
-
95
- eventHandler(event, 'focus', this.node)
96
- })
97
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
98
- if (this.node) {
99
- this.node._nodeInfo.areaInfo = res[1]
100
- }
101
- }))
102
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
103
- }
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
+ .padding(0) // Note: 移出 Input 默认 padding 设置
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))
104
106
  }
105
107
  }
@@ -1,12 +1,13 @@
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
- import { FlexManager } from './utils/FlexManager'
7
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
6
+ import { FlexManager } from './utils/flexManager'
7
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
8
8
 
9
9
  import type { TaroLabelElement, TaroElement, TaroAny, TaroRadioElement, TaroCheckboxElement } from '@tarojs/runtime'
10
+ import { isUndefined } from '@tarojs/shared'
10
11
 
11
12
  function handleTargetChange (id: string) {
12
13
  const taro: TaroAny = Current.taro
@@ -34,45 +35,71 @@ function handleTargetChange (id: string) {
34
35
  }
35
36
  }
36
37
 
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)
38
+ @Component
39
+ export default struct TaroLabel {
40
+ @Builder customBuilder() {}
41
+ @BuilderParam createLazyChildren: (node: TaroLabelElement) => void = this.customBuilder
42
+ @ObjectLink node: TaroLabelElement
43
+ @State overwriteStyle: Record<string, TaroAny> = {}
44
+
45
+ aboutToAppear(): void {
46
+ if (this.node) {
47
+ this.node._instance = this
42
48
  }
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)
49
+ }
50
+
51
+ build() {
52
+ if (FlexManager.useFlexLayout(this.node)) {
53
+ Flex(FlexManager.flexOptions(this.node)) {
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
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
70
+ Row() {
71
+ this.createLazyChildren(this.node)
72
+ }
73
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
74
+ .onClick((e: ClickEvent) => {
75
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
76
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
77
+
78
+ handleTargetChange(id)
79
+ eventHandler(e, 'click', this.node)
80
+ })
81
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
82
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
83
+ this.node._nodeInfo.areaInfo = res[1]
84
+ }))
85
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
86
+ } else {
87
+ Column() {
88
+ this.createLazyChildren(this.node)
89
+ }
90
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
91
+ .onClick((e: ClickEvent) => {
92
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
93
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
94
+
95
+ handleTargetChange(id)
96
+ eventHandler(e, 'click', this.node)
97
+ })
98
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
99
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
100
+ this.node._nodeInfo.areaInfo = res[1]
101
+ }))
102
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
61
103
  }
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
104
  }
78
105
  }
@@ -0,0 +1,26 @@
1
+ import commonStyleModify from './style'
2
+
3
+ import type { TaroViewElement, TaroAny } from '@tarojs/runtime'
4
+
5
+ @Component
6
+ export default struct TaroListView {
7
+ @Builder customBuilder() {}
8
+ @BuilderParam createLazyChildren: (node: TaroViewElement) => void = this.customBuilder
9
+ @ObjectLink node: TaroViewElement
10
+ @State overwriteStyle: Record<string, TaroAny> = {}
11
+
12
+ aboutToAppear(): void {
13
+ if (this.node) {
14
+ this.node._instance = this
15
+ }
16
+ }
17
+
18
+ build() {
19
+ ListItem() {
20
+ Stack() {
21
+ this.createLazyChildren(this.node)
22
+ }
23
+ }
24
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
25
+ }
26
+ }
@@ -0,0 +1,126 @@
1
+ import type { TaroAny, TaroMovableAreaElement, TaroMovableViewElement } from '@tarojs/runtime'
2
+
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+
5
+ import { FlexManager } from './utils/flexManager'
6
+ import { isUndefined } from '@tarojs/shared'
7
+
8
+ @Component
9
+ export default struct TaroMovableArea {
10
+ @Builder customBuilder() {}
11
+ @BuilderParam createLazyChildren: (node: TaroMovableAreaElement) => void = this.customBuilder
12
+ @ObjectLink node: TaroMovableAreaElement
13
+ @State overwriteStyle: Record<string, TaroAny> = {}
14
+
15
+ aboutToAppear(): void {
16
+ if (this.node) {
17
+ this.node._instance = this
18
+ }
19
+ }
20
+
21
+ build() {
22
+ if (FlexManager.useFlexLayout(this.node)) {
23
+ Flex(FlexManager.flexOptions(this.node)) {
24
+ this.createLazyChildren(this.node)
25
+ }
26
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
27
+ .clip(true)
28
+ .onAreaChange((oldValue: Area, newValue: Area) => {
29
+ this.node.childNodes.forEach(item => {
30
+ if(item.nodeName === 'MOVABLE-VIEW') {
31
+ ;(item as TaroMovableViewElement).area = {
32
+ w: Number( newValue.width),
33
+ h: Number(newValue.height)
34
+ }
35
+ }
36
+ })
37
+ })
38
+ .gesture(
39
+ PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
40
+ this.node.childNodes.forEach(item => {
41
+ if(item.nodeName === 'MOVABLE-VIEW') {
42
+ ;(item as TaroMovableViewElement).startScale()
43
+ }
44
+ })
45
+ }).onActionUpdate((event) => {
46
+ const scaleArea = this.node.getAttribute('scaleArea')
47
+ if (scaleArea) {
48
+ this.node.childNodes.forEach(item => {
49
+ if(item.nodeName === 'MOVABLE-VIEW') {
50
+ ;(item as TaroMovableViewElement).doScale(event.scale)
51
+ }
52
+ })
53
+ }
54
+ })
55
+ )
56
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
57
+ Row() {
58
+ this.createLazyChildren(this.node)
59
+ }
60
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
61
+ .clip(true)
62
+ .onAreaChange((oldValue: Area, newValue: Area) => {
63
+ this.node.childNodes.forEach(item => {
64
+ if(item.nodeName === 'MOVABLE-VIEW') {
65
+ ;(item as TaroMovableViewElement).area = {
66
+ w: Number( newValue.width),
67
+ h: Number(newValue.height)
68
+ }
69
+ }
70
+ })
71
+ })
72
+ .gesture(
73
+ PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
74
+ this.node.childNodes.forEach(item => {
75
+ if(item.nodeName === 'MOVABLE-VIEW') {
76
+ ;(item as TaroMovableViewElement).startScale()
77
+ }
78
+ })
79
+ }).onActionUpdate((event) => {
80
+ const scaleArea = this.node.getAttribute('scaleArea')
81
+ if (scaleArea) {
82
+ this.node.childNodes.forEach(item => {
83
+ if(item.nodeName === 'MOVABLE-VIEW') {
84
+ ;(item as TaroMovableViewElement).doScale(event.scale)
85
+ }
86
+ })
87
+ }
88
+ })
89
+ )
90
+ } else {
91
+ Column() {
92
+ this.createLazyChildren(this.node)
93
+ }
94
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
95
+ .clip(true)
96
+ .onAreaChange((oldValue: Area, newValue: Area) => {
97
+ this.node.childNodes.forEach(item => {
98
+ if(item.nodeName === 'MOVABLE-VIEW') {
99
+ ;(item as TaroMovableViewElement).area = {
100
+ w: Number( newValue.width),
101
+ h: Number(newValue.height)
102
+ }
103
+ }
104
+ })
105
+ })
106
+ .gesture(
107
+ PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
108
+ this.node.childNodes.forEach(item => {
109
+ if(item.nodeName === 'MOVABLE-VIEW') {
110
+ ;(item as TaroMovableViewElement).startScale()
111
+ }
112
+ })
113
+ }).onActionUpdate((event) => {
114
+ const scaleArea = this.node.getAttribute('scaleArea')
115
+ if (scaleArea) {
116
+ this.node.childNodes.forEach(item => {
117
+ if(item.nodeName === 'MOVABLE-VIEW') {
118
+ ;(item as TaroMovableViewElement).doScale(event.scale)
119
+ }
120
+ })
121
+ }
122
+ })
123
+ )
124
+ }
125
+ }
126
+ }
@@ -0,0 +1,73 @@
1
+ import type { TaroAny, TaroMovableViewElement } from '@tarojs/runtime'
2
+
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+
5
+ import { FlexManager } from './utils/flexManager'
6
+ import { isUndefined } from '@tarojs/shared'
7
+
8
+ @Component
9
+ export default struct TaroMovableView {
10
+ @Builder customBuilder() {}
11
+ @BuilderParam createLazyChildren: (node: TaroMovableViewElement) => void = this.customBuilder
12
+ @ObjectLink node: TaroMovableViewElement
13
+ @State overwriteStyle: Record<string, TaroAny> = {}
14
+
15
+ aboutToAppear(): void {
16
+ if (this.node) {
17
+ this.node._instance = this
18
+ }
19
+ }
20
+
21
+ build() {
22
+ Stack() {
23
+ if (FlexManager.useFlexLayout(this.node)) {
24
+ Flex(FlexManager.flexOptions(this.node)) {
25
+ this.createLazyChildren(this.node)
26
+ }
27
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
28
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
29
+ Row() {
30
+ this.createLazyChildren(this.node)
31
+ }
32
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
33
+ } else {
34
+ Column() {
35
+ this.createLazyChildren(this.node)
36
+ }
37
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
38
+ }
39
+ }
40
+ .translate({ x: this.node.position.x, y: this.node.position.y })
41
+ .scale({ x: this.node.scaleValue, y: this.node.scaleValue })
42
+ .onAreaChange((oldValue: Area, newValue: Area) => {
43
+ this.node.selfSize = {w: Number(newValue.width), h: Number(newValue.height)}
44
+ })
45
+ .gesture(
46
+ GestureGroup(GestureMode.Exclusive,
47
+ PanGesture({fingers:1}).onActionStart((e: GestureEvent) => {
48
+
49
+ this.node.startMove()
50
+ }).onActionUpdate((e: GestureEvent) => {
51
+
52
+ this.node.doMove({
53
+ x: e.offsetX,
54
+ y: e.offsetY
55
+ })
56
+ // 事件处理
57
+ const bindchange = this.node.getAttribute('bindchange')
58
+ if (typeof bindchange === 'function') {
59
+ }
60
+
61
+ }).onActionEnd(() => {
62
+ // this.updatePosition()
63
+ this.node.checkPositionBoundary(this.node.position, this.node.scaleValue)
64
+ }),
65
+ PinchGesture({ fingers: 2 }).onActionStart((event: GestureEvent) => {
66
+ this.node.startScale()
67
+ }).onActionUpdate((event) => {
68
+ this.node.doScale(event.scale)
69
+ })
70
+ )
71
+ )
72
+ }
73
+ }
@@ -0,0 +1,65 @@
1
+ import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
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) => 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 && 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)
63
+ }
64
+ }
65
+ }
@@ -0,0 +1,94 @@
1
+ import { APP, eventCenter } from '@tarojs/runtime/dist/runtime.esm'
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) => 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 && 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)
92
+ }
93
+ }
94
+ }