@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.
- package/dist/apis/base/system.ts +53 -20
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +3 -1
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +124 -60
- package/dist/apis/wxml/IntersectionObserver.ts +5 -3
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/components-harmony-ets/button.ets +41 -78
- package/dist/components-harmony-ets/checkbox.ets +19 -209
- package/dist/components-harmony-ets/form.ets +38 -160
- package/dist/components-harmony-ets/icon.ets +31 -83
- package/dist/components-harmony-ets/image.ets +22 -78
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +10 -67
- package/dist/components-harmony-ets/label.ets +52 -173
- package/dist/components-harmony-ets/movableArea.ets +89 -0
- package/dist/components-harmony-ets/movableView.ets +67 -0
- package/dist/components-harmony-ets/picker.ets +32 -147
- package/dist/components-harmony-ets/progress.ets +47 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +19 -210
- package/dist/components-harmony-ets/richText.ets +22 -102
- package/dist/components-harmony-ets/scrollView.ets +66 -169
- package/dist/components-harmony-ets/slider.ets +10 -72
- package/dist/components-harmony-ets/style.ets +244 -0
- package/dist/components-harmony-ets/swiper.ets +30 -87
- package/dist/components-harmony-ets/switch.ets +9 -71
- package/dist/components-harmony-ets/text.ets +38 -89
- package/dist/components-harmony-ets/textArea.ets +10 -67
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +1 -1
- package/dist/components-harmony-ets/utils/flexManager.ets +8 -7
- package/dist/components-harmony-ets/utils/helper.ets +5 -4
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/index.ts +55 -2
- package/dist/components-harmony-ets/utils/styles.ets +45 -85
- package/dist/components-harmony-ets/video.ets +33 -88
- package/dist/components-harmony-ets/view.ets +47 -160
- package/dist/components-harmony-ets/webView.ets +44 -99
- package/dist/index.d.ts +151 -0
- package/dist/index.js +58 -29
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/window.ts +4 -2
- package/dist/runtime-ets/current.ts +2 -0
- package/dist/runtime-ets/dom/bind.ts +0 -1
- package/dist/runtime-ets/dom/cssNesting.ts +311 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +15 -40
- package/dist/runtime-ets/dom/document.ts +21 -8
- package/dist/runtime-ets/dom/element/element.ts +53 -9
- package/dist/runtime-ets/dom/element/form.ts +11 -4
- package/dist/runtime-ets/dom/element/index.ts +12 -1
- package/dist/runtime-ets/dom/element/movableArea.ts +12 -0
- package/dist/runtime-ets/dom/element/movableView.ts +193 -0
- package/dist/runtime-ets/dom/element/normal.ts +8 -3
- package/dist/runtime-ets/dom/element/progress.ts +13 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -0
- package/dist/runtime-ets/dom/element/video.ts +1 -0
- package/dist/runtime-ets/dom/element/webView.ts +8 -0
- package/dist/runtime-ets/dom/event.ts +0 -1
- package/dist/runtime-ets/dom/eventTarget.ts +0 -3
- package/dist/runtime-ets/dom/node.ts +18 -17
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +184 -207
- package/dist/runtime-ets/dom/stylesheet/index.ts +28 -308
- package/dist/runtime-ets/dom/stylesheet/type.ts +18 -6
- package/dist/runtime-ets/dom/stylesheet/util.ts +19 -15
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/utils/index.ts +24 -9
- package/dist/runtime-framework/react/app.ts +5 -1
- package/dist/runtime-framework/react/hooks.ts +3 -3
- package/dist/runtime-framework/react/native-page.ts +14 -9
- package/dist/runtime-framework/react/page.ts +1 -0
- package/dist/runtime-framework/solid/hooks.ts +3 -3
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +825 -0
- package/dist/runtime-utils.js +185 -91
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +185 -91
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +10 -10
- package/types/index.d.ts +4 -0
- 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.
|
|
89
|
-
hmStyle.
|
|
90
|
-
hmStyle.
|
|
91
|
-
hmStyle.
|
|
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.
|
|
22
|
+
hmStyle.paddingTop = getUnit(value)
|
|
96
23
|
break
|
|
97
24
|
}
|
|
98
25
|
case 'paddingBottom': {
|
|
99
|
-
hmStyle.
|
|
26
|
+
hmStyle.paddingBottom = getUnit(value)
|
|
100
27
|
break
|
|
101
28
|
}
|
|
102
29
|
case 'paddingLeft': {
|
|
103
|
-
hmStyle.
|
|
30
|
+
hmStyle.paddingLeft = getUnit(value)
|
|
104
31
|
break
|
|
105
32
|
}
|
|
106
33
|
case 'paddingRight': {
|
|
107
|
-
hmStyle.
|
|
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.
|
|
113
|
-
hmStyle.
|
|
114
|
-
hmStyle.
|
|
115
|
-
hmStyle.
|
|
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.
|
|
46
|
+
hmStyle.marginTop = getUnit(value)
|
|
120
47
|
break
|
|
121
48
|
}
|
|
122
49
|
case 'marginBottom': {
|
|
123
|
-
hmStyle.
|
|
50
|
+
hmStyle.marginBottom = getUnit(value)
|
|
124
51
|
break
|
|
125
52
|
}
|
|
126
53
|
case 'marginLeft': {
|
|
127
|
-
hmStyle.
|
|
54
|
+
hmStyle.marginLeft = getUnit(value)
|
|
128
55
|
break
|
|
129
56
|
}
|
|
130
57
|
case 'marginRight': {
|
|
131
|
-
hmStyle.
|
|
58
|
+
hmStyle.marginRight = getUnit(value)
|
|
132
59
|
break
|
|
133
60
|
}
|
|
134
61
|
case 'top': {
|
|
135
|
-
hmStyle.
|
|
62
|
+
hmStyle.top = getUnit(value)
|
|
136
63
|
break
|
|
137
64
|
}
|
|
138
65
|
case 'left': {
|
|
139
|
-
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)
|
|
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.
|
|
157
|
-
hmStyle.
|
|
158
|
-
hmStyle.
|
|
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.
|
|
97
|
+
hmStyle.flexGrow = getUnit(value)
|
|
163
98
|
break
|
|
164
99
|
}
|
|
165
100
|
case 'flexShrink': {
|
|
166
|
-
hmStyle.
|
|
101
|
+
hmStyle.flexShrink = Number(value)
|
|
167
102
|
break
|
|
168
103
|
}
|
|
169
104
|
case 'flexBasis': {
|
|
170
|
-
hmStyle.
|
|
105
|
+
hmStyle.flexBasis = Number(value)
|
|
171
106
|
break
|
|
172
107
|
}
|
|
173
108
|
case 'alignSelf': {
|
|
174
|
-
hmStyle.
|
|
109
|
+
hmStyle.alignSelf = FlexManager.itemAlign(value)
|
|
175
110
|
break
|
|
176
111
|
}
|
|
177
112
|
case 'flexDirection': {
|
|
178
|
-
hmStyle.
|
|
113
|
+
hmStyle.flexDirection = FlexManager.direction(value)
|
|
179
114
|
break
|
|
180
115
|
}
|
|
181
116
|
case 'justifyContent': {
|
|
182
|
-
hmStyle.
|
|
117
|
+
hmStyle.justifyContent = FlexManager.flexAlign(value)
|
|
183
118
|
break
|
|
184
119
|
}
|
|
185
120
|
case 'alignItems': {
|
|
186
|
-
hmStyle.
|
|
121
|
+
hmStyle.alignItems = FlexManager.itemAlign(value)
|
|
187
122
|
break
|
|
188
123
|
}
|
|
189
124
|
case 'alignContent': {
|
|
190
|
-
hmStyle.
|
|
125
|
+
hmStyle.alignContent = FlexManager.flexAlign(value)
|
|
191
126
|
break
|
|
192
127
|
}
|
|
193
128
|
case 'flexWrap': {
|
|
194
|
-
hmStyle.
|
|
129
|
+
hmStyle.flexWrap = FlexManager.flexWrap(value)
|
|
195
130
|
break
|
|
196
131
|
}
|
|
197
132
|
case 'width': {
|
|
198
|
-
hmStyle.
|
|
133
|
+
hmStyle.width = getUnit(value)
|
|
199
134
|
break
|
|
200
135
|
}
|
|
201
136
|
case 'height': {
|
|
202
|
-
hmStyle.
|
|
137
|
+
hmStyle.height = getUnit(value)
|
|
203
138
|
break
|
|
204
139
|
}
|
|
205
140
|
case 'minWidth': {
|
|
206
|
-
hmStyle.
|
|
141
|
+
hmStyle.minWidth = getUnit(value)
|
|
207
142
|
break
|
|
208
143
|
}
|
|
209
144
|
case 'minHeight': {
|
|
210
|
-
hmStyle.
|
|
145
|
+
hmStyle.minHeight = getUnit(value)
|
|
211
146
|
break
|
|
212
147
|
}
|
|
213
148
|
case 'maxWidth': {
|
|
214
|
-
hmStyle.
|
|
149
|
+
hmStyle.maxWidth = getUnit(value)
|
|
215
150
|
break
|
|
216
151
|
}
|
|
217
152
|
case 'maxHeight': {
|
|
218
|
-
hmStyle.
|
|
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.
|
|
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.
|
|
248
|
-
hmStyle.
|
|
249
|
-
hmStyle.
|
|
250
|
-
hmStyle.
|
|
251
|
-
hmStyle.
|
|
252
|
-
hmStyle.
|
|
253
|
-
hmStyle.
|
|
254
|
-
hmStyle.
|
|
255
|
-
hmStyle.
|
|
256
|
-
hmStyle.
|
|
257
|
-
hmStyle.
|
|
258
|
-
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
|
|
259
194
|
break
|
|
260
195
|
}
|
|
261
196
|
case 'borderTop': {
|
|
262
197
|
const [width, style, color] = value.split(' ')
|
|
263
|
-
hmStyle.
|
|
264
|
-
hmStyle.
|
|
265
|
-
hmStyle.
|
|
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.
|
|
271
|
-
hmStyle.
|
|
272
|
-
hmStyle.
|
|
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.
|
|
278
|
-
hmStyle.
|
|
279
|
-
hmStyle.
|
|
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.
|
|
285
|
-
hmStyle.
|
|
286
|
-
hmStyle.
|
|
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.
|
|
291
|
-
hmStyle.
|
|
292
|
-
hmStyle.
|
|
293
|
-
hmStyle.
|
|
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.
|
|
232
|
+
hmStyle.borderLeftWidth = getUnit(value)
|
|
298
233
|
break
|
|
299
234
|
}
|
|
300
235
|
case 'borderRightWidth': {
|
|
301
|
-
hmStyle.
|
|
236
|
+
hmStyle.borderRightWidth = getUnit(value)
|
|
302
237
|
break
|
|
303
238
|
}
|
|
304
239
|
case 'borderTopWidth': {
|
|
305
|
-
hmStyle.
|
|
240
|
+
hmStyle.borderTopWidth = getUnit(value)
|
|
306
241
|
break
|
|
307
242
|
}
|
|
308
243
|
case 'borderBottomWidth': {
|
|
309
|
-
hmStyle.
|
|
244
|
+
hmStyle.borderBottomWidth = getUnit(value)
|
|
310
245
|
break
|
|
311
246
|
}
|
|
312
247
|
case 'borderStyle': {
|
|
313
|
-
hmStyle.
|
|
314
|
-
hmStyle.
|
|
315
|
-
hmStyle.
|
|
316
|
-
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)
|
|
317
252
|
break
|
|
318
253
|
}
|
|
319
254
|
case 'borderLeftStyle': {
|
|
320
|
-
hmStyle.
|
|
255
|
+
hmStyle.borderLeftStyle = BORDER_STYLE_MAP.get(value)
|
|
321
256
|
break
|
|
322
257
|
}
|
|
323
258
|
case 'borderRightStyle': {
|
|
324
|
-
hmStyle.
|
|
259
|
+
hmStyle.borderRightStyle = BORDER_STYLE_MAP.get(value)
|
|
325
260
|
break
|
|
326
261
|
}
|
|
327
262
|
case 'borderTopStyle': {
|
|
328
|
-
hmStyle.
|
|
263
|
+
hmStyle.borderTopStyle = BORDER_STYLE_MAP.get(value)
|
|
329
264
|
break
|
|
330
265
|
}
|
|
331
266
|
case 'borderBottomStyle': {
|
|
332
|
-
hmStyle.
|
|
267
|
+
hmStyle.borderBottomStyle = BORDER_STYLE_MAP.get(value)
|
|
333
268
|
break
|
|
334
269
|
}
|
|
335
270
|
case 'borderColor': {
|
|
336
|
-
hmStyle.
|
|
337
|
-
hmStyle.
|
|
338
|
-
hmStyle.
|
|
339
|
-
hmStyle.
|
|
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.
|
|
278
|
+
hmStyle.borderLeftColor = value
|
|
344
279
|
break
|
|
345
280
|
}
|
|
346
281
|
case 'borderRightColor': {
|
|
347
|
-
hmStyle.
|
|
282
|
+
hmStyle.borderRightColor = value
|
|
348
283
|
break
|
|
349
284
|
}
|
|
350
285
|
case 'borderTopColor': {
|
|
351
|
-
hmStyle.
|
|
286
|
+
hmStyle.borderTopColor = value
|
|
352
287
|
break
|
|
353
288
|
}
|
|
354
289
|
case 'borderBottomColor': {
|
|
355
|
-
hmStyle.
|
|
290
|
+
hmStyle.borderBottomColor = value
|
|
356
291
|
break
|
|
357
292
|
}
|
|
358
293
|
case 'borderRadius': {
|
|
359
|
-
hmStyle.
|
|
360
|
-
hmStyle.
|
|
361
|
-
hmStyle.
|
|
362
|
-
hmStyle.
|
|
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.
|
|
301
|
+
hmStyle.borderTopLeftRadius = getUnit(value)
|
|
367
302
|
break
|
|
368
303
|
}
|
|
369
304
|
case 'borderTopRightRadius': {
|
|
370
|
-
hmStyle.
|
|
305
|
+
hmStyle.borderTopRightRadius = getUnit(value)
|
|
371
306
|
break
|
|
372
307
|
}
|
|
373
308
|
case 'borderBottomLeftRadius': {
|
|
374
|
-
hmStyle.
|
|
309
|
+
hmStyle.borderBottomLeftRadius = getUnit(value)
|
|
375
310
|
break
|
|
376
311
|
}
|
|
377
312
|
case 'borderBottomRightRadius': {
|
|
378
|
-
hmStyle.
|
|
313
|
+
hmStyle.borderBottomRightRadius = getUnit(value)
|
|
379
314
|
break
|
|
380
315
|
}
|
|
381
316
|
case 'color': {
|
|
382
|
-
hmStyle.
|
|
317
|
+
hmStyle.color = value
|
|
383
318
|
break
|
|
384
319
|
}
|
|
385
320
|
case 'fontSize': {
|
|
386
|
-
hmStyle.
|
|
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.
|
|
331
|
+
hmStyle.fontStyle = FontStyle.Italic
|
|
397
332
|
break
|
|
398
333
|
default:
|
|
399
|
-
hmStyle.
|
|
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.
|
|
341
|
+
hmStyle.textAlign = TextAlign.Start
|
|
407
342
|
break
|
|
408
343
|
case 'center':
|
|
409
|
-
hmStyle.
|
|
344
|
+
hmStyle.textAlign = TextAlign.Center
|
|
410
345
|
break
|
|
411
346
|
case 'right':
|
|
412
|
-
hmStyle.
|
|
347
|
+
hmStyle.textAlign = TextAlign.End
|
|
413
348
|
break
|
|
414
349
|
default:
|
|
415
|
-
hmStyle.
|
|
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.
|
|
374
|
+
hmStyle.lineHeight = getUnit(value)
|
|
422
375
|
break
|
|
423
376
|
}
|
|
424
377
|
case 'letterSpacing': {
|
|
425
|
-
hmStyle.
|
|
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.
|
|
432
|
-
case 'overline': hmStyle.
|
|
433
|
-
case 'line-through': hmStyle.
|
|
434
|
-
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
|
|
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.
|
|
400
|
+
hmStyle.textOverflow = {
|
|
448
401
|
overflow
|
|
449
402
|
}
|
|
450
403
|
}
|
|
451
404
|
break
|
|
452
405
|
}
|
|
453
406
|
case 'WebkitLineClamp': {
|
|
454
|
-
hmStyle.
|
|
407
|
+
hmStyle.WebkitLineClamp = Number(value)
|
|
455
408
|
break
|
|
456
409
|
}
|
|
457
410
|
case 'transform': {
|
|
458
|
-
|
|
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.
|
|
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.
|
|
486
|
-
case 'repeat-y': hmStyle.
|
|
487
|
-
case 'no-repeat': hmStyle.
|
|
488
|
-
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
|
|
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.
|
|
473
|
+
hmStyle.backgroundSize = { width: getUnit(sizes[0]) }
|
|
498
474
|
} else if (sizes.length === 2) {
|
|
499
|
-
hmStyle.
|
|
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.
|
|
487
|
+
hmStyle.backgroundPosition = Alignment.TopStart
|
|
512
488
|
} else if (horizontal === 'center' && vertical === 'top') {
|
|
513
|
-
hmStyle.
|
|
489
|
+
hmStyle.backgroundPosition = Alignment.Top
|
|
514
490
|
} else if (horizontal === 'right' && vertical === 'top') {
|
|
515
|
-
hmStyle.
|
|
491
|
+
hmStyle.backgroundPosition = Alignment.TopEnd
|
|
516
492
|
} else if (horizontal === 'left' && vertical === 'center') {
|
|
517
|
-
hmStyle.
|
|
493
|
+
hmStyle.backgroundPosition = Alignment.Start
|
|
518
494
|
} else if (horizontal === 'center' && vertical === 'center') {
|
|
519
|
-
hmStyle.
|
|
495
|
+
hmStyle.backgroundPosition = Alignment.Center
|
|
520
496
|
} else if (horizontal === 'right' && vertical === 'center') {
|
|
521
|
-
hmStyle.
|
|
497
|
+
hmStyle.backgroundPosition = Alignment.End
|
|
522
498
|
} else if (horizontal === 'left' && vertical === 'bottom') {
|
|
523
|
-
hmStyle.
|
|
499
|
+
hmStyle.backgroundPosition = Alignment.BottomStart
|
|
524
500
|
} else if (horizontal === 'center' && vertical === 'bottom') {
|
|
525
|
-
hmStyle.
|
|
501
|
+
hmStyle.backgroundPosition = Alignment.Bottom
|
|
526
502
|
} else if (horizontal === 'right' && vertical === 'bottom') {
|
|
527
|
-
hmStyle.
|
|
503
|
+
hmStyle.backgroundPosition = Alignment.BottomEnd
|
|
528
504
|
} else {
|
|
529
505
|
if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(horizontal)) {
|
|
530
|
-
hmStyle.
|
|
506
|
+
hmStyle.backgroundPosition = { x: getUnit(horizontal) }
|
|
531
507
|
if (/^\d+(\.\d+)?(px|%|vw|vh)$/.test(vertical)) {
|
|
532
|
-
hmStyle.
|
|
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.
|
|
542
|
-
case 'bold': hmStyle.
|
|
543
|
-
case 'bolder': hmStyle.
|
|
544
|
-
case 'lighter': hmStyle.
|
|
545
|
-
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
|
|
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 = []
|