@tarojs/plugin-platform-harmony-ets 4.0.0-beta.17 → 4.0.0-beta.19
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/components-harmony-ets/button.ets +32 -29
- package/dist/components-harmony-ets/checkbox.ets +2 -2
- package/dist/components-harmony-ets/form.ets +28 -25
- package/dist/components-harmony-ets/icon.ets +18 -16
- package/dist/components-harmony-ets/image.ets +13 -11
- package/dist/components-harmony-ets/innerHtml.ets +1 -1
- package/dist/components-harmony-ets/input.ets +1 -1
- package/dist/components-harmony-ets/label.ets +39 -36
- package/dist/components-harmony-ets/movableArea.ets +1 -1
- package/dist/components-harmony-ets/movableView.ets +1 -1
- package/dist/components-harmony-ets/picker.ets +1 -1
- package/dist/components-harmony-ets/progress.ets +1 -1
- package/dist/components-harmony-ets/pseudo.ets +20 -19
- package/dist/components-harmony-ets/radio.ets +2 -2
- package/dist/components-harmony-ets/richText.ets +10 -31
- package/dist/components-harmony-ets/scrollView.ets +54 -43
- package/dist/components-harmony-ets/slider.ets +1 -1
- package/dist/components-harmony-ets/style.ets +40 -6
- package/dist/components-harmony-ets/swiper.ets +19 -17
- package/dist/components-harmony-ets/switch.ets +1 -1
- package/dist/components-harmony-ets/text.ets +13 -10
- package/dist/components-harmony-ets/textArea.ets +1 -1
- package/dist/components-harmony-ets/utils/index.ts +54 -1
- package/dist/components-harmony-ets/utils/styles.ets +8 -2
- package/dist/components-harmony-ets/video.ets +3 -1
- package/dist/components-harmony-ets/view.ets +38 -27
- package/dist/components-harmony-ets/webView.ets +34 -33
- package/dist/index.d.ts +149 -0
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/dom/cssNesting.ts +24 -37
- package/dist/runtime-ets/dom/element/element.ts +2 -10
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +19 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +13 -0
- package/dist/runtime-ets/dom/stylesheet/type.ts +11 -3
- package/dist/runtime-ets/dom/stylesheet/util.ts +17 -10
- package/dist/runtime-utils.d.ts +825 -0
- package/dist/runtime.d.ts +1 -0
- package/index.js +3 -1
- package/package.json +8 -8
- package/types/index.d.ts +4 -0
|
@@ -68,7 +68,7 @@ function depthTraversal(root: ReactElement) {
|
|
|
68
68
|
|
|
69
69
|
const traverse = (tree) => {
|
|
70
70
|
const result: Record<string, TMapping> = {}
|
|
71
|
-
if (tree && tree.props
|
|
71
|
+
if (tree && tree.props) {
|
|
72
72
|
// 后代选择器
|
|
73
73
|
const descendant_map = {
|
|
74
74
|
children: {},
|
|
@@ -115,6 +115,14 @@ function depthTraversal(root: ReactElement) {
|
|
|
115
115
|
|
|
116
116
|
const processLeaf = (leaf, descendant_map: TMappingNode) => {
|
|
117
117
|
if (!leaf) return
|
|
118
|
+
|
|
119
|
+
// 如果是个数组
|
|
120
|
+
if (leaf instanceof Array) {
|
|
121
|
+
for (let i = 0; i < leaf.length; i++) {
|
|
122
|
+
processLeaf(leaf[i], descendant_map)
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
118
126
|
const leaf_map = traverse(leaf)
|
|
119
127
|
if (!leaf_map) return
|
|
120
128
|
// 直接后代
|
|
@@ -125,7 +133,7 @@ function depthTraversal(root: ReactElement) {
|
|
|
125
133
|
for (let i = 0; i < keys.length; i++) {
|
|
126
134
|
const leaf_child_map = class_mapping[keys[i]]
|
|
127
135
|
if (leaf_child_map) {
|
|
128
|
-
Object.assign(descendant_map.descendants, leaf_child_map.
|
|
136
|
+
Object.assign(descendant_map.descendants, leaf_child_map.descendants)
|
|
129
137
|
}
|
|
130
138
|
}
|
|
131
139
|
}
|
|
@@ -180,44 +188,23 @@ function combineStyle(nestingStyle: NestingStyle, class_mapping: TMapping, alias
|
|
|
180
188
|
return []
|
|
181
189
|
}
|
|
182
190
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
let
|
|
189
|
-
|
|
190
|
-
if (ele
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (Object.isFrozen(ele)) {
|
|
196
|
-
ele = unfreeze(ele)
|
|
197
|
-
selectors_elements[i].node = ele
|
|
198
|
-
}
|
|
191
|
+
if (nestingStyle && nestingStyle instanceof Array) {
|
|
192
|
+
// 合并样式
|
|
193
|
+
nestingStyle.forEach(({ selectors, declaration }) => {
|
|
194
|
+
// 获取选中的节点列表
|
|
195
|
+
const selectors_elements = findSelector(selectors, class_mapping)
|
|
196
|
+
for (let i = 0; i < selectors_elements.length; i++) {
|
|
197
|
+
const ele = selectors_elements[i].node
|
|
198
|
+
if (ele) {
|
|
199
|
+
if (ele.props.style) {
|
|
200
|
+
Object.assign(ele.props.style, declaration)
|
|
201
|
+
} else {
|
|
202
|
+
ele.props.style = declaration
|
|
199
203
|
}
|
|
200
|
-
ele.props.style = declaration
|
|
201
204
|
}
|
|
202
205
|
}
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// dev模式下解冻props,使其可以对props进行操作
|
|
208
|
-
function unfreeze(object) {
|
|
209
|
-
const oo: any = {}
|
|
210
|
-
Object.keys(object).forEach(property => {
|
|
211
|
-
if (property === 'props') {
|
|
212
|
-
oo.props = {
|
|
213
|
-
...object.props,
|
|
214
|
-
style: {}
|
|
215
|
-
}
|
|
216
|
-
} else {
|
|
217
|
-
oo[property] = object[property]
|
|
218
|
-
}
|
|
219
|
-
})
|
|
220
|
-
return oo
|
|
206
|
+
})
|
|
207
|
+
}
|
|
221
208
|
}
|
|
222
209
|
|
|
223
210
|
// 合并嵌套样式
|
|
@@ -174,11 +174,7 @@ export class TaroElement<T extends StandardProps = StandardProps> extends TaroNo
|
|
|
174
174
|
|
|
175
175
|
// 伪类,不存在style动态设置,均已被转换为鸿蒙样式
|
|
176
176
|
// TODO:可根据实际情况,迁移到具体的组件中,如View、ScrollView中,Text\Image其实是不需要的
|
|
177
|
-
public _pseudo_before: StyleSheet | null
|
|
178
|
-
|
|
179
|
-
public get pseudo_before () {
|
|
180
|
-
return this._pseudo_before?.hmStyle
|
|
181
|
-
}
|
|
177
|
+
public _pseudo_before: StyleSheet | null = null
|
|
182
178
|
|
|
183
179
|
public set_pseudo_before (value: HarmonyStyle | null) {
|
|
184
180
|
if (value) {
|
|
@@ -193,11 +189,7 @@ export class TaroElement<T extends StandardProps = StandardProps> extends TaroNo
|
|
|
193
189
|
}
|
|
194
190
|
}
|
|
195
191
|
|
|
196
|
-
public _pseudo_after: StyleSheet | null
|
|
197
|
-
|
|
198
|
-
public get pseudo_after () {
|
|
199
|
-
return this._pseudo_after?.hmStyle
|
|
200
|
-
}
|
|
192
|
+
public _pseudo_after: StyleSheet | null = null
|
|
201
193
|
|
|
202
194
|
public set_pseudo_after (value: HarmonyStyle | null) {
|
|
203
195
|
if (value) {
|
|
@@ -70,6 +70,7 @@ export const WEB_STYLE_MAP = {
|
|
|
70
70
|
fontWeight: ['_fontWeight'],
|
|
71
71
|
fontStyle: ['_fontStyle'],
|
|
72
72
|
textAlign: ['_textAlign'],
|
|
73
|
+
verticalAlign: ['_align'],
|
|
73
74
|
lineHeight: ['_lineHeight'],
|
|
74
75
|
letterSpacing: ['_letterSpacing'],
|
|
75
76
|
textDecoration: ['_textDecoration'],
|
|
@@ -419,6 +420,24 @@ export default function convertWebStyle2HmStyle(webStyle: CSSProperties) {
|
|
|
419
420
|
}
|
|
420
421
|
break
|
|
421
422
|
}
|
|
423
|
+
case 'verticalAlign': {
|
|
424
|
+
switch (value) {
|
|
425
|
+
case 'supper':
|
|
426
|
+
case 'top':
|
|
427
|
+
case 'text-top':
|
|
428
|
+
hmStyle._align = Alignment.Top
|
|
429
|
+
break
|
|
430
|
+
case 'middle':
|
|
431
|
+
hmStyle._align = Alignment.Center
|
|
432
|
+
break
|
|
433
|
+
case 'sub':
|
|
434
|
+
case 'text-bottom':
|
|
435
|
+
case 'bottom':
|
|
436
|
+
hmStyle._align = Alignment.Bottom
|
|
437
|
+
break
|
|
438
|
+
}
|
|
439
|
+
break
|
|
440
|
+
}
|
|
422
441
|
case 'lineHeight': {
|
|
423
442
|
hmStyle._lineHeight = getUnit(value)
|
|
424
443
|
break
|
|
@@ -578,6 +578,19 @@ export default class StyleSheet {
|
|
|
578
578
|
this.hmStyle.textAlign = value
|
|
579
579
|
}
|
|
580
580
|
|
|
581
|
+
get verticalAlign() {
|
|
582
|
+
switch (this.hmStyle.verticalAlign) {
|
|
583
|
+
case Alignment.Center: return 'middle'; break
|
|
584
|
+
case Alignment.Top: return 'top'; break
|
|
585
|
+
case Alignment.Bottom: return 'bottom'; break
|
|
586
|
+
default: return ''
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
set _align (value: string) {
|
|
591
|
+
this.hmStyle.verticalAlign = value
|
|
592
|
+
}
|
|
593
|
+
|
|
581
594
|
get lineHeight () {
|
|
582
595
|
return this.hmStyle.lineHeight
|
|
583
596
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import matrix4 from '@ohos.matrix4'
|
|
2
|
+
// import matrix4 from '@ohos.matrix4'
|
|
3
3
|
|
|
4
4
|
export interface HarmonyStyle extends TaroStyleType {
|
|
5
5
|
textAlign?: TextAlign
|
|
6
6
|
textOverflow?: HarmonyType.Overflow
|
|
7
7
|
WebkitLineClamp?: number
|
|
8
8
|
letterSpacing?: number | string
|
|
9
|
+
verticalAlign?: Alignment
|
|
10
|
+
lineHeight?: Length
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export interface TaroStyleType {
|
|
@@ -89,7 +91,6 @@ export interface TaroStyleType {
|
|
|
89
91
|
fontStyle?: FontStyle
|
|
90
92
|
fontWeight?: number | FontWeight | string
|
|
91
93
|
fontFamily?: string | Resource
|
|
92
|
-
lineHeight?: string | number | Resource
|
|
93
94
|
textDecoration?: TextDecorationType
|
|
94
95
|
|
|
95
96
|
// gradient
|
|
@@ -108,6 +109,8 @@ export interface TaroTextStyleType {
|
|
|
108
109
|
textOverflow?: HarmonyType.Overflow
|
|
109
110
|
WebkitLineClamp?: number
|
|
110
111
|
letterSpacing?: number | string
|
|
112
|
+
verticalAlign?: Alignment
|
|
113
|
+
lineHeight?: string | number | Resource
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
export namespace HarmonyType {
|
|
@@ -167,6 +170,11 @@ export namespace HarmonyType {
|
|
|
167
170
|
centerX?: number | string
|
|
168
171
|
centerY?: number | string
|
|
169
172
|
}
|
|
170
|
-
export type Transform = matrix4.Matrix4Transit
|
|
173
|
+
// export type Transform = matrix4.Matrix4Transit
|
|
174
|
+
export type Transform = {
|
|
175
|
+
Translate?: Translate
|
|
176
|
+
Scale?: Scale
|
|
177
|
+
Rotate?: Rotate
|
|
178
|
+
}
|
|
171
179
|
}
|
|
172
180
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
import matrix4 from '@ohos.matrix4'
|
|
2
|
+
// import matrix4 from '@ohos.matrix4'
|
|
3
3
|
import { isNumber } from '@tarojs/shared'
|
|
4
4
|
|
|
5
5
|
import { convertNumber2VP } from '../../'
|
|
@@ -235,16 +235,23 @@ export function getUnit (val) {
|
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
export function getTransform(transform) {
|
|
238
|
+
// if (transform) {
|
|
239
|
+
// return transform.reduce((res, item) => {
|
|
240
|
+
// switch (item.type) {
|
|
241
|
+
// case 'Translate': return res.translate(item.value)
|
|
242
|
+
// case 'Scale': return res.scale(item.value)
|
|
243
|
+
// case 'Rotate': return res.rotate(item.value)
|
|
244
|
+
// case 'Matrix': return res.combine(matrix4.init(item.value))
|
|
245
|
+
// }
|
|
246
|
+
// return res
|
|
247
|
+
// }, matrix4.identity())
|
|
248
|
+
// }
|
|
249
|
+
const result = {}
|
|
238
250
|
if (transform) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
case 'Rotate': return res.rotate(item.value)
|
|
244
|
-
case 'Matrix': return res.combine(matrix4.init(item.value))
|
|
245
|
-
}
|
|
246
|
-
return res
|
|
247
|
-
}, matrix4.identity())
|
|
251
|
+
transform.forEach((item) => {
|
|
252
|
+
result[item.type] = item.value
|
|
253
|
+
})
|
|
254
|
+
return result
|
|
248
255
|
}
|
|
249
256
|
}
|
|
250
257
|
|