@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/LICENSE +160 -0
  2. package/dist/apis/apis.ts +15 -0
  3. package/dist/apis/base/index.ts +5 -0
  4. package/dist/apis/base/system.ts +77 -0
  5. package/dist/apis/device/accelerometer.ts +76 -0
  6. package/dist/apis/device/battery.ts +24 -0
  7. package/dist/apis/device/clipboard.ts +70 -0
  8. package/dist/apis/device/index.ts +9 -0
  9. package/dist/apis/device/keyboard.ts +62 -0
  10. package/dist/apis/device/memory.ts +4 -0
  11. package/dist/apis/device/network.ts +72 -0
  12. package/dist/apis/device/phone.ts +43 -0
  13. package/dist/apis/device/screen.ts +79 -0
  14. package/dist/apis/device/vibrate.ts +24 -0
  15. package/dist/apis/files/index.ts +135 -0
  16. package/dist/apis/files/manager.ts +941 -0
  17. package/dist/apis/framework/index.ts +32 -0
  18. package/dist/apis/index.ts +124 -0
  19. package/dist/apis/location/index.ts +133 -0
  20. package/dist/apis/media/common.ts +74 -0
  21. package/dist/apis/media/image.ts +122 -0
  22. package/dist/apis/media/index.ts +3 -0
  23. package/dist/apis/media/video.ts +86 -0
  24. package/dist/apis/navigate/index.ts +8 -0
  25. package/dist/apis/network/downloadFile.ts +113 -0
  26. package/dist/apis/network/index.ts +4 -0
  27. package/dist/apis/network/request.ts +113 -0
  28. package/dist/apis/network/uploadFile.ts +158 -0
  29. package/dist/apis/network/webSocket.ts +130 -0
  30. package/dist/apis/open-api/index.ts +7 -0
  31. package/dist/apis/open-api/user-info/index.ts +85 -0
  32. package/dist/apis/page/index.ts +92 -0
  33. package/dist/apis/route/index.ts +138 -0
  34. package/dist/apis/storage/index.ts +133 -0
  35. package/dist/apis/tabbar/index.ts +147 -0
  36. package/dist/apis/ui/animation.ts +222 -0
  37. package/dist/apis/ui/background.ts +35 -0
  38. package/dist/apis/ui/index.ts +14 -0
  39. package/dist/apis/ui/interaction/index.ts +195 -0
  40. package/dist/apis/ui/navigation-bar/index.ts +33 -0
  41. package/dist/apis/ui/pull-down-refresh.ts +41 -0
  42. package/dist/apis/utils/handler.ts +116 -0
  43. package/dist/apis/utils/index.ts +85 -0
  44. package/dist/apis/utils/types.ts +12 -0
  45. package/dist/apis/utils/validate.ts +87 -0
  46. package/dist/apis/wxml/IntersectionObserver.ts +119 -0
  47. package/dist/apis/wxml/index.ts +12 -0
  48. package/dist/apis/wxml/nodesRef.ts +56 -0
  49. package/dist/apis/wxml/selectorQuery.ts +287 -0
  50. package/dist/components/components-react.js +51 -0
  51. package/dist/components/components-react.js.map +1 -0
  52. package/dist/components-harmony/button/index.css +109 -0
  53. package/dist/components-harmony/button/index.hml +31 -0
  54. package/dist/components-harmony/button/index.js +105 -0
  55. package/dist/components-harmony/camera/index.hml +6 -0
  56. package/dist/components-harmony/camera/index.js +12 -0
  57. package/dist/components-harmony/checkbox/index.hml +11 -0
  58. package/dist/components-harmony/checkbox/index.js +60 -0
  59. package/dist/components-harmony/checkbox-group/index.hml +3 -0
  60. package/dist/components-harmony/checkbox-group/index.js +22 -0
  61. package/dist/components-harmony/cover-image/index.css +4 -0
  62. package/dist/components-harmony/cover-image/index.hml +9 -0
  63. package/dist/components-harmony/cover-image/index.js +15 -0
  64. package/dist/components-harmony/form/index.hml +10 -0
  65. package/dist/components-harmony/form/index.js +11 -0
  66. package/dist/components-harmony/icon/index.css +27 -0
  67. package/dist/components-harmony/icon/index.hml +54 -0
  68. package/dist/components-harmony/icon/index.js +17 -0
  69. package/dist/components-harmony/image/index.css +5 -0
  70. package/dist/components-harmony/image/index.hml +11 -0
  71. package/dist/components-harmony/image/index.js +28 -0
  72. package/dist/components-harmony/input/index.hml +21 -0
  73. package/dist/components-harmony/input/index.js +98 -0
  74. package/dist/components-harmony/label/index.hml +3 -0
  75. package/dist/components-harmony/label/index.js +6 -0
  76. package/dist/components-harmony/navbar/index.css +56 -0
  77. package/dist/components-harmony/navbar/index.hml +9 -0
  78. package/dist/components-harmony/navbar/index.js +30 -0
  79. package/dist/components-harmony/navigator/index.css +8 -0
  80. package/dist/components-harmony/navigator/index.hml +9 -0
  81. package/dist/components-harmony/navigator/index.js +104 -0
  82. package/dist/components-harmony/picker/index.hml +25 -0
  83. package/dist/components-harmony/picker/index.js +132 -0
  84. package/dist/components-harmony/picker-view/index.hml +23 -0
  85. package/dist/components-harmony/picker-view/index.js +161 -0
  86. package/dist/components-harmony/picker-view-column/index.hml +3 -0
  87. package/dist/components-harmony/picker-view-column/index.js +3 -0
  88. package/dist/components-harmony/progress/index.css +4 -0
  89. package/dist/components-harmony/progress/index.hml +28 -0
  90. package/dist/components-harmony/progress/index.js +23 -0
  91. package/dist/components-harmony/radio/index.hml +11 -0
  92. package/dist/components-harmony/radio/index.js +41 -0
  93. package/dist/components-harmony/radio-group/index.hml +3 -0
  94. package/dist/components-harmony/radio-group/index.js +11 -0
  95. package/dist/components-harmony/rich-text/index.hml +5 -0
  96. package/dist/components-harmony/rich-text/index.js +16 -0
  97. package/dist/components-harmony/scroll-view/index.css +5 -0
  98. package/dist/components-harmony/scroll-view/index.hml +12 -0
  99. package/dist/components-harmony/scroll-view/index.js +65 -0
  100. package/dist/components-harmony/slider/index.hml +16 -0
  101. package/dist/components-harmony/slider/index.js +53 -0
  102. package/dist/components-harmony/swiper/index.css +3 -0
  103. package/dist/components-harmony/swiper/index.hml +14 -0
  104. package/dist/components-harmony/swiper/index.js +19 -0
  105. package/dist/components-harmony/switch/index.hml +7 -0
  106. package/dist/components-harmony/switch/index.js +16 -0
  107. package/dist/components-harmony/tabbar/index.css +7 -0
  108. package/dist/components-harmony/tabbar/index.hml +26 -0
  109. package/dist/components-harmony/tabbar/index.js +42 -0
  110. package/dist/components-harmony/textarea/index.hml +24 -0
  111. package/dist/components-harmony/textarea/index.js +92 -0
  112. package/dist/components-harmony/utils/index.js +41 -0
  113. package/dist/components-harmony/video/index.hml +7 -0
  114. package/dist/components-harmony/video/index.js +73 -0
  115. package/dist/components-harmony/web-view/index.hml +8 -0
  116. package/dist/components-harmony/web-view/index.js +22 -0
  117. package/dist/components-harmony-ets/base.ets +63 -0
  118. package/dist/components-harmony-ets/button.ets +119 -0
  119. package/dist/components-harmony-ets/checkbox.ets +219 -0
  120. package/dist/components-harmony-ets/element.ets +223 -0
  121. package/dist/components-harmony-ets/form.ets +149 -0
  122. package/dist/components-harmony-ets/icon.ets +84 -0
  123. package/dist/components-harmony-ets/image.ets +85 -0
  124. package/dist/components-harmony-ets/index.ts +49 -0
  125. package/dist/components-harmony-ets/innerHtml.ets +79 -0
  126. package/dist/components-harmony-ets/input.ets +195 -0
  127. package/dist/components-harmony-ets/label.ets +111 -0
  128. package/dist/components-harmony-ets/picker.ets +370 -0
  129. package/dist/components-harmony-ets/radio.ets +225 -0
  130. package/dist/components-harmony-ets/richText.ets +97 -0
  131. package/dist/components-harmony-ets/scrollView.ets +199 -0
  132. package/dist/components-harmony-ets/slider.ets +159 -0
  133. package/dist/components-harmony-ets/swiper.ets +204 -0
  134. package/dist/components-harmony-ets/switch.ets +113 -0
  135. package/dist/components-harmony-ets/text.ets +97 -0
  136. package/dist/components-harmony-ets/textArea.ets +169 -0
  137. package/dist/components-harmony-ets/utils/AttributeManager.ets +250 -0
  138. package/dist/components-harmony-ets/utils/DynamicCenter.ts +48 -0
  139. package/dist/components-harmony-ets/utils/constant/event.ets +25 -0
  140. package/dist/components-harmony-ets/utils/constant/icon.ts +19 -0
  141. package/dist/components-harmony-ets/utils/constant/style.ets +88 -0
  142. package/dist/components-harmony-ets/utils/events.ts +24 -0
  143. package/dist/components-harmony-ets/utils/flexManager.ets +107 -0
  144. package/dist/components-harmony-ets/utils/helper.ets +99 -0
  145. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +103 -0
  146. package/dist/components-harmony-ets/utils/htmlParser/index.ts +56 -0
  147. package/dist/components-harmony-ets/utils/index.ts +83 -0
  148. package/dist/components-harmony-ets/utils/styles.ets +91 -0
  149. package/dist/components-harmony-ets/video.ets +161 -0
  150. package/dist/components-harmony-ets/view.ets +79 -0
  151. package/dist/index.js +1183 -0
  152. package/dist/index.js.map +1 -0
  153. package/dist/runtime-ets/bom/document.ts +38 -0
  154. package/dist/runtime-ets/bom/getComputedStyle.ts +5 -0
  155. package/dist/runtime-ets/bom/navigator.ts +21 -0
  156. package/dist/runtime-ets/bom/raf.ts +37 -0
  157. package/dist/runtime-ets/bom/window.ts +44 -0
  158. package/dist/runtime-ets/constant.ts +29 -0
  159. package/dist/runtime-ets/current.ts +16 -0
  160. package/dist/runtime-ets/dom/class-list.ts +117 -0
  161. package/dist/runtime-ets/dom/comment.ts +10 -0
  162. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +105 -0
  163. package/dist/runtime-ets/dom/document.ts +108 -0
  164. package/dist/runtime-ets/dom/element.ts +457 -0
  165. package/dist/runtime-ets/dom/event.ts +164 -0
  166. package/dist/runtime-ets/dom/eventTarget.ts +98 -0
  167. package/dist/runtime-ets/dom/node.ts +215 -0
  168. package/dist/runtime-ets/dom/stylesheet/index.ts +687 -0
  169. package/dist/runtime-ets/dom/stylesheet/type.ts +136 -0
  170. package/dist/runtime-ets/dom/stylesheet/util.ts +134 -0
  171. package/dist/runtime-ets/dom/text.ts +19 -0
  172. package/dist/runtime-ets/index.ts +19 -0
  173. package/dist/runtime-ets/interface/event.ts +9 -0
  174. package/dist/runtime-ets/interface/index.ts +1 -0
  175. package/dist/runtime-ets/utils/bind.ts +35 -0
  176. package/dist/runtime-ets/utils/index.ts +135 -0
  177. package/dist/runtime-ets/utils/info.ts +128 -0
  178. package/dist/runtime-framework/react/app.ts +256 -0
  179. package/dist/runtime-framework/react/connect.ts +24 -0
  180. package/dist/runtime-framework/react/constant.ts +5 -0
  181. package/dist/runtime-framework/react/hooks.ts +101 -0
  182. package/dist/runtime-framework/react/index.ts +16 -0
  183. package/dist/runtime-framework/react/page.ts +263 -0
  184. package/dist/runtime-framework/react/utils/index.ts +25 -0
  185. package/dist/runtime-framework/react/utils/is.ts +46 -0
  186. package/dist/runtime-framework/solid/README.md +99 -0
  187. package/dist/runtime-framework/solid/app.ts +200 -0
  188. package/dist/runtime-framework/solid/connect.ts +11 -0
  189. package/dist/runtime-framework/solid/contant.ts +5 -0
  190. package/dist/runtime-framework/solid/hooks.ts +88 -0
  191. package/dist/runtime-framework/solid/index.ts +10 -0
  192. package/dist/runtime-framework/solid/page.ts +202 -0
  193. package/dist/runtime-framework/solid/reconciler/h.ts +132 -0
  194. package/dist/runtime-framework/solid/reconciler/index.ts +3 -0
  195. package/dist/runtime-framework/solid/reconciler/props.ts +151 -0
  196. package/dist/runtime-framework/solid/reconciler/render.ts +61 -0
  197. package/dist/runtime-framework/solid/reconciler/use.ts +8 -0
  198. package/dist/runtime-framework/solid/utils/index.ts +49 -0
  199. package/dist/runtime-framework/solid/utils/is.ts +46 -0
  200. package/dist/runtime-utils.js +4149 -0
  201. package/dist/runtime-utils.js.map +1 -0
  202. package/dist/runtime.js +4150 -0
  203. package/dist/runtime.js.map +1 -0
  204. package/dist/template/container.js +7 -0
  205. package/index.js +4 -0
  206. package/package.json +54 -0
  207. package/types/api.d.ts +4 -0
  208. package/types/component.d.ts +4 -0
  209. package/types/harmony.d.ts +11 -0
  210. package/types/runtime.d.ts +15 -0
  211. package/types/taro.d.ts +7 -0
  212. package/types/webpack-sources.d.ts +108 -0
@@ -0,0 +1,687 @@
1
+ /* eslint-disable accessor-pairs */
2
+ // @ts-nocheck
3
+ import matrix4 from '@ohos.matrix4'
4
+
5
+ import { ObjectAssign, TaroAny } from '../../'
6
+ import { FlexManager, getNodeMarginOrPaddingData, getUnit } from './util'
7
+
8
+ import type { HarmonyStyle, HarmonyType, TaroStyleType, TaroTextStyleType } from './type'
9
+
10
+ export { HarmonyStyle, HarmonyType, TaroStyleType, TaroTextStyleType }
11
+
12
+ export default class StyleSheet {
13
+
14
+ public hmStyle: HarmonyStyle = {}
15
+
16
+ get display () {
17
+ return this.hmStyle.display
18
+ }
19
+
20
+ set display (value: string) {
21
+ this.hmStyle.display = value
22
+ }
23
+
24
+ get position () {
25
+ return this.hmStyle.position
26
+ }
27
+
28
+ set position (value: string) {
29
+ this.hmStyle.position = value
30
+ }
31
+
32
+ get padding () {
33
+ const { top = 0, right = 0, bottom = 0, left = 0 } = this.hmStyle.padding || {}
34
+ return `${top} ${right} ${bottom} ${left}`
35
+ }
36
+
37
+ set padding (value: string) {
38
+ this.hmStyle.padding = getNodeMarginOrPaddingData(value)
39
+ }
40
+
41
+ set _padding (value: Margin) {
42
+ this.hmStyle.padding = value
43
+ }
44
+
45
+ get paddingTop () {
46
+ return this.hmStyle.padding?.top
47
+ }
48
+
49
+ set paddingTop (value: string) {
50
+ this.hmStyle.padding = ObjectAssign({}, this.hmStyle.padding, { top: getUnit(value) })
51
+ }
52
+
53
+ get paddingBottom () {
54
+ return this.hmStyle.padding?.bottom
55
+ }
56
+
57
+ set paddingBottom (value: string) {
58
+ this.hmStyle.padding = ObjectAssign({}, this.hmStyle.padding, { bottom: getUnit(value) })
59
+ }
60
+
61
+ get paddingRight () {
62
+ return this.hmStyle.padding?.right
63
+ }
64
+
65
+ set paddingRight (value: string) {
66
+ this.hmStyle.padding = ObjectAssign({}, this.hmStyle.padding, { right: getUnit(value) })
67
+ }
68
+
69
+ get paddingLeft () {
70
+ return this.hmStyle.padding?.left
71
+ }
72
+
73
+ set paddingLeft (value: string) {
74
+ this.hmStyle.padding = ObjectAssign({}, this.hmStyle.padding, { left: getUnit(value) })
75
+ }
76
+
77
+ get margin () {
78
+ const { top = 0, right = 0, bottom = 0, left = 0 } = this.hmStyle.margin || {}
79
+ return `${top} ${right} ${bottom} ${left}`
80
+ }
81
+
82
+ set margin (value: string) {
83
+ this.hmStyle.margin = getNodeMarginOrPaddingData(value)
84
+ }
85
+
86
+ set _margin (value: Margin) {
87
+ this.hmStyle.margin = value
88
+ }
89
+
90
+ get marginTop () {
91
+ return this.hmStyle.margin?.top
92
+ }
93
+
94
+ set marginTop (value: string) {
95
+ this.hmStyle.margin = ObjectAssign({}, this.hmStyle.margin, { top: getUnit(value) })
96
+ }
97
+
98
+ get marginBottom () {
99
+ return this.hmStyle.margin?.bottom
100
+ }
101
+
102
+ set marginBottom (value: string) {
103
+ this.hmStyle.margin = ObjectAssign({}, this.hmStyle.margin, { bottom: getUnit(value) })
104
+ }
105
+
106
+ get marginRight () {
107
+ return this.hmStyle.margin?.right
108
+ }
109
+
110
+ set marginRight (value: string) {
111
+ this.hmStyle.margin = ObjectAssign({}, this.hmStyle.margin, { right: getUnit(value) })
112
+ }
113
+
114
+ get marginLeft () {
115
+ return this.hmStyle.margin?.left
116
+ }
117
+
118
+ set marginLeft (value: string) {
119
+ this.hmStyle.margin = ObjectAssign({}, this.hmStyle.margin, { left: getUnit(value) })
120
+ }
121
+
122
+ get top () {
123
+ return this.hmStyle.top
124
+ }
125
+
126
+ set top (value: string | number) {
127
+ this.hmStyle.top = getUnit(value)
128
+ }
129
+
130
+ set _top (value: Length) {
131
+ this.hmStyle.top = value
132
+ }
133
+
134
+ get left () {
135
+ return this.hmStyle.left
136
+ }
137
+
138
+ set left (value: string | number) {
139
+ this.hmStyle.left = getUnit(value)
140
+ }
141
+
142
+ set _left (value: Length) {
143
+ this.hmStyle.left = value
144
+ }
145
+
146
+ get flexBasis () {
147
+ return this.hmStyle.flexBasis
148
+ }
149
+
150
+ set flexBasis (value: string) {
151
+ this.hmStyle.flexBasis = getUnit(value)
152
+ }
153
+
154
+ set _flexBasis (value: number | string) {
155
+ this.hmStyle.flexBasis = value
156
+ }
157
+
158
+ get flexGrow () {
159
+ return Number(this.hmStyle.flexGrow)
160
+ }
161
+
162
+ set flexGrow (value: number | string) {
163
+ this.hmStyle.flexGrow = Number(value)
164
+ }
165
+
166
+ set _flexGrow (value: number) {
167
+ this.hmStyle.flexGrow = value
168
+ }
169
+
170
+ get flexShrink () {
171
+ return Number(this.hmStyle.flexShrink)
172
+ }
173
+
174
+ set flexShrink (value: number | string) {
175
+ this.hmStyle.flexShrink = Number(value)
176
+ }
177
+
178
+ set _flexShrink (value: number) {
179
+ this.hmStyle.flexShrink = value
180
+ }
181
+
182
+ get alignSelf () {
183
+ return FlexManager.reverseItemAlign(this.hmStyle.alignSelf)
184
+ }
185
+
186
+ set alignSelf (value: string | number) {
187
+ this.hmStyle.alignSelf = FlexManager.itemAlign(value)
188
+ }
189
+
190
+ set _alignSelf (value: ItemAlign) {
191
+ this.hmStyle.alignSelf = value
192
+ }
193
+
194
+ set _flexOptions (value) {
195
+ if (typeof value.direction !== 'undefined') {
196
+ this.hmStyle.direction = value.direction
197
+ }
198
+ if (typeof value.justifyContent !== 'undefined') {
199
+ this.hmStyle.justifyContent = value.justifyContent
200
+ }
201
+ if (typeof value.alignItems !== 'undefined') {
202
+ this.hmStyle.alignItems = value.alignItems
203
+ }
204
+ }
205
+
206
+ get flexDirection () {
207
+ return FlexManager.reverseDirection(this.hmStyle.direction)
208
+ }
209
+
210
+ set flexDirection (value: string) {
211
+ this.hmStyle.direction = FlexManager.direction(value)
212
+ }
213
+
214
+ set _direction (value: FlexDirection) {
215
+ this.hmStyle.direction = value
216
+ }
217
+
218
+ get justifyContent () {
219
+ return FlexManager.reverseFlexAlign(this.hmStyle.justifyContent)
220
+ }
221
+
222
+ set justifyContent (value: string) {
223
+ this.hmStyle.justifyContent = FlexManager.flexAlign(value)
224
+ }
225
+
226
+ set _justifyContent (value: FlexAlign) {
227
+ this.hmStyle.justifyContent = value
228
+ }
229
+
230
+ get alignItems () {
231
+ return FlexManager.reverseItemAlign(this.hmStyle.alignItems)
232
+ }
233
+
234
+ set alignItems (value: string) {
235
+ this.hmStyle.alignItems = FlexManager.itemAlign(value)
236
+ }
237
+
238
+ set _alignItems (value: ItemAlign) {
239
+ this.hmStyle.alignItems = value
240
+ }
241
+
242
+ get width () {
243
+ return this.hmStyle.width
244
+ }
245
+
246
+ set width (value: string | number) {
247
+ this.hmStyle.width = getUnit(value)
248
+ }
249
+
250
+ set _width (value: Length) {
251
+ this.hmStyle.width = value
252
+ }
253
+
254
+ get height () {
255
+ return this.hmStyle.height
256
+ }
257
+
258
+ set height (value: string | number) {
259
+ this.hmStyle.height = getUnit(value)
260
+ }
261
+
262
+ set _height (value: Length) {
263
+ this.hmStyle.height = value
264
+ }
265
+
266
+ set _constraintSize(value: ConstraintSizeOptions) {
267
+ this.hmStyle.constraintSize = value
268
+ }
269
+
270
+ get minHeight () {
271
+ return this.hmStyle.constraintSize?.minHeight
272
+ }
273
+
274
+ set minHeight (value: string | number) {
275
+ this._minHeight = getUnit(value)
276
+ }
277
+
278
+ get maxHeight () {
279
+ return this.hmStyle.constraintSize?.maxHeight
280
+ }
281
+
282
+ set maxHeight (value: string | number) {
283
+ this._maxHeight = getUnit(value)
284
+ }
285
+
286
+ get minWidth () {
287
+ return this.hmStyle.constraintSize?.minWidth
288
+ }
289
+
290
+ set minWidth (value: string | number) {
291
+ this._minWidth = getUnit(value)
292
+ }
293
+
294
+ get maxWidth () {
295
+ return this.hmStyle.constraintSize?.maxWidth
296
+ }
297
+
298
+ set maxWidth (value: string | number) {
299
+ this._maxWidth = getUnit(value)
300
+ }
301
+
302
+ get background () {
303
+ return `${this.backgroundColor} ${this.backgroundImage} ${this.backgroundRepeat} ${this.backgroundSize}`.trim()
304
+ }
305
+
306
+ // TODO: 未实现
307
+ set background (value: string) {
308
+
309
+ }
310
+
311
+ set _background (value: TaroAny) {
312
+ const _backgroundImage: HarmonyType.Background.backgroundImage = value?.image?.[0]
313
+ if (_backgroundImage) {
314
+ this.hmStyle.backgroundImage = _backgroundImage.src
315
+ if (_backgroundImage.repeat) {
316
+ this.hmStyle.backgroundRepeat = _backgroundImage.repeat
317
+ }
318
+ }
319
+ this.hmStyle.backgroundImageSize = value?.size?.[0]
320
+ this.hmStyle.backgroundColor = this.hmStyle.backgroundImage ? null : value?.color
321
+ }
322
+
323
+ get backgroundColor () {
324
+ return this.hmStyle.backgroundColor
325
+ }
326
+
327
+ set backgroundColor (value: string) {
328
+ this.hmStyle.backgroundColor = value
329
+ }
330
+
331
+ get backgroundImage () {
332
+ return this.hmStyle.backgroundImage && `url(${this.hmStyle.backgroundImage})`
333
+ }
334
+
335
+ set backgroundImage (value: string) {
336
+ if (typeof value === 'string' && value.indexOf('url(') !== -1 && value.indexOf(')') !== -1) {
337
+ // 如果包含 url(),则说明是 background-image 属性
338
+ const match = value.match(new RegExp('url\\([\'"]?(.*?)[\'"]?\\)'))
339
+ if (match) {
340
+ this.hmStyle.backgroundImage = match[1]
341
+ }
342
+ }
343
+ }
344
+
345
+ get backgroundRepeat () {
346
+ if (this.hmStyle.backgroundRepeat) {
347
+ switch (this.hmStyle.backgroundRepeat) {
348
+ case ImageRepeat.X: return 'repeat-x'; break
349
+ case ImageRepeat.Y: return 'repeat-y'; break
350
+ case ImageRepeat.XY: return 'repeat'; break
351
+ case ImageRepeat.NoRepeat: return 'no-repeat'; break
352
+ }
353
+ }
354
+ }
355
+
356
+ set backgroundRepeat (value: string) {
357
+ if (typeof value === 'string') {
358
+ switch (value) {
359
+ case 'repeat-x': this.hmStyle.backgroundRepeat = ImageRepeat.X; break
360
+ case 'repeat-y': this.hmStyle.backgroundRepeat = ImageRepeat.Y; break
361
+ case 'no-repeat': this.hmStyle.backgroundRepeat = ImageRepeat.NoRepeat; break
362
+ default: this.hmStyle.backgroundRepeat = ImageRepeat.XY; break
363
+ }
364
+ }
365
+ }
366
+
367
+ get backgroundSize () {
368
+ if (this.hmStyle.backgroundImage) {
369
+ return [this.hmStyle.backgroundImageSize.width, this.hmStyle.backgroundImageSize.height].join(' ')
370
+ }
371
+ }
372
+
373
+ set backgroundSize (value: string) {
374
+ if (typeof value === 'string') {
375
+ const sizes = value.split(' ')
376
+ if (sizes.length === 1) {
377
+ this.hmStyle.backgroundImageSize = { width: getUnit(sizes[0]) }
378
+ } else if (sizes.length === 2) {
379
+ this.hmStyle.backgroundImageSize = { width: getUnit(sizes[0]), height: getUnit(sizes[1]) }
380
+ }
381
+ }
382
+ }
383
+
384
+ get border () {
385
+ return [this.borderWidth, this.borderStyle, this.bordercolor].join(' ')
386
+ }
387
+
388
+ set border (value: string) {
389
+ const [width, style, color] = value.split(' ')
390
+ this.hmStyle.borderWidth = getUnit(width)
391
+ this.hmStyle.borderStyle = BORDERhmStyleYLE_MAP.get(style)
392
+ this.hmStyle.borderColor = color
393
+ }
394
+
395
+ get borderWidth () {
396
+ return this.hmStyle.borderWidth
397
+ }
398
+
399
+ set borderWidth (value: string) {
400
+ this.hmStyle.borderWidth = getUnit(value)
401
+ }
402
+
403
+ set _borderWidth (value: Length | EdgeWidths) {
404
+ this.hmStyle.borderWidth = value
405
+ }
406
+
407
+ get borderColor () {
408
+ return this.hmStyle.borderColor
409
+ }
410
+
411
+ set borderColor (value: string) {
412
+ this.hmStyle.borderColor = value
413
+ }
414
+
415
+ set _borderColor (value: ResourceColor | EdgeColors) {
416
+ this.hmStyle.borderColor = value
417
+ }
418
+
419
+ get borderStyle () {
420
+ return BORDERhmStyleYLE_MAP.reverse(this.hmStyle.borderStyle)
421
+ }
422
+
423
+ set borderStyle (value: string) {
424
+ this.hmStyle.borderStyle = BORDERhmStyleYLE_MAP.get(value)
425
+ }
426
+
427
+ set _borderStyle (value: BorderStyle | EdgeStyles) {
428
+ this.hmStyle.borderStyle = value
429
+ }
430
+
431
+ get borderRadius () {
432
+ return this.hmStyle.borderRadius
433
+ }
434
+
435
+ set borderRadius (value: string) {
436
+ this.hmStyle.borderRadius = getUnit(value)
437
+ }
438
+
439
+ set _borderRadius (value: Length | BorderRadiuses) {
440
+ this.hmStyle.borderRadius = value
441
+ }
442
+
443
+ get zIndex (): number {
444
+ return Number(this.hmStyle.zIndex)
445
+ }
446
+
447
+ set zIndex (value: string) {
448
+ this.hmStyle.zIndex = Number(value)
449
+ }
450
+
451
+ get opacity () {
452
+ return this.hmStyle.opacity
453
+ }
454
+
455
+ set opacity (value: string) {
456
+ this.hmStyle.opacity = Number(value)
457
+ }
458
+
459
+ get overflow () {
460
+ return this.hmStyle.clip ? 'hidden' : 'visible'
461
+ }
462
+
463
+ set overflow (value: string) {
464
+ this.hmStyle.clip = value === 'hidden'
465
+ }
466
+
467
+ set _overflow (value: boolean) {
468
+ this.hmStyle.clip = value
469
+ }
470
+
471
+ get focus () {
472
+ return !!this.hmStyle.focus
473
+ }
474
+
475
+ set focus (value: boolean) {
476
+ this.hmStyle.focus = value
477
+ }
478
+
479
+ set _focus (value: boolean) {
480
+ this.hmStyle.focus = value
481
+ }
482
+
483
+ // 文本相关
484
+ get color () {
485
+ return this.hmStyle.color
486
+ }
487
+
488
+ set color (value: string) {
489
+ this.hmStyle.color = value
490
+ }
491
+
492
+ set _color (value: ResourceColor) {
493
+ this.hmStyle.color = value
494
+ }
495
+
496
+ get fontSize () {
497
+ return this.hmStyle.fontSize
498
+ }
499
+
500
+ set fontSize (value: string) {
501
+ this.hmStyle.fontSize = getUnit(value)
502
+ }
503
+
504
+ set _fontSize (value: number | string | Resource) {
505
+ this.hmStyle.fontSize = value
506
+ }
507
+
508
+ get fontWeight () {
509
+ return this.hmStyle.fontWeight
510
+ }
511
+
512
+ set fontWeight (value: string) {
513
+ this.hmStyle.fontWeight = value
514
+ }
515
+
516
+ set _fontWeight (value: number | FontWeight | string) {
517
+ this.hmStyle.fontWeight = value
518
+ }
519
+
520
+ get fontFamily () {
521
+ return this.hmStyle.fontFamily
522
+ }
523
+
524
+ set fontFamily (value: string) {
525
+ this.hmStyle.fontFamily = value
526
+ }
527
+
528
+ set _fontFamily (value: string | Resource) {
529
+ this.hmStyle.fontFamily = value
530
+ }
531
+
532
+ get textAlign () {
533
+ switch (this.hmStyle.textAlign) {
534
+ case TextAlign.End: return 'right'; break
535
+ case TextAlign.Center: return 'center'; break
536
+ case TextAlign.Start: return 'left'; break
537
+ default: return ''
538
+ }
539
+ }
540
+
541
+ set textAlign (value: string) {
542
+ switch (value) {
543
+ case 'right':
544
+ return TextAlign.End
545
+ case 'center':
546
+ return TextAlign.Center
547
+ default:
548
+ return TextAlign.Start
549
+ }
550
+ }
551
+
552
+ set _textAlign (value: TextAlign) {
553
+ this.hmStyle.textAlign = value
554
+ }
555
+
556
+ get lineHeight () {
557
+ return this.hmStyle.lineHeight
558
+ }
559
+
560
+ set lineHeight (value: string) {
561
+ this.hmStyle.lineHeight = getUnit(value)
562
+ }
563
+
564
+ set _lineHeight (value: string | number | Resource) {
565
+ this.hmStyle.lineHeight = value
566
+ }
567
+
568
+ get letterSpacing () {
569
+ return this.hmStyle.letterSpacing
570
+ }
571
+
572
+ set letterSpacing (value: string) {
573
+ this.hmStyle.letterSpacing = getUnit(value)
574
+ }
575
+
576
+ set _letterSpacing (value: number | string) {
577
+ this.hmStyle.letterSpacing = value
578
+ }
579
+
580
+ get textDecoration () {
581
+ switch (this.hmStyle.decoration) {
582
+ case TextDecorationType.Underline: return 'underline'; break
583
+ case TextDecorationType.Overline: return 'overline'; break
584
+ case TextDecorationType.LineThrough: return 'line-through'; break
585
+ case TextDecorationType.None: return 'none'; break
586
+ default: return ''
587
+ }
588
+ }
589
+
590
+ set textDecoration (value: string) {
591
+ if (typeof value === 'string') {
592
+ switch (value) {
593
+ case 'underline': this.hmStyle.decoration = TextDecorationType.Underline; break
594
+ case 'overline': this.hmStyle.decoration = TextDecorationType.Overline; break
595
+ case 'line-through': this.hmStyle.decoration = TextDecorationType.LineThrough; break
596
+ default: this.hmStyle.decoration = TextDecorationType.None; break
597
+ }
598
+ }
599
+ }
600
+
601
+ set _textDecoration (value: TextDecorationType) {
602
+ this.hmStyle.decoration = value
603
+ }
604
+
605
+ get textOverflow () {
606
+ if (this.hmStyle.textOverflow) {
607
+ switch (this.hmStyle.textOverflow.overflow) {
608
+ case TextOverflow.Clip: return 'clip'; break
609
+ case TextOverflow.Ellipsis: return 'ellipsis'; break
610
+ case TextOverflow.MARQUEE: return 'marquee'; break
611
+ default: return 'none'
612
+ }
613
+ }
614
+ }
615
+
616
+ set textOverflow (value: string) {
617
+ if (typeof value === 'string') {
618
+ let overflow = TextOverflow.None
619
+ switch (value) {
620
+ case 'clip': overflow = TextOverflow.Clip; break
621
+ case 'ellipsis': overflow = TextOverflow.Ellipsis; break
622
+ case 'marquee': overflow = TextOverflow.MARQUEE; break
623
+ }
624
+ this.hmStyle.textOverflow = {
625
+ overflow
626
+ }
627
+ }
628
+ }
629
+
630
+ set _textOverflow (value: TextOverflow) {
631
+ this.hmStyle.textOverflow = value
632
+ }
633
+
634
+ get WebkitLineClamp () {
635
+ return Number(this.hmStyle.maxLines)
636
+ }
637
+
638
+ set WebkitLineClamp (value: string | number) {
639
+ this.hmStyle.maxLines = Number(value)
640
+ }
641
+
642
+ set _WebkitLineClamp (value: number) {
643
+ this.hmStyle.maxLines = value
644
+ }
645
+
646
+ // TODO: 未实现转换为w3c
647
+ get linearGradient (): HarmonyType.LinearGradient {
648
+ return this.hmStyle.linearGradient
649
+ }
650
+
651
+ set _linearGradient (value: HarmonyType.LinearGradient[]) {
652
+ this.hmStyle.linearGradient = value?.[0]
653
+ }
654
+
655
+ get transform () {
656
+ return this.hmStyle.transform
657
+ }
658
+
659
+ set _tranform (value: HarmonyType.Transform.Transform) {
660
+ this.hmStyle.transform = value
661
+ }
662
+ }
663
+
664
+
665
+ class BORDERhmStyleYLE_MAP {
666
+ static solid = BorderStyle.Solid
667
+ static dotted = BorderStyle.Dotted
668
+ static dashed = BorderStyle.Dashed
669
+
670
+ static get(type: string): BorderStyle {
671
+ switch (type) {
672
+ case 'dotted': return BorderStyle.Dotted
673
+ case 'dashed': return BorderStyle.Dashed
674
+ default: return BorderStyle.Solid
675
+ }
676
+ }
677
+
678
+ static reverse(type: BorderStyle): string {
679
+ switch (type) {
680
+ case BorderStyle.Dotted: return 'dotted'
681
+ case BorderStyle.Dashed: return 'dashed'
682
+ case BorderStyle.Solid: return 'solid'
683
+ default: return ''
684
+ }
685
+
686
+ }
687
+ }