@tarojs/plugin-platform-harmony-ets 4.0.0-alpha.0 → 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/base/system.ts +73 -20
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +16 -8
- package/dist/apis/device/memory.ts +10 -3
- package/dist/apis/framework/index.ts +1 -5
- package/dist/apis/index.ts +27 -17
- package/dist/apis/media/image/index.ts +1 -1
- package/dist/apis/media/video/VideoContext.ts +56 -7
- package/dist/apis/media/video/index.ts +3 -2
- package/dist/apis/network/request.ts +5 -5
- package/dist/apis/route/index.ts +15 -0
- package/dist/apis/storage/index.ts +146 -78
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +2 -1
- package/dist/apis/ui/interaction/index.ts +42 -59
- package/dist/apis/ui/navigation-bar/index.ts +1 -1
- package/dist/apis/ui/pull-down-refresh.ts +9 -3
- package/dist/apis/ui/scroll/index.ts +5 -5
- package/dist/apis/ui/tab-bar.ts +3 -3
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/index.ts +2 -0
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +68 -68
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +81 -102
- package/dist/components-harmony-ets/form.ets +54 -45
- package/dist/components-harmony-ets/icon.ets +34 -50
- package/dist/components-harmony-ets/image.ets +35 -45
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +11 -6
- package/dist/components-harmony-ets/input.ets +51 -67
- package/dist/components-harmony-ets/label.ets +73 -53
- 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 +74 -77
- 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 +82 -104
- package/dist/components-harmony-ets/richText.ets +20 -68
- package/dist/components-harmony-ets/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +67 -103
- package/dist/components-harmony-ets/slider.ets +23 -47
- 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 +64 -53
- package/dist/components-harmony-ets/switch.ets +44 -55
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +134 -75
- package/dist/components-harmony-ets/textArea.ets +54 -62
- 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/flexManager.ets +76 -8
- package/dist/components-harmony-ets/utils/helper.ets +20 -7
- 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 +54 -50
- package/dist/components-harmony-ets/utils/styles.ets +178 -63
- package/dist/components-harmony-ets/video.ets +37 -54
- package/dist/components-harmony-ets/view.ets +63 -94
- package/dist/components-harmony-ets/webView.ets +56 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +199 -58
- 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 +28 -12
- package/dist/runtime-ets/dom/class-list.ts +2 -2
- package/dist/runtime-ets/dom/cssNesting.ts +409 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +29 -19
- package/dist/runtime-ets/dom/document.ts +22 -8
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +334 -57
- package/dist/runtime-ets/dom/element/form.ts +32 -26
- package/dist/runtime-ets/dom/element/index.ts +33 -2
- 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 +36 -8
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +1 -0
- package/dist/runtime-ets/dom/element/text.ts +1 -8
- package/dist/runtime-ets/dom/element/video.ts +5 -4
- package/dist/runtime-ets/dom/element/webView.ts +68 -0
- package/dist/runtime-ets/dom/event.ts +2 -4
- package/dist/runtime-ets/dom/eventTarget.ts +2 -3
- package/dist/runtime-ets/dom/node.ts +62 -27
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +98 -518
- package/dist/runtime-ets/dom/stylesheet/type.ts +92 -17
- package/dist/runtime-ets/dom/stylesheet/util.ts +74 -16
- package/dist/runtime-ets/index.ts +2 -2
- package/dist/runtime-ets/interface/event.ts +3 -2
- package/dist/runtime-ets/utils/index.ts +77 -12
- package/dist/runtime-ets/utils/info.ts +4 -2
- package/dist/runtime-framework/react/app.ts +17 -22
- 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 +4 -9
- 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 -30
- 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 +510 -237
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +510 -237
- 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 +3 -1
- package/dist/runtime-ets/utils/bind.ts +0 -24
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,73 +1,25 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import type { TaroAny,
|
|
8
|
-
|
|
9
|
-
@
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
24
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
25
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
26
|
-
.rotate(style.rotate)
|
|
27
|
-
.scale(style.scale)
|
|
28
|
-
.translate(style.translate)
|
|
29
|
-
.transform(style.transform)
|
|
30
|
-
.borderStyle(style.borderStyle)
|
|
31
|
-
.borderWidth(style.borderWidth)
|
|
32
|
-
.borderColor(style.borderColor)
|
|
33
|
-
.borderRadius(style.borderRadius)
|
|
34
|
-
// .linearGradient(style.linearGradient)
|
|
35
|
-
.zIndex(style.zIndex)
|
|
36
|
-
.opacity(style.opacity)
|
|
37
|
-
.clip(style.clip)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
function generateText (node: TaroRichTextElement): string {
|
|
42
|
-
return parseHtmlNode(node._attrs.nodes || '')
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
@Builder
|
|
46
|
-
export default function TaroRichText (node: TaroRichTextElement) {
|
|
47
|
-
RichText(generateText(node))
|
|
48
|
-
.attrs(getNormalAttributes(node))
|
|
49
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
|
|
50
|
-
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
51
|
-
node._nodeInfo.areaInfo = res[1]
|
|
52
|
-
}))
|
|
53
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// 将nodeTree转换成harmony需要的string结构
|
|
57
|
-
function nodeToHtml(node: RichTextProps.Text | RichTextProps.HTMLElement): string {
|
|
58
|
-
if (node.type === 'text') {
|
|
59
|
-
return node.text;
|
|
60
|
-
}
|
|
61
|
-
if (node.attrs) {
|
|
62
|
-
const attributes = Object.entries(node.attrs)
|
|
63
|
-
.map((item: [string, string]) => `${item[0]}="${item[1]}"`)
|
|
64
|
-
.join(' ');
|
|
65
|
-
const childrenHtml: string = typeof node.children === 'string' ? node.children : (node.children || []).map((child: RichTextProps.Text | RichTextProps.HTMLElement) => nodeToHtml(child)).join('');
|
|
66
|
-
return `<${node.name}${attributes ? ' ' + attributes : ''}>${childrenHtml}</${node.name}>`;
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { generateText } from './utils'
|
|
5
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
6
|
+
|
|
7
|
+
import type { TaroAny, TaroRichTextElement } from '@tarojs/runtime'
|
|
8
|
+
|
|
9
|
+
@Component
|
|
10
|
+
export default struct TaroRichText {
|
|
11
|
+
@Builder customBuilder() {}
|
|
12
|
+
@BuilderParam createLazyChildren: (node: TaroRichTextElement) => void = this.customBuilder
|
|
13
|
+
@ObjectLink node: TaroRichTextElement
|
|
14
|
+
|
|
15
|
+
build () {
|
|
16
|
+
RichText(generateText(this.node))
|
|
17
|
+
.attributeModifier(commonStyleModify.setNode(this.node))
|
|
18
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
19
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
20
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
21
|
+
}))
|
|
22
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
67
23
|
}
|
|
68
|
-
return ''
|
|
69
24
|
}
|
|
70
25
|
|
|
71
|
-
function parseHtmlNode (nodes: Array<RichTextProps.Text | RichTextProps.HTMLElement> | string) {
|
|
72
|
-
return typeof nodes === 'string' ? nodes: `<div>${nodes.map(node => nodeToHtml(node)).join('')}</div>`
|
|
73
|
-
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
6
|
+
|
|
7
|
+
import type { TaroScrollViewElement, TaroAny, TaroEvent } from '@tarojs/runtime'
|
|
8
|
+
|
|
9
|
+
interface ScrollViewAttrs {
|
|
10
|
+
scrollBar: BarState
|
|
11
|
+
}
|
|
12
|
+
interface ScrollViewCurrentOffset {
|
|
13
|
+
xOffset: number
|
|
14
|
+
yOffset: number
|
|
15
|
+
}
|
|
16
|
+
interface ScrollViewEvent {
|
|
17
|
+
deltaX: number
|
|
18
|
+
deltaY: number
|
|
19
|
+
scrollLeft: number
|
|
20
|
+
scrollTop: number
|
|
21
|
+
scrollWidth: number
|
|
22
|
+
scrollHeight: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
|
|
26
|
+
const _attrs = node._attrs
|
|
27
|
+
const scrollAttrs: ScrollViewAttrs = {
|
|
28
|
+
scrollBar: typeof _attrs.showScrollbar === 'boolean'
|
|
29
|
+
? _attrs.showScrollbar ? BarState.On : BarState.Off
|
|
30
|
+
: BarState.Auto
|
|
31
|
+
}
|
|
32
|
+
return scrollAttrs
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', scrollOffset?: number) {
|
|
36
|
+
const currentOffset = node.scroller.currentOffset() as ScrollViewCurrentOffset
|
|
37
|
+
const currentXOffset = currentOffset?.xOffset || 0
|
|
38
|
+
const currentYOffset = currentOffset?.yOffset || 0
|
|
39
|
+
const value: ScrollViewEvent = {
|
|
40
|
+
deltaX: vp2px(node._attrs.scrollX ? scrollOffset : 0),
|
|
41
|
+
deltaY: vp2px(node._attrs.scrollX ? 0 : scrollOffset),
|
|
42
|
+
scrollLeft: vp2px(currentXOffset),
|
|
43
|
+
scrollTop: vp2px(currentYOffset),
|
|
44
|
+
scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
|
|
45
|
+
scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
|
|
46
|
+
}
|
|
47
|
+
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
|
|
48
|
+
|
|
49
|
+
eventHandler(event, eventName, node)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Component
|
|
53
|
+
export default struct TaroScrollList {
|
|
54
|
+
@Builder customBuilder() {}
|
|
55
|
+
@BuilderParam createLazyChildren: (node: TaroScrollViewElement) => void = this.customBuilder
|
|
56
|
+
@ObjectLink node: TaroScrollViewElement
|
|
57
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
58
|
+
|
|
59
|
+
aboutToAppear(): void {
|
|
60
|
+
if (this.node) {
|
|
61
|
+
this.node._instance = this
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
handleScroll = (scrollOffset: number) => {
|
|
66
|
+
handleScrollEvent(this.node, 'scroll', scrollOffset)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
build() {
|
|
70
|
+
List({
|
|
71
|
+
scroller: this.node.scroller
|
|
72
|
+
}) {
|
|
73
|
+
this.createLazyChildren(this.node)
|
|
74
|
+
}
|
|
75
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
76
|
+
.sticky(StickyStyle.Header)
|
|
77
|
+
.listDirection(this.node.getAttribute('scrollX') ? Axis.Horizontal: Axis.Vertical)
|
|
78
|
+
.align(Alignment.TopStart)
|
|
79
|
+
.clip(true)
|
|
80
|
+
.scrollBar(getAttributes(this.node).scrollBar)
|
|
81
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
82
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
83
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
84
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
85
|
+
}))
|
|
86
|
+
.onDidScroll(shouldBindEvent((scrollOffset: number) => { handleScrollEvent(this.node, 'scroll', scrollOffset) }, this.node, ['scroll']))
|
|
87
|
+
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
88
|
+
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
89
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
90
|
+
.onReachEnd(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrolltolower') }, this.node, ['scrolltolower']))
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import PseduoChildren from './pseudo'
|
|
5
|
+
import { FlexManager } from './utils/flexManager'
|
|
4
6
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
5
|
-
import { getNodeThresholds,
|
|
7
|
+
import { getNodeThresholds, getStyleAttr, shouldBindEvent } from './utils/helper'
|
|
6
8
|
|
|
7
|
-
import type { TaroAny,
|
|
9
|
+
import type { TaroAny, TaroScrollViewElement, TaroEvent } from '@tarojs/runtime'
|
|
8
10
|
|
|
9
11
|
interface ScrollViewAttrs {
|
|
10
12
|
scrollBar: BarState
|
|
@@ -22,77 +24,6 @@ interface ScrollViewEvent {
|
|
|
22
24
|
scrollHeight: number
|
|
23
25
|
}
|
|
24
26
|
|
|
25
|
-
@Extend(Row)
|
|
26
|
-
function rowAttrs (style: TaroStyleType) {
|
|
27
|
-
.id(style.id)
|
|
28
|
-
.key(style.id)
|
|
29
|
-
.padding(style.padding)
|
|
30
|
-
.margin(style.margin)
|
|
31
|
-
.height(style.height)
|
|
32
|
-
.constraintSize({
|
|
33
|
-
minWidth: style?.constraintSize?.minWidth || style.width,
|
|
34
|
-
minHeight: style?.constraintSize?.minHeight,
|
|
35
|
-
maxWidth: style?.constraintSize?.maxWidth,
|
|
36
|
-
maxHeight: style?.constraintSize?.maxHeight,
|
|
37
|
-
})
|
|
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
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
46
|
-
.rotate(style.rotate)
|
|
47
|
-
.scale(style.scale)
|
|
48
|
-
.translate(style.translate)
|
|
49
|
-
.transform(style.transform)
|
|
50
|
-
.borderStyle(style.borderStyle)
|
|
51
|
-
.borderWidth(style.borderWidth)
|
|
52
|
-
.borderColor(style.borderColor)
|
|
53
|
-
.borderRadius(style.borderRadius)
|
|
54
|
-
.linearGradient(style.linearGradient)
|
|
55
|
-
.zIndex(style.zIndex)
|
|
56
|
-
.opacity(style.opacity)
|
|
57
|
-
.clip(style.clip)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
@Extend(Column)
|
|
61
|
-
function columnAttrs (style: TaroStyleType) {
|
|
62
|
-
.id(style.id)
|
|
63
|
-
.key(style.id)
|
|
64
|
-
.padding(style.padding)
|
|
65
|
-
.margin(style.margin)
|
|
66
|
-
.width(style.width)
|
|
67
|
-
.constraintSize({
|
|
68
|
-
minWidth: style?.constraintSize?.minWidth,
|
|
69
|
-
minHeight: style?.constraintSize?.minHeight || style.height,
|
|
70
|
-
maxWidth: style?.constraintSize?.maxWidth,
|
|
71
|
-
maxHeight: style?.constraintSize?.maxHeight,
|
|
72
|
-
})
|
|
73
|
-
.flexGrow(style.flexGrow)
|
|
74
|
-
.flexShrink(style.flexShrink)
|
|
75
|
-
.flexBasis(style.flexBasis)
|
|
76
|
-
.alignSelf(style.alignSelf)
|
|
77
|
-
.backgroundColor(style.backgroundColor)
|
|
78
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
79
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
80
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
81
|
-
.rotate(style.rotate)
|
|
82
|
-
.scale(style.scale)
|
|
83
|
-
.translate(style.translate)
|
|
84
|
-
.transform(style.transform)
|
|
85
|
-
.borderStyle(style.borderStyle)
|
|
86
|
-
.borderWidth(style.borderWidth)
|
|
87
|
-
.borderColor(style.borderColor)
|
|
88
|
-
.borderRadius(style.borderRadius)
|
|
89
|
-
.linearGradient(style.linearGradient)
|
|
90
|
-
.zIndex(style.zIndex)
|
|
91
|
-
.opacity(style.opacity)
|
|
92
|
-
.clip(style.clip)
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
|
|
96
27
|
function getAttributes (node: TaroScrollViewElement): ScrollViewAttrs {
|
|
97
28
|
const _attrs = node._attrs
|
|
98
29
|
const scrollAttrs: ScrollViewAttrs = {
|
|
@@ -110,7 +41,7 @@ function getScrollable (node: TaroScrollViewElement) {
|
|
|
110
41
|
}
|
|
111
42
|
|
|
112
43
|
function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', xOffset?: number, yOffset?: number) {
|
|
113
|
-
const currentOffset
|
|
44
|
+
const currentOffset = node.scroller.currentOffset() as ScrollViewCurrentOffset
|
|
114
45
|
const currentXOffset = currentOffset.xOffset
|
|
115
46
|
const currentYOffset = currentOffset.yOffset
|
|
116
47
|
const value: ScrollViewEvent = {
|
|
@@ -118,50 +49,83 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
|
|
|
118
49
|
deltaY: vp2px(yOffset),
|
|
119
50
|
scrollLeft: vp2px(currentXOffset),
|
|
120
51
|
scrollTop: vp2px(currentYOffset),
|
|
121
|
-
scrollWidth: vp2px(Number(node._scroll?.width)),
|
|
122
|
-
scrollHeight: vp2px(Number(node._scroll?.height)),
|
|
52
|
+
scrollWidth: vp2px(Number(node._nodeInfo?._scroll?.width)),
|
|
53
|
+
scrollHeight: vp2px(Number(node._nodeInfo?._scroll?.height)),
|
|
123
54
|
}
|
|
124
55
|
const event: TaroEvent = createTaroEvent(eventName, { detail: value }, node)
|
|
125
56
|
|
|
126
57
|
eventHandler(event, eventName, node)
|
|
127
58
|
}
|
|
128
59
|
|
|
129
|
-
@
|
|
130
|
-
export default
|
|
131
|
-
|
|
132
|
-
|
|
60
|
+
@Component
|
|
61
|
+
export default struct TaroScrollView {
|
|
62
|
+
@Builder customBuilder() {}
|
|
63
|
+
@BuilderParam createLazyChildren: (node: TaroScrollViewElement) => void = this.customBuilder
|
|
64
|
+
@ObjectLink node: TaroScrollViewElement
|
|
65
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
66
|
+
|
|
67
|
+
aboutToAppear(): void {
|
|
68
|
+
if (this.node) {
|
|
69
|
+
this.node._instance = this
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
isScrollX() {
|
|
74
|
+
return this.node._attrs.scrollX || getStyleAttr(this.node, 'overflow') === 'scroll' && getStyleAttr(this.node, 'flexDirection') === FlexDirection.Row
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
build () {
|
|
78
|
+
Scroll(this.node.scroller) {
|
|
79
|
+
if (this.isScrollX()) {
|
|
133
80
|
Row() {
|
|
134
|
-
|
|
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)
|
|
85
|
+
}
|
|
135
86
|
}
|
|
87
|
+
.alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
|
|
88
|
+
.justifyContent(FlexManager.justifyContent(this.node))
|
|
89
|
+
.height(getStyleAttr(this.node, 'height'))
|
|
136
90
|
.width(null)
|
|
137
|
-
.rowAttrs(getNormalAttributes(node))
|
|
138
91
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
139
|
-
node._scroll = areaResult
|
|
140
|
-
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
92
|
+
this.node._nodeInfo._scroll = areaResult
|
|
93
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
94
|
+
.flexGrow(0).flexShrink(0)
|
|
141
95
|
} else {
|
|
142
96
|
Column() {
|
|
143
|
-
|
|
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)
|
|
101
|
+
}
|
|
144
102
|
}
|
|
103
|
+
.alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
|
|
104
|
+
.justifyContent(FlexManager.justifyContent(this.node))
|
|
105
|
+
.width(getStyleAttr(this.node, 'width'))
|
|
145
106
|
.height(null)
|
|
146
|
-
.columnAttrs(getNormalAttributes(node))
|
|
147
|
-
.alignItems(HorizontalAlign.Start)
|
|
148
107
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
149
|
-
node._scroll = areaResult
|
|
150
|
-
}, node, ['scroll', 'scrollstart', 'scrollend']))
|
|
108
|
+
this.node._nodeInfo._scroll = areaResult
|
|
109
|
+
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
110
|
+
.flexGrow(0).flexShrink(0)
|
|
151
111
|
}
|
|
152
112
|
}
|
|
153
|
-
.
|
|
154
|
-
.
|
|
155
|
-
.
|
|
156
|
-
.
|
|
157
|
-
.
|
|
158
|
-
.
|
|
159
|
-
.
|
|
160
|
-
.
|
|
161
|
-
|
|
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]
|
|
162
124
|
}))
|
|
163
|
-
.
|
|
164
|
-
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(node, 'scrollstart') }, node, ['scrollstart']))
|
|
165
|
-
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(node, 'scrollend') }, node, ['scrollend']))
|
|
166
|
-
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
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']))
|
|
130
|
+
}
|
|
167
131
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
4
5
|
|
|
5
|
-
import type { TaroAny, TaroSliderElement,
|
|
6
|
+
import type { TaroAny, TaroSliderElement, TaroEvent } from '@tarojs/runtime'
|
|
6
7
|
|
|
7
8
|
interface SliderAttrs {
|
|
8
9
|
selectedColor?: ResourceColor
|
|
@@ -11,37 +12,6 @@ interface SliderAttrs {
|
|
|
11
12
|
blockColor?: ResourceColor
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
@Extend(Slider)
|
|
15
|
-
function style (style: TaroStyleType) {
|
|
16
|
-
.id(style.id)
|
|
17
|
-
.key(style.id)
|
|
18
|
-
.padding(style.padding)
|
|
19
|
-
.margin(style.margin)
|
|
20
|
-
.width(style.width)
|
|
21
|
-
.height(style.height)
|
|
22
|
-
.constraintSize(style.constraintSize)
|
|
23
|
-
.flexGrow(style.flexGrow)
|
|
24
|
-
.flexShrink(style.flexShrink)
|
|
25
|
-
.flexBasis(style.flexBasis)
|
|
26
|
-
.alignSelf(style.alignSelf)
|
|
27
|
-
.backgroundColor(style.backgroundColor)
|
|
28
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
29
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
30
|
-
.backgroundImagePosition(style.backgroundImagePosition)
|
|
31
|
-
.rotate(style.rotate)
|
|
32
|
-
.scale(style.scale)
|
|
33
|
-
.translate(style.translate)
|
|
34
|
-
.transform(style.transform)
|
|
35
|
-
.borderStyle(style.borderStyle)
|
|
36
|
-
.borderWidth(style.borderWidth)
|
|
37
|
-
.borderColor(style.borderColor)
|
|
38
|
-
.borderRadius(style.borderRadius)
|
|
39
|
-
.linearGradient(style.linearGradient)
|
|
40
|
-
.zIndex(style.zIndex)
|
|
41
|
-
.opacity(style.opacity)
|
|
42
|
-
.clip(style.clip)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
15
|
@Extend(Slider)
|
|
46
16
|
function attrs (attr: SliderAttrs) {
|
|
47
17
|
.selectedColor(attr.selectedColor)
|
|
@@ -67,14 +37,22 @@ function themeStyles(isDisabled: boolean) {
|
|
|
67
37
|
|
|
68
38
|
@Component
|
|
69
39
|
export default struct TaroSlider {
|
|
70
|
-
|
|
40
|
+
@Builder customBuilder() {}
|
|
41
|
+
@BuilderParam createLazyChildren: (node: TaroSliderElement) => void = this.customBuilder
|
|
42
|
+
@ObjectLink node: TaroSliderElement
|
|
71
43
|
|
|
72
44
|
@State value: number = 0
|
|
45
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
73
46
|
|
|
74
47
|
aboutToAppear () {
|
|
75
48
|
if (this.node) {
|
|
76
49
|
this.value = this.node.value
|
|
77
50
|
this.node._instance = this
|
|
51
|
+
|
|
52
|
+
if (!this.node._isInit) {
|
|
53
|
+
this.node._isInit = true
|
|
54
|
+
this.node._reset = this.node.value || 0
|
|
55
|
+
}
|
|
78
56
|
}
|
|
79
57
|
}
|
|
80
58
|
|
|
@@ -87,7 +65,7 @@ export default struct TaroSlider {
|
|
|
87
65
|
style: SliderStyle.OutSet,
|
|
88
66
|
direction: Axis.Horizontal
|
|
89
67
|
})
|
|
90
|
-
.
|
|
68
|
+
.attributeModifier(commonStyleModify.setNode(node).setAnimationStyle(this.overwriteStyle))
|
|
91
69
|
.attrs(getAttributes(node))
|
|
92
70
|
.width(!!node._attrs.showValue ? '90%' : '100%')
|
|
93
71
|
.themeStyles(!!node._attrs.disabled)
|
|
@@ -99,7 +77,7 @@ export default struct TaroSlider {
|
|
|
99
77
|
} else {
|
|
100
78
|
this.value = value
|
|
101
79
|
this.node?.updateFormWidgetValue(value)
|
|
102
|
-
|
|
80
|
+
|
|
103
81
|
if (mode === SliderChangeMode.End) {
|
|
104
82
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, node)
|
|
105
83
|
eventHandler(event, 'change', node)
|
|
@@ -119,18 +97,16 @@ export default struct TaroSlider {
|
|
|
119
97
|
}
|
|
120
98
|
|
|
121
99
|
build() {
|
|
122
|
-
if (this.node) {
|
|
123
|
-
|
|
124
|
-
Row() {
|
|
125
|
-
this.createSlider(this.node)
|
|
126
|
-
Text(Number(this.value).toFixed(0))
|
|
127
|
-
.width('10%')
|
|
128
|
-
.textAlign(TextAlign.Center)
|
|
129
|
-
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
130
|
-
}
|
|
131
|
-
} else {
|
|
100
|
+
if (!!this.node._attrs.showValue) {
|
|
101
|
+
Row() {
|
|
132
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)
|
|
133
107
|
}
|
|
108
|
+
} else {
|
|
109
|
+
this.createSlider(this.node)
|
|
134
110
|
}
|
|
135
111
|
}
|
|
136
|
-
}
|
|
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
|
+
}
|