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