@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
@@ -4,79 +4,6 @@ import { CSSProperties } from 'react'
4
4
 
5
5
  import { BORDER_STYLE_MAP, capitalizeFirstLetter, FlexManager, getNodeMarginOrPaddingData, getUnit } from './util'
6
6
 
7
- export const WEB_STYLE_MAP = {
8
- padding: ['_paddingTop', '_paddingRight', '_paddingBottom', '_paddingLeft'],
9
- paddingTop: ['_paddingTop'],
10
- paddingRight: ['_paddingRight'],
11
- paddingBottom: ['_paddingBottom'],
12
- paddingLeft: ['_paddingLeft'],
13
- margin: ['_marginTop', '_marginRight', '_marginBottom', '_marginLeft'],
14
- marginTop: ['_marginTop'],
15
- marginRight: ['_marginRight'],
16
- marginBottom: ['_marginBottom'],
17
- marginLeft: ['_marginLeft'],
18
- top: ['_top'],
19
- left: ['_left'],
20
- flex: ['_flexGrow', '_flexShrink', '_flexBasis'],
21
- flexGrow: ['_flexGrow'],
22
- flexShrink: ['_flexShrink'],
23
- flexBasis: ['_flexBasis'],
24
- alignSelf: ['_alignSelf'],
25
- flexDirection: ['_flexDirection'],
26
- justifyContent: ['_justifyContent'],
27
- alignItems: ['_alignItems'],
28
- alignContent: ['_alignContent'],
29
- flexWrap: ['_flexWrap'],
30
- width: ['_width'],
31
- height: ['_height'],
32
- minWidth: ['_minWidth'],
33
- minHeight: ['_minHeight'],
34
- maxWidth: ['_maxWidth'],
35
- maxHeight: ['_maxHeight'],
36
- background: ['_backgroundColor', '_backgroundImage', '_backgroundRepeat', '_backgroundSize', '_backgroundPosition'],
37
- backgroundColor: ['_backgroundColor'],
38
- backgroundImage: ['_backgroundImage'],
39
- backgroundRepeat: ['_backgroundRepeat'],
40
- backgroundSize: ['_backgroundSize'],
41
- backgroundPosition: ['_backgroundPosition'],
42
- border: ['_borderTopWidth', '_borderRightWidth', '_borderBottomWidth', '_borderLeftWidth', '_borderTopStyle', '_borderRightStyle', '_borderBottomStyle', '_borderLeftStyle', '_borderTopColor', '_borderRightColor', '_borderBottomColor', '_borderLeftColor'],
43
- borderTop: ['_borderTopWidth', '_borderTopStyle', '_borderTopColor'],
44
- borderRight: ['_borderRightWidth', '_borderRightStyle', '_borderRightColor'],
45
- borderBottom: ['_borderBottomWidth', '_borderBottomStyle', '_borderBottomColor'],
46
- borderLeft: ['_borderLeftWidth', '_borderLeftStyle', '_borderLeftColor'],
47
- borderWidth: ['_borderTopWidth', '_borderRightWidth', '_borderBottomWidth', '_borderLeftWidth'],
48
- borderLeftWidth: ['_borderLeftWidth'],
49
- borderRightWidth: ['_borderRightWidth'],
50
- borderTopWidth: ['_borderTopWidth'],
51
- borderBottomWidth: ['_borderBottomWidth'],
52
- borderStyle: ['_borderTopStyle', '_borderRightStyle', '_borderBottomStyle', '_borderLeftStyle'],
53
- borderLeftStyle: ['_borderLeftStyle'],
54
- borderRightStyle: ['_borderRightStyle'],
55
- borderTopStyle: ['_borderTopStyle'],
56
- borderBottomStyle: ['_borderBottomStyle'],
57
- borderColor: ['_borderTopColor', '_borderRightColor', '_borderBottomColor', '_borderLeftColor'],
58
- borderLeftColor: ['_borderLeftColor'],
59
- borderRightColor: ['_borderRightColor'],
60
- borderTopColor: ['_borderTopColor'],
61
- borderBottomColor: ['_borderBottomColor'],
62
- borderRadius: ['_borderTopLeftRadius', '_borderTopRightRadius', '_borderBottomLeftRadius', '_borderBottomRightRadius'],
63
- borderTopLeftRadius: ['_borderTopLeftRadius'],
64
- borderTopRightRadius: ['_borderTopRightRadius'],
65
- borderBottomLeftRadius: ['_borderBottomLeftRadius'],
66
- borderBottomRightRadius: ['_borderBottomRightRadius'],
67
- color: ['_color'],
68
- fontSize: ['_fontSize'],
69
- fontWeight: ['_fontWeight'],
70
- fontStyle: ['_fontStyle'],
71
- textAlign: ['_textAlign'],
72
- lineHeight: ['_lineHeight'],
73
- letterSpacing: ['_letterSpacing'],
74
- textDecoration: ['_textDecoration'],
75
- textOverflow: ['_textOverflow'],
76
- WebkitLineClamp: ['_WebkitLineClamp'],
77
- transform: ['_transform']
78
- }
79
-
80
7
  // 将web端的style转换为hm端的style
81
8
  export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
82
9
  const hmStyle: Record<string, any> = {}
@@ -85,58 +12,66 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
85
12
  switch (key) {
86
13
  case 'padding': {
87
14
  const { top, bottom, left, right } = getNodeMarginOrPaddingData(value)
88
- hmStyle._paddingTop = top
89
- hmStyle._paddingBottom = bottom
90
- hmStyle._paddingLeft = left
91
- hmStyle._paddingRight = right
15
+ hmStyle.paddingTop = top
16
+ hmStyle.paddingBottom = bottom
17
+ hmStyle.paddingLeft = left
18
+ hmStyle.paddingRight = right
92
19
  break
93
20
  }
94
21
  case 'paddingTop': {
95
- hmStyle._paddingTop = getUnit(value)
22
+ hmStyle.paddingTop = getUnit(value)
96
23
  break
97
24
  }
98
25
  case 'paddingBottom': {
99
- hmStyle._paddingBottom = getUnit(value)
26
+ hmStyle.paddingBottom = getUnit(value)
100
27
  break
101
28
  }
102
29
  case 'paddingLeft': {
103
- hmStyle._paddingLeft = getUnit(value)
30
+ hmStyle.paddingLeft = getUnit(value)
104
31
  break
105
32
  }
106
33
  case 'paddingRight': {
107
- hmStyle._paddingRight = getUnit(value)
34
+ hmStyle.paddingRight = getUnit(value)
108
35
  break
109
36
  }
110
37
  case 'margin': {
111
38
  const { top, bottom, left, right } = getNodeMarginOrPaddingData(value)
112
- hmStyle._marginTop = top
113
- hmStyle._marginBottom = bottom
114
- hmStyle._marginLeft = left
115
- hmStyle._marginRight = right
39
+ hmStyle.marginTop = top
40
+ hmStyle.marginBottom = bottom
41
+ hmStyle.marginLeft = left
42
+ hmStyle.marginRight = right
116
43
  break
117
44
  }
118
45
  case 'marginTop': {
119
- hmStyle._marginTop = getUnit(value)
46
+ hmStyle.marginTop = getUnit(value)
120
47
  break
121
48
  }
122
49
  case 'marginBottom': {
123
- hmStyle._marginBottom = getUnit(value)
50
+ hmStyle.marginBottom = getUnit(value)
124
51
  break
125
52
  }
126
53
  case 'marginLeft': {
127
- hmStyle._marginLeft = getUnit(value)
54
+ hmStyle.marginLeft = getUnit(value)
128
55
  break
129
56
  }
130
57
  case 'marginRight': {
131
- hmStyle._marginRight = getUnit(value)
58
+ hmStyle.marginRight = getUnit(value)
132
59
  break
133
60
  }
134
61
  case 'top': {
135
- hmStyle._top = getUnit(value)
62
+ hmStyle.top = getUnit(value)
136
63
  break
137
64
  }
138
65
  case 'left': {
139
- hmStyle._left = getUnit(value)
66
+ hmStyle.left = getUnit(value)
67
+ break
68
+ }
69
+ case 'right': {
70
+ hmStyle.right = getUnit(value)
71
+ break
72
+ }
73
+ case 'bottom': {
74
+ hmStyle.bottom = getUnit(value)
140
75
  break
141
76
  }
142
77
  case 'flex': {
@@ -153,69 +88,69 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
153
88
  res[index] = index < 2 ? Number(item) : item
154
89
  })
155
90
  }
156
- hmStyle._flexGrow = getUnit(res[0])
157
- hmStyle._flexShrink = Number(res[1])
158
- hmStyle._flexBasis = Number(res[2])
91
+ hmStyle.flexGrow = getUnit(res[0])
92
+ hmStyle.flexShrink = Number(res[1])
93
+ hmStyle.flexBasis = Number(res[2])
159
94
  break
160
95
  }
161
96
  case 'flexGrow': {
162
- hmStyle._flexGrow = getUnit(value)
97
+ hmStyle.flexGrow = getUnit(value)
163
98
  break
164
99
  }
165
100
  case 'flexShrink': {
166
- hmStyle._flexShrink = Number(value)
101
+ hmStyle.flexShrink = Number(value)
167
102
  break
168
103
  }
169
104
  case 'flexBasis': {
170
- hmStyle._flexBasis = Number(value)
105
+ hmStyle.flexBasis = Number(value)
171
106
  break
172
107
  }
173
108
  case 'alignSelf': {
174
- hmStyle._alignSelf = FlexManager.itemAlign(value)
109
+ hmStyle.alignSelf = FlexManager.itemAlign(value)
175
110
  break
176
111
  }
177
112
  case 'flexDirection': {
178
- hmStyle._flexDirection = FlexManager.direction(value)
113
+ hmStyle.flexDirection = FlexManager.direction(value)
179
114
  break
180
115
  }
181
116
  case 'justifyContent': {
182
- hmStyle._justifyContent = FlexManager.flexAlign(value)
117
+ hmStyle.justifyContent = FlexManager.flexAlign(value)
183
118
  break
184
119
  }
185
120
  case 'alignItems': {
186
- hmStyle._alignItems = FlexManager.itemAlign(value)
121
+ hmStyle.alignItems = FlexManager.itemAlign(value)
187
122
  break
188
123
  }
189
124
  case 'alignContent': {
190
- hmStyle._alignContent = FlexManager.flexAlign(value)
125
+ hmStyle.alignContent = FlexManager.flexAlign(value)
191
126
  break
192
127
  }
193
128
  case 'flexWrap': {
194
- hmStyle._flexWrap = FlexManager.flexWrap(value)
129
+ hmStyle.flexWrap = FlexManager.flexWrap(value)
195
130
  break
196
131
  }
197
132
  case 'width': {
198
- hmStyle._width = getUnit(value)
133
+ hmStyle.width = getUnit(value)
199
134
  break
200
135
  }
201
136
  case 'height': {
202
- hmStyle._height = getUnit(value)
137
+ hmStyle.height = getUnit(value)
203
138
  break
204
139
  }
205
140
  case 'minWidth': {
206
- hmStyle._minWidth = getUnit(value)
141
+ hmStyle.minWidth = getUnit(value)
207
142
  break
208
143
  }
209
144
  case 'minHeight': {
210
- hmStyle._minHeight = getUnit(value)
145
+ hmStyle.minHeight = getUnit(value)
211
146
  break
212
147
  }
213
148
  case 'maxWidth': {
214
- hmStyle._maxWidth = getUnit(value)
149
+ hmStyle.maxWidth = getUnit(value)
215
150
  break
216
151
  }
217
152
  case 'maxHeight': {
218
- hmStyle._maxHeight = getUnit(value)
153
+ hmStyle.maxHeight = getUnit(value)
219
154
  break
220
155
  }
221
156
  case 'background': {
@@ -223,7 +158,7 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
223
158
  break
224
159
  }
225
160
  case 'backgroundColor': {
226
- hmStyle._backgroundColor = value
161
+ hmStyle.backgroundColor = value
227
162
  break
228
163
  }
229
164
  case 'backgroundImage': {
@@ -244,146 +179,146 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
244
179
  }
245
180
  case 'border': {
246
181
  const [width, style, color] = value.split(' ')
247
- hmStyle._borderTopWidth = getUnit(width)
248
- hmStyle._borderRightWidth = getUnit(width)
249
- hmStyle._borderBottomWidth = getUnit(width)
250
- hmStyle._borderLeftWidth = getUnit(width)
251
- hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(style)
252
- hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(style)
253
- hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(style)
254
- hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(style)
255
- hmStyle._borderTopColor = color
256
- hmStyle._borderRightColor = color
257
- hmStyle._borderBottomColor = color
258
- hmStyle._borderLeftColor = color
182
+ hmStyle.borderTopWidth = getUnit(width)
183
+ hmStyle.borderRightWidth = getUnit(width)
184
+ hmStyle.borderBottomWidth = getUnit(width)
185
+ hmStyle.borderLeftWidth = getUnit(width)
186
+ hmStyle.borderTopStyle = BORDER_STYLE_MAP.get(style)
187
+ hmStyle.borderRightStyle = BORDER_STYLE_MAP.get(style)
188
+ hmStyle.borderBottomStyle = BORDER_STYLE_MAP.get(style)
189
+ hmStyle.borderLeftStyle = BORDER_STYLE_MAP.get(style)
190
+ hmStyle.borderTopColor = color
191
+ hmStyle.borderRightColor = color
192
+ hmStyle.borderBottomColor = color
193
+ hmStyle.borderLeftColor = color
259
194
  break
260
195
  }
261
196
  case 'borderTop': {
262
197
  const [width, style, color] = value.split(' ')
263
- hmStyle._borderTopWidth = getUnit(width)
264
- hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(style)
265
- hmStyle._borderTopColor = color
198
+ hmStyle.borderTopWidth = getUnit(width)
199
+ hmStyle.borderTopStyle = BORDER_STYLE_MAP.get(style)
200
+ hmStyle.borderTopColor = color
266
201
  break
267
202
  }
268
203
  case 'borderRight': {
269
204
  const [width, style, color] = value.split(' ')
270
- hmStyle._borderRightWidth = getUnit(width)
271
- hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(style)
272
- hmStyle._borderRightColor = color
205
+ hmStyle.borderRightWidth = getUnit(width)
206
+ hmStyle.borderRightStyle = BORDER_STYLE_MAP.get(style)
207
+ hmStyle.borderRightColor = color
273
208
  break
274
209
  }
275
210
  case 'borderBottom': {
276
211
  const [width, style, color] = value.split(' ')
277
- hmStyle._borderBottomWidth = getUnit(width)
278
- hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(style)
279
- hmStyle._borderBottomColor = color
212
+ hmStyle.borderBottomWidth = getUnit(width)
213
+ hmStyle.borderBottomStyle = BORDER_STYLE_MAP.get(style)
214
+ hmStyle.borderBottomColor = color
280
215
  break
281
216
  }
282
217
  case 'borderLeft': {
283
218
  const [width, style, color] = value.split(' ')
284
- hmStyle._borderLeftWidth = getUnit(width)
285
- hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(style)
286
- hmStyle._borderLeftColor = color
219
+ hmStyle.borderLeftWidth = getUnit(width)
220
+ hmStyle.borderLeftStyle = BORDER_STYLE_MAP.get(style)
221
+ hmStyle.borderLeftColor = color
287
222
  break
288
223
  }
289
224
  case 'borderWidth': {
290
- hmStyle._borderTopWidth = getUnit(value)
291
- hmStyle._borderRightWidth = getUnit(value)
292
- hmStyle._borderBottomWidth = getUnit(value)
293
- hmStyle._borderLeftWidth = getUnit(value)
225
+ hmStyle.borderTopWidth = getUnit(value)
226
+ hmStyle.borderRightWidth = getUnit(value)
227
+ hmStyle.borderBottomWidth = getUnit(value)
228
+ hmStyle.borderLeftWidth = getUnit(value)
294
229
  break
295
230
  }
296
231
  case 'borderLeftWidth': {
297
- hmStyle._borderLeftWidth = getUnit(value)
232
+ hmStyle.borderLeftWidth = getUnit(value)
298
233
  break
299
234
  }
300
235
  case 'borderRightWidth': {
301
- hmStyle._borderRightWidth = getUnit(value)
236
+ hmStyle.borderRightWidth = getUnit(value)
302
237
  break
303
238
  }
304
239
  case 'borderTopWidth': {
305
- hmStyle._borderTopWidth = getUnit(value)
240
+ hmStyle.borderTopWidth = getUnit(value)
306
241
  break
307
242
  }
308
243
  case 'borderBottomWidth': {
309
- hmStyle._borderBottomWidth = getUnit(value)
244
+ hmStyle.borderBottomWidth = getUnit(value)
310
245
  break
311
246
  }
312
247
  case 'borderStyle': {
313
- hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(value)
314
- hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(value)
315
- hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(value)
316
- hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(value)
248
+ hmStyle.borderTopStyle = BORDER_STYLE_MAP.get(value)
249
+ hmStyle.borderRightStyle = BORDER_STYLE_MAP.get(value)
250
+ hmStyle.borderBottomStyle = BORDER_STYLE_MAP.get(value)
251
+ hmStyle.borderLeftStyle = BORDER_STYLE_MAP.get(value)
317
252
  break
318
253
  }
319
254
  case 'borderLeftStyle': {
320
- hmStyle._borderLeftStyle = BORDER_STYLE_MAP.get(value)
255
+ hmStyle.borderLeftStyle = BORDER_STYLE_MAP.get(value)
321
256
  break
322
257
  }
323
258
  case 'borderRightStyle': {
324
- hmStyle._borderRightStyle = BORDER_STYLE_MAP.get(value)
259
+ hmStyle.borderRightStyle = BORDER_STYLE_MAP.get(value)
325
260
  break
326
261
  }
327
262
  case 'borderTopStyle': {
328
- hmStyle._borderTopStyle = BORDER_STYLE_MAP.get(value)
263
+ hmStyle.borderTopStyle = BORDER_STYLE_MAP.get(value)
329
264
  break
330
265
  }
331
266
  case 'borderBottomStyle': {
332
- hmStyle._borderBottomStyle = BORDER_STYLE_MAP.get(value)
267
+ hmStyle.borderBottomStyle = BORDER_STYLE_MAP.get(value)
333
268
  break
334
269
  }
335
270
  case 'borderColor': {
336
- hmStyle._borderTopColor = value
337
- hmStyle._borderRightColor = value
338
- hmStyle._borderBottomColor = value
339
- hmStyle._borderLeftColor = value
271
+ hmStyle.borderTopColor = value
272
+ hmStyle.borderRightColor = value
273
+ hmStyle.borderBottomColor = value
274
+ hmStyle.borderLeftColor = value
340
275
  break
341
276
  }
342
277
  case 'borderLeftColor': {
343
- hmStyle._borderLeftColor = value
278
+ hmStyle.borderLeftColor = value
344
279
  break
345
280
  }
346
281
  case 'borderRightColor': {
347
- hmStyle._borderRightColor = value
282
+ hmStyle.borderRightColor = value
348
283
  break
349
284
  }
350
285
  case 'borderTopColor': {
351
- hmStyle._borderTopColor = value
286
+ hmStyle.borderTopColor = value
352
287
  break
353
288
  }
354
289
  case 'borderBottomColor': {
355
- hmStyle._borderBottomColor = value
290
+ hmStyle.borderBottomColor = value
356
291
  break
357
292
  }
358
293
  case 'borderRadius': {
359
- hmStyle._borderTopLeftRadius = getUnit(value)
360
- hmStyle._borderTopRightRadius = getUnit(value)
361
- hmStyle._borderBottomLeftRadius = getUnit(value)
362
- hmStyle._borderBottomRightRadius = getUnit(value)
294
+ hmStyle.borderTopLeftRadius = getUnit(value)
295
+ hmStyle.borderTopRightRadius = getUnit(value)
296
+ hmStyle.borderBottomLeftRadius = getUnit(value)
297
+ hmStyle.borderBottomRightRadius = getUnit(value)
363
298
  break
364
299
  }
365
300
  case 'borderTopLeftRadius': {
366
- hmStyle._borderTopLeftRadius = getUnit(value)
301
+ hmStyle.borderTopLeftRadius = getUnit(value)
367
302
  break
368
303
  }
369
304
  case 'borderTopRightRadius': {
370
- hmStyle._borderTopRightRadius = getUnit(value)
305
+ hmStyle.borderTopRightRadius = getUnit(value)
371
306
  break
372
307
  }
373
308
  case 'borderBottomLeftRadius': {
374
- hmStyle._borderBottomLeftRadius = getUnit(value)
309
+ hmStyle.borderBottomLeftRadius = getUnit(value)
375
310
  break
376
311
  }
377
312
  case 'borderBottomRightRadius': {
378
- hmStyle._borderBottomRightRadius = getUnit(value)
313
+ hmStyle.borderBottomRightRadius = getUnit(value)
379
314
  break
380
315
  }
381
316
  case 'color': {
382
- hmStyle._color = value
317
+ hmStyle.color = value
383
318
  break
384
319
  }
385
320
  case 'fontSize': {
386
- hmStyle._fontSize = getUnit(value)
321
+ hmStyle.fontSize = getUnit(value)
387
322
  break
388
323
  }
389
324
  case 'fontWeight': {
@@ -393,45 +328,63 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
393
328
  case 'fontStyle': {
394
329
  switch (value) {
395
330
  case 'italic':
396
- hmStyle._fontStyle = FontStyle.Italic
331
+ hmStyle.fontStyle = FontStyle.Italic
397
332
  break
398
333
  default:
399
- hmStyle._fontStyle = FontStyle.Normal
334
+ hmStyle.fontStyle = FontStyle.Normal
400
335
  }
401
336
  break
402
337
  }
403
338
  case 'textAlign': {
404
339
  switch (value) {
405
340
  case 'left':
406
- hmStyle._textAlign = TextAlign.Start
341
+ hmStyle.textAlign = TextAlign.Start
407
342
  break
408
343
  case 'center':
409
- hmStyle._textAlign = TextAlign.Center
344
+ hmStyle.textAlign = TextAlign.Center
410
345
  break
411
346
  case 'right':
412
- hmStyle._textAlign = TextAlign.End
347
+ hmStyle.textAlign = TextAlign.End
413
348
  break
414
349
  default:
415
- hmStyle._textAlign = TextAlign.Start
350
+ hmStyle.textAlign = TextAlign.Start
351
+ break
352
+ }
353
+ break
354
+ }
355
+ case 'verticalAlign': {
356
+ switch (value) {
357
+ case 'supper':
358
+ case 'top':
359
+ case 'text-top':
360
+ hmStyle.verticalAlign = Alignment.Top
361
+ break
362
+ case 'middle':
363
+ hmStyle.verticalAlign = Alignment.Center
364
+ break
365
+ case 'sub':
366
+ case 'text-bottom':
367
+ case 'bottom':
368
+ hmStyle.verticalAlign = Alignment.Bottom
416
369
  break
417
370
  }
418
371
  break
419
372
  }
420
373
  case 'lineHeight': {
421
- hmStyle._lineHeight = getUnit(value)
374
+ hmStyle.lineHeight = getUnit(value)
422
375
  break
423
376
  }
424
377
  case 'letterSpacing': {
425
- hmStyle._letterSpacing = getUnit(value)
378
+ hmStyle.letterSpacing = getUnit(value)
426
379
  break
427
380
  }
428
381
  case 'textDecoration': {
429
382
  if (typeof value === 'string') {
430
383
  switch (value) {
431
- case 'underline': hmStyle._textDecoration = TextDecorationType.Underline; break
432
- case 'overline': hmStyle._textDecoration = TextDecorationType.Overline; break
433
- case 'line-through': hmStyle._textDecoration = TextDecorationType.LineThrough; break
434
- default: hmStyle._textDecoration = TextDecorationType.None; break
384
+ case 'underline': hmStyle.textDecoration = TextDecorationType.Underline; break
385
+ case 'overline': hmStyle.textDecoration = TextDecorationType.Overline; break
386
+ case 'line-through': hmStyle.textDecoration = TextDecorationType.LineThrough; break
387
+ default: hmStyle.textDecoration = TextDecorationType.None; break
435
388
  }
436
389
  }
437
390
  break
@@ -444,18 +397,40 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
444
397
  case 'ellipsis': overflow = TextOverflow.Ellipsis; break
445
398
  case 'marquee': overflow = TextOverflow.MARQUEE; break
446
399
  }
447
- hmStyle._textOverflow = {
400
+ hmStyle.textOverflow = {
448
401
  overflow
449
402
  }
450
403
  }
451
404
  break
452
405
  }
453
406
  case 'WebkitLineClamp': {
454
- hmStyle._WebkitLineClamp = Number(value)
407
+ hmStyle.WebkitLineClamp = Number(value)
455
408
  break
456
409
  }
457
410
  case 'transform': {
458
- hmStyle._transform = parseTransform(value)
411
+ // todo: 需要更新
412
+ // hmStyle.transform = parseTransform(value)
413
+ break
414
+ }
415
+ case 'position': {
416
+ hmStyle.position = value
417
+ break
418
+ }
419
+ case 'display': {
420
+ hmStyle.display = value
421
+ break
422
+ }
423
+ case 'zIndex': {
424
+ hmStyle.zIndex = Number(value)
425
+ break
426
+ }
427
+ case 'opacity': {
428
+ const val = Number(value)
429
+ hmStyle.opacity = Number.isNaN(val) ? 1 : val
430
+ break
431
+ }
432
+ case 'overflow': {
433
+ hmStyle.overflow = value
459
434
  break
460
435
  }
461
436
  default: {
@@ -472,20 +447,21 @@ function setBackgroundImage(hmStyle, value) {
472
447
  // 如果包含 url(),则说明是 background-image 属性
473
448
  const match = value.match(new RegExp('url\\([\'"]?(.*?)[\'"]?\\)'))
474
449
  if (match) {
475
- hmStyle._backgroundImage = [{
450
+ hmStyle.backgroundImage = {
476
451
  src: match[1]
477
- }]
452
+ }
478
453
  }
479
454
  }
455
+ // todo 渐变需要处理
480
456
  }
481
457
 
482
458
  function setBackgroundRepeat(hmStyle, value) {
483
459
  if (typeof value === 'string') {
484
460
  switch (value) {
485
- case 'repeat-x': hmStyle._backgroundRepeat = [ImageRepeat.X]; break
486
- case 'repeat-y': hmStyle._backgroundRepeat = [ImageRepeat.Y]; break
487
- case 'no-repeat': hmStyle._backgroundRepeat = [ImageRepeat.NoRepeat]; break
488
- default: hmStyle._backgroundRepeat = [ImageRepeat.XY]; break
461
+ case 'repeat-x': hmStyle.backgroundRepeat = ImageRepeat.X; break
462
+ case 'repeat-y': hmStyle.backgroundRepeat = ImageRepeat.Y; break
463
+ case 'no-repeat': hmStyle.backgroundRepeat = ImageRepeat.NoRepeat; break
464
+ default: hmStyle.backgroundRepeat = ImageRepeat.XY; break
489
465
  }
490
466
  }
491
467
  }
@@ -494,9 +470,9 @@ function setBackgroundSize(hmStyle, value) {
494
470
  if (typeof value === 'string') {
495
471
  const sizes = value.split(' ')
496
472
  if (sizes.length === 1) {
497
- hmStyle._backgroundSize = [{ width: getUnit(sizes[0]) }]
473
+ hmStyle.backgroundSize = { width: getUnit(sizes[0]) }
498
474
  } else if (sizes.length === 2) {
499
- hmStyle._backgroundSize = [{ width: getUnit(sizes[0]), height: getUnit(sizes[1]) }]
475
+ hmStyle.backgroundSize = { width: getUnit(sizes[0]), height: getUnit(sizes[1]) }
500
476
  }
501
477
  }
502
478
  }
@@ -508,28 +484,28 @@ function setBackgroundPosistion (hmStyle, value) {
508
484
  const vertical = positions[1].toLowerCase() || 'top'
509
485
 
510
486
  if (horizontal === 'left' && vertical === 'top') {
511
- hmStyle._backgroundPosition = [Alignment.TopStart]
487
+ hmStyle.backgroundPosition = Alignment.TopStart
512
488
  } else if (horizontal === 'center' && vertical === 'top') {
513
- hmStyle._backgroundPosition = [Alignment.Top]
489
+ hmStyle.backgroundPosition = Alignment.Top
514
490
  } else if (horizontal === 'right' && vertical === 'top') {
515
- hmStyle._backgroundPosition = [Alignment.TopEnd]
491
+ hmStyle.backgroundPosition = Alignment.TopEnd
516
492
  } else if (horizontal === 'left' && vertical === 'center') {
517
- hmStyle._backgroundPosition = [Alignment.Start]
493
+ hmStyle.backgroundPosition = Alignment.Start
518
494
  } else if (horizontal === 'center' && vertical === 'center') {
519
- hmStyle._backgroundPosition = [Alignment.Center]
495
+ hmStyle.backgroundPosition = Alignment.Center
520
496
  } else if (horizontal === 'right' && vertical === 'center') {
521
- hmStyle._backgroundPosition = [Alignment.End]
497
+ hmStyle.backgroundPosition = Alignment.End
522
498
  } else if (horizontal === 'left' && vertical === 'bottom') {
523
- hmStyle._backgroundPosition = [Alignment.BottomStart]
499
+ hmStyle.backgroundPosition = Alignment.BottomStart
524
500
  } else if (horizontal === 'center' && vertical === 'bottom') {
525
- hmStyle._backgroundPosition = [Alignment.Bottom]
501
+ hmStyle.backgroundPosition = Alignment.Bottom
526
502
  } else if (horizontal === 'right' && vertical === 'bottom') {
527
- hmStyle._backgroundPosition = [Alignment.BottomEnd]
503
+ hmStyle.backgroundPosition = Alignment.BottomEnd
528
504
  } else {
529
505
  if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(horizontal)) {
530
- hmStyle._backgroundPosition = [{ x: getUnit(horizontal) }]
506
+ hmStyle.backgroundPosition = { x: getUnit(horizontal) }
531
507
  if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(vertical)) {
532
- hmStyle._backgroundPosition = [{ x: getUnit(horizontal), y: getUnit(vertical) }]
508
+ hmStyle.backgroundPosition = { x: getUnit(horizontal), y: getUnit(vertical) }
533
509
  }
534
510
  }
535
511
  }
@@ -538,14 +514,15 @@ function setBackgroundPosistion (hmStyle, value) {
538
514
 
539
515
  function setFontWeight (hmStyle, value) {
540
516
  switch (value) {
541
- case 'normal': hmStyle._fontWeight = FontWeight.Normal; break
542
- case 'bold': hmStyle._fontWeight = FontWeight.Bold; break
543
- case 'bolder': hmStyle._fontWeight = FontWeight.Bolder; break
544
- case 'lighter': hmStyle._fontWeight = FontWeight.Lighter; break
545
- default: hmStyle._fontWeight = Number(value); break
517
+ case 'normal': hmStyle.fontWeight = FontWeight.Normal; break
518
+ case 'bold': hmStyle.fontWeight = FontWeight.Bold; break
519
+ case 'bolder': hmStyle.fontWeight = FontWeight.Bolder; break
520
+ case 'lighter': hmStyle.fontWeight = FontWeight.Lighter; break
521
+ default: hmStyle.fontWeight = Number(value); break
546
522
  }
547
523
  }
548
524
 
525
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
549
526
  function parseTransform(transformString) {
550
527
  const transformRegex = /(\w+)\(([^)]+)\)/g
551
528
  const transforms = []