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