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

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 (139) 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 +16 -8
  4. package/dist/apis/device/memory.ts +10 -3
  5. package/dist/apis/framework/index.ts +1 -5
  6. package/dist/apis/index.ts +27 -17
  7. package/dist/apis/media/image/index.ts +1 -1
  8. package/dist/apis/media/video/VideoContext.ts +56 -7
  9. package/dist/apis/media/video/index.ts +3 -2
  10. package/dist/apis/network/request.ts +5 -5
  11. package/dist/apis/route/index.ts +15 -0
  12. package/dist/apis/storage/index.ts +146 -78
  13. package/dist/apis/ui/animation/animation.ts +71 -29
  14. package/dist/apis/ui/background.ts +2 -1
  15. package/dist/apis/ui/interaction/index.ts +42 -59
  16. package/dist/apis/ui/navigation-bar/index.ts +1 -1
  17. package/dist/apis/ui/pull-down-refresh.ts +9 -3
  18. package/dist/apis/ui/scroll/index.ts +5 -5
  19. package/dist/apis/ui/tab-bar.ts +3 -3
  20. package/dist/apis/utils/index.ts +1 -1
  21. package/dist/apis/wxml/IntersectionObserver.ts +18 -10
  22. package/dist/apis/wxml/index.ts +2 -0
  23. package/dist/apis/wxml/selectorQuery.ts +26 -13
  24. package/dist/components-harmony-ets/button.ets +68 -68
  25. package/dist/components-harmony-ets/canvas.ets +51 -0
  26. package/dist/components-harmony-ets/checkbox.ets +81 -102
  27. package/dist/components-harmony-ets/form.ets +54 -45
  28. package/dist/components-harmony-ets/icon.ets +34 -50
  29. package/dist/components-harmony-ets/image.ets +35 -45
  30. package/dist/components-harmony-ets/index.ets +92 -0
  31. package/dist/components-harmony-ets/innerHtml.ets +11 -6
  32. package/dist/components-harmony-ets/input.ets +51 -67
  33. package/dist/components-harmony-ets/label.ets +73 -53
  34. package/dist/components-harmony-ets/listView.ets +26 -0
  35. package/dist/components-harmony-ets/movableArea.ets +124 -0
  36. package/dist/components-harmony-ets/movableView.ets +93 -0
  37. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  38. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  39. package/dist/components-harmony-ets/picker.ets +74 -77
  40. package/dist/components-harmony-ets/progress.ets +52 -0
  41. package/dist/components-harmony-ets/pseudo.ets +80 -0
  42. package/dist/components-harmony-ets/radio.ets +82 -104
  43. package/dist/components-harmony-ets/richText.ets +20 -68
  44. package/dist/components-harmony-ets/scrollList.ets +94 -0
  45. package/dist/components-harmony-ets/scrollView.ets +67 -103
  46. package/dist/components-harmony-ets/slider.ets +23 -47
  47. package/dist/components-harmony-ets/stickySection.ets +42 -0
  48. package/dist/components-harmony-ets/style.ets +396 -0
  49. package/dist/components-harmony-ets/swiper.ets +64 -53
  50. package/dist/components-harmony-ets/switch.ets +44 -55
  51. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  52. package/dist/components-harmony-ets/text.ets +134 -75
  53. package/dist/components-harmony-ets/textArea.ets +54 -62
  54. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  55. package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
  56. package/dist/components-harmony-ets/utils/flexManager.ets +76 -8
  57. package/dist/components-harmony-ets/utils/helper.ets +20 -7
  58. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  59. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  60. package/dist/components-harmony-ets/utils/index.ts +54 -50
  61. package/dist/components-harmony-ets/utils/styles.ets +178 -63
  62. package/dist/components-harmony-ets/video.ets +37 -54
  63. package/dist/components-harmony-ets/view.ets +63 -94
  64. package/dist/components-harmony-ets/webView.ets +56 -0
  65. package/dist/index.d.ts +152 -0
  66. package/dist/index.js +199 -58
  67. package/dist/index.js.map +1 -1
  68. package/dist/runtime-ets/bom/document.ts +6 -4
  69. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  70. package/dist/runtime-ets/bom/window.ts +9 -2
  71. package/dist/runtime-ets/current.ts +3 -0
  72. package/dist/runtime-ets/dom/bind.ts +28 -12
  73. package/dist/runtime-ets/dom/class-list.ts +2 -2
  74. package/dist/runtime-ets/dom/cssNesting.ts +409 -0
  75. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +29 -19
  76. package/dist/runtime-ets/dom/document.ts +22 -8
  77. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  78. package/dist/runtime-ets/dom/element/element.ts +334 -57
  79. package/dist/runtime-ets/dom/element/form.ts +32 -26
  80. package/dist/runtime-ets/dom/element/index.ts +33 -2
  81. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  82. package/dist/runtime-ets/dom/element/movableView.ts +242 -0
  83. package/dist/runtime-ets/dom/element/normal.ts +36 -8
  84. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  85. package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
  86. package/dist/runtime-ets/dom/element/text.ts +1 -8
  87. package/dist/runtime-ets/dom/element/video.ts +5 -4
  88. package/dist/runtime-ets/dom/element/webView.ts +68 -0
  89. package/dist/runtime-ets/dom/event.ts +2 -4
  90. package/dist/runtime-ets/dom/eventTarget.ts +2 -3
  91. package/dist/runtime-ets/dom/node.ts +62 -27
  92. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
  93. package/dist/runtime-ets/dom/stylesheet/index.ts +98 -518
  94. package/dist/runtime-ets/dom/stylesheet/type.ts +92 -17
  95. package/dist/runtime-ets/dom/stylesheet/util.ts +74 -16
  96. package/dist/runtime-ets/index.ts +2 -2
  97. package/dist/runtime-ets/interface/event.ts +3 -2
  98. package/dist/runtime-ets/utils/index.ts +77 -12
  99. package/dist/runtime-ets/utils/info.ts +4 -2
  100. package/dist/runtime-framework/react/app.ts +17 -22
  101. package/dist/runtime-framework/react/hooks.ts +3 -4
  102. package/dist/runtime-framework/react/index.ts +1 -2
  103. package/dist/runtime-framework/react/native-page.ts +421 -0
  104. package/dist/runtime-framework/react/page.ts +4 -9
  105. package/dist/runtime-framework/solid/app.ts +25 -45
  106. package/dist/runtime-framework/solid/connect.ts +21 -3
  107. package/dist/runtime-framework/solid/hooks.ts +17 -12
  108. package/dist/runtime-framework/solid/index.ts +6 -2
  109. package/dist/runtime-framework/solid/page.ts +84 -30
  110. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  111. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  112. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  113. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  114. package/dist/runtime-utils.d.ts +827 -0
  115. package/dist/runtime-utils.js +510 -237
  116. package/dist/runtime-utils.js.map +1 -1
  117. package/dist/runtime.d.ts +1 -0
  118. package/dist/runtime.js +510 -237
  119. package/dist/runtime.js.map +1 -1
  120. package/index.js +3 -1
  121. package/package.json +14 -15
  122. package/static/media/cancel.svg +1 -0
  123. package/static/media/circle.svg +1 -0
  124. package/static/media/clear.svg +1 -0
  125. package/static/media/download.svg +1 -0
  126. package/static/media/info.svg +1 -0
  127. package/static/media/info_circle.svg +1 -0
  128. package/static/media/search.svg +1 -0
  129. package/static/media/success.svg +1 -0
  130. package/static/media/success_no_circle.svg +1 -0
  131. package/static/media/taro_arrow_left.svg +1 -0
  132. package/static/media/taro_home.svg +1 -0
  133. package/static/media/waiting.svg +1 -0
  134. package/static/media/warn.svg +1 -0
  135. package/types/harmony.d.ts +4 -0
  136. package/types/index.d.ts +4 -0
  137. package/types/runtime.d.ts +3 -1
  138. package/dist/runtime-ets/utils/bind.ts +0 -24
  139. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,384 +1,154 @@
1
1
  /* eslint-disable accessor-pairs */
2
2
  // @ts-nocheck
3
- import { ObjectAssign, TaroAny } from '../../'
4
- import { FlexManager, getNodeMarginOrPaddingData, getUnit } from './util'
3
+ import { BORDER_STYLE_MAP, FlexManager } from './util'
5
4
 
6
5
  import type { HarmonyStyle, HarmonyType, TaroStyleType, TaroTextStyleType } from './type'
7
6
 
8
7
  export { HarmonyStyle, HarmonyType, TaroStyleType, TaroTextStyleType }
9
8
 
10
9
  export default class StyleSheet {
11
-
12
10
  public hmStyle: HarmonyStyle = {}
13
11
 
14
12
  get display () {
15
13
  return this.hmStyle.display
16
14
  }
17
15
 
18
- set display (value: string) {
19
- this.hmStyle.display = value
20
- }
21
-
22
16
  get position () {
23
17
  return this.hmStyle.position
24
18
  }
25
19
 
26
- set position (value: string) {
27
- this.hmStyle.position = value
28
- }
29
-
30
20
  get padding () {
31
- const { top = 0, right = 0, bottom = 0, left = 0 } = this.hmStyle.padding || {}
32
- return `${top} ${right} ${bottom} ${left}`
33
- }
34
-
35
- set padding (value: string) {
36
- this.hmStyle.padding = getNodeMarginOrPaddingData(value)
37
- }
38
-
39
- set _padding (value: Margin) {
40
- this.hmStyle.padding = value
21
+ return `${this.hmStyle.paddingTop} ${this.hmStyle.paddingRight} ${this.hmStyle.paddingBottom} ${this.hmStyle.paddingLeft}`
41
22
  }
42
23
 
43
24
  get paddingTop () {
44
- return this.hmStyle.padding?.top
45
- }
46
-
47
- set paddingTop (value: string) {
48
- this.hmStyle.padding = ObjectAssign({}, this.hmStyle.padding, { top: getUnit(value) })
25
+ return this.hmStyle.paddingTop
49
26
  }
50
27
 
51
28
  get paddingBottom () {
52
- return this.hmStyle.padding?.bottom
53
- }
54
-
55
- set paddingBottom (value: string) {
56
- this.hmStyle.padding = ObjectAssign({}, this.hmStyle.padding, { bottom: getUnit(value) })
57
- }
58
-
59
- get paddingRight () {
60
- return this.hmStyle.padding?.right
61
- }
62
-
63
- set paddingRight (value: string) {
64
- this.hmStyle.padding = ObjectAssign({}, this.hmStyle.padding, { right: getUnit(value) })
29
+ return this.hmStyle.paddingBottom
65
30
  }
66
31
 
67
32
  get paddingLeft () {
68
- return this.hmStyle.padding?.left
33
+ return this.hmStyle.paddingLeft
69
34
  }
70
35
 
71
- set paddingLeft (value: string) {
72
- this.hmStyle.padding = ObjectAssign({}, this.hmStyle.padding, { left: getUnit(value) })
36
+ get paddingRight () {
37
+ return this.hmStyle.paddingRight
73
38
  }
74
39
 
75
40
  get margin () {
76
- const { top = 0, right = 0, bottom = 0, left = 0 } = this.hmStyle.margin || {}
77
- return `${top} ${right} ${bottom} ${left}`
78
- }
79
-
80
- set margin (value: string) {
81
- this.hmStyle.margin = getNodeMarginOrPaddingData(value)
82
- }
83
-
84
- set _margin (value: Margin) {
85
- this.hmStyle.margin = value
41
+ return `${this.hmStyle.marginTop} ${this.hmStyle.marginRight} ${this.hmStyle.marginBottom} ${this.hmStyle.marginLeft}`
86
42
  }
87
43
 
88
44
  get marginTop () {
89
- return this.hmStyle.margin?.top
90
- }
91
-
92
- set marginTop (value: string) {
93
- this.hmStyle.margin = ObjectAssign({}, this.hmStyle.margin, { top: getUnit(value) })
45
+ return this.hmStyle.marginTop
94
46
  }
95
47
 
96
48
  get marginBottom () {
97
- return this.hmStyle.margin?.bottom
98
- }
99
-
100
- set marginBottom (value: string) {
101
- this.hmStyle.margin = ObjectAssign({}, this.hmStyle.margin, { bottom: getUnit(value) })
102
- }
103
-
104
- get marginRight () {
105
- return this.hmStyle.margin?.right
106
- }
107
-
108
- set marginRight (value: string) {
109
- this.hmStyle.margin = ObjectAssign({}, this.hmStyle.margin, { right: getUnit(value) })
49
+ return this.hmStyle.marginBottom
110
50
  }
111
51
 
112
52
  get marginLeft () {
113
- return this.hmStyle.margin?.left
53
+ return this.hmStyle.marginLeft
114
54
  }
115
55
 
116
- set marginLeft (value: string) {
117
- this.hmStyle.margin = ObjectAssign({}, this.hmStyle.margin, { left: getUnit(value) })
56
+ get marginRight () {
57
+ return this.hmStyle.marginRight
118
58
  }
119
59
 
120
60
  get top () {
121
61
  return this.hmStyle.top
122
62
  }
123
63
 
124
- set top (value: string | number) {
125
- this.hmStyle.top = getUnit(value)
126
- }
127
-
128
- set _top (value: Length) {
129
- this.hmStyle.top = value
130
- }
131
-
132
64
  get left () {
133
65
  return this.hmStyle.left
134
66
  }
135
67
 
136
- set left (value: string | number) {
137
- this.hmStyle.left = getUnit(value)
68
+ get right () {
69
+ return this.hmStyle.right
138
70
  }
139
71
 
140
- set _left (value: Length) {
141
- this.hmStyle.left = value
72
+ get bottom () {
73
+ return this.hmStyle.bottom
142
74
  }
143
75
 
144
76
  get flex () {
145
- return this.hmStyle.flex
146
- }
147
-
148
- set flex (value: string | number) {
149
- let res: [number, number, number | string] = [0, 0, 'auto']
150
-
151
- if (typeof value === 'number') {
152
- res = [value, 1, 0]
153
- } else if (value === 'auto') {
154
- res = [1, 1, 'auto']
155
- } else if (value === 'none') {
156
- res = [0, 0, 'auto']
157
- } else if (typeof value === 'string') {
158
- const FlexList = value.replace(new RegExp('/\\s+/g'), ' ').split(' ')
159
- FlexList.forEach((item, index) => {
160
- res[index] = index < 2 ? Number(item) : item
161
- })
162
- }
163
-
164
- this.flexGrow = res[0]
165
- this.flexShrink = res[1]
166
- this.flexBasis = res[2]
167
- this.hmStyle.flex = value
77
+ return `${this.hmStyle.flexGrow} ${this.hmStyle.flexShrink} ${this.hmStyle.flexBasis}`
168
78
  }
169
79
 
170
80
  get flexBasis () {
171
81
  return this.hmStyle.flexBasis
172
82
  }
173
83
 
174
- set flexBasis (value: string) {
175
- this.hmStyle.flexBasis = getUnit(value)
176
- }
177
-
178
- set _flexBasis (value: number | string) {
179
- this.hmStyle.flexBasis = value
180
- }
181
-
182
84
  get flexGrow () {
183
85
  return Number(this.hmStyle.flexGrow)
184
86
  }
185
87
 
186
- set flexGrow (value: number | string) {
187
- this.hmStyle.flexGrow = Number(value)
188
- }
189
-
190
- set _flexGrow (value: number) {
191
- this.hmStyle.flexGrow = value
192
- }
193
-
194
88
  get flexShrink () {
195
89
  return Number(this.hmStyle.flexShrink)
196
90
  }
197
91
 
198
- set flexShrink (value: number | string) {
199
- this.hmStyle.flexShrink = Number(value)
200
- }
201
-
202
- set _flexShrink (value: number) {
203
- this.hmStyle.flexShrink = value
204
- }
205
-
206
92
  get alignSelf () {
207
93
  return FlexManager.reverseItemAlign(this.hmStyle.alignSelf)
208
94
  }
209
95
 
210
- set alignSelf (value: string | number) {
211
- this.hmStyle.alignSelf = FlexManager.itemAlign(value)
212
- }
213
-
214
- set _alignSelf (value: ItemAlign) {
215
- this.hmStyle.alignSelf = value
216
- }
217
-
218
- set _flexOptions (value) {
219
- if (typeof value.direction !== 'undefined') {
220
- this.hmStyle.direction = value.direction
221
- }
222
- if (typeof value.justifyContent !== 'undefined') {
223
- this.hmStyle.justifyContent = value.justifyContent
224
- }
225
- if (typeof value.alignItems !== 'undefined') {
226
- this.hmStyle.alignItems = value.alignItems
227
- }
228
- if (typeof value.wrap !== 'undefined') {
229
- this.hmStyle.flexWrap = value.wrap
230
- }
231
- if (typeof value.alignContent !== 'undefined') {
232
- this.hmStyle.alignContent = value.alignContent
233
- }
234
- }
235
-
236
96
  get flexDirection () {
237
- return FlexManager.reverseDirection(this.hmStyle.direction)
238
- }
239
-
240
- set flexDirection (value: string) {
241
- this.hmStyle.direction = FlexManager.direction(value)
97
+ return FlexManager.reverseDirection(this.hmStyle.flexDirection)
242
98
  }
243
99
 
244
100
  get justifyContent () {
245
101
  return FlexManager.reverseFlexAlign(this.hmStyle.justifyContent)
246
102
  }
247
103
 
248
- set justifyContent (value: string) {
249
- this.hmStyle.justifyContent = FlexManager.flexAlign(value)
250
- }
251
-
252
104
  get alignItems () {
253
105
  return FlexManager.reverseItemAlign(this.hmStyle.alignItems)
254
106
  }
255
107
 
256
- set alignItems (value: string) {
257
- this.hmStyle.alignItems = FlexManager.itemAlign(value)
258
- }
259
-
260
108
  get alignContent () {
261
109
  return FlexManager.reverseFlexAlign(this.hmStyle.alignContent)
262
110
  }
263
111
 
264
- set alignContent (value: string) {
265
- this.hmStyle.alignContent = FlexManager.flexAlign(value)
266
- }
267
-
268
112
  get flexWrap () {
269
- return FlexManager.reverseFlexWrap(this.hmStyle.wrap)
270
- }
271
-
272
- set flexWrap (value: string) {
273
- this.hmStyle.wrap = FlexManager.flexWrap(value)
113
+ return FlexManager.reverseFlexWrap(this.hmStyle.flexWrap)
274
114
  }
275
115
 
276
116
  get width () {
277
117
  return this.hmStyle.width
278
118
  }
279
119
 
280
- set width (value: string | number) {
281
- this.hmStyle.width = getUnit(value)
282
- }
283
-
284
- set _width (value: Length) {
285
- this.hmStyle.width = value
286
- }
287
-
288
120
  get height () {
289
121
  return this.hmStyle.height
290
122
  }
291
123
 
292
- set height (value: string | number) {
293
- this.hmStyle.height = getUnit(value)
294
- }
295
-
296
- set _height (value: Length) {
297
- this.hmStyle.height = value
298
- }
299
-
300
- set _constraintSize(value: ConstraintSizeOptions) {
301
- this.hmStyle.constraintSize = value
302
- }
303
-
304
124
  get minHeight () {
305
- return this.hmStyle.constraintSize?.minHeight
306
- }
307
-
308
- set minHeight (value: string | number) {
309
- this._minHeight = getUnit(value)
125
+ return this.hmStyle.minHeight
310
126
  }
311
127
 
312
128
  get maxHeight () {
313
- return this.hmStyle.constraintSize?.maxHeight
314
- }
315
-
316
- set maxHeight (value: string | number) {
317
- this._maxHeight = getUnit(value)
129
+ return this.hmStyle.maxHeight
318
130
  }
319
131
 
320
132
  get minWidth () {
321
- return this.hmStyle.constraintSize?.minWidth
322
- }
323
-
324
- set minWidth (value: string | number) {
325
- this._minWidth = getUnit(value)
133
+ return this.hmStyle.minWidth
326
134
  }
327
135
 
328
136
  get maxWidth () {
329
- return this.hmStyle.constraintSize?.maxWidth
330
- }
331
-
332
- set maxWidth (value: string | number) {
333
- this._maxWidth = getUnit(value)
137
+ return this.hmStyle.maxWidth
334
138
  }
335
139
 
336
140
  get background () {
337
141
  return `${this.backgroundColor} ${this.backgroundImage} ${this.backgroundRepeat} ${this.backgroundSize}`.trim()
338
142
  }
339
143
 
340
- // TODO: 未实现
341
- set background (value: string) {
342
-
343
- }
344
-
345
- set _background (value: TaroAny) {
346
- const _backgroundImage: HarmonyType.Background.backgroundImage = value?.image?.[0]
347
- if (_backgroundImage) {
348
- this.hmStyle.backgroundImage = _backgroundImage.src
349
- if (_backgroundImage.repeat) {
350
- this.hmStyle.backgroundRepeat = _backgroundImage.repeat
351
- }
352
- }
353
- this.hmStyle.backgroundImageSize = value?.size?.[0]
354
- this.hmStyle.backgroundColor = this.hmStyle.backgroundImage ? null : value?.color
355
-
356
- const _backgroundPosition: HarmonyType.Background.backgroundImagePosition = value?.position?.[0]
357
- this.hmStyle.backgroundImagePosition = _backgroundPosition
358
- }
359
-
360
144
  get backgroundColor () {
361
145
  return this.hmStyle.backgroundColor
362
146
  }
363
147
 
364
- set backgroundColor (value: string) {
365
- this.hmStyle.backgroundColor = value
366
- }
367
-
368
148
  get backgroundImage () {
369
149
  return this.hmStyle.backgroundImage && `url(${this.hmStyle.backgroundImage})`
370
150
  }
371
151
 
372
- set backgroundImage (value: string) {
373
- if (typeof value === 'string' && value.indexOf('url(') !== -1 && value.indexOf(')') !== -1) {
374
- // 如果包含 url(),则说明是 background-image 属性
375
- const match = value.match(new RegExp('url\\([\'"]?(.*?)[\'"]?\\)'))
376
- if (match) {
377
- this.hmStyle.backgroundImage = match[1]
378
- }
379
- }
380
- }
381
-
382
152
  get backgroundRepeat () {
383
153
  if (this.hmStyle.backgroundRepeat) {
384
154
  switch (this.hmStyle.backgroundRepeat) {
@@ -386,41 +156,19 @@ export default class StyleSheet {
386
156
  case ImageRepeat.Y: return 'repeat-y'; break
387
157
  case ImageRepeat.XY: return 'repeat'; break
388
158
  case ImageRepeat.NoRepeat: return 'no-repeat'; break
389
- }
390
- }
391
- }
392
-
393
- set backgroundRepeat (value: string) {
394
- if (typeof value === 'string') {
395
- switch (value) {
396
- case 'repeat-x': this.hmStyle.backgroundRepeat = ImageRepeat.X; break
397
- case 'repeat-y': this.hmStyle.backgroundRepeat = ImageRepeat.Y; break
398
- case 'no-repeat': this.hmStyle.backgroundRepeat = ImageRepeat.NoRepeat; break
399
- default: this.hmStyle.backgroundRepeat = ImageRepeat.XY; break
400
159
  }
401
160
  }
402
161
  }
403
162
 
404
163
  get backgroundSize () {
405
164
  if (this.hmStyle.backgroundImage) {
406
- return [this.hmStyle.backgroundImageSize.width, this.hmStyle.backgroundImageSize.height].join(' ')
407
- }
408
- }
409
-
410
- set backgroundSize (value: string) {
411
- if (typeof value === 'string') {
412
- const sizes = value.split(' ')
413
- if (sizes.length === 1) {
414
- this.hmStyle.backgroundImageSize = { width: getUnit(sizes[0]) }
415
- } else if (sizes.length === 2) {
416
- this.hmStyle.backgroundImageSize = { width: getUnit(sizes[0]), height: getUnit(sizes[1]) }
417
- }
165
+ return [this.hmStyle.backgroundSize.width, this.hmStyle.backgroundSize.height].join(' ')
418
166
  }
419
167
  }
420
168
 
421
169
  get backgroundPosition () {
422
- if (this.hmStyle.backgroundImagePosition) {
423
- switch (this.hmStyle.backgroundImagePosition) {
170
+ if (this.hmStyle.backgroundPosition) {
171
+ switch (this.hmStyle.backgroundPosition) {
424
172
  case Alignment.TopStart: return 'left top'; break
425
173
  case Alignment.Top: return 'center top'; break
426
174
  case Alignment.TopEnd: return 'right top'; break
@@ -431,43 +179,8 @@ export default class StyleSheet {
431
179
  case Alignment.Bottom: return 'center bottom'; break
432
180
  case Alignment.BottomEnd: return 'right bottom'; break
433
181
  default: {
434
- if (this.hmStyle.backgroundImagePosition) {
435
- return [this.hmStyle.backgroundImagePosition, this.hmStyle.backgroundImagePosition.y].join(' ')
436
- }
437
- }
438
- }
439
- }
440
- }
441
-
442
- set backgroundPosition (value: string) {
443
- if (typeof value === 'string') {
444
- const positions = backgroundImagePosition.split(' ')
445
- const horizontal = positions[0].toLowerCase()
446
- const vertical = positions[1].toLowerCase() || 'top'
447
-
448
- if (horizontal === 'left' && vertical === 'top') {
449
- this.hmStyle.backgroundImagePosition = Alignment.TopStart
450
- } else if (horizontal === 'center' && vertical === 'top') {
451
- this.hmStyle.backgroundImagePosition = Alignment.Top
452
- } else if (horizontal === 'right' && vertical === 'top') {
453
- this.hmStyle.backgroundImagePosition = Alignment.TopEnd
454
- } else if (horizontal === 'left' && vertical === 'center') {
455
- this.hmStyle.backgroundImagePosition = Alignment.Start
456
- } else if (horizontal === 'center' && vertical === 'center') {
457
- this.hmStyle.backgroundImagePosition = Alignment.Center
458
- } else if (horizontal === 'right' && vertical === 'center') {
459
- this.hmStyle.backgroundImagePosition = Alignment.End
460
- } else if (horizontal === 'left' && vertical === 'bottom') {
461
- this.hmStyle.backgroundImagePosition = Alignment.BottomStart
462
- } else if (horizontal === 'center' && vertical === 'bottom') {
463
- this.hmStyle.backgroundImagePosition = Alignment.Bottom
464
- } else if (horizontal === 'right' && vertical === 'bottom') {
465
- this.hmStyle.backgroundImagePosition = Alignment.BottomEnd
466
- } else {
467
- if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(horizontal)) {
468
- this.hmStyle.backgroundImagePosition = { x: getUnit(horizontal) }
469
- if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(vertical)) {
470
- this.hmStyle.backgroundImagePosition = { x: getUnit(horizontal), y: getUnit(vertical) }
182
+ if (this.hmStyle.backgroundPosition) {
183
+ return [this.hmStyle.backgroundPosition, this.hmStyle.backgroundPosition.y].join(' ')
471
184
  }
472
185
  }
473
186
  }
@@ -478,97 +191,100 @@ export default class StyleSheet {
478
191
  return [this.borderWidth, this.borderStyle, this.bordercolor].join(' ')
479
192
  }
480
193
 
481
- set border (value: string) {
482
- const [width, style, color] = value.split(' ')
483
- this.hmStyle.borderWidth = getUnit(width)
484
- this.hmStyle.borderStyle = BORDERhmStyleYLE_MAP.get(style)
485
- this.hmStyle.borderColor = color
486
- }
487
-
488
194
  get borderWidth () {
489
195
  return this.hmStyle.borderWidth
490
196
  }
491
197
 
492
- set borderWidth (value: string) {
493
- this.hmStyle.borderWidth = getUnit(value)
198
+ get borderLeftWidth () {
199
+ return this.hmStyle.borderLeftWidth
494
200
  }
495
201
 
496
- set _borderWidth (value: Length | EdgeWidths) {
497
- this.hmStyle.borderWidth = value
202
+ get borderRightWidth () {
203
+ return this.hmStyle.borderRightWidth
204
+ }
205
+
206
+ get borderTopWidth () {
207
+ return this.hmStyle.borderTopWidth
208
+ }
209
+
210
+ get borderBottomWidth () {
211
+ return this.hmStyle.borderBottomWidth
498
212
  }
499
213
 
500
214
  get borderColor () {
501
215
  return this.hmStyle.borderColor
502
216
  }
503
217
 
504
- set borderColor (value: string) {
505
- this.hmStyle.borderColor = value
218
+ get borderLeftColor () {
219
+ return this.hmStyle.borderLeftColor
506
220
  }
507
221
 
508
- set _borderColor (value: ResourceColor | EdgeColors) {
509
- this.hmStyle.borderColor = value
222
+ get borderRightColor () {
223
+ return this.hmStyle.borderRightColor
510
224
  }
511
225
 
512
- get borderStyle () {
513
- return BORDERhmStyleYLE_MAP.reverse(this.hmStyle.borderStyle)
226
+ get borderTopColor () {
227
+ return this.hmStyle.borderTopColor
514
228
  }
515
229
 
516
- set borderStyle (value: string) {
517
- this.hmStyle.borderStyle = BORDERhmStyleYLE_MAP.get(value)
230
+ get borderBottomColor () {
231
+ return this.hmStyle.borderBottomColor
518
232
  }
519
233
 
520
- set _borderStyle (value: BorderStyle | EdgeStyles) {
521
- this.hmStyle.borderStyle = value
234
+ get borderStyle () {
235
+ return BORDER_STYLE_MAP.reverse(this.hmStyle.borderStyle)
522
236
  }
523
-
524
- get borderRadius () {
525
- return this.hmStyle.borderRadius
237
+
238
+ get borderLeftStyle () {
239
+ return BORDER_STYLE_MAP.reverse(this.hmStyle.borderLeftStyle)
526
240
  }
527
241
 
528
- set borderRadius (value: string) {
529
- this.hmStyle.borderRadius = getUnit(value)
242
+ get borderRightStyle () {
243
+ return BORDER_STYLE_MAP.reverse(this.hmStyle.borderRightStyle)
530
244
  }
531
245
 
532
- set _borderRadius (value: Length | BorderRadiuses) {
533
- this.hmStyle.borderRadius = value
246
+ get borderTopStyle () {
247
+ return BORDER_STYLE_MAP.reverse(this.hmStyle.borderTopStyle)
534
248
  }
535
249
 
536
- get zIndex (): number {
537
- return Number(this.hmStyle.zIndex)
250
+ get borderBottomStyle () {
251
+ return BORDER_STYLE_MAP.reverse(this.hmStyle.borderBottomStyle)
538
252
  }
539
253
 
540
- set zIndex (value: string) {
541
- this.hmStyle.zIndex = Number(value)
254
+ get borderRadius () {
255
+ return this.hmStyle.borderRadius
542
256
  }
543
257
 
544
- get opacity () {
545
- return this.hmStyle.opacity
258
+ get borderTopLeftRadius () {
259
+ return this.hmStyle.borderTopLeftRadius
546
260
  }
547
261
 
548
- set opacity (value: string) {
549
- const val = Number(value)
262
+ get borderTopRightRadius () {
263
+ return this.hmStyle.borderTopRightRadius
264
+ }
550
265
 
551
- this.hmStyle.opacity = Number.isNaN(val) ? 1 : val
266
+ get borderBottomLeftRadius () {
267
+ return this.hmStyle.borderBottomLeftRadius
552
268
  }
553
269
 
554
- get overflow () {
555
- return this.hmStyle.clip ? 'hidden' : 'visible'
270
+ get borderBottomRightRadius () {
271
+ return this.hmStyle.borderBottomRightRadius
556
272
  }
557
273
 
558
- set overflow (value: string) {
559
- this.hmStyle.clip = value === 'hidden'
274
+ get zIndex () {
275
+ return this.hmStyle.zIndex
560
276
  }
561
277
 
562
- get focus () {
563
- return !!this.hmStyle.focus
278
+ get opacity () {
279
+ return this.hmStyle.opacity
564
280
  }
565
281
 
566
- set focus (value: boolean) {
567
- this.hmStyle.focus = value
282
+ get overflow () {
283
+ return this.hmStyle.overflow ? 'hidden' : 'visible'
568
284
  }
569
285
 
570
- set _focus (value: boolean) {
571
- this.hmStyle.focus = value
286
+ get focus () {
287
+ return !!this.hmStyle.focus
572
288
  }
573
289
 
574
290
  // 文本相关
@@ -576,38 +292,14 @@ export default class StyleSheet {
576
292
  return this.hmStyle.color
577
293
  }
578
294
 
579
- set color (value: string) {
580
- this.hmStyle.color = value
581
- }
582
-
583
- set _color (value: ResourceColor) {
584
- this.hmStyle.color = value
585
- }
586
-
587
295
  get fontSize () {
588
296
  return this.hmStyle.fontSize
589
297
  }
590
298
 
591
- set fontSize (value: string) {
592
- this.hmStyle.fontSize = getUnit(value)
593
- }
594
-
595
- set _fontSize (value: number | string | Resource) {
596
- this.hmStyle.fontSize = value
597
- }
598
-
599
299
  get fontWeight () {
600
300
  return this.hmStyle.fontWeight
601
301
  }
602
302
 
603
- set fontWeight (value: string) {
604
- this.hmStyle.fontWeight = value
605
- }
606
-
607
- set _fontWeight (value: number | FontWeight | string) {
608
- this.hmStyle.fontWeight = value
609
- }
610
-
611
303
  get fontStyle () {
612
304
  switch (this.hmStyle.fontStyle) {
613
305
  case FontStyle.Italic: return 'italic'; break
@@ -616,31 +308,10 @@ export default class StyleSheet {
616
308
  }
617
309
  }
618
310
 
619
- set fontStyle (value: string) {
620
- switch (value) {
621
- case 'italic':
622
- return FontStyle.Italic
623
- default:
624
- return FontStyle.Normal
625
- }
626
- }
627
-
628
- set _fontStyle (value: FontStyle) {
629
- this.hmStyle.fontStyle = value
630
- }
631
-
632
311
  get fontFamily () {
633
312
  return this.hmStyle.fontFamily
634
313
  }
635
314
 
636
- set fontFamily (value: string) {
637
- this.hmStyle.fontFamily = value
638
- }
639
-
640
- set _fontFamily (value: string | Resource) {
641
- this.hmStyle.fontFamily = value
642
- }
643
-
644
315
  get textAlign () {
645
316
  switch (this.hmStyle.textAlign) {
646
317
  case TextAlign.End: return 'right'; break
@@ -650,68 +321,34 @@ export default class StyleSheet {
650
321
  }
651
322
  }
652
323
 
653
- set textAlign (value: string) {
654
- switch (value) {
655
- case 'right':
656
- return TextAlign.End
657
- case 'center':
658
- return TextAlign.Center
659
- default:
660
- return TextAlign.Start
324
+ get verticalAlign() {
325
+ switch (this.hmStyle.verticalAlign) {
326
+ case Alignment.Center: return 'middle'; break
327
+ case Alignment.Top: return 'top'; break
328
+ case Alignment.Bottom: return 'bottom'; break
329
+ default: return ''
661
330
  }
662
331
  }
663
332
 
664
- set _textAlign (value: TextAlign) {
665
- this.hmStyle.textAlign = value
666
- }
667
-
668
333
  get lineHeight () {
669
334
  return this.hmStyle.lineHeight
670
335
  }
671
336
 
672
- set lineHeight (value: string) {
673
- this.hmStyle.lineHeight = getUnit(value)
674
- }
675
-
676
- set _lineHeight (value: string | number | Resource) {
677
- this.hmStyle.lineHeight = value
678
- }
679
-
680
337
  get letterSpacing () {
681
338
  return this.hmStyle.letterSpacing
682
339
  }
683
340
 
684
- set letterSpacing (value: string) {
685
- this.hmStyle.letterSpacing = getUnit(value)
686
- }
687
-
688
- set _letterSpacing (value: number | string) {
689
- this.hmStyle.letterSpacing = value
690
- }
691
-
692
341
  get textDecoration () {
693
- switch (this.hmStyle.decoration) {
694
- case TextDecorationType.Underline: return 'underline'; break
695
- case TextDecorationType.Overline: return 'overline'; break
696
- case TextDecorationType.LineThrough: return 'line-through'; break
697
- case TextDecorationType.None: return 'none'; break
698
- default: return ''
699
- }
700
- }
701
-
702
- set textDecoration (value: string) {
703
- if (typeof value === 'string') {
704
- switch (value) {
705
- case 'underline': this.hmStyle.decoration = TextDecorationType.Underline; break
706
- case 'overline': this.hmStyle.decoration = TextDecorationType.Overline; break
707
- case 'line-through': this.hmStyle.decoration = TextDecorationType.LineThrough; break
708
- default: this.hmStyle.decoration = TextDecorationType.None; break
342
+ if (this.hmStyle.textDecoration) {
343
+ switch (this.hmStyle.textDecoration.type) {
344
+ case TextDecorationType.Underline: return 'underline'; break
345
+ case TextDecorationType.Overline: return 'overline'; break
346
+ case TextDecorationType.LineThrough: return 'line-through'; break
347
+ case TextDecorationType.None: return 'none'; break
348
+ default: return ''
709
349
  }
710
350
  }
711
- }
712
-
713
- set _decoration (value: TextDecorationType) {
714
- this.hmStyle.decoration = value
351
+ return ''
715
352
  }
716
353
 
717
354
  get textOverflow () {
@@ -725,76 +362,19 @@ export default class StyleSheet {
725
362
  }
726
363
  }
727
364
 
728
- set textOverflow (value: string) {
729
- if (typeof value === 'string') {
730
- let overflow = TextOverflow.None
731
- switch (value) {
732
- case 'clip': overflow = TextOverflow.Clip; break
733
- case 'ellipsis': overflow = TextOverflow.Ellipsis; break
734
- case 'marquee': overflow = TextOverflow.MARQUEE; break
735
- }
736
- this.hmStyle.textOverflow = {
737
- overflow
738
- }
739
- }
740
- }
741
-
742
- set _textOverflow (value: TextOverflow) {
743
- switch (value.overflow) {
744
- case TextOverflow.Clip:
745
- case TextOverflow.Ellipsis:
746
- case TextOverflow.None: this.hmStyle.maxLines = this.hmStyle.maxLines || 1; break
747
- default: break
748
- }
749
- this.hmStyle.textOverflow = value
750
- }
751
-
752
365
  get WebkitLineClamp () {
753
- return Number(this.hmStyle.maxLines)
754
- }
755
-
756
- set WebkitLineClamp (value: string | number) {
757
- this.hmStyle.maxLines = Number(value)
758
- }
759
-
760
- set _WebkitLineClamp (value: number) {
761
- this.hmStyle.maxLines = value
366
+ return Number(this.hmStyle.WebkitLineClamp)
762
367
  }
763
368
 
764
- set _linearGradient (value: HarmonyType.LinearGradient[]) {
765
- this.hmStyle.linearGradient = value?.[0]
766
- }
767
-
768
369
  get transform () {
769
370
  return this.hmStyle.transform
770
371
  }
771
372
 
772
- set _tranform (value: HarmonyType.Transform.Transform) {
773
- this.hmStyle.transform = value
774
- }
775
- }
776
-
777
-
778
- class BORDERhmStyleYLE_MAP {
779
- static solid = BorderStyle.Solid
780
- static dotted = BorderStyle.Dotted
781
- static dashed = BorderStyle.Dashed
782
-
783
- static get(type: string): BorderStyle {
784
- switch (type) {
785
- case 'dotted': return BorderStyle.Dotted
786
- case 'dashed': return BorderStyle.Dashed
787
- default: return BorderStyle.Solid
788
- }
373
+ get transformOrigin () {
374
+ return this.hmStyle.transformOrigin
789
375
  }
790
376
 
791
- static reverse(type: BorderStyle): string {
792
- switch (type) {
793
- case BorderStyle.Dotted: return 'dotted'
794
- case BorderStyle.Dashed: return 'dashed'
795
- case BorderStyle.Solid: return 'solid'
796
- default: return ''
797
- }
798
-
377
+ get content () {
378
+ return this.hmStyle._content
799
379
  }
800
380
  }