@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,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
3
2
|
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import PseduoChildren from './pseudo'
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
6
6
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
7
|
-
import {
|
|
8
|
-
import { getNodeThresholds, getNormalAttributes, shouldBindEvent, bindAnimation } from './utils/helper'
|
|
7
|
+
import { getNodeThresholds, getStyleAttr, shouldBindEvent } from './utils/helper'
|
|
9
8
|
|
|
10
|
-
import type { TaroScrollViewElement,
|
|
11
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
9
|
+
import type { TaroAny, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
|
|
12
10
|
|
|
13
11
|
interface ScrollViewAttrs {
|
|
14
12
|
scrollBar: BarState
|
|
@@ -26,67 +24,6 @@ interface ScrollViewEvent {
|
|
|
26
24
|
scrollHeight: number
|
|
27
25
|
}
|
|
28
26
|
|
|
29
|
-
@Extend(Row)
|
|
30
|
-
function rowAttrs (style: TaroStyleType) {
|
|
31
|
-
.id(style.id)
|
|
32
|
-
.key(style.id)
|
|
33
|
-
.padding(style.padding)
|
|
34
|
-
.margin(style.margin)
|
|
35
|
-
.width(style.width)
|
|
36
|
-
.height(style.height)
|
|
37
|
-
.constraintSize(style.constraintSize)
|
|
38
|
-
.flexGrow(style.flexGrow)
|
|
39
|
-
.flexShrink(style.flexShrink)
|
|
40
|
-
.flexBasis(style.flexBasis)
|
|
41
|
-
.alignSelf(style.alignSelf)
|
|
42
|
-
.backgroundColor(style.backgroundColor)
|
|
43
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
44
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
45
|
-
.rotate(style.rotate)
|
|
46
|
-
.scale(style.scale)
|
|
47
|
-
.translate(style.translate)
|
|
48
|
-
.transform(style.transform)
|
|
49
|
-
.borderStyle(style.borderStyle)
|
|
50
|
-
.borderWidth(style.borderWidth)
|
|
51
|
-
.borderColor(style.borderColor)
|
|
52
|
-
.borderRadius(style.borderRadius)
|
|
53
|
-
.linearGradient(style.linearGradient)
|
|
54
|
-
.zIndex(style.zIndex)
|
|
55
|
-
.opacity(style.opacity)
|
|
56
|
-
.clip(style.clip)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@Extend(Column)
|
|
60
|
-
function columnAttrs (style: TaroStyleType) {
|
|
61
|
-
.id(style.id)
|
|
62
|
-
.key(style.id)
|
|
63
|
-
.padding(style.padding)
|
|
64
|
-
.margin(style.margin)
|
|
65
|
-
.width(style.width)
|
|
66
|
-
.height(style.height)
|
|
67
|
-
.constraintSize(style.constraintSize)
|
|
68
|
-
.flexGrow(style.flexGrow)
|
|
69
|
-
.flexShrink(style.flexShrink)
|
|
70
|
-
.flexBasis(style.flexBasis)
|
|
71
|
-
.alignSelf(style.alignSelf)
|
|
72
|
-
.backgroundColor(style.backgroundColor)
|
|
73
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
74
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
75
|
-
.rotate(style.rotate)
|
|
76
|
-
.scale(style.scale)
|
|
77
|
-
.translate(style.translate)
|
|
78
|
-
.transform(style.transform)
|
|
79
|
-
.borderStyle(style.borderStyle)
|
|
80
|
-
.borderWidth(style.borderWidth)
|
|
81
|
-
.borderColor(style.borderColor)
|
|
82
|
-
.borderRadius(style.borderRadius)
|
|
83
|
-
.linearGradient(style.linearGradient)
|
|
84
|
-
.zIndex(style.zIndex)
|
|
85
|
-
.opacity(style.opacity)
|
|
86
|
-
.clip(style.clip)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
27
|
function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
|
|
91
28
|
const _attrs = node._attrs
|
|
92
29
|
const scrollAttrs: ScrollViewAttrs = {
|
|
@@ -97,103 +34,98 @@ function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
|
|
|
97
34
|
return scrollAttrs
|
|
98
35
|
}
|
|
99
36
|
|
|
37
|
+
function getScrollable (node: TaroScrollViewElement) {
|
|
38
|
+
const _attrs = node._attrs
|
|
100
39
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
nodeInfoMap: TaroAny = {}
|
|
104
|
-
|
|
105
|
-
wrapper?: Area
|
|
40
|
+
return _attrs.scrollX ? ScrollDirection.Horizontal : ScrollDirection.Vertical
|
|
41
|
+
}
|
|
106
42
|
|
|
107
|
-
|
|
108
|
-
|
|
43
|
+
function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', xOffset?: number, yOffset?: number) {
|
|
44
|
+
const currentOffset = node.scroller.currentOffset() as ScrollViewCurrentOffset
|
|
45
|
+
const currentXOffset = currentOffset.xOffset
|
|
46
|
+
const currentYOffset = currentOffset.yOffset
|
|
47
|
+
const value: ScrollViewEvent = {
|
|
48
|
+
deltaX: vp2px(xOffset),
|
|
49
|
+
deltaY: vp2px(yOffset),
|
|
50
|
+
scrollLeft: vp2px(currentXOffset),
|
|
51
|
+
scrollTop: vp2px(currentYOffset),
|
|
52
|
+
scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
|
|
53
|
+
scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
|
|
109
54
|
}
|
|
55
|
+
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
|
|
110
56
|
|
|
111
|
-
|
|
57
|
+
eventHandler(event, eventName, node)
|
|
58
|
+
}
|
|
112
59
|
|
|
60
|
+
@Component
|
|
61
|
+
export default struct TaroScrollView {
|
|
62
|
+
@Builder customBuilder() {}
|
|
63
|
+
@BuilderParam createLazyChildren: (node: TaroScrollViewElement) => void = this.customBuilder
|
|
113
64
|
@ObjectLink node: TaroScrollViewElement
|
|
65
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
114
66
|
|
|
115
|
-
aboutToAppear
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
bindAnimation(this.node)
|
|
120
|
-
bindScrollTo(this.node, this)
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@Styles defaultEvent () {
|
|
124
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
125
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
126
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
127
|
-
const eventResult: TaroAny = res.eventResult
|
|
128
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
129
|
-
}))
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
@Styles defaultContainerEvent () {
|
|
133
|
-
.onAreaChange(shouldBindEvent((areaResult: Area) => {
|
|
134
|
-
this.wrapper = areaResult
|
|
135
|
-
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
67
|
+
aboutToAppear(): void {
|
|
68
|
+
if (this.node) {
|
|
69
|
+
this.node._instance = this
|
|
70
|
+
}
|
|
136
71
|
}
|
|
137
72
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
const currentOffset: ScrollViewCurrentOffset = this.scroller.currentOffset()
|
|
141
|
-
const currentXOffset = currentOffset.xOffset
|
|
142
|
-
const currentYOffset = currentOffset.yOffset
|
|
143
|
-
const value: ScrollViewEvent = {
|
|
144
|
-
deltaX: vp2px(xOffset),
|
|
145
|
-
deltaY: vp2px(yOffset),
|
|
146
|
-
scrollLeft: vp2px(currentXOffset),
|
|
147
|
-
scrollTop: vp2px(currentYOffset),
|
|
148
|
-
scrollWidth: vp2px(Number(this.wrapper?.width)),
|
|
149
|
-
scrollHeight: vp2px(Number(this.wrapper?.height)),
|
|
150
|
-
}
|
|
151
|
-
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, this.node)
|
|
152
|
-
eventHandler(event, eventName, this.node)
|
|
73
|
+
isScrollX() {
|
|
74
|
+
return this.node._attrs.scrollX || getStyleAttr(this.node, 'overflow') === 'scroll' && getStyleAttr(this.node, 'flexDirection') === FlexDirection.Row
|
|
153
75
|
}
|
|
154
76
|
|
|
155
|
-
build() {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}, (item: TaroElement) => item._nid)
|
|
77
|
+
build () {
|
|
78
|
+
Scroll(this.node.scroller) {
|
|
79
|
+
if (this.isScrollX()) {
|
|
80
|
+
Row() {
|
|
81
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
82
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
83
|
+
} else {
|
|
84
|
+
this.createLazyChildren(this.node)
|
|
164
85
|
}
|
|
165
|
-
.rowAttrs(getNormalAttributes(this.node))
|
|
166
|
-
.width(null)
|
|
167
|
-
.defaultContainerEvent()
|
|
168
86
|
}
|
|
169
|
-
.
|
|
170
|
-
.
|
|
171
|
-
.
|
|
172
|
-
.
|
|
173
|
-
.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
.
|
|
87
|
+
.alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
|
|
88
|
+
.justifyContent(FlexManager.justifyContent(this.node))
|
|
89
|
+
.height(getStyleAttr(this.node, 'height'))
|
|
90
|
+
.width(null)
|
|
91
|
+
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
92
|
+
this.node._nodeInfo._scroll = areaResult
|
|
93
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
94
|
+
.flexGrow(0).flexShrink(0)
|
|
177
95
|
} else {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
96
|
+
Column() {
|
|
97
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
98
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
99
|
+
} else {
|
|
100
|
+
this.createLazyChildren(this.node)
|
|
183
101
|
}
|
|
184
|
-
.columnAttrs(getNormalAttributes(this.node))
|
|
185
|
-
.height(null)
|
|
186
|
-
.defaultContainerEvent()
|
|
187
102
|
}
|
|
188
|
-
.
|
|
189
|
-
.
|
|
190
|
-
.
|
|
191
|
-
.
|
|
192
|
-
.
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
.
|
|
103
|
+
.alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
|
|
104
|
+
.justifyContent(FlexManager.justifyContent(this.node))
|
|
105
|
+
.width(getStyleAttr(this.node, 'width'))
|
|
106
|
+
.height(null)
|
|
107
|
+
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
108
|
+
this.node._nodeInfo._scroll = areaResult
|
|
109
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
110
|
+
.flexGrow(0).flexShrink(0)
|
|
196
111
|
}
|
|
197
112
|
}
|
|
113
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
114
|
+
.width(this.isScrollX() ? getStyleAttr(this.node, 'width') : undefined)
|
|
115
|
+
.height(!this.isScrollX() ? getStyleAttr(this.node, 'height') : undefined)
|
|
116
|
+
.align(Alignment.TopStart)
|
|
117
|
+
.clip(true)
|
|
118
|
+
.scrollable(getScrollable(this.node))
|
|
119
|
+
.scrollBar(getAttributes(this.node).scrollBar)
|
|
120
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
121
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
122
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
123
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
124
|
+
}))
|
|
125
|
+
.onDidScroll(shouldBindEvent((xOffset: number, yOffset: number) => { handleScrollEvent(this.node, 'scroll', xOffset, yOffset) }, this.node, ['scroll']))
|
|
126
|
+
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
127
|
+
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
128
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
129
|
+
.onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
|
|
198
130
|
}
|
|
199
131
|
}
|
|
@@ -1,60 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
3
2
|
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { getNodeThresholds, shouldBindEvent, getNormalAttributes } from './utils/helper'
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
7
5
|
|
|
8
|
-
import type { TaroSliderElement } from '
|
|
9
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
6
|
+
import type { TaroAny, TaroSliderElement, TaroEvent } from '@tarojs/runtime'
|
|
10
7
|
|
|
11
|
-
interface SliderOptions {
|
|
12
|
-
min?: number
|
|
13
|
-
max?: number
|
|
14
|
-
value?: number
|
|
15
|
-
step?: number
|
|
16
|
-
style?: SliderStyle
|
|
17
|
-
direction?: Axis
|
|
18
|
-
}
|
|
19
8
|
interface SliderAttrs {
|
|
20
9
|
selectedColor?: ResourceColor
|
|
21
10
|
trackColor?: ResourceColor
|
|
22
11
|
trackThickness?: Length
|
|
23
12
|
blockColor?: ResourceColor
|
|
24
13
|
}
|
|
25
|
-
interface SliderParams {
|
|
26
|
-
width: string
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@Extend(Slider)
|
|
30
|
-
function style (style: TaroStyleType) {
|
|
31
|
-
.id(style.id)
|
|
32
|
-
.key(style.id)
|
|
33
|
-
.padding(style.padding)
|
|
34
|
-
.margin(style.margin)
|
|
35
|
-
.width(style.width)
|
|
36
|
-
.height(style.height)
|
|
37
|
-
.constraintSize(style.constraintSize)
|
|
38
|
-
.flexGrow(style.flexGrow)
|
|
39
|
-
.flexShrink(style.flexShrink)
|
|
40
|
-
.flexBasis(style.flexBasis)
|
|
41
|
-
.alignSelf(style.alignSelf)
|
|
42
|
-
.backgroundColor(style.backgroundColor)
|
|
43
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
44
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
45
|
-
.rotate(style.rotate)
|
|
46
|
-
.scale(style.scale)
|
|
47
|
-
.translate(style.translate)
|
|
48
|
-
.transform(style.transform)
|
|
49
|
-
.borderStyle(style.borderStyle)
|
|
50
|
-
.borderWidth(style.borderWidth)
|
|
51
|
-
.borderColor(style.borderColor)
|
|
52
|
-
.borderRadius(style.borderRadius)
|
|
53
|
-
.linearGradient(style.linearGradient)
|
|
54
|
-
.zIndex(style.zIndex)
|
|
55
|
-
.opacity(style.opacity)
|
|
56
|
-
.clip(style.clip)
|
|
57
|
-
}
|
|
58
14
|
|
|
59
15
|
@Extend(Slider)
|
|
60
16
|
function attrs (attr: SliderAttrs) {
|
|
@@ -81,79 +37,76 @@ function themeStyles(isDisabled: boolean) {
|
|
|
81
37
|
|
|
82
38
|
@Component
|
|
83
39
|
export default struct TaroSlider {
|
|
84
|
-
|
|
85
|
-
|
|
40
|
+
@Builder customBuilder() {}
|
|
41
|
+
@BuilderParam createLazyChildren: (node: TaroSliderElement) => void = this.customBuilder
|
|
86
42
|
@ObjectLink node: TaroSliderElement
|
|
87
43
|
|
|
88
44
|
@State value: number = 0
|
|
89
|
-
|
|
90
|
-
@Styles visibleChangeEvent () {
|
|
91
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
92
|
-
}
|
|
45
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
93
46
|
|
|
94
47
|
aboutToAppear () {
|
|
95
|
-
|
|
96
|
-
|
|
48
|
+
if (this.node) {
|
|
49
|
+
this.value = this.node.value
|
|
50
|
+
this.node._instance = this
|
|
97
51
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
104
|
-
const eventResult: TaroAny = res.eventResult
|
|
105
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
106
|
-
}))
|
|
52
|
+
if (!this.node._isInit) {
|
|
53
|
+
this.node._isInit = true
|
|
54
|
+
this.node._reset = this.node.value || 0
|
|
55
|
+
}
|
|
56
|
+
}
|
|
107
57
|
}
|
|
108
58
|
|
|
109
|
-
@Builder createSlider () {
|
|
59
|
+
@Builder createSlider (node: TaroSliderElement) {
|
|
110
60
|
Slider({
|
|
111
|
-
min: Number(
|
|
112
|
-
max: Number(
|
|
61
|
+
min: Number(node._attrs.min || 0),
|
|
62
|
+
max: Number(node._attrs.max || 100),
|
|
113
63
|
value: this.value,
|
|
114
|
-
step: Number(
|
|
64
|
+
step: Number(node._attrs.step || 1),
|
|
115
65
|
style: SliderStyle.OutSet,
|
|
116
66
|
direction: Axis.Horizontal
|
|
117
67
|
})
|
|
118
|
-
.
|
|
119
|
-
.
|
|
120
|
-
.
|
|
121
|
-
.
|
|
122
|
-
.themeStyles(!!this.node._attrs.disabled)
|
|
68
|
+
.attributeModifier(commonStyleModify.setNode(node).setAnimationStyle(this.overwriteStyle))
|
|
69
|
+
.attrs(getAttributes(node))
|
|
70
|
+
.width(!!node._attrs.showValue ? '90%' : '100%')
|
|
71
|
+
.themeStyles(!!node._attrs.disabled)
|
|
123
72
|
.onChange((value: number, mode: SliderChangeMode) => {
|
|
124
|
-
if (!!
|
|
73
|
+
if (!!node._attrs.disabled) {
|
|
125
74
|
if (mode === SliderChangeMode.End) {
|
|
126
|
-
|
|
127
|
-
this.value = this.value + 0.01
|
|
128
|
-
this.value = this.value - 0.01
|
|
75
|
+
this.node?.updateComponent()
|
|
129
76
|
}
|
|
130
77
|
} else {
|
|
131
78
|
this.value = value
|
|
79
|
+
this.node?.updateFormWidgetValue(value)
|
|
80
|
+
|
|
132
81
|
if (mode === SliderChangeMode.End) {
|
|
133
|
-
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } },
|
|
134
|
-
eventHandler(event, 'change',
|
|
82
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, node)
|
|
83
|
+
eventHandler(event, 'change', node)
|
|
135
84
|
} else if (mode === SliderChangeMode.Moving) {
|
|
136
|
-
const event: TaroEvent = createTaroEvent('changing', { detail: { value: this.value } },
|
|
137
|
-
eventHandler(event, 'changing',
|
|
85
|
+
const event: TaroEvent = createTaroEvent('changing', { detail: { value: this.value } }, node)
|
|
86
|
+
eventHandler(event, 'changing', node)
|
|
138
87
|
}
|
|
139
88
|
}
|
|
140
89
|
})
|
|
141
|
-
.
|
|
90
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
91
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
92
|
+
if (this.node) {
|
|
93
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
94
|
+
}
|
|
95
|
+
}))
|
|
96
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
142
97
|
}
|
|
143
98
|
|
|
144
99
|
build() {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
153
|
-
}
|
|
154
|
-
} else {
|
|
155
|
-
this.createSlider()
|
|
100
|
+
if (!!this.node._attrs.showValue) {
|
|
101
|
+
Row() {
|
|
102
|
+
this.createSlider(this.node)
|
|
103
|
+
Text(Number(this.value).toFixed(0))
|
|
104
|
+
.width('10%')
|
|
105
|
+
.textAlign(TextAlign.Center)
|
|
106
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
156
107
|
}
|
|
108
|
+
} else {
|
|
109
|
+
this.createSlider(this.node)
|
|
157
110
|
}
|
|
158
111
|
}
|
|
159
112
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import commonStyleModify from './style'
|
|
2
|
+
|
|
3
|
+
import type { TaroViewElement, TaroElement, TaroAny } from '@tarojs/runtime'
|
|
4
|
+
|
|
5
|
+
@Component
|
|
6
|
+
export default struct TaroStickySection {
|
|
7
|
+
@Builder customBuilder() {}
|
|
8
|
+
@BuilderParam createLazyChildren: (node: TaroViewElement) => void = this.customBuilder
|
|
9
|
+
@ObjectLink node: TaroViewElement
|
|
10
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
11
|
+
|
|
12
|
+
aboutToAppear(): void {
|
|
13
|
+
if (this.node) {
|
|
14
|
+
this.node._instance = this
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@Builder
|
|
19
|
+
itemHead(header: TaroViewElement) {
|
|
20
|
+
Stack() {
|
|
21
|
+
LazyForEach(header, (item: TaroElement) => {
|
|
22
|
+
if (item.tagName === 'STICKY-HEADER') {
|
|
23
|
+
this.createLazyChildren(item as TaroViewElement)
|
|
24
|
+
}
|
|
25
|
+
}, (item: TaroElement) => `${item._nid}-${item._nodeInfo?.layer || 0}`)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
build() {
|
|
30
|
+
ListItemGroup({
|
|
31
|
+
header: this.itemHead(this.node)
|
|
32
|
+
}) {
|
|
33
|
+
ForEach(this.node.children, (item: TaroElement) => {
|
|
34
|
+
if (item.tagName === 'LIST-VIEW') {
|
|
35
|
+
this.createLazyChildren(item as TaroViewElement)
|
|
36
|
+
}
|
|
37
|
+
}, (item: TaroElement) => `${item._nid}-${item._nodeInfo?.layer || 0}`)
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
41
|
+
}
|
|
42
|
+
}
|