@tarojs/plugin-platform-harmony-ets 4.0.0-canary.8 → 4.0.0

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 (135) hide show
  1. package/dist/apis/base/system.ts +73 -20
  2. package/dist/apis/canvas/index.ts +10 -1
  3. package/dist/apis/device/clipboard.ts +23 -8
  4. package/dist/apis/framework/index.ts +1 -5
  5. package/dist/apis/index.ts +27 -17
  6. package/dist/apis/media/image/index.ts +169 -17
  7. package/dist/apis/network/request.ts +5 -5
  8. package/dist/apis/route/index.ts +15 -0
  9. package/dist/apis/storage/index.ts +146 -78
  10. package/dist/apis/ui/animation/animation.ts +71 -29
  11. package/dist/apis/ui/background.ts +2 -1
  12. package/dist/apis/ui/interaction/index.ts +58 -59
  13. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  14. package/dist/apis/ui/pull-down-refresh.ts +9 -3
  15. package/dist/apis/ui/scroll/index.ts +5 -5
  16. package/dist/apis/ui/tab-bar.ts +3 -3
  17. package/dist/apis/utils/index.ts +21 -2
  18. package/dist/apis/utils/permissions.ts +6 -0
  19. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  20. package/dist/apis/wxml/index.ts +2 -0
  21. package/dist/apis/wxml/selectorQuery.ts +26 -13
  22. package/dist/components-harmony-ets/button.ets +63 -77
  23. package/dist/components-harmony-ets/canvas.ets +51 -0
  24. package/dist/components-harmony-ets/checkbox.ets +75 -258
  25. package/dist/components-harmony-ets/form.ets +51 -158
  26. package/dist/components-harmony-ets/icon.ets +33 -83
  27. package/dist/components-harmony-ets/image.ets +35 -79
  28. package/dist/components-harmony-ets/index.ets +92 -0
  29. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  30. package/dist/components-harmony-ets/input.ets +64 -101
  31. package/dist/components-harmony-ets/label.ets +72 -174
  32. package/dist/components-harmony-ets/listView.ets +31 -0
  33. package/dist/components-harmony-ets/movableArea.ets +126 -0
  34. package/dist/components-harmony-ets/movableView.ets +93 -0
  35. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  36. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  37. package/dist/components-harmony-ets/picker.ets +46 -163
  38. package/dist/components-harmony-ets/progress.ets +52 -0
  39. package/dist/components-harmony-ets/pseudo.ets +80 -0
  40. package/dist/components-harmony-ets/radio.ets +80 -264
  41. package/dist/components-harmony-ets/richText.ets +20 -102
  42. package/dist/components-harmony-ets/scrollList.ets +108 -0
  43. package/dist/components-harmony-ets/scrollView.ets +71 -160
  44. package/dist/components-harmony-ets/slider.ets +22 -82
  45. package/dist/components-harmony-ets/stickySection.ets +42 -0
  46. package/dist/components-harmony-ets/style.ets +410 -0
  47. package/dist/components-harmony-ets/swiper.ets +64 -87
  48. package/dist/components-harmony-ets/switch.ets +39 -99
  49. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  50. package/dist/components-harmony-ets/text.ets +111 -113
  51. package/dist/components-harmony-ets/textArea.ets +51 -95
  52. package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
  53. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
  54. package/dist/components-harmony-ets/utils/flexManager.ets +50 -19
  55. package/dist/components-harmony-ets/utils/helper.ets +20 -8
  56. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  57. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  58. package/dist/components-harmony-ets/utils/index.ts +54 -50
  59. package/dist/components-harmony-ets/utils/styles.ets +172 -92
  60. package/dist/components-harmony-ets/video.ets +37 -88
  61. package/dist/components-harmony-ets/view.ets +63 -159
  62. package/dist/components-harmony-ets/webView.ets +41 -98
  63. package/dist/index.d.ts +152 -0
  64. package/dist/index.js +187 -56
  65. package/dist/index.js.map +1 -1
  66. package/dist/runtime-ets/bom/document.ts +6 -4
  67. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  68. package/dist/runtime-ets/bom/window.ts +9 -2
  69. package/dist/runtime-ets/current.ts +5 -1
  70. package/dist/runtime-ets/dom/bind.ts +28 -12
  71. package/dist/runtime-ets/dom/class-list.ts +2 -2
  72. package/dist/runtime-ets/dom/cssNesting.ts +419 -0
  73. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
  74. package/dist/runtime-ets/dom/document.ts +22 -8
  75. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  76. package/dist/runtime-ets/dom/element/element.ts +376 -57
  77. package/dist/runtime-ets/dom/element/form.ts +31 -26
  78. package/dist/runtime-ets/dom/element/index.ts +30 -2
  79. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  80. package/dist/runtime-ets/dom/element/movableView.ts +248 -0
  81. package/dist/runtime-ets/dom/element/normal.ts +35 -8
  82. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  83. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  84. package/dist/runtime-ets/dom/element/text.ts +1 -8
  85. package/dist/runtime-ets/dom/element/video.ts +5 -4
  86. package/dist/runtime-ets/dom/element/webView.ts +12 -5
  87. package/dist/runtime-ets/dom/event.ts +3 -5
  88. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  89. package/dist/runtime-ets/dom/node.ts +65 -32
  90. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
  91. package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
  92. package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
  93. package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
  94. package/dist/runtime-ets/index.ts +2 -2
  95. package/dist/runtime-ets/interface/event.ts +1 -1
  96. package/dist/runtime-ets/utils/index.ts +74 -13
  97. package/dist/runtime-ets/utils/info.ts +2 -2
  98. package/dist/runtime-framework/react/app.ts +25 -30
  99. package/dist/runtime-framework/react/hooks.ts +3 -4
  100. package/dist/runtime-framework/react/index.ts +0 -2
  101. package/dist/runtime-framework/react/native-page.ts +219 -82
  102. package/dist/runtime-framework/react/page.ts +6 -10
  103. package/dist/runtime-framework/react/utils/index.ts +3 -3
  104. package/dist/runtime-framework/solid/app.ts +30 -46
  105. package/dist/runtime-framework/solid/connect.ts +21 -3
  106. package/dist/runtime-framework/solid/hooks.ts +17 -12
  107. package/dist/runtime-framework/solid/index.ts +6 -2
  108. package/dist/runtime-framework/solid/page.ts +85 -31
  109. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  110. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  111. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  112. package/dist/runtime-framework/solid/utils/index.ts +3 -5
  113. package/dist/runtime-utils.d.ts +827 -0
  114. package/dist/runtime-utils.js +618 -245
  115. package/dist/runtime-utils.js.map +1 -1
  116. package/dist/runtime.d.ts +1 -0
  117. package/dist/runtime.js +618 -245
  118. package/dist/runtime.js.map +1 -1
  119. package/index.js +3 -1
  120. package/package.json +14 -15
  121. package/static/media/cancel.svg +1 -1
  122. package/static/media/circle.svg +1 -1
  123. package/static/media/clear.svg +1 -1
  124. package/static/media/download.svg +1 -1
  125. package/static/media/info.svg +1 -1
  126. package/static/media/info_circle.svg +1 -1
  127. package/static/media/search.svg +1 -1
  128. package/static/media/success.svg +1 -1
  129. package/static/media/success_no_circle.svg +1 -1
  130. package/static/media/warn.svg +1 -1
  131. package/types/harmony.d.ts +5 -0
  132. package/types/index.d.ts +4 -0
  133. package/types/runtime.d.ts +3 -1
  134. package/dist/runtime-ets/utils/bind.ts +0 -24
  135. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -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 { createLazyChildren } from './render'
4
- import { FlexManager } from './utils/FlexManager'
5
- import { shouldBindEvent, getNormalAttributes, getNodeThresholds } from './utils/helper'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+ import { FlexManager } from './utils/flexManager'
5
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
6
6
 
7
- import type { TaroStyleType, TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
7
+ import type { TaroAny, TaroEvent, TaroCheckboxElement, TaroCheckboxGroupElement } from '@tarojs/runtime'
8
+ import { isUndefined } from '@tarojs/shared'
8
9
 
9
10
  interface CheckboxOptions {
10
11
  name?: string
@@ -12,82 +13,20 @@ interface CheckboxOptions {
12
13
  }
13
14
  interface CheckboxAttrs {
14
15
  selectedColor?: ResourceColor
15
- }
16
-
17
- @Extend(Checkbox)
18
- function checkboxStyle (style: TaroStyleType) {
19
- .id(style.id)
20
- .key(style.id)
21
- .flexGrow(style.flexGrow)
22
- .flexShrink(style.flexShrink)
23
- .flexBasis(style.flexBasis)
24
- .alignSelf(style.alignSelf)
25
- .padding({
26
- top: style.paddingTop,
27
- right: style.paddingRight,
28
- bottom: style.paddingBottom,
29
- left: style.paddingLeft
30
- })
31
- .margin({
32
- top: style.marginTop,
33
- right: style.marginRight,
34
- bottom: style.marginBottom,
35
- left: style.marginLeft
36
- })
37
- .width(style.width)
38
- .height(style.height)
39
- .constraintSize({
40
- minWidth: style.minWidth,
41
- maxWidth: style.maxWidth,
42
- minHeight: style.minHeight,
43
- maxHeight: style.maxHeight
44
- })
45
- .backgroundColor(style.backgroundColor)
46
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
47
- .backgroundImageSize(style.backgroundSize)
48
- .backgroundImagePosition(style.backgroundPosition)
49
- .borderStyle({
50
- top: style.borderTopStyle,
51
- right: style.borderRightStyle,
52
- bottom: style.borderBottomStyle,
53
- left: style.borderLeftStyle
54
- })
55
- .borderWidth({
56
- top: style.borderTopWidth,
57
- right: style.borderRightWidth,
58
- bottom: style.borderBottomWidth,
59
- left: style.borderLeftWidth
60
- })
61
- .borderColor({
62
- top: style.borderTopColor,
63
- right: style.borderRightColor,
64
- bottom: style.borderBottomColor,
65
- left: style.borderLeftColor
66
- })
67
- .borderRadius({
68
- topLeft: style.borderTopLeftRadius,
69
- topRight: style.borderTopRightRadius,
70
- bottomLeft: style.borderBottomLeftRadius,
71
- bottomRight: style.borderBottomRightRadius
72
- })
73
- .zIndex(style.zIndex)
74
- .opacity(style.opacity)
75
- .linearGradient(style.linearGradient)
76
- .clip(style.overflow)
77
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
78
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
79
- .transform(style.transform)
16
+ disabled?: boolean
80
17
  }
81
18
 
82
19
  @Extend(Checkbox)
83
20
  function checkboxAttr(attr: CheckboxAttrs) {
84
21
  .selectedColor(attr.selectedColor)
22
+ .enabled(!attr.disabled)
85
23
  }
86
24
 
87
25
  function getAttributes (node: TaroCheckboxElement): CheckboxAttrs {
88
26
  const _attrs = node._attrs
89
27
  const checkboxAttrs: CheckboxAttrs = {}
90
28
  checkboxAttrs.selectedColor = _attrs.color || '#1aad19'
29
+ checkboxAttrs.disabled = !!_attrs.disabled
91
30
  return checkboxAttrs
92
31
  }
93
32
 
@@ -97,198 +36,74 @@ function getOptions (node: TaroCheckboxElement): CheckboxOptions {
97
36
  }
98
37
  }
99
38
 
39
+
100
40
  @Component
101
41
  export struct TaroCheckbox {
102
- node: TaroCheckboxElement | null = null
42
+ @Builder customBuilder() {}
43
+ @BuilderParam createLazyChildren: (node: TaroCheckboxElement, layer?: number) => void = this.customBuilder
44
+ @ObjectLink node: TaroCheckboxElement
45
+ @State overwriteStyle: Record<string, TaroAny> = {}
103
46
 
104
47
  aboutToAppear () {
105
48
  if (this.node && !this.node._isInit) {
106
49
  this.node._isInit = true
50
+ this.node._instance = this
107
51
  this.node._reset = this.node.checked || false
108
52
  }
109
53
  }
110
54
 
111
55
  build () {
112
- if (this.node) {
113
- Stack() {
114
- Row() {
115
- Checkbox(getOptions(this.node))
116
- .checkboxStyle(getNormalAttributes(this.node))
117
- .checkboxAttr(getAttributes(this.node))
118
- .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
119
- .select(this.node.checked)
120
- .onChange((value: boolean) => {
121
- if (this.node) {
122
- if (!!this.node?._attrs.disabled) {
123
- this.node.updateComponent()
124
- } else {
125
- this.node.updateCheckedValue(value)
126
-
127
- if (value) {
128
- const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
129
- eventHandler(event, 'change', this.node)
130
- }
56
+ Stack() {
57
+ Row() {
58
+ Checkbox(getOptions(this.node))
59
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
60
+ .checkboxAttr(getAttributes(this.node))
61
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
62
+ .select(this.node.checked)
63
+ .onChange((value: boolean) => {
64
+ if (this.node) {
65
+ if (!!this.node?._attrs.disabled) {
66
+ this.node.updateComponent()
67
+ } else {
68
+ this.node.updateCheckedValue(value)
69
+
70
+ if (value) {
71
+ const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
72
+ eventHandler(event, 'change', this.node)
131
73
  }
132
74
  }
133
- })
134
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
135
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
136
- if (this.node) {
137
- this.node._nodeInfo.areaInfo = res[1]
138
- }
139
- }))
140
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
141
- Text(this.node.textContent)
142
- .textAlign(TextAlign.Center)
143
- .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
144
- }
145
- .onClick(() => {
146
- if (this.node) {
147
- if (!this.node?._attrs.disabled) {
148
- this.node.checked = !this.node.checked
149
75
  }
150
- }
151
- })
76
+ })
77
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
78
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
79
+ if (this.node) {
80
+ this.node._nodeInfo.areaInfo = res[1]
81
+ }
82
+ }))
83
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
84
+ Text(this.node.textContent)
85
+ .textAlign(TextAlign.Center)
86
+ .opacity(!!this.node._attrs.disabled ? 0.4 : 1)
152
87
  }
88
+ .onClick(() => {
89
+ if (this.node) {
90
+ if (!this.node?._attrs.disabled) {
91
+ this.node.checked = !this.node.checked
92
+ }
93
+ }
94
+ })
153
95
  }
154
96
  }
155
97
  }
156
98
 
157
- @Extend(Column)
158
- function checkboxGroupColumnAttrs (style: TaroStyleType) {
159
- .id(style.id)
160
- .key(style.id)
161
- .flexGrow(style.flexGrow)
162
- .flexShrink(style.flexShrink)
163
- .flexBasis(style.flexBasis)
164
- .alignSelf(style.alignSelf)
165
- .padding({
166
- top: style.paddingTop,
167
- right: style.paddingRight,
168
- bottom: style.paddingBottom,
169
- left: style.paddingLeft
170
- })
171
- .margin({
172
- top: style.marginTop,
173
- right: style.marginRight,
174
- bottom: style.marginBottom,
175
- left: style.marginLeft
176
- })
177
- .width(style.width)
178
- .height(style.height)
179
- .constraintSize({
180
- minWidth: style.minWidth,
181
- maxWidth: style.maxWidth,
182
- minHeight: style.minHeight,
183
- maxHeight: style.maxHeight
184
- })
185
- .backgroundColor(style.backgroundColor)
186
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
187
- .backgroundImageSize(style.backgroundSize)
188
- .backgroundImagePosition(style.backgroundPosition)
189
- .borderStyle({
190
- top: style.borderTopStyle,
191
- right: style.borderRightStyle,
192
- bottom: style.borderBottomStyle,
193
- left: style.borderLeftStyle
194
- })
195
- .borderWidth({
196
- top: style.borderTopWidth,
197
- right: style.borderRightWidth,
198
- bottom: style.borderBottomWidth,
199
- left: style.borderLeftWidth
200
- })
201
- .borderColor({
202
- top: style.borderTopColor,
203
- right: style.borderRightColor,
204
- bottom: style.borderBottomColor,
205
- left: style.borderLeftColor
206
- })
207
- .borderRadius({
208
- topLeft: style.borderTopLeftRadius,
209
- topRight: style.borderTopRightRadius,
210
- bottomLeft: style.borderBottomLeftRadius,
211
- bottomRight: style.borderBottomRightRadius
212
- })
213
- .zIndex(style.zIndex)
214
- .opacity(style.opacity)
215
- .linearGradient(style.linearGradient)
216
- .clip(style.overflow)
217
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
218
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
219
- .transform(style.transform)
220
- }
221
-
222
- @Extend(Row)
223
- function checkboxGroupRowAttrs (style: TaroStyleType) {
224
- .id(style.id)
225
- .key(style.id)
226
- .flexGrow(style.flexGrow)
227
- .flexShrink(style.flexShrink)
228
- .flexBasis(style.flexBasis)
229
- .alignSelf(style.alignSelf)
230
- .padding({
231
- top: style.paddingTop,
232
- right: style.paddingRight,
233
- bottom: style.paddingBottom,
234
- left: style.paddingLeft
235
- })
236
- .margin({
237
- top: style.marginTop,
238
- right: style.marginRight,
239
- bottom: style.marginBottom,
240
- left: style.marginLeft
241
- })
242
- .width(style.width)
243
- .height(style.height)
244
- .constraintSize({
245
- minWidth: style.minWidth,
246
- maxWidth: style.maxWidth,
247
- minHeight: style.minHeight,
248
- maxHeight: style.maxHeight
249
- })
250
- .backgroundColor(style.backgroundColor)
251
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
252
- .backgroundImageSize(style.backgroundSize)
253
- .backgroundImagePosition(style.backgroundPosition)
254
- .borderStyle({
255
- top: style.borderTopStyle,
256
- right: style.borderRightStyle,
257
- bottom: style.borderBottomStyle,
258
- left: style.borderLeftStyle
259
- })
260
- .borderWidth({
261
- top: style.borderTopWidth,
262
- right: style.borderRightWidth,
263
- bottom: style.borderBottomWidth,
264
- left: style.borderLeftWidth
265
- })
266
- .borderColor({
267
- top: style.borderTopColor,
268
- right: style.borderRightColor,
269
- bottom: style.borderBottomColor,
270
- left: style.borderLeftColor
271
- })
272
- .borderRadius({
273
- topLeft: style.borderTopLeftRadius,
274
- topRight: style.borderTopRightRadius,
275
- bottomLeft: style.borderBottomLeftRadius,
276
- bottomRight: style.borderBottomRightRadius
277
- })
278
- .zIndex(style.zIndex)
279
- .opacity(style.opacity)
280
- .linearGradient(style.linearGradient)
281
- .clip(style.overflow)
282
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
283
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
284
- .transform(style.transform)
285
- }
286
-
287
99
  interface ChangeEventDetail { value: string[] }
288
100
 
289
101
  @Component
290
102
  export struct TaroCheckboxGroup {
291
- node: TaroCheckboxGroupElement | null = null
103
+ @Builder customBuilder() {}
104
+ @BuilderParam createLazyChildren: (node: TaroCheckboxGroupElement, layer?: number) => void = this.customBuilder
105
+ @ObjectLink node: TaroCheckboxGroupElement
106
+ @State overwriteStyle: Record<string, TaroAny> = {}
292
107
 
293
108
  @Styles visibleChangeEvent () {
294
109
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
@@ -296,6 +111,7 @@ export struct TaroCheckboxGroup {
296
111
 
297
112
  aboutToAppear () {
298
113
  if (this.node) {
114
+ this.node._instance = this
299
115
  // 阻止事件冒泡传递上去
300
116
  this.node.addEventListener('change', (e: TaroEvent<ChangeEventDetail>) => {
301
117
  e.stopPropagation()
@@ -305,7 +121,7 @@ export struct TaroCheckboxGroup {
305
121
  }
306
122
 
307
123
  @Styles defaultEvent () {
308
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
124
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
309
125
  .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
310
126
  if (this.node) {
311
127
  this.node._nodeInfo.areaInfo = res[1]
@@ -314,26 +130,27 @@ export struct TaroCheckboxGroup {
314
130
  }
315
131
 
316
132
  build() {
317
- if (this.node) {
318
- if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
319
- Row() {
320
- createLazyChildren(this.node)
321
- }
322
- .checkboxGroupRowAttrs(getNormalAttributes(this.node))
323
- .defaultEvent()
324
- .visibleChangeEvent()
325
- .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
326
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
327
- } else {
328
- Column() {
329
- createLazyChildren(this.node)
330
- }
331
- .checkboxGroupColumnAttrs(getNormalAttributes(this.node))
332
- .defaultEvent()
333
- .visibleChangeEvent()
334
- .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
335
- .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
133
+ if (FlexManager.useFlexLayout(this.node)) {
134
+ Flex(FlexManager.flexOptions(this.node)) {
135
+ this.createLazyChildren(this.node, 0)
136
+ }
137
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
138
+ .defaultEvent()
139
+ .visibleChangeEvent()
140
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
141
+ Row() {
142
+ this.createLazyChildren(this.node, 0)
143
+ }
144
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
145
+ .defaultEvent()
146
+ .visibleChangeEvent()
147
+ } else {
148
+ Column() {
149
+ this.createLazyChildren(this.node, 0)
336
150
  }
151
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
152
+ .defaultEvent()
153
+ .visibleChangeEvent()
337
154
  }
338
155
  }
339
156
  }
@@ -1,169 +1,62 @@
1
1
  import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import { createLazyChildren } from './render'
3
+ import commonStyleModify, { rowModify, columnModify } from './style'
4
+
4
5
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
- import { FlexManager } from './utils/FlexManager'
6
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
6
+ import { FlexManager } from './utils/flexManager'
7
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
8
 
8
- import type { TaroAny, TaroFormElement, TaroStyleType } from '@tarojs/runtime'
9
+ import type { TaroAny, TaroFormElement } from '@tarojs/runtime'
10
+ import { isUndefined } from '@tarojs/shared'
9
11
 
10
- @Extend(Row)
11
- function rowAttrs (style: TaroStyleType) {
12
- .id(style.id)
13
- .key(style.id)
14
- .flexGrow(style.flexGrow)
15
- .flexShrink(style.flexShrink)
16
- .flexBasis(style.flexBasis)
17
- .alignSelf(style.alignSelf)
18
- .padding({
19
- top: style.paddingTop,
20
- right: style.paddingRight,
21
- bottom: style.paddingBottom,
22
- left: style.paddingLeft
23
- })
24
- .margin({
25
- top: style.marginTop,
26
- right: style.marginRight,
27
- bottom: style.marginBottom,
28
- left: style.marginLeft
29
- })
30
- .width(style.width)
31
- .height(style.height)
32
- .constraintSize({
33
- minWidth: style.minWidth,
34
- maxWidth: style.maxWidth,
35
- minHeight: style.minHeight,
36
- maxHeight: style.maxHeight
37
- })
38
- .backgroundColor(style.backgroundColor)
39
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
40
- .backgroundImageSize(style.backgroundSize)
41
- .backgroundImagePosition(style.backgroundPosition)
42
- .borderStyle({
43
- top: style.borderTopStyle,
44
- right: style.borderRightStyle,
45
- bottom: style.borderBottomStyle,
46
- left: style.borderLeftStyle
47
- })
48
- .borderWidth({
49
- top: style.borderTopWidth,
50
- right: style.borderRightWidth,
51
- bottom: style.borderBottomWidth,
52
- left: style.borderLeftWidth
53
- })
54
- .borderColor({
55
- top: style.borderTopColor,
56
- right: style.borderRightColor,
57
- bottom: style.borderBottomColor,
58
- left: style.borderLeftColor
59
- })
60
- .borderRadius({
61
- topLeft: style.borderTopLeftRadius,
62
- topRight: style.borderTopRightRadius,
63
- bottomLeft: style.borderBottomLeftRadius,
64
- bottomRight: style.borderBottomRightRadius
65
- })
66
- .zIndex(style.zIndex)
67
- .opacity(style.opacity)
68
- .linearGradient(style.linearGradient)
69
- .clip(style.overflow)
70
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
71
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
72
- .transform(style.transform)
73
- }
12
+ @Component
13
+ export default struct TaroForm {
14
+ @Builder customBuilder() {}
15
+ @BuilderParam createLazyChildren: (node: TaroFormElement, layer?: number) => void = this.customBuilder
16
+ @ObjectLink node: TaroFormElement
74
17
 
75
- @Extend(Column)
76
- function columnAttrs (style: TaroStyleType) {
77
- .id(style.id)
78
- .key(style.id)
79
- .flexGrow(style.flexGrow)
80
- .flexShrink(style.flexShrink)
81
- .flexBasis(style.flexBasis)
82
- .alignSelf(style.alignSelf)
83
- .padding({
84
- top: style.paddingTop,
85
- right: style.paddingRight,
86
- bottom: style.paddingBottom,
87
- left: style.paddingLeft
88
- })
89
- .margin({
90
- top: style.marginTop,
91
- right: style.marginRight,
92
- bottom: style.marginBottom,
93
- left: style.marginLeft
94
- })
95
- .width(style.width)
96
- .height(style.height)
97
- .constraintSize({
98
- minWidth: style.minWidth,
99
- maxWidth: style.maxWidth,
100
- minHeight: style.minHeight,
101
- maxHeight: style.maxHeight
102
- })
103
- .backgroundColor(style.backgroundColor)
104
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
105
- .backgroundImageSize(style.backgroundSize)
106
- .backgroundImagePosition(style.backgroundPosition)
107
- .borderStyle({
108
- top: style.borderTopStyle,
109
- right: style.borderRightStyle,
110
- bottom: style.borderBottomStyle,
111
- left: style.borderLeftStyle
112
- })
113
- .borderWidth({
114
- top: style.borderTopWidth,
115
- right: style.borderRightWidth,
116
- bottom: style.borderBottomWidth,
117
- left: style.borderLeftWidth
118
- })
119
- .borderColor({
120
- top: style.borderTopColor,
121
- right: style.borderRightColor,
122
- bottom: style.borderBottomColor,
123
- left: style.borderLeftColor
124
- })
125
- .borderRadius({
126
- topLeft: style.borderTopLeftRadius,
127
- topRight: style.borderTopRightRadius,
128
- bottomLeft: style.borderBottomLeftRadius,
129
- bottomRight: style.borderBottomRightRadius
130
- })
131
- .zIndex(style.zIndex)
132
- .opacity(style.opacity)
133
- .linearGradient(style.linearGradient)
134
- .clip(style.overflow)
135
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
136
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
137
- .transform(style.transform)
138
- }
18
+ @State overwriteStyle: Record<string, TaroAny> = {}
139
19
 
140
- @Builder
141
- export default function TaroForm (node: TaroFormElement) {
142
- if (FlexManager.isFlexNode(node) && FlexManager.flexOptions(node).direction !== FlexDirection.Column) {
143
- Row() {
144
- createLazyChildren(node)
20
+ aboutToAppear(): void {
21
+ if (this.node) {
22
+ this.node._instance = this
145
23
  }
146
- .rowAttrs(getNormalAttributes(node))
147
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
148
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
149
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
150
- node._nodeInfo.areaInfo = res[1]
151
- }))
152
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
153
- .alignItems(FlexManager.flexOptions(node).alignItems as VerticalAlign)
154
- .justifyContent(FlexManager.flexOptions(node).justifyContent)
155
- } else {
156
- Column() {
157
- createLazyChildren(node)
24
+ }
25
+
26
+ build() {
27
+ if (FlexManager.useFlexLayout(this.node)) {
28
+ Flex(FlexManager.flexOptions(this.node)) {
29
+ this.createLazyChildren(this.node, 0)
30
+ }
31
+ .attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
32
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
33
+ .onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
34
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
35
+ this.node._nodeInfo.areaInfo = res[1]
36
+ }))
37
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
38
+ } else if (FlexManager.isFlexNode(this.node) && FlexManager.direction(this.node) !== FlexDirection.Column) {
39
+ Row() {
40
+ this.createLazyChildren(this.node, 0)
41
+ }
42
+ .attributeModifier(rowModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
43
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
44
+ .onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
45
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
46
+ this.node._nodeInfo.areaInfo = res[1]
47
+ }))
48
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
49
+ } else {
50
+ Column() {
51
+ this.createLazyChildren(this.node, 0)
52
+ }
53
+ .attributeModifier(columnModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
54
+ .onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
55
+ .onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
56
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
57
+ this.node._nodeInfo.areaInfo = res[1]
58
+ }))
59
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
158
60
  }
159
- .columnAttrs(getNormalAttributes(node))
160
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
161
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
162
- .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
163
- node._nodeInfo.areaInfo = res[1]
164
- }))
165
- .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
166
- .alignItems(FlexManager.flexOptions(node).alignItems as HorizontalAlign)
167
- .justifyContent(FlexManager.flexOptions(node).justifyContent)
168
61
  }
169
62
  }