@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
|
@@ -10,30 +10,33 @@ export class TEXT_DEFAULT_STYLE {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
interface IBUTTON_THEME_COLOR {
|
|
13
|
-
text:
|
|
13
|
+
text: Color
|
|
14
14
|
background: string
|
|
15
|
+
plainText: string | Color
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
export class BUTTON_THEME_COLOR {
|
|
18
19
|
static get (type: string): IBUTTON_THEME_COLOR {
|
|
19
20
|
switch (type) {
|
|
20
21
|
case 'primary': return {
|
|
21
|
-
text:
|
|
22
|
+
text: Color.White,
|
|
22
23
|
background: '#1aad19',
|
|
24
|
+
plainText: '#1aad19'
|
|
23
25
|
}
|
|
24
26
|
case 'warn': return {
|
|
25
|
-
text:
|
|
26
|
-
background: '#e64340'
|
|
27
|
+
text: Color.White,
|
|
28
|
+
background: '#e64340',
|
|
29
|
+
plainText: '#e64340'
|
|
27
30
|
}
|
|
28
31
|
default: return {
|
|
29
|
-
text:
|
|
32
|
+
text: Color.Black,
|
|
30
33
|
background: '#f7f7f7',
|
|
34
|
+
plainText: Color.Black
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
|
|
37
40
|
export class INPUT_TYPE_MAP {
|
|
38
41
|
static get (type: string) {
|
|
39
42
|
switch (type) {
|
|
@@ -1,106 +1,89 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TaroElement, HarmonyStyle } from '@tarojs/runtime'
|
|
2
|
+
import { isUndefined } from '@tarojs/shared'
|
|
3
|
+
import { getNormalAttributes } from './styles.ets'
|
|
4
|
+
|
|
5
|
+
interface IFlexOptions {
|
|
6
|
+
direction: FlexDirection,
|
|
7
|
+
justifyContent: FlexAlign,
|
|
8
|
+
alignItems: ItemAlign,
|
|
9
|
+
wrap?: FlexWrap,
|
|
10
|
+
alignContent?: FlexAlign
|
|
11
|
+
}
|
|
2
12
|
|
|
3
13
|
class FlexManager {
|
|
4
|
-
static
|
|
5
|
-
|
|
14
|
+
static isFlexNode (node: TaroElement): boolean {
|
|
15
|
+
return !!node.hmStyle?.display?.includes('flex')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static convertFlexAlignItemsToColumnOrRow (direction: FlexDirection, alignItems: ItemAlign | undefined): VerticalAlign | HorizontalAlign {
|
|
19
|
+
if (direction === FlexDirection.Column) {
|
|
20
|
+
switch (alignItems) {
|
|
21
|
+
case ItemAlign.Center:
|
|
22
|
+
return HorizontalAlign.Center
|
|
23
|
+
case ItemAlign.End:
|
|
24
|
+
return HorizontalAlign.End
|
|
25
|
+
default:
|
|
26
|
+
return HorizontalAlign.Start
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
switch (alignItems) {
|
|
30
|
+
case ItemAlign.Center:
|
|
31
|
+
return VerticalAlign.Center
|
|
32
|
+
case ItemAlign.End:
|
|
33
|
+
return VerticalAlign.Bottom
|
|
34
|
+
default:
|
|
35
|
+
return VerticalAlign.Top
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static useFlexLayout (node: TaroElement): boolean {
|
|
41
|
+
const hmStyle: HarmonyStyle = getNormalAttributes(node) || {}
|
|
42
|
+
const isReverse = hmStyle.flexDirection && [FlexDirection.RowReverse, FlexDirection.ColumnReverse].indexOf(hmStyle.flexDirection) !== -1;
|
|
43
|
+
const isUnknownAlign = [ItemAlign.Stretch, ItemAlign.Baseline].indexOf(hmStyle.alignItems!) !== -1;
|
|
44
|
+
return !isUndefined(hmStyle.flexWrap) || isReverse || isUnknownAlign;
|
|
45
|
+
}
|
|
6
46
|
|
|
7
|
-
|
|
47
|
+
static flexOptions (node: TaroElement): IFlexOptions {
|
|
48
|
+
const hmStyle: HarmonyStyle = getNormalAttributes(node) || {}
|
|
49
|
+
const isFlex = FlexManager.isFlexNode(node)
|
|
50
|
+
let flexDirection = hmStyle.flexDirection
|
|
8
51
|
if (!flexDirection && flexDirection !== 0) {
|
|
9
52
|
flexDirection = hmStyle.display === 'flex' ? FlexDirection.Row : FlexDirection.Column
|
|
10
53
|
}
|
|
11
54
|
|
|
12
55
|
return {
|
|
56
|
+
alignItems: isFlex ? (isUndefined(hmStyle.alignItems) ? ItemAlign.Start : hmStyle.alignItems) : ItemAlign.Start,
|
|
57
|
+
justifyContent: isFlex ? (isUndefined(hmStyle.justifyContent) ? FlexAlign.Start : hmStyle.justifyContent) : FlexAlign.Start,
|
|
13
58
|
direction: flexDirection,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
static flexAlign (value: string | number | undefined): FlexAlign {
|
|
20
|
-
switch (value) {
|
|
21
|
-
case 'flex-end':
|
|
22
|
-
return FlexAlign.End
|
|
23
|
-
case 'center':
|
|
24
|
-
return FlexAlign.Center
|
|
25
|
-
case 'space-between':
|
|
26
|
-
return FlexAlign.SpaceBetween
|
|
27
|
-
case 'space-around':
|
|
28
|
-
return FlexAlign.SpaceAround
|
|
29
|
-
case 'space-evenly':
|
|
30
|
-
return FlexAlign.SpaceEvenly
|
|
31
|
-
default:
|
|
32
|
-
return FlexAlign.Start
|
|
59
|
+
wrap: isFlex ? hmStyle.flexWrap: FlexWrap.NoWrap,
|
|
60
|
+
alignContent: isFlex ? hmStyle.alignContent: FlexAlign.Start
|
|
33
61
|
}
|
|
34
62
|
}
|
|
35
63
|
|
|
36
|
-
static direction (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
default: return FlexDirection.Column;
|
|
64
|
+
static direction (node: TaroElement): FlexDirection {
|
|
65
|
+
const hmStyle: HarmonyStyle = getNormalAttributes(node)
|
|
66
|
+
let flexDirection = hmStyle.flexDirection
|
|
67
|
+
if (!flexDirection && flexDirection !== 0) {
|
|
68
|
+
flexDirection = hmStyle.display === 'flex' ? FlexDirection.Row : FlexDirection.Column
|
|
42
69
|
}
|
|
70
|
+
return flexDirection
|
|
43
71
|
}
|
|
44
72
|
|
|
45
|
-
static
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
case 'center':
|
|
52
|
-
return ItemAlign.Center
|
|
53
|
-
case 'stretch':
|
|
54
|
-
return ItemAlign.Stretch
|
|
55
|
-
case 'baseline':
|
|
56
|
-
return ItemAlign.Baseline
|
|
57
|
-
default:
|
|
58
|
-
return ItemAlign.Auto
|
|
73
|
+
static alignItems<T> (node: TaroElement): T {
|
|
74
|
+
const hmStyle: HarmonyStyle = getNormalAttributes(node)
|
|
75
|
+
const isFlex = FlexManager.isFlexNode(node)
|
|
76
|
+
let flexDirection = hmStyle.flexDirection
|
|
77
|
+
if (!flexDirection && flexDirection !== 0) {
|
|
78
|
+
flexDirection = hmStyle.display === 'flex' ? FlexDirection.Row : FlexDirection.Column
|
|
59
79
|
}
|
|
80
|
+
return (isFlex ? FlexManager.convertFlexAlignItemsToColumnOrRow(flexDirection, hmStyle.alignItems) : HorizontalAlign.Start) as T
|
|
60
81
|
}
|
|
61
82
|
|
|
62
|
-
static justifyContent (
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
static alignItems (value: string): ItemAlign {
|
|
67
|
-
return FlexManager.itemAlign(value)
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
static alignSelf (value: string): ItemAlign {
|
|
71
|
-
return FlexManager.itemAlign(value)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
static flexWrap (value: string): FlexWrap {
|
|
75
|
-
return value === 'wrap' ? FlexWrap.Wrap : FlexWrap.NoWrap
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
static alignContent (style: Record<string, string | number> = {}): FlexAlign | undefined {
|
|
79
|
-
if (style.flexWrap !== 'wrap') return undefined
|
|
80
|
-
const value = style.alignContent
|
|
81
|
-
return FlexManager.flexAlign(value)
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
static flexSize (style: Record<string, string | number> = {}): [number, number, number | string] {
|
|
85
|
-
const flex = style.flex
|
|
86
|
-
const flexGrow = style.flexGrow || 0
|
|
87
|
-
const flexShrink = style.flexShrink || 0
|
|
88
|
-
const flexBasis = style.flexBasis || 'auto'
|
|
89
|
-
let res: [number, number, number | string] = [Number(flexGrow), Number(flexShrink), flexBasis]
|
|
90
|
-
|
|
91
|
-
if (typeof flex === 'number') {
|
|
92
|
-
res = [flex, 1, 0]
|
|
93
|
-
} else if (flex === 'auto') {
|
|
94
|
-
res = [1, 1, 'auto']
|
|
95
|
-
} else if (flex === 'none') {
|
|
96
|
-
res = [0, 0, 'auto']
|
|
97
|
-
} else if (typeof flex === 'string') {
|
|
98
|
-
const FlexList = flex.replace(new RegExp("/\s+/g"), ' ').split(' ')
|
|
99
|
-
FlexList.forEach((item, index) => {
|
|
100
|
-
res[index] = index < 2 ? Number(item) : item
|
|
101
|
-
})
|
|
102
|
-
}
|
|
103
|
-
return res
|
|
83
|
+
static justifyContent (node: TaroElement): FlexAlign {
|
|
84
|
+
const hmStyle: HarmonyStyle = getNormalAttributes(node)
|
|
85
|
+
const isFlex = FlexManager.isFlexNode(node)
|
|
86
|
+
return isFlex ? (isUndefined(hmStyle.justifyContent) ? FlexAlign.Start : hmStyle.justifyContent) : FlexAlign.Start
|
|
104
87
|
}
|
|
105
88
|
}
|
|
106
89
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { bindAttributesCallback, ObjectAssign } from '@tarojs/runtime'
|
|
1
|
+
import { VIEW } from '@tarojs/runtime/dist/runtime.esm'
|
|
3
2
|
|
|
4
|
-
import
|
|
5
|
-
|
|
3
|
+
import { getNormalAttributes, getFontAttributes, getStyleAttr } from './styles'
|
|
4
|
+
|
|
5
|
+
import type { TFunc } from '@tarojs/runtime/dist/runtime.esm'
|
|
6
|
+
import type { TaroElement, TaroNode } from '@tarojs/runtime'
|
|
6
7
|
|
|
7
8
|
export const parseStyles = (styles = ''): Record<string, string> => {
|
|
8
9
|
const styleObj: Record<string, string> = {}
|
|
@@ -21,8 +22,7 @@ export const parseStyles = (styles = ''): Record<string, string> => {
|
|
|
21
22
|
return styleObj
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
export function shouldBindEvent (cb: Func, node: TaroElement, eventNames: string[], disabled = false) {
|
|
25
|
+
export function shouldBindEvent (cb: TFunc, node: TaroElement | null, eventNames: string[], disabled = false) {
|
|
26
26
|
if (!node || node._attrs?.disabled || disabled) return null
|
|
27
27
|
if (!node.__listeners) {
|
|
28
28
|
return null
|
|
@@ -33,67 +33,20 @@ export function shouldBindEvent (cb: Func, node: TaroElement, eventNames: string
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export function getNodeThresholds (node: TaroElement): number[] | null {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const id = node._nid
|
|
39
|
-
const instance: TaroAny = node._instance
|
|
40
|
-
|
|
41
|
-
return instance?.nodeInfoMap?.[id]?.thresholds || null
|
|
36
|
+
return node?._nodeInfo?.thresholds || null
|
|
42
37
|
}
|
|
43
38
|
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
export function bindAnimation (node: TaroElement) {
|
|
50
|
-
bindAttributesCallback(node, 'animation', async (animation: TaroAny) => {
|
|
51
|
-
if (animation && animation.actions) {
|
|
52
|
-
for (let i = 0; i < animation.actions.length; i++) {
|
|
53
|
-
const anim: TaroAny = animation.actions[i]
|
|
54
|
-
// 动画队列
|
|
55
|
-
await new Promise<TaroAny>((resolve: TaroAny) => {
|
|
56
|
-
const timingFunction: TaroAny = anim.timingFunction
|
|
57
|
-
const animateParams: AnimateParam = {
|
|
58
|
-
duration: anim.duration,
|
|
59
|
-
delay: anim.delay,
|
|
60
|
-
tempo: 1,
|
|
61
|
-
// TODO: ETS转TS
|
|
62
|
-
playMode: PlayMode.Normal,
|
|
63
|
-
iterations: 1,
|
|
64
|
-
onFinish: resolve
|
|
65
|
-
}
|
|
66
|
-
if (timingFunction === 'step-start') {
|
|
67
|
-
animateParams.tempo = 0
|
|
68
|
-
} else if (timingFunction === 'step-end') {
|
|
69
|
-
animateParams.tempo = 0
|
|
70
|
-
animateParams.delay = anim.duration + anim.delay
|
|
71
|
-
animateParams.duration = 0
|
|
72
|
-
}
|
|
73
|
-
animateParams.curve = Curve[convertToCamelCase(timingFunction)] || Curve.EaseInOut
|
|
74
|
-
animateTo(animateParams, () => {
|
|
75
|
-
const component: TaroAny = node._instance
|
|
76
|
-
const transformOrigin: string = anim.transformOrigin
|
|
39
|
+
export function isTagFirstChild (node: TaroElement, tagName = VIEW, level = 0): boolean {
|
|
40
|
+
const parent: TaroElement | null = node.parentElement
|
|
41
|
+
const list: TaroNode[] = node.parentNode?.childNodes || []
|
|
42
|
+
if (list.length < 1 || level < 0) return false
|
|
43
|
+
else if (!parent) return true
|
|
77
44
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
centerX: splitOrigin[0],
|
|
84
|
-
centerY: splitOrigin[1],
|
|
85
|
-
})
|
|
86
|
-
}
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
component.nodeInfoMap[node._nid].overwriteStyle = anim.rule
|
|
91
|
-
node.updateComponent()
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
})
|
|
45
|
+
if (parent.nodeName === tagName.toUpperCase()) {
|
|
46
|
+
return list[0] === node
|
|
47
|
+
} else {
|
|
48
|
+
return (list[0] === node) && isTagFirstChild(parent, tagName, --level)
|
|
49
|
+
}
|
|
97
50
|
}
|
|
98
51
|
|
|
99
|
-
export { getNormalAttributes, getFontAttributes }
|
|
52
|
+
export { getNormalAttributes, getFontAttributes, getStyleAttr }
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { convertNumber2VP } from '@tarojs/runtime'
|
|
2
|
-
import { isNumber } from '@tarojs/shared'
|
|
2
|
+
import { isNumber, isUndefined } from '@tarojs/shared'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import type { RichTextProps } from '@tarojs/components/types/RichText'
|
|
5
|
+
import type { TaroRichTextElement } from '@tarojs/runtime'
|
|
6
|
+
|
|
7
|
+
export function getSingleSelector(range, rangeKey): any[] {
|
|
5
8
|
return range.map((data) => data[rangeKey])
|
|
6
9
|
}
|
|
7
10
|
|
|
@@ -18,66 +21,67 @@ export function getMultiSelector(ctx, range, rangeKey, value) {
|
|
|
18
21
|
}))
|
|
19
22
|
}
|
|
20
23
|
|
|
21
|
-
export function getUnit (val) {
|
|
22
|
-
if (/\d+
|
|
24
|
+
export function getUnit (val: string | number): string {
|
|
25
|
+
if (isNumber(val) || /\d+px$/.test(val)) {
|
|
26
|
+
return convertNumber2VP(parseFloat(val as string))
|
|
27
|
+
} else if (/\d+(vp)$/.test(val)) {
|
|
23
28
|
return val
|
|
24
|
-
} else if (isNumber(val) || /\d+px$/.test(val)) {
|
|
25
|
-
return convertNumber2VP(parseFloat(val))
|
|
26
29
|
}
|
|
27
30
|
return val
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const values = dataValue.trim().split(/\s+/)
|
|
34
|
-
const data = handler(values)
|
|
35
|
-
|
|
36
|
-
if (!data) return res
|
|
37
|
-
|
|
38
|
-
res = data
|
|
33
|
+
export function generateText (node: TaroRichTextElement): string {
|
|
34
|
+
return parseHtmlNode(node._attrs.nodes || '')
|
|
35
|
+
}
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
37
|
+
// 将nodeTree转换成harmony需要的string结构
|
|
38
|
+
function nodeToHtml(node: RichTextProps.Text | RichTextProps.HTMLElement): string {
|
|
39
|
+
if (node.type === 'text') {
|
|
40
|
+
return node.text
|
|
41
|
+
}
|
|
42
|
+
if (node.attrs) {
|
|
43
|
+
const attributes = Object.entries(node.attrs)
|
|
44
|
+
.map((item: [string, string]) => `${item[0]}="${item[1]}"`)
|
|
45
|
+
.join(' ')
|
|
46
|
+
const childrenHtml: string = typeof node.children === 'string' ? node.children : (node.children || []).map((child: RichTextProps.Text | RichTextProps.HTMLElement) => nodeToHtml(child)).join('')
|
|
47
|
+
return `<${node.name}${attributes ? ' ' + attributes : ''}>${childrenHtml}</${node.name}>`
|
|
46
48
|
}
|
|
49
|
+
return ''
|
|
50
|
+
}
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
function parseHtmlNode (nodes: Array<RichTextProps.Text | RichTextProps.HTMLElement> | string) {
|
|
53
|
+
return typeof nodes === 'string' ? nodes : `<div>${nodes.map(node => nodeToHtml(node)).join('')}</div>`
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
// 背景偏移算法:https://developer.mozilla.org/zh-CN/docs/Web/CSS/background-position
|
|
57
|
+
export function computeBackgroundPosition(style) {
|
|
58
|
+
let offsetX = style.backgroundPosition?.x || 0
|
|
59
|
+
let offsetY = style.backgroundPosition?.y || 0
|
|
60
|
+
if (style.backgroundSize && typeof style.backgroundSize !== 'number') {
|
|
61
|
+
if (!isUndefined(style.backgroundSize.width) && style.width) {
|
|
62
|
+
if (typeof style.backgroundPosition.x === 'string' && style.backgroundPosition.x.indexOf('%') > 0) {
|
|
63
|
+
// (container width - image width) * (position x%) = (x offset value)
|
|
64
|
+
const width = parseFloat(style.width)
|
|
65
|
+
const bgWidth = parseFloat(style.backgroundSize.width)
|
|
66
|
+
const bgOffsetX = parseFloat(style.backgroundPosition.x)
|
|
67
|
+
offsetX = Number((width - bgWidth) * (bgOffsetX) / 100) || 0
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (!isUndefined(style.backgroundSize.height) && style.height) {
|
|
71
|
+
if (typeof style.backgroundPosition.y === 'string' && style.backgroundPosition.y.indexOf('%') > 0) {
|
|
72
|
+
// (container height - image height) * (position y%) = (y offset value)
|
|
73
|
+
const height = parseFloat(style.height)
|
|
74
|
+
const bgHeight = parseFloat(style.backgroundSize.height)
|
|
75
|
+
const bgOffsetY = parseFloat(style.backgroundPosition.y)
|
|
76
|
+
offsetY = Number((height - bgHeight) * (bgOffsetY) / 100) || 0
|
|
77
|
+
}
|
|
64
78
|
}
|
|
65
|
-
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return { offsetX, offsetY }
|
|
66
82
|
}
|
|
67
83
|
|
|
68
|
-
export function
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
case 1:
|
|
72
|
-
return { top: values[0], right: values[0], bottom: values[0], left: values[0] }
|
|
73
|
-
case 2:
|
|
74
|
-
return { top: values[0], right: values[1], bottom: values[0], left: values[1] }
|
|
75
|
-
case 3:
|
|
76
|
-
return { top: values[0], right: values[1], bottom: values[2], left: values[1] }
|
|
77
|
-
case 4:
|
|
78
|
-
return { top: values[0], right: values[1], bottom: values[2], left: values[3] }
|
|
79
|
-
default:
|
|
80
|
-
break
|
|
81
|
-
}
|
|
82
|
-
})
|
|
84
|
+
export function convertVp2Px(val: string | number) {
|
|
85
|
+
const vp = parseFloat(`${val}`)
|
|
86
|
+
return vp2px(vp)
|
|
83
87
|
}
|