@tarojs/plugin-platform-harmony-ets 4.0.0-beta.12 → 4.0.0-beta.121
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 +60 -25
- package/dist/apis/base/weapp/life-cycle.ts +1 -1
- package/dist/apis/canvas/index.ts +10 -1
- package/dist/apis/device/clipboard.ts +23 -8
- package/dist/apis/framework/index.ts +2 -6
- package/dist/apis/index.ts +25 -17
- package/dist/apis/media/image/index.ts +169 -17
- package/dist/apis/route/index.ts +1 -2
- package/dist/apis/storage/index.ts +135 -131
- package/dist/apis/ui/animation/animation.ts +71 -29
- package/dist/apis/ui/background.ts +3 -2
- package/dist/apis/ui/interaction/index.ts +58 -59
- package/dist/apis/ui/navigation-bar/index.ts +2 -2
- package/dist/apis/ui/pull-down-refresh.ts +9 -3
- package/dist/apis/ui/scroll/index.ts +6 -6
- package/dist/apis/ui/tab-bar.ts +4 -5
- package/dist/apis/utils/index.ts +20 -2
- package/dist/apis/utils/permissions.ts +6 -0
- package/dist/apis/wxml/IntersectionObserver.ts +18 -10
- package/dist/apis/wxml/selectorQuery.ts +26 -13
- package/dist/components-harmony-ets/button.ets +36 -9
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +69 -60
- package/dist/components-harmony-ets/form.ets +33 -15
- package/dist/components-harmony-ets/icon.ets +16 -8
- package/dist/components-harmony-ets/image.ets +22 -6
- package/dist/components-harmony-ets/index.ets +39 -0
- package/dist/components-harmony-ets/innerHtml.ets +6 -5
- package/dist/components-harmony-ets/input.ets +63 -37
- package/dist/components-harmony-ets/label.ets +43 -21
- package/dist/components-harmony-ets/listView.ets +32 -0
- package/dist/components-harmony-ets/movableArea.ets +110 -51
- package/dist/components-harmony-ets/movableView.ets +74 -47
- 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 +36 -33
- package/dist/components-harmony-ets/progress.ets +31 -24
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +75 -66
- package/dist/components-harmony-ets/richText.ets +4 -25
- package/dist/components-harmony-ets/scrollList.ets +108 -0
- package/dist/components-harmony-ets/scrollView.ets +46 -42
- package/dist/components-harmony-ets/slider.ets +19 -15
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +386 -129
- package/dist/components-harmony-ets/swiper.ets +42 -5
- package/dist/components-harmony-ets/switch.ets +36 -32
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +102 -46
- package/dist/components-harmony-ets/textArea.ets +49 -34
- package/dist/components-harmony-ets/utils/AttributeManager.ets +2 -2
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -2
- package/dist/components-harmony-ets/utils/flexManager.ets +49 -19
- package/dist/components-harmony-ets/utils/helper.ets +20 -8
- 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 +169 -91
- package/dist/components-harmony-ets/video.ets +28 -20
- package/dist/components-harmony-ets/view.ets +45 -39
- package/dist/components-harmony-ets/webView.ets +6 -5
- package/dist/index.d.ts +152 -0
- package/dist/index.js +73 -44
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/URL.ts +2 -0
- package/dist/runtime-ets/bom/document.ts +5 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -3
- package/dist/runtime-ets/bom/history.ts +1 -0
- package/dist/runtime-ets/bom/location.ts +1 -0
- package/dist/runtime-ets/bom/navigator.ts +1 -21
- package/dist/runtime-ets/bom/raf.ts +1 -37
- package/dist/runtime-ets/bom/window.ts +10 -4
- package/dist/runtime-ets/constant.ts +17 -10
- package/dist/runtime-ets/current.ts +5 -2
- 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 +419 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +28 -42
- package/dist/runtime-ets/dom/document.ts +9 -12
- package/dist/runtime-ets/dom/element/canvas.ts +137 -0
- package/dist/runtime-ets/dom/element/element.ts +379 -55
- package/dist/runtime-ets/dom/element/form.ts +26 -22
- package/dist/runtime-ets/dom/element/index.ts +22 -2
- package/dist/runtime-ets/dom/element/movableArea.ts +0 -1
- package/dist/runtime-ets/dom/element/movableView.ts +238 -2
- package/dist/runtime-ets/dom/element/normal.ts +27 -6
- package/dist/runtime-ets/dom/element/progress.ts +0 -2
- package/dist/runtime-ets/dom/element/text.ts +0 -8
- package/dist/runtime-ets/dom/element/video.ts +4 -4
- package/dist/runtime-ets/dom/element/webView.ts +4 -5
- package/dist/runtime-ets/dom/event-source.ts +1 -0
- package/dist/runtime-ets/dom/event.ts +3 -5
- package/dist/runtime-ets/dom/eventTarget.ts +3 -4
- package/dist/runtime-ets/dom/node.ts +53 -22
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +418 -237
- package/dist/runtime-ets/dom/stylesheet/index.ts +29 -311
- package/dist/runtime-ets/dom/stylesheet/type.ts +53 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +33 -27
- package/dist/runtime-ets/emitter/emitter.ts +1 -0
- package/dist/runtime-ets/env.ts +1 -0
- package/dist/runtime-ets/index.ts +23 -7
- package/dist/runtime-ets/interface/event.ts +1 -1
- package/dist/runtime-ets/interface/index.ts +6 -0
- package/dist/runtime-ets/utils/index.ts +78 -19
- package/dist/runtime-ets/utils/info.ts +2 -2
- package/dist/runtime-ets/utils/router.ts +9 -0
- package/dist/runtime-framework/react/app.ts +15 -11
- package/dist/runtime-framework/react/hooks.ts +1 -2
- package/dist/runtime-framework/react/index.ts +0 -2
- package/dist/runtime-framework/react/native-page.ts +217 -81
- package/dist/runtime-framework/react/page.ts +4 -10
- package/dist/runtime-framework/react/utils/index.ts +3 -3
- package/dist/runtime-framework/solid/app.ts +29 -46
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +16 -11
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -31
- package/dist/runtime-framework/solid/reconciler/props.ts +73 -29
- 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 +3 -5
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +574 -285
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +574 -285
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- package/static/media/cancel.svg +1 -1
- package/static/media/circle.svg +1 -1
- package/static/media/clear.svg +1 -1
- package/static/media/download.svg +1 -1
- package/static/media/info.svg +1 -1
- package/static/media/info_circle.svg +1 -1
- package/static/media/search.svg +1 -1
- package/static/media/success.svg +1 -1
- package/static/media/success_no_circle.svg +1 -1
- package/static/media/warn.svg +1 -1
- package/types/harmony.d.ts +5 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +1 -1
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
|
-
import
|
|
4
|
+
import PseduoChildren from './pseudo'
|
|
5
5
|
import { FlexManager } from './utils/flexManager'
|
|
6
6
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
7
|
-
import { getNodeThresholds,
|
|
7
|
+
import { getNodeThresholds, getStyleAttr, shouldBindEvent } from './utils/helper'
|
|
8
8
|
|
|
9
|
-
import type { TaroAny,
|
|
9
|
+
import type { TaroAny, TaroEvent, TaroScrollViewElement } from '@tarojs/runtime'
|
|
10
10
|
|
|
11
11
|
interface ScrollViewAttrs {
|
|
12
12
|
scrollBar: BarState
|
|
@@ -41,7 +41,12 @@ function getScrollable (node: TaroScrollViewElement) {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', xOffset?: number, yOffset?: number) {
|
|
44
|
+
if (!node || !node.scroller) return
|
|
45
|
+
|
|
44
46
|
const currentOffset = node.scroller.currentOffset() as ScrollViewCurrentOffset
|
|
47
|
+
|
|
48
|
+
if (!currentOffset) return
|
|
49
|
+
|
|
45
50
|
const currentXOffset = currentOffset.xOffset
|
|
46
51
|
const currentYOffset = currentOffset.yOffset
|
|
47
52
|
const value: ScrollViewEvent = {
|
|
@@ -57,73 +62,72 @@ function handleScrollEvent (node: TaroScrollViewElement, eventName = 'scroll', x
|
|
|
57
62
|
eventHandler(event, eventName, node)
|
|
58
63
|
}
|
|
59
64
|
|
|
60
|
-
@Extend(Row)
|
|
61
|
-
function rowAttrs (style: TaroStyleType) {
|
|
62
|
-
.constraintSize({
|
|
63
|
-
minWidth: style.minWidth || style.width,
|
|
64
|
-
maxWidth: style.maxWidth,
|
|
65
|
-
minHeight: style.minHeight,
|
|
66
|
-
maxHeight: style.maxHeight
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
@Extend(Column)
|
|
71
|
-
function columnAttrs (style: TaroStyleType) {
|
|
72
|
-
.constraintSize({
|
|
73
|
-
minWidth: style.minWidth,
|
|
74
|
-
maxWidth: style.maxWidth,
|
|
75
|
-
minHeight: style.minHeight || style.height,
|
|
76
|
-
maxHeight: style.maxHeight
|
|
77
|
-
})
|
|
78
|
-
}
|
|
79
|
-
|
|
80
65
|
@Component
|
|
81
66
|
export default struct TaroScrollView {
|
|
67
|
+
@Builder customBuilder() {}
|
|
68
|
+
@BuilderParam createLazyChildren: (node: TaroScrollViewElement, layer?: number) => void = this.customBuilder
|
|
82
69
|
@ObjectLink node: TaroScrollViewElement
|
|
70
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
71
|
+
|
|
72
|
+
aboutToAppear(): void {
|
|
73
|
+
if (this.node) {
|
|
74
|
+
this.node._instance = this
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
isScrollX() {
|
|
79
|
+
return this.node._attrs.scrollX || getStyleAttr(this.node, 'overflow') === 'scroll' && getStyleAttr(this.node, 'flexDirection') === FlexDirection.Row
|
|
80
|
+
}
|
|
83
81
|
|
|
84
82
|
build () {
|
|
85
83
|
Scroll(this.node.scroller) {
|
|
86
|
-
if (this.
|
|
84
|
+
if (this.isScrollX()) {
|
|
87
85
|
Row() {
|
|
88
|
-
|
|
86
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
87
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
88
|
+
} else {
|
|
89
|
+
this.createLazyChildren(this.node, 0)
|
|
90
|
+
}
|
|
89
91
|
}
|
|
90
|
-
.
|
|
91
|
-
.
|
|
92
|
+
.alignItems(FlexManager.alignItems<VerticalAlign>(this.node))
|
|
93
|
+
.justifyContent(FlexManager.justifyContent(this.node))
|
|
94
|
+
.height(getStyleAttr(this.node, 'height'))
|
|
92
95
|
.width(null)
|
|
93
96
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
94
97
|
this.node._nodeInfo._scroll = areaResult
|
|
95
98
|
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
96
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as VerticalAlign)
|
|
97
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
98
99
|
.flexGrow(0).flexShrink(0)
|
|
99
100
|
} else {
|
|
100
101
|
Column() {
|
|
101
|
-
|
|
102
|
+
if (this.node._pseudo_before || this.node._pseudo_after) {
|
|
103
|
+
PseduoChildren({ node: this.node, createLazyChildren: this.createLazyChildren })
|
|
104
|
+
} else {
|
|
105
|
+
this.createLazyChildren(this.node, 0)
|
|
106
|
+
}
|
|
102
107
|
}
|
|
103
|
-
.
|
|
104
|
-
.
|
|
108
|
+
.alignItems(FlexManager.alignItems<HorizontalAlign>(this.node))
|
|
109
|
+
.justifyContent(FlexManager.justifyContent(this.node))
|
|
110
|
+
.width(getStyleAttr(this.node, 'width'))
|
|
105
111
|
.height(null)
|
|
106
|
-
.alignItems(HorizontalAlign.Start)
|
|
107
112
|
.onAreaChange(shouldBindEvent((_: Area, areaResult: Area) => {
|
|
108
113
|
this.node._nodeInfo._scroll = areaResult
|
|
109
114
|
}, this.node, ['scroll', 'scrollstart', 'scrollend']))
|
|
110
|
-
.alignItems(FlexManager.flexOptions(this.node).alignItems as HorizontalAlign)
|
|
111
|
-
.justifyContent(FlexManager.flexOptions(this.node).justifyContent)
|
|
112
115
|
.flexGrow(0).flexShrink(0)
|
|
113
116
|
}
|
|
114
117
|
}
|
|
115
|
-
.
|
|
116
|
-
.
|
|
117
|
-
.
|
|
118
|
-
.
|
|
118
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
119
|
+
.width(this.isScrollX() ? getStyleAttr(this.node, 'width') : undefined)
|
|
120
|
+
.height(!this.isScrollX() ? getStyleAttr(this.node, 'height') : undefined)
|
|
121
|
+
.align(Alignment.TopStart)
|
|
122
|
+
.clip(true)
|
|
119
123
|
.scrollable(getScrollable(this.node))
|
|
120
124
|
.scrollBar(getAttributes(this.node).scrollBar)
|
|
121
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
122
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
125
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
126
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => { eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node) }, this.node, TOUCH_EVENT_MAP.values()))
|
|
123
127
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
124
128
|
this.node._nodeInfo.areaInfo = res[1]
|
|
125
129
|
}))
|
|
126
|
-
.
|
|
130
|
+
.onDidScroll(shouldBindEvent((xOffset: number, yOffset: number) => { handleScrollEvent(this.node, 'scroll', xOffset, yOffset) }, this.node, ['scroll']))
|
|
127
131
|
.onScrollStart(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollstart') }, this.node, ['scrollstart']))
|
|
128
132
|
.onScrollStop(shouldBindEvent(() => { handleScrollEvent(this.node, 'scrollend') }, this.node, ['scrollend']))
|
|
129
133
|
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
@@ -3,13 +3,14 @@ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBL
|
|
|
3
3
|
import commonStyleModify from './style'
|
|
4
4
|
import { getNodeThresholds, shouldBindEvent } from './utils/helper'
|
|
5
5
|
|
|
6
|
-
import type { TaroAny,
|
|
6
|
+
import type { TaroAny, TaroEvent, TaroSliderElement } from '@tarojs/runtime'
|
|
7
7
|
|
|
8
8
|
interface SliderAttrs {
|
|
9
9
|
selectedColor?: ResourceColor
|
|
10
10
|
trackColor?: ResourceColor
|
|
11
11
|
trackThickness?: Length
|
|
12
12
|
blockColor?: ResourceColor
|
|
13
|
+
disabled?: boolean
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
@Extend(Slider)
|
|
@@ -18,6 +19,7 @@ function attrs (attr: SliderAttrs) {
|
|
|
18
19
|
.trackColor(attr.trackColor)
|
|
19
20
|
.trackThickness(attr.trackThickness)
|
|
20
21
|
.blockColor(attr.blockColor)
|
|
22
|
+
.enabled(!attr.disabled)
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
function getAttributes (node: TaroSliderElement): SliderAttrs {
|
|
@@ -27,6 +29,7 @@ function getAttributes (node: TaroSliderElement): SliderAttrs {
|
|
|
27
29
|
sliderAttrs.trackColor = _attrs.backgroundColor || _attrs.color || '#e9e9e9'
|
|
28
30
|
sliderAttrs.trackThickness = _attrs.blockSize
|
|
29
31
|
sliderAttrs.blockColor = _attrs.blockColor || '#ffffff'
|
|
32
|
+
sliderAttrs.disabled = !!_attrs.disabled
|
|
30
33
|
return sliderAttrs
|
|
31
34
|
}
|
|
32
35
|
|
|
@@ -37,9 +40,12 @@ function themeStyles(isDisabled: boolean) {
|
|
|
37
40
|
|
|
38
41
|
@Component
|
|
39
42
|
export default struct TaroSlider {
|
|
43
|
+
@Builder customBuilder() {}
|
|
44
|
+
@BuilderParam createLazyChildren: (node: TaroSliderElement, layer?: number) => void = this.customBuilder
|
|
40
45
|
@ObjectLink node: TaroSliderElement
|
|
41
46
|
|
|
42
47
|
@State value: number = 0
|
|
48
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
43
49
|
|
|
44
50
|
aboutToAppear () {
|
|
45
51
|
if (this.node) {
|
|
@@ -62,7 +68,7 @@ export default struct TaroSlider {
|
|
|
62
68
|
style: SliderStyle.OutSet,
|
|
63
69
|
direction: Axis.Horizontal
|
|
64
70
|
})
|
|
65
|
-
.attributeModifier(commonStyleModify.setNode(node))
|
|
71
|
+
.attributeModifier(commonStyleModify.setNode(node).setAnimationStyle(this.overwriteStyle))
|
|
66
72
|
.attrs(getAttributes(node))
|
|
67
73
|
.width(!!node._attrs.showValue ? '90%' : '100%')
|
|
68
74
|
.themeStyles(!!node._attrs.disabled)
|
|
@@ -74,7 +80,7 @@ export default struct TaroSlider {
|
|
|
74
80
|
} else {
|
|
75
81
|
this.value = value
|
|
76
82
|
this.node?.updateFormWidgetValue(value)
|
|
77
|
-
|
|
83
|
+
|
|
78
84
|
if (mode === SliderChangeMode.End) {
|
|
79
85
|
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, node)
|
|
80
86
|
eventHandler(event, 'change', node)
|
|
@@ -84,7 +90,7 @@ export default struct TaroSlider {
|
|
|
84
90
|
}
|
|
85
91
|
}
|
|
86
92
|
})
|
|
87
|
-
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
93
|
+
.onClick(shouldBindEvent((e: ClickEvent) => { eventHandler(e, 'click', this.node) }, this.node, ['click']))
|
|
88
94
|
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
89
95
|
if (this.node) {
|
|
90
96
|
this.node._nodeInfo.areaInfo = res[1]
|
|
@@ -94,18 +100,16 @@ export default struct TaroSlider {
|
|
|
94
100
|
}
|
|
95
101
|
|
|
96
102
|
build() {
|
|
97
|
-
if (this.node) {
|
|
98
|
-
|
|
99
|
-
Row() {
|
|
100
|
-
this.createSlider(this.node)
|
|
101
|
-
Text(Number(this.value).toFixed(0))
|
|
102
|
-
.width('10%')
|
|
103
|
-
.textAlign(TextAlign.Center)
|
|
104
|
-
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
105
|
-
}
|
|
106
|
-
} else {
|
|
103
|
+
if (!!this.node._attrs.showValue) {
|
|
104
|
+
Row() {
|
|
107
105
|
this.createSlider(this.node)
|
|
106
|
+
Text(Number(this.value).toFixed(0))
|
|
107
|
+
.width('10%')
|
|
108
|
+
.textAlign(TextAlign.Center)
|
|
109
|
+
.opacity(!!this.node._attrs.disabled ? 0.4 : 1)
|
|
108
110
|
}
|
|
111
|
+
} else {
|
|
112
|
+
this.createSlider(this.node)
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
|
-
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import commonStyleModify from './style'
|
|
2
|
+
import TaroListView from './listView'
|
|
3
|
+
|
|
4
|
+
import type { TaroViewElement, TaroElement, TaroAny } from '@tarojs/runtime'
|
|
5
|
+
|
|
6
|
+
@Component
|
|
7
|
+
export default struct TaroStickySection {
|
|
8
|
+
@Builder customBuilder() {}
|
|
9
|
+
@BuilderParam createLazyChildren: (node: TaroViewElement, layer?: number) => void = this.customBuilder
|
|
10
|
+
@ObjectLink node: TaroViewElement
|
|
11
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
12
|
+
|
|
13
|
+
aboutToAppear(): void {
|
|
14
|
+
if (this.node) {
|
|
15
|
+
this.node._instance = this
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@Builder
|
|
20
|
+
itemHead(header: TaroViewElement) {
|
|
21
|
+
Stack() {
|
|
22
|
+
LazyForEach(header, (item: TaroElement) => {
|
|
23
|
+
if (item.tagName === 'STICKY-HEADER') {
|
|
24
|
+
this.createLazyChildren(item as TaroViewElement, 0)
|
|
25
|
+
}
|
|
26
|
+
}, (item: TaroElement) => `${item._nid}-${item._nodeInfo?.layer || 0}`)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
build() {
|
|
31
|
+
ListItemGroup({
|
|
32
|
+
header: this.itemHead(this.node)
|
|
33
|
+
}) {
|
|
34
|
+
ForEach(this.node.children, (item: TaroElement) => {
|
|
35
|
+
if (item.tagName === 'LIST-VIEW') {
|
|
36
|
+
TaroListView({ node: item as TaroAny, createLazyChildren: this.createLazyChildren }).reuseId(item._nid.toString())
|
|
37
|
+
}
|
|
38
|
+
}, (item: TaroElement) => `${item._nid}-${item._nodeInfo?.layer || 0}`)
|
|
39
|
+
}
|
|
40
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
41
|
+
}
|
|
42
|
+
}
|