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