@tarojs/plugin-platform-harmony-ets 4.0.0-beta.4 → 4.0.0-beta.40

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 (105) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/framework/index.ts +1 -5
  4. package/dist/apis/index.ts +32 -17
  5. package/dist/apis/network/request.ts +5 -5
  6. package/dist/apis/route/index.ts +15 -0
  7. package/dist/apis/storage/index.ts +205 -63
  8. package/dist/apis/ui/animation/animation.ts +2 -1
  9. package/dist/apis/utils/index.ts +1 -1
  10. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  11. package/dist/apis/wxml/index.ts +2 -0
  12. package/dist/apis/wxml/selectorQuery.ts +18 -9
  13. package/dist/components-harmony-ets/button.ets +48 -34
  14. package/dist/components-harmony-ets/canvas.ets +51 -0
  15. package/dist/components-harmony-ets/checkbox.ets +69 -61
  16. package/dist/components-harmony-ets/form.ets +51 -29
  17. package/dist/components-harmony-ets/icon.ets +34 -19
  18. package/dist/components-harmony-ets/image.ets +27 -14
  19. package/dist/components-harmony-ets/index.ets +76 -0
  20. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  21. package/dist/components-harmony-ets/input.ets +41 -40
  22. package/dist/components-harmony-ets/label.ets +71 -42
  23. package/dist/components-harmony-ets/movableArea.ets +126 -0
  24. package/dist/components-harmony-ets/movableView.ets +73 -0
  25. package/dist/components-harmony-ets/picker.ets +42 -38
  26. package/dist/components-harmony-ets/progress.ets +52 -0
  27. package/dist/components-harmony-ets/pseudo.ets +80 -0
  28. package/dist/components-harmony-ets/radio.ets +71 -64
  29. package/dist/components-harmony-ets/richText.ets +14 -30
  30. package/dist/components-harmony-ets/scrollView.ets +57 -30
  31. package/dist/components-harmony-ets/slider.ets +15 -14
  32. package/dist/components-harmony-ets/style.ets +385 -130
  33. package/dist/components-harmony-ets/swiper.ets +32 -20
  34. package/dist/components-harmony-ets/switch.ets +30 -28
  35. package/dist/components-harmony-ets/text.ets +121 -51
  36. package/dist/components-harmony-ets/textArea.ets +35 -34
  37. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  38. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  39. package/dist/components-harmony-ets/utils/flexManager.ets +43 -19
  40. package/dist/components-harmony-ets/utils/helper.ets +4 -5
  41. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  42. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  43. package/dist/components-harmony-ets/utils/index.ts +50 -51
  44. package/dist/components-harmony-ets/utils/styles.ets +164 -92
  45. package/dist/components-harmony-ets/video.ets +34 -20
  46. package/dist/components-harmony-ets/view.ets +62 -29
  47. package/dist/components-harmony-ets/webView.ets +40 -34
  48. package/dist/index.d.ts +152 -0
  49. package/dist/index.js +74 -37
  50. package/dist/index.js.map +1 -1
  51. package/dist/runtime-ets/bom/document.ts +1 -1
  52. package/dist/runtime-ets/bom/window.ts +7 -0
  53. package/dist/runtime-ets/current.ts +3 -0
  54. package/dist/runtime-ets/dom/bind.ts +20 -6
  55. package/dist/runtime-ets/dom/cssNesting.ts +393 -0
  56. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +12 -40
  57. package/dist/runtime-ets/dom/document.ts +23 -8
  58. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  59. package/dist/runtime-ets/dom/element/element.ts +218 -51
  60. package/dist/runtime-ets/dom/element/form.ts +15 -18
  61. package/dist/runtime-ets/dom/element/index.ts +18 -2
  62. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  63. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  64. package/dist/runtime-ets/dom/element/normal.ts +13 -4
  65. package/dist/runtime-ets/dom/element/progress.ts +12 -0
  66. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  67. package/dist/runtime-ets/dom/element/text.ts +1 -8
  68. package/dist/runtime-ets/dom/element/video.ts +5 -3
  69. package/dist/runtime-ets/dom/element/webView.ts +8 -0
  70. package/dist/runtime-ets/dom/event.ts +0 -1
  71. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  72. package/dist/runtime-ets/dom/node.ts +45 -27
  73. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +330 -230
  74. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  75. package/dist/runtime-ets/dom/stylesheet/type.ts +28 -9
  76. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  77. package/dist/runtime-ets/index.ts +2 -2
  78. package/dist/runtime-ets/interface/event.ts +1 -1
  79. package/dist/runtime-ets/utils/index.ts +43 -10
  80. package/dist/runtime-ets/utils/info.ts +1 -1
  81. package/dist/runtime-framework/react/app.ts +7 -2
  82. package/dist/runtime-framework/react/index.ts +0 -2
  83. package/dist/runtime-framework/react/native-page.ts +22 -12
  84. package/dist/runtime-framework/react/page.ts +3 -8
  85. package/dist/runtime-framework/solid/app.ts +25 -45
  86. package/dist/runtime-framework/solid/connect.ts +21 -3
  87. package/dist/runtime-framework/solid/hooks.ts +16 -11
  88. package/dist/runtime-framework/solid/index.ts +6 -2
  89. package/dist/runtime-framework/solid/page.ts +84 -30
  90. package/dist/runtime-framework/solid/reconciler/props.ts +65 -20
  91. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  92. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  93. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  94. package/dist/runtime-utils.d.ts +827 -0
  95. package/dist/runtime-utils.js +293 -119
  96. package/dist/runtime-utils.js.map +1 -1
  97. package/dist/runtime.d.ts +1 -0
  98. package/dist/runtime.js +293 -119
  99. package/dist/runtime.js.map +1 -1
  100. package/index.js +3 -1
  101. package/package.json +13 -13
  102. package/types/index.d.ts +4 -0
  103. package/dist/runtime-ets/utils/bind.ts +0 -24
  104. /package/dist/components-harmony-ets/{index.ts → tag.ts} +0 -0
  105. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,11 +1,11 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
3
  import commonStyleModify from './style'
4
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
5
5
 
6
- import type { TaroImageElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
6
+ import type { TaroImageElement, TaroAny } from '@tarojs/runtime'
7
7
 
8
- function getImageMode (mode: string): ImageFit {
8
+ export function getImageMode (mode: string): ImageFit {
9
9
  switch (mode) {
10
10
  case 'aspectFit': return ImageFit.Contain
11
11
  case 'aspectFill': return ImageFit.Cover
@@ -16,15 +16,28 @@ 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
+ @Builder customBuilder() {}
22
+ @BuilderParam createLazyChildren: (node: TaroImageElement) => void = this.customBuilder
23
+ @ObjectLink node: TaroImageElement
24
+ @State overwriteStyle: Record<string, TaroAny> = {}
25
+
26
+ aboutToAppear(): void {
27
+ if (this.node) {
28
+ this.node._instance = this
29
+ }
30
+ }
31
+
32
+ build() {
33
+ Image(this.node.getAttribute('src'))
34
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
35
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
36
+ this.node._nodeInfo.areaInfo = res[1]
37
+ }))
38
+ .objectFit(getImageMode(this.node.getAttribute('mode')))
39
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
40
+ .onComplete(e => eventHandler(e, 'complete', this.node))
41
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
42
+ }
30
43
  }
@@ -0,0 +1,76 @@
1
+ import TaroImage from './image'
2
+ import TaroText from './text'
3
+ import TaroView from './view'
4
+ import TaroIcon from './icon'
5
+ import TaroForm from './form'
6
+ import TaroLabel from './label'
7
+ import TaroInput from './input'
8
+ import TaroVideo from './video'
9
+ import TaroCanvas from './canvas'
10
+ import TaroButton from './button'
11
+ import TaroPicker from './picker'
12
+ import TaroSlider from './slider'
13
+ import TaroSwitch from './switch'
14
+ import TaroSwiper from './swiper'
15
+ import TaroWebView from './webView'
16
+ import TaroTextArea from './textArea'
17
+ import TaroRichText from './richText'
18
+ import TaroProgress from './progress'
19
+ import TaroInnerHtml from './innerHtml'
20
+ import TaroScrollView from './scrollView'
21
+ import TaroMovableArea from './movableArea'
22
+ import TaroMovableView from './movableView'
23
+ import { TaroRadio, TaroRadioGroup } from './radio'
24
+ import { TaroCheckboxGroup, TaroCheckbox } from './checkbox'
25
+
26
+ import commonStyleModify, { rowModify, columnModify } from './style'
27
+ import { getButtonColor } from './button'
28
+ import { FlexManager } from './utils/flexManager'
29
+ import { DynamicCenter } from './utils/DynamicCenter'
30
+ import { TOUCH_EVENT_MAP } from './utils/constant/event'
31
+ import { BUTTON_THEME_COLOR } from './utils/constant/style'
32
+ import { shouldBindEvent, getNodeThresholds, getNormalAttributes, getFontAttributes } from './utils/helper'
33
+
34
+ export {
35
+ FlexManager,
36
+ DynamicCenter,
37
+ getButtonColor,
38
+ TOUCH_EVENT_MAP,
39
+ shouldBindEvent,
40
+ getFontAttributes,
41
+ commonStyleModify,
42
+ rowModify,
43
+ columnModify,
44
+ getNodeThresholds,
45
+ BUTTON_THEME_COLOR,
46
+ getNormalAttributes,
47
+ }
48
+
49
+ export {
50
+ TaroImage,
51
+ TaroCanvas,
52
+ TaroText,
53
+ TaroView,
54
+ TaroIcon,
55
+ TaroForm,
56
+ TaroLabel,
57
+ TaroInput,
58
+ TaroVideo,
59
+ TaroButton,
60
+ TaroPicker,
61
+ TaroSlider,
62
+ TaroSwitch,
63
+ TaroSwiper,
64
+ TaroWebView,
65
+ TaroTextArea,
66
+ TaroRichText,
67
+ TaroProgress,
68
+ TaroInnerHtml,
69
+ TaroScrollView,
70
+ TaroMovableArea,
71
+ TaroMovableView,
72
+ TaroRadio,
73
+ TaroRadioGroup,
74
+ TaroCheckboxGroup,
75
+ TaroCheckbox
76
+ }
@@ -1,11 +1,16 @@
1
1
  import htmlParser from './utils/htmlParser'
2
- import { createChildItem } from './render'
3
2
 
4
- import type { TaroElement } from '@tarojs/runtime'
3
+ import type { TaroElement, TaroInnerHtmlElement } from '@tarojs/runtime'
5
4
 
6
- @Builder
7
- export default function TaroInnerHtml (node: TaroElement) {
8
- if (node.innerHTML) {
9
- createChildItem(htmlParser(node.innerHTML))
5
+ @Component
6
+ export default struct TaroInnerHtml {
7
+ @Builder customBuilder() {}
8
+ @BuilderParam createChildItem: (node: TaroElement, callback?: (node: TaroElement) => void) => void = this.customBuilder
9
+ @ObjectLink node: TaroInnerHtmlElement
10
+
11
+ build() {
12
+ if (this.node?.hmStyle?.display !== 'none' && this.node.innerHTML) {
13
+ this.createChildItem(htmlParser(this.node.innerHTML))
14
+ }
10
15
  }
11
16
  }
@@ -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,41 @@ 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
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
76
+ .styles(this.node?.hmStyle)
77
+ .attrs(getAttributes(this.node))
78
+ .onChange((value: string) => {
79
+ const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
80
+
81
+ this.value = value
82
+ this.node?.updateFormWidgetValue(value)
83
+ eventHandler(event, 'input', this.node)
84
+ })
85
+ .onSubmit(() => {
86
+ const event: TaroEvent = createTaroEvent('confirm', { detail: { value: this.value } }, this.node)
87
+ eventHandler(event, 'confirm', this.node)
88
+ })
89
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
90
+ .onBlur(() => {
91
+ const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
92
+ eventHandler(event, 'blur', this.node)
93
+ })
94
+ .onFocus(() => {
95
+ const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
96
+
97
+ eventHandler(event, 'focus', this.node)
98
+ })
99
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
100
+ if (this.node) {
101
+ this.node._nodeInfo.areaInfo = res[1]
102
+ }
103
+ }))
104
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
104
105
  }
105
106
  }
@@ -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,73 @@ 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
+
39
+ @Component
40
+ export default struct TaroLabel {
41
+ @Builder customBuilder() {}
42
+ @BuilderParam createLazyChildren: (node:TaroLabelElement) => void = this.customBuilder
43
+ @ObjectLink node:TaroLabelElement
44
+ @State overwriteStyle: Record<string, TaroAny> = {}
45
+
46
+ aboutToAppear(): void {
47
+ if (this.node) {
48
+ this.node._instance = this
42
49
  }
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)
50
+ }
51
+
52
+ build() {
53
+
54
+ if (!isUndefined(this.node._st.hmStyle.flexWrap)) {
55
+ Flex(FlexManager.flexOptions(this.node)) {
56
+ this.createLazyChildren(this.node)
57
+ }
58
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
59
+ .onClick((e: ClickEvent) => {
60
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
61
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
62
+
63
+ handleTargetChange(id)
64
+ eventHandler(e, 'click', this.node)
65
+ })
66
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
67
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
68
+ this.node._nodeInfo.areaInfo = res[1]
69
+ }))
70
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
71
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
72
+ Row() {
73
+ this.createLazyChildren(this.node)
74
+ }
75
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
76
+ .onClick((e: ClickEvent) => {
77
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
78
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
79
+
80
+ handleTargetChange(id)
81
+ eventHandler(e, 'click', this.node)
82
+ })
83
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
84
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
85
+ this.node._nodeInfo.areaInfo = res[1]
86
+ }))
87
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
88
+ } else {
89
+ Column() {
90
+ this.createLazyChildren(this.node)
91
+ }
92
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
93
+ .onClick((e: ClickEvent) => {
94
+ const firstChild: TaroElement | null = this.node.childNodes[0] as TaroElement | null
95
+ const id: string = this.node._attrs.for || firstChild?._attrs.id || firstChild?._nid || ''
96
+
97
+ handleTargetChange(id)
98
+ eventHandler(e, 'click', this.node)
99
+ })
100
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
101
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
102
+ this.node._nodeInfo.areaInfo = res[1]
103
+ }))
104
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
61
105
  }
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
106
  }
78
107
  }
@@ -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 (!isUndefined(this.node._st.hmStyle.flexWrap)) {
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 (!isUndefined(this.node._st.hmStyle.flexWrap)) {
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
+ }