@tarojs/plugin-platform-harmony-ets 4.0.0-beta.2 → 4.0.0-beta.21

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 (87) hide show
  1. package/dist/apis/base/system.ts +53 -20
  2. package/dist/apis/framework/index.ts +1 -5
  3. package/dist/apis/index.ts +3 -1
  4. package/dist/apis/network/request.ts +5 -5
  5. package/dist/apis/route/index.ts +15 -0
  6. package/dist/apis/storage/index.ts +124 -60
  7. package/dist/apis/wxml/IntersectionObserver.ts +5 -3
  8. package/dist/apis/wxml/index.ts +2 -0
  9. package/dist/components-harmony-ets/button.ets +41 -78
  10. package/dist/components-harmony-ets/checkbox.ets +19 -209
  11. package/dist/components-harmony-ets/form.ets +38 -160
  12. package/dist/components-harmony-ets/icon.ets +31 -83
  13. package/dist/components-harmony-ets/image.ets +22 -78
  14. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  15. package/dist/components-harmony-ets/input.ets +10 -67
  16. package/dist/components-harmony-ets/label.ets +52 -173
  17. package/dist/components-harmony-ets/movableArea.ets +89 -0
  18. package/dist/components-harmony-ets/movableView.ets +67 -0
  19. package/dist/components-harmony-ets/picker.ets +32 -147
  20. package/dist/components-harmony-ets/progress.ets +47 -0
  21. package/dist/components-harmony-ets/pseudo.ets +80 -0
  22. package/dist/components-harmony-ets/radio.ets +19 -210
  23. package/dist/components-harmony-ets/richText.ets +22 -102
  24. package/dist/components-harmony-ets/scrollView.ets +66 -169
  25. package/dist/components-harmony-ets/slider.ets +10 -72
  26. package/dist/components-harmony-ets/style.ets +244 -0
  27. package/dist/components-harmony-ets/swiper.ets +30 -87
  28. package/dist/components-harmony-ets/switch.ets +9 -71
  29. package/dist/components-harmony-ets/text.ets +38 -89
  30. package/dist/components-harmony-ets/textArea.ets +10 -67
  31. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  32. package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
  33. package/dist/components-harmony-ets/utils/flexManager.ets +8 -7
  34. package/dist/components-harmony-ets/utils/helper.ets +5 -4
  35. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  36. package/dist/components-harmony-ets/utils/index.ts +55 -2
  37. package/dist/components-harmony-ets/utils/styles.ets +45 -85
  38. package/dist/components-harmony-ets/video.ets +33 -88
  39. package/dist/components-harmony-ets/view.ets +47 -160
  40. package/dist/components-harmony-ets/webView.ets +44 -99
  41. package/dist/index.d.ts +151 -0
  42. package/dist/index.js +58 -29
  43. package/dist/index.js.map +1 -1
  44. package/dist/runtime-ets/bom/window.ts +4 -2
  45. package/dist/runtime-ets/current.ts +2 -0
  46. package/dist/runtime-ets/dom/bind.ts +0 -1
  47. package/dist/runtime-ets/dom/cssNesting.ts +311 -0
  48. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +15 -40
  49. package/dist/runtime-ets/dom/document.ts +21 -8
  50. package/dist/runtime-ets/dom/element/element.ts +53 -9
  51. package/dist/runtime-ets/dom/element/form.ts +11 -4
  52. package/dist/runtime-ets/dom/element/index.ts +12 -1
  53. package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
  54. package/dist/runtime-ets/dom/element/movableView.ts +193 -0
  55. package/dist/runtime-ets/dom/element/normal.ts +8 -3
  56. package/dist/runtime-ets/dom/element/progress.ts +13 -0
  57. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  58. package/dist/runtime-ets/dom/element/text.ts +1 -0
  59. package/dist/runtime-ets/dom/element/video.ts +1 -0
  60. package/dist/runtime-ets/dom/element/webView.ts +8 -0
  61. package/dist/runtime-ets/dom/event.ts +0 -1
  62. package/dist/runtime-ets/dom/eventTarget.ts +0 -3
  63. package/dist/runtime-ets/dom/node.ts +18 -17
  64. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +184 -207
  65. package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
  66. package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
  67. package/dist/runtime-ets/dom/stylesheet/util.ts +19 -15
  68. package/dist/runtime-ets/index.ts +2 -2
  69. package/dist/runtime-ets/interface/event.ts +1 -1
  70. package/dist/runtime-ets/utils/index.ts +24 -9
  71. package/dist/runtime-framework/react/app.ts +5 -1
  72. package/dist/runtime-framework/react/hooks.ts +3 -3
  73. package/dist/runtime-framework/react/native-page.ts +14 -9
  74. package/dist/runtime-framework/react/page.ts +1 -0
  75. package/dist/runtime-framework/solid/hooks.ts +3 -3
  76. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  77. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  78. package/dist/runtime-utils.d.ts +825 -0
  79. package/dist/runtime-utils.js +185 -91
  80. package/dist/runtime-utils.js.map +1 -1
  81. package/dist/runtime.d.ts +1 -0
  82. package/dist/runtime.js +185 -91
  83. package/dist/runtime.js.map +1 -1
  84. package/index.js +3 -1
  85. package/package.json +10 -10
  86. package/types/index.d.ts +4 -0
  87. package/dist/runtime-ets/utils/bind.ts +0 -24
@@ -1,144 +1,14 @@
1
1
  import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, TaroPickerElement, createTaroEvent } from '@tarojs/runtime'
2
- import { createLazyChildren } from './render'
2
+ import commonStyleModify from './style'
3
3
  import { getSingleSelector, getMultiSelector } from './utils'
4
4
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
- import { FlexManager } from './utils/FlexManager'
6
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
5
+ import { FlexManager } from './utils/flexManager'
6
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
7
 
8
- import type { TaroAny, TaroStyleType, TaroEvent } from '@tarojs/runtime'
8
+ import type { TaroAny, TaroEvent } from '@tarojs/runtime'
9
9
 
10
10
  import { PickerDateProps, PickerMultiSelectorProps, PickerSelectorProps, PickerTimeProps } from './types'
11
11
 
12
- @Extend(TextPicker)
13
- function textPickerAttrs (style: TaroStyleType) {
14
- .id(style.id)
15
- .key(style.id)
16
- .flexGrow(style.flexGrow)
17
- .flexShrink(style.flexShrink)
18
- .flexBasis(style.flexBasis)
19
- .alignSelf(style.alignSelf)
20
- .padding({
21
- top: style.paddingTop,
22
- right: style.paddingRight,
23
- bottom: style.paddingBottom,
24
- left: style.paddingLeft
25
- })
26
- .margin({
27
- top: style.marginTop,
28
- right: style.marginRight,
29
- bottom: style.marginBottom,
30
- left: style.marginLeft
31
- })
32
- .width(style.width || '100%')
33
- .height(style.height)
34
- .constraintSize({
35
- minWidth: style.minWidth,
36
- maxWidth: style.maxWidth,
37
- minHeight: style.minHeight,
38
- maxHeight: style.maxHeight
39
- })
40
- .backgroundColor(style.backgroundColor || '#fff')
41
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
42
- .backgroundImageSize(style.backgroundSize)
43
- .backgroundImagePosition(style.backgroundPosition)
44
- .borderStyle({
45
- top: style.borderTopStyle,
46
- right: style.borderRightStyle,
47
- bottom: style.borderBottomStyle,
48
- left: style.borderLeftStyle
49
- })
50
- .borderWidth({
51
- top: style.borderTopWidth,
52
- right: style.borderRightWidth,
53
- bottom: style.borderBottomWidth,
54
- left: style.borderLeftWidth
55
- })
56
- .borderColor({
57
- top: style.borderTopColor,
58
- right: style.borderRightColor,
59
- bottom: style.borderBottomColor,
60
- left: style.borderLeftColor
61
- })
62
- .borderRadius({
63
- topLeft: style.borderTopLeftRadius,
64
- topRight: style.borderTopRightRadius,
65
- bottomLeft: style.borderBottomLeftRadius,
66
- bottomRight: style.borderBottomRightRadius
67
- })
68
- .zIndex(style.zIndex)
69
- .opacity(style.opacity)
70
- .linearGradient(style.linearGradient)
71
- .clip(style.overflow)
72
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
73
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
74
- .transform(style.transform)
75
- }
76
-
77
- @Extend(DatePicker)
78
- function datePickerAttrs (style: TaroStyleType) {
79
- .id(style.id)
80
- .key(style.id)
81
- .flexGrow(style.flexGrow)
82
- .flexShrink(style.flexShrink)
83
- .flexBasis(style.flexBasis)
84
- .alignSelf(style.alignSelf)
85
- .padding({
86
- top: style.paddingTop,
87
- right: style.paddingRight,
88
- bottom: style.paddingBottom,
89
- left: style.paddingLeft
90
- })
91
- .margin({
92
- top: style.marginTop,
93
- right: style.marginRight,
94
- bottom: style.marginBottom,
95
- left: style.marginLeft
96
- })
97
- .width(style.width || '100%')
98
- .height(style.height)
99
- .constraintSize({
100
- minWidth: style.minWidth,
101
- maxWidth: style.maxWidth,
102
- minHeight: style.minHeight,
103
- maxHeight: style.maxHeight
104
- })
105
- .backgroundColor(style.backgroundColor || '#fff')
106
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
107
- .backgroundImageSize(style.backgroundSize)
108
- .backgroundImagePosition(style.backgroundPosition)
109
- .borderStyle({
110
- top: style.borderTopStyle,
111
- right: style.borderRightStyle,
112
- bottom: style.borderBottomStyle,
113
- left: style.borderLeftStyle
114
- })
115
- .borderWidth({
116
- top: style.borderTopWidth,
117
- right: style.borderRightWidth,
118
- bottom: style.borderBottomWidth,
119
- left: style.borderLeftWidth
120
- })
121
- .borderColor({
122
- top: style.borderTopColor,
123
- right: style.borderRightColor,
124
- bottom: style.borderBottomColor,
125
- left: style.borderLeftColor
126
- })
127
- .borderRadius({
128
- topLeft: style.borderTopLeftRadius,
129
- topRight: style.borderTopRightRadius,
130
- bottomLeft: style.borderBottomLeftRadius,
131
- bottomRight: style.borderBottomRightRadius
132
- })
133
- .zIndex(style.zIndex)
134
- .opacity(style.opacity)
135
- .linearGradient(style.linearGradient)
136
- .clip(style.overflow)
137
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
138
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
139
- .transform(style.transform)
140
- }
141
-
142
12
  interface TimeRange {
143
13
  startHH: number
144
14
  startMM: number
@@ -197,7 +67,7 @@ export struct PickerView {
197
67
  const left = generateNumberArray(timeRange.startHH, timeRange.endHH)
198
68
  const right = generateNumberArray(timeRange.startMM, timeRange.endMM)
199
69
  const range = [left, right]
200
- const _selected = _attrs.value.split(':')
70
+ const _selected = _attrs.value?.split(':') as string[]
201
71
  return {
202
72
  range: range,
203
73
  selected: [left.findIndex(i => parseInt(_selected[0]) === Number(i)), right.findIndex(i => parseInt(_selected[1]) === Number(i))],
@@ -275,7 +145,10 @@ export struct PickerView {
275
145
  color: '#000'
276
146
  })
277
147
  .canLoop(false)
278
- .textPickerAttrs(getNormalAttributes(this.node))
148
+ .attributeModifier(commonStyleModify.setNode(this.node, {
149
+ width: '100%',
150
+ backgroundColor: '#fff'
151
+ }))
279
152
  .onChange((_, index) => {
280
153
  this.node?.updateFormWidgetValue(index)
281
154
  })
@@ -285,7 +158,10 @@ export struct PickerView {
285
158
  color: '#000'
286
159
  })
287
160
  .canLoop(false)
288
- .textPickerAttrs(getNormalAttributes(this.node))
161
+ .attributeModifier(commonStyleModify.setNode(this.node, {
162
+ width: '100%',
163
+ backgroundColor: '#fff'
164
+ }))
289
165
  .onChange((_, index) => {
290
166
  if (index instanceof Array) {
291
167
  this.node?.updateFormWidgetValue(index)
@@ -312,7 +188,10 @@ export struct PickerView {
312
188
  .selectedTextStyle({
313
189
  color: '#000'
314
190
  })
315
- .datePickerAttrs(getNormalAttributes(this.node))
191
+ .attributeModifier(commonStyleModify.setNode(this.node, {
192
+ width: '100%',
193
+ backgroundColor: '#fff'
194
+ }))
316
195
  .onDateChange(value => {
317
196
  const data = value.toLocaleDateString().split('/')
318
197
  const day = data[1]
@@ -326,7 +205,10 @@ export struct PickerView {
326
205
  color: '#000'
327
206
  })
328
207
  .canLoop(false)
329
- .textPickerAttrs(getNormalAttributes(this.node))
208
+ .attributeModifier(commonStyleModify.setNode(this.node, {
209
+ width: '100%',
210
+ backgroundColor: '#fff'
211
+ }))
330
212
  .onChange((value) => {
331
213
  this.node?.updateFormWidgetValue(`${('00'+value[0]).slice(-2)}:${('00'+value[1]).slice(-2)}`)
332
214
  })
@@ -340,9 +222,12 @@ export struct PickerView {
340
222
  }
341
223
  }
342
224
 
225
+
343
226
  @Component
344
227
  export default struct TaroPicker {
345
- node: TaroPickerElement | null = null
228
+ @Builder customBuilder() {}
229
+ @BuilderParam createLazyChildren: (node: TaroPickerElement) => void = this.customBuilder
230
+ @ObjectLink node: TaroPickerElement
346
231
 
347
232
  aboutToAppear () {
348
233
  this.node?.addEventListener('click', this.handleClick)
@@ -358,8 +243,8 @@ export default struct TaroPicker {
358
243
  break
359
244
  case 'time': {
360
245
  const hour = new Date().getHours()
361
- const minute = new Date().getMinutes()
362
-
246
+ const minute = new Date().getMinutes()
247
+
363
248
  defaultResetValue = `${('00'+hour).slice(-2)}:${('00'+minute).slice(-2)}`
364
249
  break
365
250
  }
@@ -368,7 +253,7 @@ export default struct TaroPicker {
368
253
  const day = data[1]
369
254
  const month = data[0]
370
255
  const year = data[2]
371
-
256
+
372
257
  defaultResetValue = `${year}-${month}-${day}`
373
258
  break
374
259
  }
@@ -376,7 +261,7 @@ export default struct TaroPicker {
376
261
  defaultResetValue = ''
377
262
  break
378
263
  }
379
-
264
+
380
265
  this.node._isInit = true
381
266
  this.node._reset = this.node.value || defaultResetValue
382
267
  }
@@ -426,10 +311,10 @@ export default struct TaroPicker {
426
311
  }
427
312
 
428
313
  build() {
429
- if (this.node) {
314
+ if (this.node && this.node.hmStyle?.display !== 'none') {
430
315
  if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
431
316
  Row() {
432
- createLazyChildren(this.node)
317
+ this.createLazyChildren(this.node)
433
318
  }
434
319
  .defaultEvent()
435
320
  .visibleChangeEvent()
@@ -437,7 +322,7 @@ export default struct TaroPicker {
437
322
  .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
438
323
  } else {
439
324
  Column() {
440
- createLazyChildren(this.node)
325
+ this.createLazyChildren(this.node)
441
326
  }
442
327
  .defaultEvent()
443
328
  .visibleChangeEvent()
@@ -0,0 +1,47 @@
1
+ import type { TaroProgressElement, TaroAny } from '@tarojs/runtime'
2
+ import commonStyleModify from './style'
3
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
4
+ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
5
+
6
+ const PROGRESS_ACTIVECOLOR = '#09BB07'
7
+ const PROGRESS_BACKGROUNDCOLOR = '#EBEBEB'
8
+ const PROGRESS_DEFAULTINFOFONTSIZE = 16
9
+
10
+ @Component
11
+ export default struct TaroProgress {
12
+ @Builder customBuilder() {}
13
+ @BuilderParam createLazyChildren: (node: TaroProgressElement) => void = this.customBuilder
14
+ @ObjectLink node: TaroProgressElement
15
+
16
+ build() {
17
+ if (this.node && this.node.hmStyle?.display !== 'none') {
18
+ Row({ space: 5 }) {
19
+ Progress({
20
+ value: parseFloat(this.node.getAttribute('percent')),
21
+ type: ProgressType.Linear
22
+ })
23
+ .attributeModifier(commonStyleModify.setNode(this.node))
24
+ .color(this.node.getAttribute('activeColor') ?? PROGRESS_ACTIVECOLOR)
25
+ .backgroundColor(this.node.getAttribute('backgroundColor') ?? PROGRESS_BACKGROUNDCOLOR)
26
+ .style({
27
+ strokeWidth: this.node.getAttribute('strokeWidth'),
28
+ strokeRadius: parseFloat(this.node.getAttribute('borderRadius')),
29
+ enableSmoothEffect: Boolean(this.node.getAttribute('active')),
30
+ })
31
+
32
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
33
+ .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
34
+ .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
35
+ if (this.node) {
36
+ this.node._nodeInfo.areaInfo = res[1]
37
+ }
38
+ }))
39
+
40
+ if (this.node.getAttribute('showInfo')) {
41
+ Text(`${this.node.getAttribute('percent')}%`)
42
+ .fontSize(this.node.getAttribute('fontSize') ?? PROGRESS_DEFAULTINFOFONTSIZE)
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,80 @@
1
+ import { getFontAttributes } from './utils/helper'
2
+ import { pseudoModify } from './style'
3
+
4
+ import type { TaroViewElement, TaroStyleType, TaroTextStyleType, TaroAny } from '@tarojs/runtime'
5
+
6
+ @Extend(Flex)
7
+ function flexAttrs (style: TaroStyleType) {
8
+ .constraintSize({
9
+ minWidth: style.minWidth,
10
+ maxWidth: style.maxWidth,
11
+ minHeight: style.minHeight || style.height,
12
+ maxHeight: style.maxHeight
13
+ })
14
+ }
15
+
16
+
17
+ @Extend(Text)
18
+ function textNormalFontStyle (style: TaroStyleType) {
19
+ .id(style.id)
20
+ .key(style.id)
21
+ .opacity(style.opacity)
22
+ .fontColor(style.color)
23
+ .fontSize(style.fontSize)
24
+ .fontWeight(style.fontWeight)
25
+ .fontStyle(style.fontStyle)
26
+ .fontFamily(style.fontFamily)
27
+ .decoration({
28
+ type: style.textDecoration,
29
+ color: style.color
30
+ })
31
+ }
32
+
33
+ @Extend(Text)
34
+ function textSpecialFontStyle(attr: TaroTextStyleType) {
35
+ .textAlign(attr.textAlign)
36
+ .align(attr.verticalAlign)
37
+ .textOverflow(attr.textOverflow)
38
+ .maxLines(attr.WebkitLineClamp)
39
+ .letterSpacing(attr.letterSpacing)
40
+ .lineHeight(attr.lineHeight)
41
+ }
42
+
43
+ @Component
44
+ export default struct PseduoChildren {
45
+ @Builder customBuilder() {}
46
+ @BuilderParam createLazyChildren: (node: TaroAny) => void = this.customBuilder
47
+ @ObjectLink node: TaroViewElement
48
+
49
+ build () {
50
+ if (true) {
51
+ // 伪类::Before
52
+ if (this.node._pseudo_before) {
53
+ if (this.node._pseudo_before?.hmStyle.content) {
54
+ Text(this.node._pseudo_before.hmStyle.content)
55
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_before.hmStyle))
56
+ .textNormalFontStyle(this.node._pseudo_before.hmStyle || {})
57
+ .textSpecialFontStyle(getFontAttributes(this.node))
58
+ } else {
59
+ Flex() {}
60
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_before.hmStyle || {}))
61
+ .flexAttrs(this.node._pseudo_before.hmStyle || {})
62
+ }
63
+ }
64
+ this.createLazyChildren(this.node)
65
+ // 伪类::After
66
+ if (this.node._pseudo_after) {
67
+ if (this.node._pseudo_after?.hmStyle.content) {
68
+ Text(this.node._pseudo_after.hmStyle.content)
69
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_after.hmStyle))
70
+ .textNormalFontStyle(this.node._pseudo_after.hmStyle || {})
71
+ .textSpecialFontStyle(getFontAttributes(this.node))
72
+ } else {
73
+ Flex() {}
74
+ .attributeModifier(pseudoModify.setStyle(this.node._pseudo_after.hmStyle || {}))
75
+ .flexAttrs(this.node._pseudo_after.hmStyle || {})
76
+ }
77
+ }
78
+ }
79
+ }
80
+ }
@@ -1,82 +1,17 @@
1
1
  import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
2
2
 
3
- import { createLazyChildren } from './render'
3
+ import commonStyleModify from './style'
4
4
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
5
- import { FlexManager } from './utils/FlexManager'
6
- import { shouldBindEvent, getNormalAttributes, getNodeThresholds } from './utils/helper'
5
+ import { FlexManager } from './utils/flexManager'
6
+ import { shouldBindEvent, getNodeThresholds } from './utils/helper'
7
7
 
8
- import { TaroEvent, TaroAny, TaroStyleType, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
8
+ import { TaroEvent, TaroAny, HarmonyType, TaroRadioGroupElement, TaroRadioElement } from '@tarojs/runtime'
9
9
 
10
10
  interface RadioAttrs {
11
11
  radioStyle?: HarmonyType.RadioStyle
12
12
  themeStyles?: boolean
13
13
  }
14
14
 
15
- @Extend(Radio)
16
- function style (style: TaroStyleType) {
17
- .id(style.id)
18
- .key(style.id)
19
- .flexGrow(style.flexGrow)
20
- .flexShrink(style.flexShrink)
21
- .flexBasis(style.flexBasis)
22
- .alignSelf(style.alignSelf)
23
- .padding({
24
- top: style.paddingTop,
25
- right: style.paddingRight,
26
- bottom: style.paddingBottom,
27
- left: style.paddingLeft
28
- })
29
- .margin({
30
- top: style.marginTop,
31
- right: style.marginRight,
32
- bottom: style.marginBottom,
33
- left: style.marginLeft
34
- })
35
- .width(style.width)
36
- .height(style.height)
37
- .constraintSize({
38
- minWidth: style.minWidth,
39
- maxWidth: style.maxWidth,
40
- minHeight: style.minHeight,
41
- maxHeight: style.maxHeight
42
- })
43
- .backgroundColor(style.backgroundColor)
44
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
45
- .backgroundImageSize(style.backgroundSize)
46
- .backgroundImagePosition(style.backgroundPosition)
47
- .borderStyle({
48
- top: style.borderTopStyle,
49
- right: style.borderRightStyle,
50
- bottom: style.borderBottomStyle,
51
- left: style.borderLeftStyle
52
- })
53
- .borderWidth({
54
- top: style.borderTopWidth,
55
- right: style.borderRightWidth,
56
- bottom: style.borderBottomWidth,
57
- left: style.borderLeftWidth
58
- })
59
- .borderColor({
60
- top: style.borderTopColor,
61
- right: style.borderRightColor,
62
- bottom: style.borderBottomColor,
63
- left: style.borderLeftColor
64
- })
65
- .borderRadius({
66
- topLeft: style.borderTopLeftRadius,
67
- topRight: style.borderTopRightRadius,
68
- bottomLeft: style.borderBottomLeftRadius,
69
- bottomRight: style.borderBottomRightRadius
70
- })
71
- .zIndex(style.zIndex)
72
- .opacity(style.opacity)
73
- .linearGradient(style.linearGradient)
74
- .clip(style.overflow)
75
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
76
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
77
- .transform(style.transform)
78
- }
79
-
80
15
  @Extend(Radio)
81
16
  function radioAttr (attr: RadioAttrs) {
82
17
  .radioStyle(attr.radioStyle)
@@ -99,8 +34,10 @@ function themeStyles(isDisabled: boolean) {
99
34
 
100
35
  @Component
101
36
  export struct TaroRadio {
102
- node: TaroRadioElement | null = null
103
-
37
+ @Builder customBuilder() {}
38
+ @BuilderParam createLazyChildren: (node: TaroRadioElement) => void = this.customBuilder
39
+ @ObjectLink node: TaroRadioElement
40
+
104
41
  aboutToAppear () {
105
42
  if (this.node && !this.node._isInit) {
106
43
  this.node._isInit = true
@@ -109,7 +46,7 @@ export struct TaroRadio {
109
46
  }
110
47
 
111
48
  build () {
112
- if (this.node) {
49
+ if (this.node && this.node.hmStyle?.display !== 'none') {
113
50
  Stack() {
114
51
  Row() {
115
52
  Radio({
@@ -117,7 +54,7 @@ export struct TaroRadio {
117
54
  value: this.node.value || '',
118
55
  })
119
56
  .checked(this.node.checked)
120
- .style(getNormalAttributes(this.node))
57
+ .attributeModifier(commonStyleModify.setNode(this.node))
121
58
  .radioAttr(getAttributes(this.node))
122
59
  .onChange((value: boolean) => {
123
60
  if (this.node) {
@@ -125,7 +62,7 @@ export struct TaroRadio {
125
62
  this.node.updateComponent()
126
63
  } else {
127
64
  this.node.updateCheckedValue(value)
128
-
65
+
129
66
  if (value) {
130
67
  const event: TaroEvent = createTaroEvent('change', { detail: { value: this.node?._attrs.value } }, this.node)
131
68
  eventHandler(event, 'change', this.node)
@@ -156,140 +93,12 @@ export struct TaroRadio {
156
93
  }
157
94
  }
158
95
 
159
- @Extend(Column)
160
- function radioGroupColumnAttrs (style: TaroStyleType) {
161
- .id(style.id)
162
- .key(style.id)
163
- .flexGrow(style.flexGrow)
164
- .flexShrink(style.flexShrink)
165
- .flexBasis(style.flexBasis)
166
- .alignSelf(style.alignSelf)
167
- .padding({
168
- top: style.paddingTop,
169
- right: style.paddingRight,
170
- bottom: style.paddingBottom,
171
- left: style.paddingLeft
172
- })
173
- .margin({
174
- top: style.marginTop,
175
- right: style.marginRight,
176
- bottom: style.marginBottom,
177
- left: style.marginLeft
178
- })
179
- .width(style.width)
180
- .height(style.height)
181
- .constraintSize({
182
- minWidth: style.minWidth,
183
- maxWidth: style.maxWidth,
184
- minHeight: style.minHeight,
185
- maxHeight: style.maxHeight
186
- })
187
- .backgroundColor(style.backgroundColor)
188
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
189
- .backgroundImageSize(style.backgroundSize)
190
- .backgroundImagePosition(style.backgroundPosition)
191
- .borderStyle({
192
- top: style.borderTopStyle,
193
- right: style.borderRightStyle,
194
- bottom: style.borderBottomStyle,
195
- left: style.borderLeftStyle
196
- })
197
- .borderWidth({
198
- top: style.borderTopWidth,
199
- right: style.borderRightWidth,
200
- bottom: style.borderBottomWidth,
201
- left: style.borderLeftWidth
202
- })
203
- .borderColor({
204
- top: style.borderTopColor,
205
- right: style.borderRightColor,
206
- bottom: style.borderBottomColor,
207
- left: style.borderLeftColor
208
- })
209
- .borderRadius({
210
- topLeft: style.borderTopLeftRadius,
211
- topRight: style.borderTopRightRadius,
212
- bottomLeft: style.borderBottomLeftRadius,
213
- bottomRight: style.borderBottomRightRadius
214
- })
215
- .zIndex(style.zIndex)
216
- .opacity(style.opacity)
217
- .linearGradient(style.linearGradient)
218
- .clip(style.overflow)
219
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
220
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
221
- .transform(style.transform)
222
- }
223
-
224
- @Extend(Row)
225
- function radioGroupRowAttrs (style: TaroStyleType) {
226
- .id(style.id)
227
- .key(style.id)
228
- .flexGrow(style.flexGrow)
229
- .flexShrink(style.flexShrink)
230
- .flexBasis(style.flexBasis)
231
- .alignSelf(style.alignSelf)
232
- .padding({
233
- top: style.paddingTop,
234
- right: style.paddingRight,
235
- bottom: style.paddingBottom,
236
- left: style.paddingLeft
237
- })
238
- .margin({
239
- top: style.marginTop,
240
- right: style.marginRight,
241
- bottom: style.marginBottom,
242
- left: style.marginLeft
243
- })
244
- .width(style.width)
245
- .height(style.height)
246
- .constraintSize({
247
- minWidth: style.minWidth,
248
- maxWidth: style.maxWidth,
249
- minHeight: style.minHeight,
250
- maxHeight: style.maxHeight
251
- })
252
- .backgroundColor(style.backgroundColor)
253
- .backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
254
- .backgroundImageSize(style.backgroundSize)
255
- .backgroundImagePosition(style.backgroundPosition)
256
- .borderStyle({
257
- top: style.borderTopStyle,
258
- right: style.borderRightStyle,
259
- bottom: style.borderBottomStyle,
260
- left: style.borderLeftStyle
261
- })
262
- .borderWidth({
263
- top: style.borderTopWidth,
264
- right: style.borderRightWidth,
265
- bottom: style.borderBottomWidth,
266
- left: style.borderLeftWidth
267
- })
268
- .borderColor({
269
- top: style.borderTopColor,
270
- right: style.borderRightColor,
271
- bottom: style.borderBottomColor,
272
- left: style.borderLeftColor
273
- })
274
- .borderRadius({
275
- topLeft: style.borderTopLeftRadius,
276
- topRight: style.borderTopRightRadius,
277
- bottomLeft: style.borderBottomLeftRadius,
278
- bottomRight: style.borderBottomRightRadius
279
- })
280
- .zIndex(style.zIndex)
281
- .opacity(style.opacity)
282
- .linearGradient(style.linearGradient)
283
- .clip(style.overflow)
284
- .rotate({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y, angle: 0 })
285
- .scale({ centerX: style.transformOrigin?.x, centerY: style.transformOrigin?.y })
286
- .transform(style.transform)
287
- }
288
-
289
96
 
290
97
  @Component
291
98
  export struct TaroRadioGroup {
292
- node: TaroRadioGroupElement | null = null
99
+ @Builder customBuilder() {}
100
+ @BuilderParam createLazyChildren: (node: TaroRadioGroupElement) => void = this.customBuilder
101
+ @ObjectLink node: TaroRadioGroupElement
293
102
 
294
103
  @Styles visibleChangeEvent () {
295
104
  .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
@@ -317,21 +126,21 @@ export struct TaroRadioGroup {
317
126
  }
318
127
 
319
128
  build() {
320
- if (this.node) {
129
+ if (this.node && this.node.hmStyle?.display !== 'none') {
321
130
  if (FlexManager.isFlexNode(this.node) && FlexManager.flexOptions(this.node).direction !== FlexDirection.Column) {
322
131
  Row() {
323
- createLazyChildren(this.node)
132
+ this.createLazyChildren(this.node)
324
133
  }
325
- .radioGroupRowAttrs(getNormalAttributes(this.node))
134
+ .attributeModifier(commonStyleModify.setNode(this.node))
326
135
  .defaultEvent()
327
136
  .visibleChangeEvent()
328
137
  .alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
329
138
  .justifyContent(FlexManager.flexOptions(this.node).justifyContent)
330
139
  } else {
331
140
  Column() {
332
- createLazyChildren(this.node)
141
+ this.createLazyChildren(this.node)
333
142
  }
334
- .radioGroupColumnAttrs(getNormalAttributes(this.node))
143
+ .attributeModifier(commonStyleModify.setNode(this.node))
335
144
  .defaultEvent()
336
145
  .visibleChangeEvent()
337
146
  .alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)