@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.0 → 4.0.0-alpha.2

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 (77) hide show
  1. package/dist/apis/device/memory.ts +10 -3
  2. package/dist/apis/index.ts +2 -0
  3. package/dist/apis/media/video/VideoContext.ts +56 -7
  4. package/dist/apis/media/video/index.ts +3 -2
  5. package/dist/apis/network/request.ts +5 -5
  6. package/dist/apis/route/index.ts +15 -0
  7. package/dist/apis/wxml/index.ts +2 -0
  8. package/dist/components-harmony-ets/button.ets +26 -40
  9. package/dist/components-harmony-ets/checkbox.ets +70 -99
  10. package/dist/components-harmony-ets/form.ets +29 -42
  11. package/dist/components-harmony-ets/icon.ets +6 -34
  12. package/dist/components-harmony-ets/image.ets +2 -32
  13. package/dist/components-harmony-ets/innerHtml.ets +2 -2
  14. package/dist/components-harmony-ets/input.ets +7 -27
  15. package/dist/components-harmony-ets/label.ets +40 -47
  16. package/dist/components-harmony-ets/picker.ets +66 -73
  17. package/dist/components-harmony-ets/radio.ets +72 -101
  18. package/dist/components-harmony-ets/richText.ets +4 -36
  19. package/dist/components-harmony-ets/scrollView.ets +34 -74
  20. package/dist/components-harmony-ets/slider.ets +9 -34
  21. package/dist/components-harmony-ets/style.ets +154 -0
  22. package/dist/components-harmony-ets/swiper.ets +4 -34
  23. package/dist/components-harmony-ets/switch.ets +43 -56
  24. package/dist/components-harmony-ets/text.ets +7 -34
  25. package/dist/components-harmony-ets/textArea.ets +8 -28
  26. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
  27. package/dist/components-harmony-ets/utils/flexManager.ets +45 -7
  28. package/dist/components-harmony-ets/utils/helper.ets +2 -2
  29. package/dist/components-harmony-ets/utils/styles.ets +58 -20
  30. package/dist/components-harmony-ets/video.ets +4 -34
  31. package/dist/components-harmony-ets/view.ets +25 -67
  32. package/dist/components-harmony-ets/webView.ets +50 -0
  33. package/dist/index.js +103 -5
  34. package/dist/index.js.map +1 -1
  35. package/dist/runtime-ets/bom/window.ts +2 -2
  36. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -6
  37. package/dist/runtime-ets/dom/document.ts +21 -4
  38. package/dist/runtime-ets/dom/element/element.ts +1 -0
  39. package/dist/runtime-ets/dom/element/form.ts +11 -2
  40. package/dist/runtime-ets/dom/element/index.ts +4 -1
  41. package/dist/runtime-ets/dom/element/normal.ts +1 -0
  42. package/dist/runtime-ets/dom/element/webView.ts +61 -0
  43. package/dist/runtime-ets/dom/node.ts +29 -16
  44. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
  45. package/dist/runtime-ets/dom/stylesheet/index.ts +216 -354
  46. package/dist/runtime-ets/dom/stylesheet/type.ts +46 -11
  47. package/dist/runtime-ets/dom/stylesheet/util.ts +58 -6
  48. package/dist/runtime-ets/index.ts +1 -2
  49. package/dist/runtime-ets/interface/event.ts +2 -1
  50. package/dist/runtime-ets/utils/index.ts +6 -1
  51. package/dist/runtime-ets/utils/info.ts +3 -1
  52. package/dist/runtime-framework/react/app.ts +12 -22
  53. package/dist/runtime-framework/react/hooks.ts +3 -3
  54. package/dist/runtime-framework/react/index.ts +1 -0
  55. package/dist/runtime-framework/react/native-page.ts +344 -0
  56. package/dist/runtime-framework/react/page.ts +2 -2
  57. package/dist/runtime-framework/solid/hooks.ts +3 -3
  58. package/dist/runtime-utils.js +76 -20
  59. package/dist/runtime-utils.js.map +1 -1
  60. package/dist/runtime.js +76 -20
  61. package/dist/runtime.js.map +1 -1
  62. package/package.json +12 -11
  63. package/static/media/cancel.svg +1 -0
  64. package/static/media/circle.svg +1 -0
  65. package/static/media/clear.svg +1 -0
  66. package/static/media/download.svg +1 -0
  67. package/static/media/info.svg +1 -0
  68. package/static/media/info_circle.svg +1 -0
  69. package/static/media/search.svg +1 -0
  70. package/static/media/success.svg +1 -0
  71. package/static/media/success_no_circle.svg +1 -0
  72. package/static/media/taro_arrow_left.svg +1 -0
  73. package/static/media/taro_home.svg +1 -0
  74. package/static/media/waiting.svg +1 -0
  75. package/static/media/warn.svg +1 -0
  76. package/types/runtime.d.ts +2 -0
  77. package/dist/runtime-ets/utils/bind.ts +0 -24
@@ -1,4 +1,11 @@
1
- import { temporarilyNotSupport } from '../utils'
1
+ import { hooks } from '@tarojs/runtime'
2
2
 
3
- export const onMemoryWarning = temporarilyNotSupport('onMemoryWarning')
4
- export const offMemoryWarning = temporarilyNotSupport('offMemoryWarning')
3
+ export const onMemoryWarning = (listener) => {
4
+ hooks.tap('getMemoryLevel', (res) => {
5
+ listener(res)
6
+ })
7
+ }
8
+
9
+ export const offMemoryWarning = (listener) => {
10
+ hooks.off('getMemoryLevel', listener)
11
+ }
@@ -120,5 +120,7 @@ export function getAppInfo () {
120
120
  }
121
121
  }
122
122
 
123
+ initNativeApi(taro)
124
+
123
125
  export * from './apis'
124
126
  export default taro
@@ -1,19 +1,68 @@
1
+ // @ts-nocheck
2
+ import { document } from '@tarojs/runtime'
3
+
1
4
  import { temporarilyNotSupport } from '../../utils'
2
5
 
6
+ import type { TaroVideoElement } from '@tarojs/runtime'
3
7
  import type Taro from '@tarojs/taro/types'
4
8
 
5
9
  export class VideoContext implements Taro.VideoContext {
10
+ id: string
11
+
12
+ video: TaroVideoElement
13
+
14
+ controller: VideoController
15
+
16
+ constructor (id: string) {
17
+ this.id = id
18
+ this.video = document.getElementById(id)
19
+
20
+ if (this.video) {
21
+ this.controller = this.video.controller
22
+ }
23
+ }
24
+
25
+ play () {
26
+ if (!this.controller) return
27
+
28
+ this.controller.play()
29
+ }
30
+
31
+ pause () {
32
+ if (!this.controller) return
33
+
34
+ this.controller.pause()
35
+ }
36
+
37
+ stop () {
38
+ if (!this.controller) return
39
+
40
+ this.controller.stop()
41
+ }
42
+
43
+ seek (position: number) {
44
+ if (!this.controller) return
45
+
46
+ this.controller.setCurrentTime(position)
47
+ }
48
+
49
+ requestFullScreen () {
50
+ if (!this.controller) return
51
+
52
+ this.controller.requestFullscreen(true)
53
+ }
54
+
55
+ exitFullScreen () {
56
+ if (!this.controller) return
57
+
58
+ this.controller.exitFullscreen()
59
+ }
60
+
61
+ requestBackgroundPlayback = temporarilyNotSupport('VideoContext.requestBackgroundPlayback')
6
62
  exitBackgroundPlayback = temporarilyNotSupport('VideoContext.exitBackgroundPlayback')
7
- exitFullScreen = temporarilyNotSupport('VideoContext.exitFullScreen')
8
63
  exitPictureInPicture = temporarilyNotSupport('VideoContext.exitPictureInPicture')
9
64
  hideStatusBar = temporarilyNotSupport('VideoContext.hideStatusBar')
10
- pause = temporarilyNotSupport('VideoContext.pause')
11
- play = temporarilyNotSupport('VideoContext.play')
12
65
  playbackRate = temporarilyNotSupport('VideoContext.playbackRate')
13
- requestBackgroundPlayback = temporarilyNotSupport('VideoContext.requestBackgroundPlayback')
14
- requestFullScreen = temporarilyNotSupport('VideoContext.requestFullScreen')
15
- seek = temporarilyNotSupport('VideoContext.seek')
16
66
  sendDanmu = temporarilyNotSupport('VideoContext.sendDanmu')
17
67
  showStatusBar = temporarilyNotSupport('VideoContext.showStatusBar')
18
- stop = temporarilyNotSupport('VideoContext.stop')
19
68
  }
@@ -26,6 +26,7 @@ import mediaLibrary from '@ohos.multimedia.mediaLibrary'
26
26
  import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../../utils'
27
27
  import { VideoContext } from './VideoContext'
28
28
 
29
+ import type { TaroAny } from '@tarojs/runtime'
29
30
  import type Taro from '@tarojs/taro/types'
30
31
 
31
32
  interface IChooseVideoOptionOHOS {
@@ -43,8 +44,8 @@ const saveVideoToPhotosAlbumSchema = {
43
44
  filePath: 'String'
44
45
  }
45
46
 
46
- export const createVideoContext: typeof Taro.createVideoContext = () => {
47
- return new VideoContext()
47
+ export const createVideoContext: typeof Taro.createVideoContext = (id: string, _: TaroAny) => {
48
+ return new VideoContext(id)
48
49
  }
49
50
 
50
51
  // TODO: 1.返回属性补全
@@ -6,7 +6,7 @@
6
6
  // ✅ RequestTask.onHeadersReceived
7
7
 
8
8
  import http from '@ohos.net.http'
9
- import { isString, isUndefined } from '@tarojs/shared'
9
+ import { isString } from '@tarojs/shared'
10
10
 
11
11
  import { callAsyncFail, callAsyncSuccess, validateParams } from '../utils'
12
12
 
@@ -59,10 +59,10 @@ export const request: typeof Taro.request = function (options) {
59
59
  }
60
60
 
61
61
  // 检查 Header 是否有 Referer
62
- if (isUndefined(header.Referer)) {
63
- const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' }
64
- callAsyncFail(reject, error, options)
65
- }
62
+ // if (isUndefined(header.Referer)) {
63
+ // const error = { errMsg: 'request fail parameter error: the header doesn‘t support Referer property' }
64
+ // callAsyncFail(reject, error, options)
65
+ // }
66
66
 
67
67
  // 检查 method 是否正确
68
68
  if (method) {
@@ -16,6 +16,21 @@ function parseURL (raw = ''): [string, Record<string, unknown>] {
16
16
  const [urlStr, queryStr = ''] = raw.split('?')
17
17
  const query: Record<string, unknown> = queryToJson(queryStr)
18
18
  let url = urlStr.replace(/^\//, '')
19
+
20
+ // 处理相对路径
21
+ if (url.indexOf('.') === 0) {
22
+ const page = router.getState()
23
+ const parts = page.path.split('/')
24
+ parts.pop()
25
+ url.split('/').forEach((item) => {
26
+ if (item === '.') {
27
+ return
28
+ }
29
+ item === '..' ? parts.pop() : parts.push(item)
30
+ })
31
+ url = parts.join('/')
32
+ }
33
+
19
34
  if (isTabPage(url)) {
20
35
  query.$page = url
21
36
  url = TARO_TABBAR_PAGE_PATH
@@ -13,3 +13,5 @@ export const createIntersectionObserver: typeof Taro.createIntersectionObserver
13
13
  }
14
14
 
15
15
  export const createMediaQueryObserver = /* @__PURE__ */ temporarilyNotSupport('createMediaQueryObserver')
16
+
17
+ export { IntersectionObserver }
@@ -1,41 +1,12 @@
1
1
  import { eventHandler, createTaroEvent, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
  import { createLazyChildren } from './render'
3
+ import commonStyleModify from './style'
3
4
  import { BUTTON_THEME_COLOR } from './utils/constant/style'
4
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
6
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
6
7
 
7
8
  import type { TaroAny, TaroEvent, TaroButtonElement, TaroStyleType } from '@tarojs/runtime'
8
9
 
9
- @Extend(Button)
10
- function attrs (style: TaroStyleType) {
11
- .id(style.id)
12
- .key(style.id)
13
- .width(style.width)
14
- .height(style.height)
15
- .padding({
16
- top: style.padding?.top,
17
- left: style.padding?.left || 10,
18
- right: style.padding?.right || 10,
19
- bottom: style.padding?.bottom,
20
- })
21
- .margin(style.margin)
22
- .flexGrow(style.flexGrow)
23
- .flexShrink(style.flexShrink)
24
- .flexBasis(style.flexBasis)
25
- .alignSelf(style.alignSelf)
26
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
27
- .backgroundImageSize(style.backgroundImageSize)
28
- .backgroundImagePosition(style.backgroundImagePosition)
29
- .rotate(style.rotate)
30
- .scale(style.scale)
31
- .translate(style.translate)
32
- .transform(style.transform)
33
- .borderStyle(style.borderStyle)
34
- .linearGradient(style.linearGradient)
35
- .zIndex(style.zIndex)
36
- .clip(style.clip)
37
- }
38
-
39
10
  @Extend(Button)
40
11
  function themeStyles(style: TaroStyleType) {
41
12
  .fontColor(style.color)
@@ -71,9 +42,24 @@ function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
71
42
  const type: string = _attrs.type || 'default'
72
43
 
73
44
  return {
74
- borderColor: hmStyle.borderColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
75
- borderWidth: hmStyle.borderWidth || 1,
76
- borderRadius: hmStyle.borderRadius || convertNumber2VP(10),
45
+ borderColor: {
46
+ top: hmStyle.borderTopColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
47
+ right: hmStyle.borderRightColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
48
+ bottom: hmStyle.borderBottomColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
49
+ left: hmStyle.borderLeftColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background)
50
+ },
51
+ borderWidth: {
52
+ top: hmStyle.borderTopWidth || 1,
53
+ right: hmStyle.borderRightWidth || 1,
54
+ bottom: hmStyle.borderBottomWidth || 1,
55
+ left: hmStyle.borderLeftWidth || 1
56
+ },
57
+ borderRadius: {
58
+ topLeft: hmStyle.borderTopLeftRadius || convertNumber2VP(10),
59
+ topRight: hmStyle.borderTopRightRadius || convertNumber2VP(10),
60
+ bottomLeft: hmStyle.borderBottomLeftRadius || convertNumber2VP(10),
61
+ bottomRight: hmStyle.borderBottomRightRadius || convertNumber2VP(10)
62
+ },
77
63
  opacity: isDisabled ? 0.4 : hmStyle.opacity,
78
64
  backgroundColor: isPlain ? Color.Transparent : (hmStyle.backgroundColor || BUTTON_THEME_COLOR.get(type).background),
79
65
  color: hmStyle.color || getButtonColor(node, BUTTON_THEME_COLOR.get(type).text),
@@ -121,16 +107,16 @@ export default function TaroButton (node: TaroButtonElement) {
121
107
  }
122
108
  }
123
109
  .themeStyles(getThemeAttributes(node))
124
- .attrs(getNormalAttributes(node))
110
+ .attributeModifier(commonStyleModify.setNode(node))
125
111
  .constraintSize({
126
- minWidth: node.hmStyle?.constraintSize?.minWidth || getButtonMinWidth(node),
127
- minHeight: node.hmStyle?.constraintSize?.minHeight || getButtonMinHeight(node),
128
- maxWidth: node.hmStyle?.constraintSize?.maxWidth,
129
- maxHeight: node.hmStyle?.constraintSize?.maxHeight,
112
+ minWidth: node.hmStyle?.minWidth || getButtonMinWidth(node),
113
+ minHeight: node.hmStyle?.minHeight || getButtonMinHeight(node),
114
+ maxWidth: node.hmStyle?.maxWidth,
115
+ maxHeight: node.hmStyle?.maxHeight,
130
116
  })
131
117
  .type(ButtonType.Normal)
132
118
  .onClick((e: ClickEvent) => {
133
- if (['submit', 'reset'].includes(node._attrs.formType)) {
119
+ if (node._attrs.formType && ['submit', 'reset'].includes(node._attrs.formType)) {
134
120
  const eventName = node._attrs.formType + '-btn'
135
121
  const event: TaroEvent = createTaroEvent(eventName, {}, node)
136
122
  eventHandler(event, eventName, node)
@@ -1,10 +1,11 @@
1
1
  import { createTaroEvent, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
+ import commonStyleModify from './style'
3
4
  import { createLazyChildren } from './render'
4
5
  import { FlexManager } from './utils/FlexManager'
5
- import { shouldBindEvent, getNormalAttributes, getNodeThresholds } from './utils/helper'
6
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
6
7
 
7
- import type { TaroStyleType, TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
8
+ import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
8
9
 
9
10
  interface CheckboxOptions {
10
11
  name?: string
@@ -14,37 +15,6 @@ interface CheckboxAttrs {
14
15
  selectedColor?: ResourceColor
15
16
  }
16
17
 
17
- @Extend(Checkbox)
18
- function checkboxStyle (style: TaroStyleType) {
19
- .id(style.id)
20
- .key(style.id)
21
- .padding(style.padding)
22
- .margin(style.margin)
23
- .width(style.width)
24
- .height(style.height)
25
- .constraintSize(style.constraintSize)
26
- .flexGrow(style.flexGrow)
27
- .flexShrink(style.flexShrink)
28
- .flexBasis(style.flexBasis)
29
- .alignSelf(style.alignSelf)
30
- .backgroundColor(style.backgroundColor)
31
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
32
- .backgroundImageSize(style.backgroundImageSize)
33
- .backgroundImagePosition(style.backgroundImagePosition)
34
- .rotate(style.rotate)
35
- .scale(style.scale)
36
- .translate(style.translate)
37
- .transform(style.transform)
38
- .borderStyle(style.borderStyle)
39
- .borderWidth(style.borderWidth)
40
- .borderColor(style.borderColor)
41
- .borderRadius(style.borderRadius)
42
- .linearGradient(style.linearGradient)
43
- .zIndex(style.zIndex)
44
- .opacity(style.opacity)
45
- .clip(style.clip)
46
- }
47
-
48
18
  @Extend(Checkbox)
49
19
  function checkboxAttr(attr: CheckboxAttrs) {
50
20
  .selectedColor(attr.selectedColor)
@@ -63,75 +33,63 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
63
33
  }
64
34
  }
65
35
 
66
- @Builder
67
- export function TaroCheckbox(node: TaroCheckboxElement) {
68
- Stack() {
69
- Row() {
70
- Checkbox(getOptions(node))
71
- .checkboxStyle(getNormalAttributes(node))
72
- .checkboxAttr(getAttributes(node))
73
- .opacity(!!node._attrs.disabled ? 0.4 : 1)
74
- .select(node.checked)
75
- .onChange((value: boolean) => {
76
- if (!!node?._attrs.disabled) {
77
- node.updateComponent()
78
- } else {
79
- node.updateCheckedValue(value)
36
+ @Component
37
+ export struct TaroCheckbox {
38
+ node: TaroCheckboxElement | null = null
80
39
 
81
- if (value) {
82
- const event: TaroEvent = createTaroEvent('change', { detail: { value: node?._attrs.value } }, node)
83
- eventHandler(event, 'change', node)
40
+ aboutToAppear () {
41
+ if (this.node && !this.node._isInit) {
42
+ this.node._isInit = true
43
+ this.node._reset = this.node.checked || false
44
+ }
45
+ }
46
+
47
+ build () {
48
+ if (this.node) {
49
+ Stack() {
50
+ Row() {
51
+ Checkbox(getOptions(this.node))
52
+ .attributeModifier(commonStyleModify.setNode(this.node))
53
+ .checkboxAttr(getAttributes(this.node))
54
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
55
+ .select(this.node.checked)
56
+ .onChange((value: boolean) => {
57
+ if (this.node) {
58
+ if (!!this.node?._attrs.disabled) {
59
+ this.node.updateComponent()
60
+ } else {
61
+ this.node.updateCheckedValue(value)
62
+
63
+ if (value) {
64
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
65
+ eventHandler(event, 'change', this.node)
66
+ }
67
+ }
68
+ }
69
+ })
70
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
71
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
72
+ if (this.node) {
73
+ this.node._nodeInfo.areaInfo = res[1]
74
+ }
75
+ }))
76
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
77
+ Text(this.node.textContent)
78
+ .textAlign(TextAlign.Center)
79
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
80
+ }
81
+ .onClick(() => {
82
+ if (this.node) {
83
+ if (!this.node?._attrs.disabled) {
84
+ this.node.checked = !this.node.checked
84
85
  }
85
86
  }
86
87
  })
87
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
88
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
89
- node._nodeInfo.areaInfo = res[1]
90
- }))
91
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
92
- Text(node.textContent)
93
- .textAlign(TextAlign.Center)
94
- .opacity(!!node._attrs.disabled ? 0.4 : 1)
95
- }
96
- .onClick(() => {
97
- if (!node?._attrs.disabled) {
98
- node.checked = !node.checked
99
88
  }
100
- })
89
+ }
101
90
  }
102
91
  }
103
92
 
104
- @Extend(Flex)
105
- function checkboxGroupAttrs (style: TaroStyleType) {
106
- .id(style.id)
107
- .key(style.id)
108
- .padding(style.padding)
109
- .margin(style.margin)
110
- .width(style.width)
111
- .height(style.height)
112
- .constraintSize(style.constraintSize)
113
- .flexGrow(style.flexGrow)
114
- .flexShrink(style.flexShrink)
115
- .flexBasis(style.flexBasis)
116
- .alignSelf(style.alignSelf)
117
- .backgroundColor(style.backgroundColor)
118
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
119
- .backgroundImageSize(style.backgroundImageSize)
120
- .backgroundImagePosition(style.backgroundImagePosition)
121
- .rotate(style.rotate)
122
- .scale(style.scale)
123
- .translate(style.translate)
124
- .transform(style.transform)
125
- .borderStyle(style.borderStyle)
126
- .borderWidth(style.borderWidth)
127
- .borderColor(style.borderColor)
128
- .borderRadius(style.borderRadius)
129
- .linearGradient(style.linearGradient)
130
- .zIndex(style.zIndex)
131
- .opacity(style.opacity)
132
- .clip(style.clip)
133
- }
134
-
135
93
  interface ChangeEventDetail { value: string[] }
136
94
 
137
95
  @Component
@@ -163,12 +121,25 @@ export struct TaroCheckboxGroup {
163
121
 
164
122
  build() {
165
123
  if (this.node) {
166
- Flex(FlexManager.flexOptions(this.node)) {
167
- createLazyChildren(this.node)
124
+ if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
125
+ Row() {
126
+ createLazyChildren(this.node)
127
+ }
128
+ .attributeModifier(commonStyleModify.setNode(this.node))
129
+ .defaultEvent()
130
+ .visibleChangeEvent()
131
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
132
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
133
+ } else {
134
+ Column() {
135
+ createLazyChildren(this.node)
136
+ }
137
+ .attributeModifier(commonStyleModify.setNode(this.node))
138
+ .defaultEvent()
139
+ .visibleChangeEvent()
140
+ .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
141
+ .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
168
142
  }
169
- .checkboxGroupAttrs(getNormalAttributes(this.node))
170
- .defaultEvent()
171
- .visibleChangeEvent()
172
143
  }
173
144
  }
174
145
  }
@@ -1,53 +1,40 @@
1
1
  import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
+ import commonStyleModify from './style'
3
4
  import { createLazyChildren } from './render'
4
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
6
  import { FlexManager } from './utils/FlexManager'
6
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
7
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
8
 
8
- import type { TaroAny, TaroFormElement, TaroStyleType } from '@tarojs/runtime'
9
-
10
- @Extend(Flex)
11
- function attrs (style: TaroStyleType) {
12
- .id(style.id)
13
- .key(style.id)
14
- .padding(style.padding)
15
- .margin(style.margin)
16
- .width(style.width)
17
- .height(style.height)
18
- .constraintSize(style.constraintSize)
19
- .flexGrow(style.flexGrow)
20
- .flexShrink(style.flexShrink)
21
- .flexBasis(style.flexBasis)
22
- .alignSelf(style.alignSelf)
23
- .backgroundColor(style.backgroundColor)
24
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
25
- .backgroundImageSize(style.backgroundImageSize)
26
- .backgroundImagePosition(style.backgroundImagePosition)
27
- .rotate(style.rotate)
28
- .scale(style.scale)
29
- .translate(style.translate)
30
- .transform(style.transform)
31
- .borderStyle(style.borderStyle)
32
- .borderWidth(style.borderWidth)
33
- .borderColor(style.borderColor)
34
- .borderRadius(style.borderRadius)
35
- .linearGradient(style.linearGradient)
36
- .zIndex(style.zIndex)
37
- .opacity(style.opacity)
38
- .clip(style.clip)
39
- }
9
+ import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
40
10
 
41
11
  @Builder
42
12
  export default function TaroForm (node: TaroFormElement) {
43
- Flex(FlexManager.flexOptions(node)) {
44
- createLazyChildren(node)
13
+ if (FlexManager.isFlexNode(node) && FlexManager.flexOptions(node).direction !== FlexDirection.Column) {
14
+ Row() {
15
+ createLazyChildren(node)
16
+ }
17
+ .attributeModifier(commonStyleModify.setNode(node))
18
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
19
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
20
+ .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
21
+ node._nodeInfo.areaInfo = res[1]
22
+ }))
23
+ .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
24
+ .alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
25
+ .justifyContent(FlexManager.flexOptions(node).justifyContent)
26
+ } else {
27
+ Column() {
28
+ createLazyChildren(node)
29
+ }
30
+ .attributeModifier(commonStyleModify.setNode(node))
31
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
32
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
33
+ .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
34
+ node._nodeInfo.areaInfo = res[1]
35
+ }))
36
+ .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
37
+ .alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
38
+ .justifyContent(FlexManager.flexOptions(node).justifyContent)
45
39
  }
46
- .attrs(getNormalAttributes(node))
47
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
48
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
49
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
50
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
51
- node._nodeInfo.areaInfo = res[1]
52
- }))
53
40
  }
@@ -1,39 +1,9 @@
1
- import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
1
+ import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, convertNumber2PX } from '@tarojs/runtime'
2
2
 
3
+ import commonStyleModify from './style'
3
4
  import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
5
 
5
- import type { TaroIconElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
6
-
7
- @Extend(Image)
8
- function attrs (style: TaroStyleType) {
9
- .id(style.id)
10
- .key(style.id)
11
- .padding(style.padding)
12
- .margin(style.margin)
13
- .width(style.width || convertNumber2VP(23))
14
- .height(style.height || convertNumber2VP(23))
15
- .constraintSize(style.constraintSize)
16
- .flexGrow(style.flexGrow)
17
- .flexShrink(style.flexShrink)
18
- .flexBasis(style.flexBasis)
19
- .alignSelf(style.alignSelf)
20
- .backgroundColor(style.backgroundColor)
21
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
22
- .backgroundImageSize(style.backgroundImageSize)
23
- .backgroundImagePosition(style.backgroundImagePosition)
24
- .rotate(style.rotate)
25
- .scale(style.scale)
26
- .translate(style.translate)
27
- .transform(style.transform)
28
- .borderStyle(style.borderStyle)
29
- .borderWidth(style.borderWidth)
30
- .borderColor(style.borderColor)
31
- .borderRadius(style.borderRadius)
32
- .linearGradient(style.linearGradient)
33
- .zIndex(style.zIndex)
34
- .opacity(style.opacity)
35
- .clip(style.clip)
36
- }
6
+ import type { TaroIconElement, TaroAny } from '@tarojs/runtime'
37
7
 
38
8
  const ICON_COLOR_MAP: TaroAny = {
39
9
  success: Color.Green,
@@ -83,11 +53,13 @@ export default function TaroIcon (node: TaroIconElement) {
83
53
  Image(getIconData(node))
84
54
  .objectFit(ImageFit.Contain)
85
55
  .fillColor(node._attrs.color || ICON_COLOR_MAP[node._attrs.type] || Color.Black)
86
- .attrs(getNormalAttributes(node))
56
+ .attributeModifier(commonStyleModify.setNode(node))
87
57
  .size({
88
58
  width: convertNumber2VP(Number(node._attrs.size) || 23),
89
59
  height: convertNumber2VP(Number(node._attrs.size) || 23),
90
60
  })
61
+ .width(getNormalAttributes(node).width || convertNumber2PX(23))
62
+ .height(getNormalAttributes(node).height || convertNumber2PX(23))
91
63
  .onComplete(e => eventHandler(e, 'complete', node))
92
64
  .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
93
65
  .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
@@ -1,40 +1,10 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
+ import commonStyleModify from './style'
3
4
  import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
4
5
 
5
6
  import type { TaroImageElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
6
7
 
7
- @Extend(Image)
8
- function attrs (style: TaroStyleType) {
9
- .id(style.id)
10
- .key(style.id)
11
- .padding(style.padding)
12
- .margin(style.margin)
13
- .width(style.width)
14
- .height(style.height)
15
- .backgroundColor(style.backgroundColor)
16
- .constraintSize(style.constraintSize)
17
- .flexGrow(style.flexGrow)
18
- .flexShrink(style.flexShrink)
19
- .flexBasis(style.flexBasis)
20
- .alignSelf(style.alignSelf)
21
- .backgroundImage(style.backgroundImage, style.backgroundRepeat)
22
- .backgroundImageSize(style.backgroundImageSize)
23
- .backgroundImagePosition(style.backgroundImagePosition)
24
- .rotate(style.rotate)
25
- .scale(style.scale)
26
- .translate(style.translate)
27
- .transform(style.transform)
28
- .borderStyle(style.borderStyle)
29
- .borderWidth(style.borderWidth)
30
- .borderColor(style.borderColor)
31
- .borderRadius(style.borderRadius)
32
- .linearGradient(style.linearGradient)
33
- .zIndex(style.zIndex)
34
- .opacity(style.opacity)
35
- .clip(style.clip)
36
- }
37
-
38
8
  function getImageMode (mode: string): ImageFit {
39
9
  switch (mode) {
40
10
  case 'aspectFit': return ImageFit.Contain
@@ -54,7 +24,7 @@ export default function TaroImage (node: TaroImageElement) {
54
24
  node._nodeInfo.areaInfo = res[1]
55
25
  }))
56
26
  .objectFit(getImageMode(node.getAttribute('mode')))
57
- .attrs(getNormalAttributes(node))
27
+ .attributeModifier(commonStyleModify.setNode(node))
58
28
  .onComplete(e => eventHandler(e, 'complete', node))
59
29
  .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
60
30
  }