@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.10
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/apis.ts +6 -2
- package/dist/apis/base/crypto.ts +4 -0
- package/dist/apis/base/debug.ts +5 -0
- package/dist/apis/base/index.ts +9 -1
- package/dist/apis/base/performance.ts +8 -0
- package/dist/apis/base/system.ts +74 -21
- package/dist/apis/base/update.ts +5 -0
- package/dist/apis/base/weapp/app-event.ts +75 -0
- package/dist/apis/base/weapp/life-cycle.ts +21 -0
- package/dist/apis/canvas/index.ts +27 -0
- package/dist/apis/data-analysis/index.ts +6 -0
- package/dist/apis/device/accelerometer.ts +2 -1
- package/dist/apis/device/accessibility.ts +4 -0
- package/dist/apis/device/battery.ts +2 -2
- package/dist/apis/device/bluetooth-ble.ts +19 -0
- package/dist/apis/device/bluetooth-peripheral.ts +6 -0
- package/dist/apis/device/bluetooth.ts +16 -0
- package/dist/apis/device/calendar.ts +5 -0
- package/dist/apis/device/clipboard.ts +17 -9
- package/dist/apis/device/compass.ts +21 -0
- package/dist/apis/device/contact.ts +5 -0
- package/dist/apis/device/crypto.ts +4 -0
- package/dist/apis/device/gyroscope.ts +7 -0
- package/dist/apis/device/iBeacon.ts +10 -0
- package/dist/apis/device/index.ts +15 -0
- package/dist/apis/device/keyboard.ts +2 -1
- package/dist/apis/device/memory.ts +10 -3
- package/dist/apis/device/motion.ts +6 -0
- package/dist/apis/device/network.ts +26 -9
- package/dist/apis/device/nfc.ts +10 -0
- package/dist/apis/device/phone.ts +2 -1
- package/dist/apis/device/scan.ts +4 -0
- package/dist/apis/device/screen.ts +2 -1
- package/dist/apis/device/sms.ts +4 -0
- package/dist/apis/device/vibrate.ts +19 -11
- package/dist/apis/device/wifi.ts +15 -0
- package/dist/apis/ext/index.ts +5 -0
- package/dist/apis/files/index.ts +2 -1
- package/dist/apis/files/manager.ts +2 -1
- package/dist/apis/framework/index.ts +3 -8
- package/dist/apis/index.ts +27 -17
- package/dist/apis/location/index.ts +61 -68
- package/dist/apis/media/EditorContext.ts +32 -0
- package/dist/apis/media/audio/index.ts +18 -0
- package/dist/apis/media/background-audio/index.ts +16 -0
- package/dist/apis/media/camera.ts +16 -0
- package/dist/apis/media/common.ts +2 -1
- package/dist/apis/media/{image.ts → image/index.ts} +4 -3
- package/dist/apis/media/index.ts +10 -0
- package/dist/apis/media/live.ts +5 -0
- package/dist/apis/media/map.ts +4 -0
- package/dist/apis/media/media-recorder.ts +4 -0
- package/dist/apis/media/recorder.ts +6 -0
- package/dist/apis/media/video/VideoContext.ts +68 -0
- package/dist/apis/media/{video.ts → video/index.ts} +13 -2
- package/dist/apis/media/video-decoder.ts +4 -0
- package/dist/apis/media/video-processing.ts +4 -0
- package/dist/apis/media/voip.ts +19 -0
- package/dist/apis/network/index.ts +3 -0
- package/dist/apis/network/mdns.ts +13 -0
- package/dist/apis/network/request.ts +7 -6
- package/dist/apis/network/tcp.ts +4 -0
- package/dist/apis/network/udp.ts +4 -0
- package/dist/apis/network/webSocket.ts +2 -6
- package/dist/apis/open-api/account.ts +4 -0
- package/dist/apis/open-api/address.ts +4 -0
- package/dist/apis/open-api/authorize.ts +5 -0
- package/dist/apis/open-api/card.ts +5 -0
- package/dist/apis/open-api/channels-live.ts +11 -0
- package/dist/apis/open-api/customer-service.ts +4 -0
- package/dist/apis/open-api/device-voip.ts +5 -0
- package/dist/apis/open-api/facial.ts +7 -0
- package/dist/apis/open-api/favorites.ts +5 -0
- package/dist/apis/open-api/group.ts +4 -0
- package/dist/apis/open-api/index.ts +20 -6
- package/dist/apis/open-api/invoice.ts +5 -0
- package/dist/apis/open-api/license-plate.ts +4 -0
- package/dist/apis/open-api/login.ts +6 -0
- package/dist/apis/open-api/my-miniprogram.ts +4 -0
- package/dist/apis/open-api/privacy.ts +7 -0
- package/dist/apis/open-api/red-package.ts +4 -0
- package/dist/apis/open-api/settings.ts +5 -0
- package/dist/apis/open-api/soter.ts +6 -0
- package/dist/apis/open-api/subscribe-message.ts +6 -0
- package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
- package/dist/apis/open-api/werun.ts +5 -0
- package/dist/apis/payment/index.ts +6 -0
- package/dist/apis/route/index.ts +19 -28
- package/dist/apis/share/index.ts +33 -0
- package/dist/apis/storage/background-fetch.ts +7 -0
- package/dist/apis/storage/cache-manager.ts +4 -0
- package/dist/apis/storage/index.ts +158 -88
- package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
- package/dist/apis/ui/animation/index.ts +7 -0
- package/dist/apis/ui/background.ts +4 -19
- package/dist/apis/ui/custom-component.ts +8 -0
- package/dist/apis/ui/fonts.ts +4 -0
- package/dist/apis/ui/index.ts +8 -10
- package/dist/apis/ui/interaction/index.ts +45 -59
- package/dist/apis/ui/menu.ts +4 -0
- package/dist/apis/ui/navigation-bar/index.ts +60 -21
- package/dist/apis/ui/pull-down-refresh.ts +10 -4
- package/dist/apis/{page → ui/scroll}/index.ts +32 -27
- package/dist/apis/ui/sticky.ts +4 -0
- package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
- package/dist/apis/ui/window.ts +20 -0
- package/dist/apis/utils/handler.ts +4 -4
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/worker/index.ts +4 -0
- package/dist/apis/wxml/IntersectionObserver.ts +24 -25
- package/dist/apis/wxml/index.ts +7 -2
- package/dist/apis/wxml/nodesRef.ts +2 -2
- package/dist/apis/wxml/selectorQuery.ts +29 -17
- package/dist/components-harmony-ets/button.ets +106 -80
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +82 -148
- package/dist/components-harmony-ets/form.ets +45 -132
- package/dist/components-harmony-ets/icon.ets +66 -69
- package/dist/components-harmony-ets/image.ets +26 -61
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +7 -70
- package/dist/components-harmony-ets/input.ets +60 -146
- package/dist/components-harmony-ets/label.ets +86 -92
- package/dist/components-harmony-ets/listView.ets +26 -0
- package/dist/components-harmony-ets/movableArea.ets +124 -0
- package/dist/components-harmony-ets/movableView.ets +93 -0
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +172 -198
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +85 -155
- package/dist/components-harmony-ets/richText.ets +15 -87
- package/dist/components-harmony-ets/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +81 -149
- package/dist/components-harmony-ets/slider.ets +47 -94
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +396 -0
- package/dist/components-harmony-ets/swiper.ets +51 -151
- package/dist/components-harmony-ets/switch.ets +35 -76
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +131 -76
- package/dist/components-harmony-ets/textArea.ets +64 -140
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
- package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
- package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
- package/dist/components-harmony-ets/utils/helper.ets +18 -65
- 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 +55 -51
- package/dist/components-harmony-ets/utils/styles.ets +177 -65
- package/dist/components-harmony-ets/video.ets +70 -116
- package/dist/components-harmony-ets/view.ets +58 -64
- package/dist/components-harmony-ets/webView.ets +56 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +230 -60
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +9 -2
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +96 -0
- package/dist/runtime-ets/dom/class-list.ts +4 -6
- package/dist/runtime-ets/dom/comment.ts +1 -2
- package/dist/runtime-ets/dom/cssNesting.ts +409 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
- package/dist/runtime-ets/dom/dataSource.ts +64 -0
- package/dist/runtime-ets/dom/document.ts +36 -51
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +439 -0
- package/dist/runtime-ets/dom/element/form.ts +403 -0
- package/dist/runtime-ets/dom/element/index.ts +120 -0
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +242 -0
- package/dist/runtime-ets/dom/element/normal.ts +103 -0
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
- package/dist/runtime-ets/dom/element/text.ts +10 -0
- package/dist/runtime-ets/dom/element/video.ts +50 -0
- package/dist/runtime-ets/dom/element/webView.ts +68 -0
- package/dist/runtime-ets/dom/event.ts +26 -5
- package/dist/runtime-ets/dom/eventTarget.ts +3 -3
- package/dist/runtime-ets/dom/node.ts +114 -49
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
- package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
- package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
- package/dist/runtime-ets/index.ts +2 -3
- package/dist/runtime-ets/interface/event.ts +3 -2
- package/dist/runtime-ets/utils/index.ts +87 -17
- package/dist/runtime-ets/utils/info.ts +21 -47
- package/dist/runtime-framework/react/app.ts +20 -28
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +1 -2
- package/dist/runtime-framework/react/native-page.ts +421 -0
- package/dist/runtime-framework/react/page.ts +5 -17
- 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 +17 -12
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -36
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- 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 +1633 -549
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +1633 -549
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- 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
- package/types/harmony.d.ts +4 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +7 -1
- package/LICENSE +0 -160
- package/dist/components-harmony-ets/base.ets +0 -63
- package/dist/components-harmony-ets/element.ets +0 -223
- package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
- package/dist/runtime-ets/dom/element.ts +0 -457
- package/dist/runtime-ets/dom/text.ts +0 -19
- package/dist/runtime-ets/utils/bind.ts +0 -35
- package/types/api.d.ts +0 -4
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,56 +1,97 @@
|
|
|
1
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
// import matrix4 from '@ohos.matrix4'
|
|
2
3
|
|
|
3
4
|
export interface HarmonyStyle extends TaroStyleType {
|
|
4
5
|
textAlign?: TextAlign
|
|
5
6
|
textOverflow?: HarmonyType.Overflow
|
|
6
|
-
|
|
7
|
+
WebkitLineClamp?: number
|
|
8
|
+
whiteSpace?: string
|
|
7
9
|
letterSpacing?: number | string
|
|
10
|
+
verticalAlign?: Alignment
|
|
11
|
+
lineHeight?: Length
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
export interface TaroStyleType {
|
|
11
15
|
id?: string
|
|
12
16
|
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
paddingTop?: Length
|
|
18
|
+
paddingRight?: Length
|
|
19
|
+
paddingBottom?: Length
|
|
20
|
+
paddingLeft?: Length
|
|
21
|
+
|
|
22
|
+
marginTop?: Length
|
|
23
|
+
marginRight?: Length
|
|
24
|
+
marginBottom?: Length
|
|
25
|
+
marginLeft?: Length
|
|
26
|
+
|
|
15
27
|
width?: Length
|
|
16
28
|
height?: Length
|
|
17
|
-
|
|
29
|
+
|
|
30
|
+
minHeight?: Length
|
|
31
|
+
maxHeight?: Length
|
|
32
|
+
minWidth?: Length
|
|
33
|
+
maxWidth?: Length
|
|
18
34
|
|
|
19
35
|
display?: 'flex' | 'block' | 'none'
|
|
36
|
+
visibility?: 'visible' | 'hidden'
|
|
20
37
|
|
|
21
38
|
// position
|
|
22
39
|
position?: 'relative' | 'absolute' | 'fixed'
|
|
23
40
|
top?: Length
|
|
24
41
|
left?: Length
|
|
42
|
+
bottom?: Length
|
|
43
|
+
right?: Length
|
|
25
44
|
|
|
26
45
|
// flex
|
|
27
46
|
flexBasis?: number | string
|
|
28
47
|
flexGrow?: number
|
|
29
48
|
flexShrink?: number
|
|
30
49
|
alignSelf?: ItemAlign
|
|
31
|
-
|
|
50
|
+
flexDirection?: FlexDirection
|
|
32
51
|
justifyContent?: FlexAlign
|
|
33
52
|
alignItems?: ItemAlign
|
|
34
|
-
|
|
53
|
+
flexWrap?: FlexWrap
|
|
35
54
|
alignContent?: FlexAlign
|
|
36
55
|
|
|
37
56
|
// background
|
|
38
57
|
backgroundColor?: ResourceColor
|
|
39
|
-
backgroundImage?:
|
|
58
|
+
backgroundImage?: HarmonyType.Background.BackgroundImage
|
|
40
59
|
backgroundRepeat?: ImageRepeat
|
|
41
|
-
|
|
60
|
+
backgroundSize?: SizeOptions | ImageSize
|
|
61
|
+
backgroundPosition?: Position | Alignment
|
|
62
|
+
|
|
63
|
+
// 渐变
|
|
64
|
+
linearGradient?: HarmonyType.LinearGradient
|
|
65
|
+
radialGradient?: HarmonyType.RadialGradient
|
|
42
66
|
|
|
43
67
|
// transform
|
|
44
68
|
rotate?: HarmonyType.Transform.Rotate
|
|
45
69
|
translate?: HarmonyType.Transform.Translate
|
|
46
70
|
scale?: HarmonyType.Transform.Scale
|
|
47
71
|
transform?: HarmonyType.Transform.Transform
|
|
72
|
+
transformOrigin?: HarmonyType.Transform.Origin
|
|
48
73
|
|
|
49
74
|
// border
|
|
50
75
|
borderWidth?: Length | EdgeWidths
|
|
76
|
+
borderLeftWidth?: Length
|
|
77
|
+
borderRightWidth?: Length
|
|
78
|
+
borderTopWidth?: Length
|
|
79
|
+
borderBottomWidth?: Length
|
|
51
80
|
borderColor?: ResourceColor | EdgeColors
|
|
81
|
+
borderLeftColor?: ResourceColor
|
|
82
|
+
borderRightColor?: ResourceColor
|
|
83
|
+
borderTopColor?: ResourceColor
|
|
84
|
+
borderBottomColor?: ResourceColor
|
|
52
85
|
borderStyle?: BorderStyle | EdgeStyles
|
|
86
|
+
borderLeftStyle?: BorderStyle
|
|
87
|
+
borderRightStyle?: BorderStyle
|
|
88
|
+
borderTopStyle?: BorderStyle
|
|
89
|
+
borderBottomStyle?: BorderStyle
|
|
53
90
|
borderRadius?: Length | BorderRadiuses
|
|
91
|
+
borderTopLeftRadius?: Length
|
|
92
|
+
borderTopRightRadius?: Length
|
|
93
|
+
borderBottomLeftRadius?: Length
|
|
94
|
+
borderBottomRightRadius?: Length
|
|
54
95
|
|
|
55
96
|
// text
|
|
56
97
|
color?: ResourceColor
|
|
@@ -58,24 +99,45 @@ export interface TaroStyleType {
|
|
|
58
99
|
fontStyle?: FontStyle
|
|
59
100
|
fontWeight?: number | FontWeight | string
|
|
60
101
|
fontFamily?: string | Resource
|
|
61
|
-
|
|
62
|
-
|
|
102
|
+
textDecoration?: {
|
|
103
|
+
type: TextDecorationType
|
|
104
|
+
}
|
|
63
105
|
|
|
64
|
-
//
|
|
65
|
-
|
|
106
|
+
// animation
|
|
107
|
+
animationName?: {
|
|
108
|
+
percentage: number
|
|
109
|
+
event: TaroStyleType
|
|
110
|
+
}[]
|
|
111
|
+
animationDuration?: number
|
|
112
|
+
animationTimingFunction?: string
|
|
113
|
+
animationDelay?: number
|
|
114
|
+
animationIterationCount?: number
|
|
115
|
+
|
|
116
|
+
// shadow
|
|
117
|
+
boxShadow?: {
|
|
118
|
+
radius: number
|
|
119
|
+
color?: string
|
|
120
|
+
offsetX?: number
|
|
121
|
+
offsetY?: number
|
|
122
|
+
fill?: boolean
|
|
123
|
+
}
|
|
66
124
|
|
|
67
125
|
// other
|
|
68
126
|
opacity?: number | Resource
|
|
69
127
|
zIndex?: number
|
|
70
|
-
|
|
128
|
+
overflow?: string
|
|
71
129
|
focus?: boolean
|
|
130
|
+
content?: string
|
|
72
131
|
}
|
|
73
132
|
|
|
74
133
|
export interface TaroTextStyleType {
|
|
75
134
|
textAlign?: TextAlign
|
|
76
135
|
textOverflow?: HarmonyType.Overflow
|
|
77
|
-
|
|
136
|
+
WebkitLineClamp?: number
|
|
137
|
+
whiteSpace?: string
|
|
78
138
|
letterSpacing?: number | string
|
|
139
|
+
verticalAlign?: Alignment
|
|
140
|
+
lineHeight?: string | number | Resource
|
|
79
141
|
}
|
|
80
142
|
|
|
81
143
|
export namespace HarmonyType {
|
|
@@ -90,6 +152,12 @@ export namespace HarmonyType {
|
|
|
90
152
|
colors: Array<[ResourceColor, number]>
|
|
91
153
|
repeating?: boolean
|
|
92
154
|
}
|
|
155
|
+
export interface RadialGradient {
|
|
156
|
+
center: any
|
|
157
|
+
radius: number | string
|
|
158
|
+
colors: Array<[ResourceColor, number]>
|
|
159
|
+
repeating?: boolean
|
|
160
|
+
}
|
|
93
161
|
export interface Overflow {
|
|
94
162
|
overflow: TextOverflow
|
|
95
163
|
}
|
|
@@ -108,6 +176,10 @@ export namespace HarmonyType {
|
|
|
108
176
|
export type backgroundImagePosition = Position | Alignment
|
|
109
177
|
}
|
|
110
178
|
export namespace Transform {
|
|
179
|
+
export interface Origin {
|
|
180
|
+
x?: number
|
|
181
|
+
y?: number
|
|
182
|
+
}
|
|
111
183
|
export interface Rotate {
|
|
112
184
|
x?: number
|
|
113
185
|
y?: number
|
|
@@ -130,7 +202,11 @@ export namespace HarmonyType {
|
|
|
130
202
|
centerX?: number | string
|
|
131
203
|
centerY?: number | string
|
|
132
204
|
}
|
|
133
|
-
export type Transform = matrix4.Matrix4Transit
|
|
205
|
+
// export type Transform = matrix4.Matrix4Transit
|
|
206
|
+
export type Transform = {
|
|
207
|
+
Translate?: Translate
|
|
208
|
+
Scale?: Scale
|
|
209
|
+
Rotate?: Rotate
|
|
210
|
+
}
|
|
134
211
|
}
|
|
135
212
|
}
|
|
136
|
-
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
+
// import matrix4 from '@ohos.matrix4'
|
|
2
3
|
import { isNumber } from '@tarojs/shared'
|
|
3
4
|
|
|
4
5
|
import { convertNumber2VP } from '../../'
|
|
5
6
|
|
|
6
7
|
export class FlexManager {
|
|
7
|
-
|
|
8
8
|
static flexAlign (value: string | number | undefined): FlexAlign {
|
|
9
9
|
switch (value) {
|
|
10
10
|
case 'flex-end':
|
|
@@ -22,6 +22,25 @@ export class FlexManager {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
+
static reverseFlexAlign (value: FlexAlign): string {
|
|
26
|
+
switch (value) {
|
|
27
|
+
case FlexAlign.Start:
|
|
28
|
+
return 'flex-start'
|
|
29
|
+
case FlexAlign.End:
|
|
30
|
+
return 'flex-end'
|
|
31
|
+
case FlexAlign.Center:
|
|
32
|
+
return 'center'
|
|
33
|
+
case FlexAlign.SpaceBetween:
|
|
34
|
+
return 'space-between'
|
|
35
|
+
case FlexAlign.SpaceAround:
|
|
36
|
+
return 'space-around'
|
|
37
|
+
case FlexAlign.SpaceEvenly:
|
|
38
|
+
return 'space-evenly'
|
|
39
|
+
default:
|
|
40
|
+
return ''
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
25
44
|
static direction (value: string): FlexDirection {
|
|
26
45
|
switch (value) {
|
|
27
46
|
case 'row': return FlexDirection.Row
|
|
@@ -31,6 +50,16 @@ export class FlexManager {
|
|
|
31
50
|
}
|
|
32
51
|
}
|
|
33
52
|
|
|
53
|
+
static reverseDirection (value: FlexDirection): string {
|
|
54
|
+
switch (value) {
|
|
55
|
+
case FlexDirection.Row: return 'row'
|
|
56
|
+
case FlexDirection.RowReverse: return 'row-reverse'
|
|
57
|
+
case FlexDirection.Column: return 'column'
|
|
58
|
+
case FlexDirection.ColumnReverse: return 'column-reverse'
|
|
59
|
+
default: return ''
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
34
63
|
static itemAlign (value: string | number | undefined): ItemAlign {
|
|
35
64
|
switch (value) {
|
|
36
65
|
case 'flex-start':
|
|
@@ -48,6 +77,25 @@ export class FlexManager {
|
|
|
48
77
|
}
|
|
49
78
|
}
|
|
50
79
|
|
|
80
|
+
static reverseItemAlign (value: ItemAlign): string {
|
|
81
|
+
switch (value) {
|
|
82
|
+
case ItemAlign.Start:
|
|
83
|
+
return 'flex-start'
|
|
84
|
+
case ItemAlign.End:
|
|
85
|
+
return 'flex-end'
|
|
86
|
+
case ItemAlign.Center:
|
|
87
|
+
return 'center'
|
|
88
|
+
case ItemAlign.Stretch:
|
|
89
|
+
return 'stretch'
|
|
90
|
+
case ItemAlign.Baseline:
|
|
91
|
+
return 'baseline'
|
|
92
|
+
case ItemAlign.Auto:
|
|
93
|
+
return 'auto'
|
|
94
|
+
default:
|
|
95
|
+
return ''
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
51
99
|
static justifyContent (value: string): FlexAlign {
|
|
52
100
|
return FlexManager.flexAlign(value)
|
|
53
101
|
}
|
|
@@ -61,7 +109,29 @@ export class FlexManager {
|
|
|
61
109
|
}
|
|
62
110
|
|
|
63
111
|
static flexWrap (value: string): FlexWrap {
|
|
64
|
-
|
|
112
|
+
switch (value) {
|
|
113
|
+
case 'nowrap':
|
|
114
|
+
return FlexWrap.NoWrap
|
|
115
|
+
case 'wrap':
|
|
116
|
+
return FlexWrap.Wrap
|
|
117
|
+
case 'wrap-reverse':
|
|
118
|
+
return FlexWrap.WrapReverse
|
|
119
|
+
default:
|
|
120
|
+
return FlexWrap.NoWrap
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static reverseFlexWrap (value: FlexWrap): string {
|
|
125
|
+
switch (value) {
|
|
126
|
+
case FlexWrap.NoWrap:
|
|
127
|
+
return 'nowrap'
|
|
128
|
+
case FlexWrap.Wrap:
|
|
129
|
+
return 'wrap'
|
|
130
|
+
case FlexWrap.WrapReverse:
|
|
131
|
+
return 'wrap-reverse'
|
|
132
|
+
default:
|
|
133
|
+
return 'nowrap'
|
|
134
|
+
}
|
|
65
135
|
}
|
|
66
136
|
|
|
67
137
|
static alignContent (style: Record<string, string | number> = {}): FlexAlign | undefined {
|
|
@@ -93,42 +163,100 @@ export class FlexManager {
|
|
|
93
163
|
}
|
|
94
164
|
}
|
|
95
165
|
|
|
166
|
+
export class BORDER_STYLE_MAP {
|
|
167
|
+
static solid = BorderStyle.Solid
|
|
168
|
+
static dotted = BorderStyle.Dotted
|
|
169
|
+
static dashed = BorderStyle.Dashed
|
|
170
|
+
|
|
171
|
+
static get(type: string): BorderStyle {
|
|
172
|
+
switch (type) {
|
|
173
|
+
case 'dotted': return BorderStyle.Dotted
|
|
174
|
+
case 'dashed': return BorderStyle.Dashed
|
|
175
|
+
default: return BorderStyle.Solid
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
static reverse(type: BorderStyle): string {
|
|
180
|
+
switch (type) {
|
|
181
|
+
case BorderStyle.Dotted: return 'dotted'
|
|
182
|
+
case BorderStyle.Dashed: return 'dashed'
|
|
183
|
+
case BorderStyle.Solid: return 'solid'
|
|
184
|
+
default: return ''
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
96
189
|
export function getNodeMarginOrPaddingData (dataValue: string) {
|
|
97
190
|
let res: any = {}
|
|
98
191
|
if (dataValue) {
|
|
99
|
-
const values = dataValue.trim().split(new RegExp('\\s+'))
|
|
192
|
+
const values = dataValue.toString().trim().split(new RegExp('\\s+'))
|
|
193
|
+
let val1: string
|
|
194
|
+
let val2: string
|
|
100
195
|
switch (values.length) {
|
|
101
196
|
case 1:
|
|
102
|
-
|
|
197
|
+
val1 = getUnit(values[0])
|
|
198
|
+
res = { top: val1, right: val1, bottom: val1, left: val1 }
|
|
103
199
|
break
|
|
104
200
|
case 2:
|
|
105
|
-
|
|
201
|
+
val1 = getUnit(values[0])
|
|
202
|
+
val2 = getUnit(values[1])
|
|
203
|
+
res = { top: val1, right: val2, bottom: val1, left: val2 }
|
|
106
204
|
break
|
|
107
205
|
case 3:
|
|
108
|
-
|
|
206
|
+
val2 = getUnit(values[1])
|
|
207
|
+
res = { top: getUnit(values[0]), right: val2, bottom: getUnit(values[2]), left: val2 }
|
|
109
208
|
break
|
|
110
209
|
case 4:
|
|
111
|
-
res = { top: values[0], right: values[1], bottom: values[2], left: values[3] }
|
|
210
|
+
res = { top: getUnit(values[0]), right: getUnit(values[1]), bottom: getUnit(values[2]), left: getUnit(values[3]) }
|
|
112
211
|
break
|
|
113
212
|
default:
|
|
114
213
|
break
|
|
115
214
|
}
|
|
116
|
-
Object.keys(res).forEach(key => {
|
|
117
|
-
const exec = `${res[key]}`.match(/(\d+)(px)$/)
|
|
118
|
-
if (exec && values.length > 1) {
|
|
119
|
-
res[key] = getUnit(+exec[1])
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
215
|
}
|
|
123
216
|
return res
|
|
124
217
|
}
|
|
125
218
|
|
|
126
|
-
|
|
127
219
|
export function getUnit (val) {
|
|
128
|
-
|
|
220
|
+
// 空的字符串代表 Reconciler remove 了这个 prop,不进行后面的逻辑了
|
|
221
|
+
if (val === '') return val
|
|
222
|
+
|
|
223
|
+
if (/\d+(vp|px)$/.test(val)) {
|
|
129
224
|
return val
|
|
130
|
-
} else if (isNumber(val)
|
|
131
|
-
return
|
|
225
|
+
} else if (isNumber(val)) {
|
|
226
|
+
return parseFloat(val) + 'px'
|
|
227
|
+
}
|
|
228
|
+
if (val) {
|
|
229
|
+
// 匹配vw\vh
|
|
230
|
+
const exec = val.match(/(-?\d*(\.\d+)?)(vw|vh)$/)
|
|
231
|
+
if (exec) {
|
|
232
|
+
const [, num, , unit] = exec
|
|
233
|
+
return convertNumber2VP(parseFloat(num), unit)
|
|
234
|
+
}
|
|
132
235
|
}
|
|
133
236
|
return val
|
|
134
237
|
}
|
|
238
|
+
|
|
239
|
+
export function getTransform(transform) {
|
|
240
|
+
// if (transform) {
|
|
241
|
+
// return transform.reduce((res, item) => {
|
|
242
|
+
// switch (item.type) {
|
|
243
|
+
// case 'Translate': return res.translate(item.value)
|
|
244
|
+
// case 'Scale': return res.scale(item.value)
|
|
245
|
+
// case 'Rotate': return res.rotate(item.value)
|
|
246
|
+
// case 'Matrix': return res.combine(matrix4.init(item.value))
|
|
247
|
+
// }
|
|
248
|
+
// return res
|
|
249
|
+
// }, matrix4.identity())
|
|
250
|
+
// }
|
|
251
|
+
const result = {}
|
|
252
|
+
if (transform) {
|
|
253
|
+
transform.forEach((item) => {
|
|
254
|
+
result[item.type] = item.value
|
|
255
|
+
})
|
|
256
|
+
return result
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export function capitalizeFirstLetter (str: string) {
|
|
261
|
+
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
262
|
+
}
|
|
@@ -9,11 +9,10 @@ export * from './bom/window'
|
|
|
9
9
|
export * from './dom/element'
|
|
10
10
|
export * from './dom/event'
|
|
11
11
|
export * from './dom/node'
|
|
12
|
-
export * from './dom/text'
|
|
13
12
|
export * from './dom/stylesheet'
|
|
13
|
+
export * from './dom/cssNesting'
|
|
14
14
|
export * from './interface'
|
|
15
15
|
export * from './utils'
|
|
16
|
-
export * from './utils/bind'
|
|
17
16
|
export * from './utils/info'
|
|
18
|
-
export { URLSearchParams, eventSource } from '@tarojs/runtime/dist/runtime.esm'
|
|
17
|
+
export { URL, URLSearchParams, eventSource, Events } from '@tarojs/runtime/dist/runtime.esm'
|
|
19
18
|
export { hooks } from '@tarojs/shared'
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _display from '@ohos.display'
|
|
2
|
+
import { getSystemInfoSync, pxTransformHelper } from '@tarojs/taro'
|
|
2
3
|
|
|
3
4
|
import { NodeType } from '../dom/node'
|
|
5
|
+
import convertWebStyle2HmStyle from '../dom/stylesheet/covertWeb2Hm'
|
|
4
6
|
|
|
5
7
|
import type { CSSProperties } from 'react'
|
|
6
|
-
import type { TaroElement } from '../dom/element'
|
|
8
|
+
import type { TaroElement } from '../dom/element/element'
|
|
7
9
|
import type { TaroNode } from '../dom/node'
|
|
8
10
|
|
|
11
|
+
const display = _display.getDefaultDisplaySync()
|
|
12
|
+
|
|
9
13
|
export function isElement (node: TaroNode): node is TaroElement {
|
|
10
14
|
return node.nodeType === NodeType.ELEMENT_NODE
|
|
11
15
|
}
|
|
@@ -18,7 +22,6 @@ export function isElement (node: TaroNode): node is TaroElement {
|
|
|
18
22
|
export function isParentBinded (node: TaroElement | null, type: string): boolean {
|
|
19
23
|
let res = false
|
|
20
24
|
|
|
21
|
-
// TODO: 当前 node 结构没有 root,因此不作判断,后续可根据情况添加 root 条件
|
|
22
25
|
while (node?.parentElement) {
|
|
23
26
|
if (node.parentElement.__listeners[type]?.length) {
|
|
24
27
|
res = true
|
|
@@ -35,21 +38,85 @@ export function convertNumber2PX (value: number) {
|
|
|
35
38
|
return pxTransformHelper(value, 'vp')
|
|
36
39
|
}
|
|
37
40
|
|
|
38
|
-
export function convertNumber2VP (value: number) {
|
|
41
|
+
export function convertNumber2VP (value: number, unit = 'px'): string | number {
|
|
42
|
+
if (unit === 'vw' || unit === 'vh') {
|
|
43
|
+
return (value / 100 * (unit === 'vw' ? display.width : display.height)) + 'px'
|
|
44
|
+
}
|
|
45
|
+
if (unit === 'PX') {
|
|
46
|
+
// 特殊单位:相当于PX、pX、Px
|
|
47
|
+
return pxTransformHelper(value, 'PX')
|
|
48
|
+
}
|
|
39
49
|
return pxTransformHelper(value, 'vp')
|
|
40
50
|
}
|
|
41
51
|
|
|
42
|
-
export function
|
|
52
|
+
export function parseClasses (classNames = ''): string[] {
|
|
53
|
+
if (typeof classNames !== 'string') {
|
|
54
|
+
return []
|
|
55
|
+
}
|
|
56
|
+
return classNames.includes(' ') ? classNames.split(' ') : [classNames]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 合并静态样式,从样式表里面找到对应的样式
|
|
60
|
+
export function calcStaticStyle (styleSheet: Record<string, CSSProperties>, classNames = ''): CSSProperties {
|
|
61
|
+
classNames = classNames || '' // 兼容有些开发者传入了false/null等非字符串类型
|
|
43
62
|
const obj: CSSProperties[] = []
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
63
|
+
|
|
64
|
+
if (!styleSheet.cache) {
|
|
65
|
+
styleSheet.cache = {}
|
|
66
|
+
}
|
|
67
|
+
const cache: Record<string, CSSProperties> = styleSheet.cache as Record<string, CSSProperties>
|
|
68
|
+
|
|
69
|
+
const classes = parseClasses(classNames)
|
|
70
|
+
if (!classes.length) return {}
|
|
71
|
+
if (classes.length === 1) {
|
|
72
|
+
// 同一个引用
|
|
73
|
+
return styleSheet[classes[0]]
|
|
74
|
+
} else {
|
|
75
|
+
if (cache[classNames]) {
|
|
76
|
+
return cache[classNames]
|
|
77
|
+
} else {
|
|
78
|
+
for (let i = 0; i < classes.length; i++) {
|
|
79
|
+
const className = classes[i]
|
|
80
|
+
if (styleSheet[className]) {
|
|
81
|
+
obj.push(styleSheet[className])
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const result = Object.assign.apply(null, [{}].concat(obj))
|
|
85
|
+
|
|
86
|
+
cache[classNames] = result
|
|
87
|
+
|
|
88
|
+
return result
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 动态样式计算,需要经过web2harmony进行反转
|
|
94
|
+
export function calcDynamicStyle (style: CSSProperties): CSSProperties {
|
|
95
|
+
if (style) {
|
|
96
|
+
return convertWebStyle2HmStyle(style)
|
|
97
|
+
}
|
|
98
|
+
return {}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// css env()环境样式获取
|
|
102
|
+
export function __env__(safeAreaType: string, fallback?: string | number) {
|
|
103
|
+
const sysInfo = getSystemInfoSync()
|
|
104
|
+
|
|
105
|
+
switch (safeAreaType) {
|
|
106
|
+
case 'safe-area-inset-top': {
|
|
107
|
+
return sysInfo.safeArea?.top ? `${sysInfo.safeArea?.top}px` : fallback
|
|
108
|
+
}
|
|
109
|
+
case 'safe-area-inset-right': {
|
|
110
|
+
return sysInfo.safeArea?.right ? `${sysInfo.screenWidth - sysInfo.safeArea?.right}px` : fallback
|
|
111
|
+
}
|
|
112
|
+
case 'safe-area-inset-bottom': {
|
|
113
|
+
return sysInfo.safeArea?.bottom ? `${sysInfo.screenHeight - sysInfo.safeArea?.bottom}px` : fallback
|
|
114
|
+
}
|
|
115
|
+
case 'safe-area-inset-left': {
|
|
116
|
+
return sysInfo.safeArea?.left ? `${sysInfo.safeArea?.left}px` : fallback
|
|
49
117
|
}
|
|
50
118
|
}
|
|
51
|
-
|
|
52
|
-
return Object.assign.apply(null, [{}].concat(obj))
|
|
119
|
+
return fallback
|
|
53
120
|
}
|
|
54
121
|
|
|
55
122
|
export function getPageScrollerOrNode (scrollerOrNode: any, page: any) {
|
|
@@ -66,6 +133,10 @@ export function getPageScrollerOrNode (scrollerOrNode: any, page: any) {
|
|
|
66
133
|
return scrollerOrNode
|
|
67
134
|
}
|
|
68
135
|
|
|
136
|
+
export function ObjectKeys(obj: object): string[] {
|
|
137
|
+
return Object.keys(obj)
|
|
138
|
+
}
|
|
139
|
+
|
|
69
140
|
export function ObjectAssign(...objects) {
|
|
70
141
|
return Object.assign.apply(this, [{}].concat(...objects))
|
|
71
142
|
}
|
|
@@ -81,13 +152,12 @@ export function bindFn (fn: any, ctx: any, ...args: any) {
|
|
|
81
152
|
}
|
|
82
153
|
}
|
|
83
154
|
|
|
84
|
-
|
|
85
155
|
// 使用深度优先遍历寻找节点树中对应的子节点,且只需要找到第一个
|
|
86
156
|
// 通过 selector 判断是 id 还是 selector,从 node 的 id 和 className 属性中寻找
|
|
87
|
-
export function findChildNodeWithDFS<T extends TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll: true):
|
|
88
|
-
export function findChildNodeWithDFS<T extends TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll?: false):
|
|
89
|
-
export function findChildNodeWithDFS<T extends TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll: boolean):
|
|
90
|
-
export function findChildNodeWithDFS<T extends TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll):
|
|
157
|
+
export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll: true): T[] | null;
|
|
158
|
+
export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll?: false): T | null;
|
|
159
|
+
export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll: boolean): T[] | T | null;
|
|
160
|
+
export function findChildNodeWithDFS<T extends TaroElement = TaroElement> (node: TaroElement, selector: string | ((ele: T) => boolean), selectAll): T[] | T | null {
|
|
91
161
|
const queue = [node]
|
|
92
162
|
|
|
93
163
|
const nodeList: TaroElement[] = []
|