@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,47 +1,14 @@
|
|
|
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 { TaroSwitchElement } from '
|
|
9
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
6
|
+
import type { TaroAny, TaroSwitchElement, TaroEvent } from '@tarojs/runtime'
|
|
10
7
|
|
|
11
8
|
interface SwitchAttrs {
|
|
12
9
|
selectedColor?: ResourceColor
|
|
13
10
|
}
|
|
14
11
|
|
|
15
|
-
@Extend(Toggle)
|
|
16
|
-
function styles (style: TaroStyleType) {
|
|
17
|
-
.id(style.id)
|
|
18
|
-
.key(style.id)
|
|
19
|
-
.padding(style.padding)
|
|
20
|
-
.margin(style.margin)
|
|
21
|
-
.width(style.width)
|
|
22
|
-
.height(style.height)
|
|
23
|
-
.constraintSize(style.constraintSize)
|
|
24
|
-
.flexGrow(style.flexGrow)
|
|
25
|
-
.flexShrink(style.flexShrink)
|
|
26
|
-
.flexBasis(style.flexBasis)
|
|
27
|
-
.alignSelf(style.alignSelf)
|
|
28
|
-
.backgroundColor(style.backgroundColor)
|
|
29
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
30
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
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
12
|
@Extend(Toggle)
|
|
46
13
|
function attrs(attr: SwitchAttrs) {
|
|
47
14
|
.selectedColor(attr.selectedColor)
|
|
@@ -61,53 +28,45 @@ function themeStyles(isDisabled: boolean) {
|
|
|
61
28
|
|
|
62
29
|
@Component
|
|
63
30
|
export default struct TaroSwitch {
|
|
64
|
-
|
|
65
|
-
|
|
31
|
+
@Builder customBuilder() {}
|
|
32
|
+
@BuilderParam createLazyChildren: (node: TaroSwitchElement) => void = this.customBuilder
|
|
66
33
|
@ObjectLink node: TaroSwitchElement
|
|
67
|
-
|
|
68
|
-
@State value: boolean = false
|
|
69
|
-
|
|
70
|
-
@Styles visibleChangeEvent () {
|
|
71
|
-
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
72
|
-
}
|
|
34
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
73
35
|
|
|
74
36
|
aboutToAppear () {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
37
|
+
if (this.node && !this.node._isInit) {
|
|
38
|
+
this.node._isInit = true
|
|
39
|
+
this.node._instance = this
|
|
40
|
+
this.node._reset = this.node.checked || false
|
|
41
|
+
}
|
|
79
42
|
}
|
|
80
43
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
44
|
+
build () {
|
|
45
|
+
Toggle({
|
|
46
|
+
type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
|
|
47
|
+
isOn: this.node.checked,
|
|
48
|
+
})
|
|
49
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
50
|
+
.attrs(getAttributes(this.node))
|
|
51
|
+
.themeStyles(!!this.node._attrs.disabled)
|
|
52
|
+
.onChange((isOn: boolean) => {
|
|
53
|
+
if (this.node) {
|
|
54
|
+
if (!this.node?._attrs.disabled) {
|
|
55
|
+
const event: TaroEvent = createTaroEvent('change', { detail: { value: isOn } }, this.node)
|
|
88
56
|
|
|
89
|
-
|
|
90
|
-
TaroComponentWrapper({ node: this.node }) {
|
|
91
|
-
Toggle({
|
|
92
|
-
type: this.node._attrs.type !== 'checkbox' ? ToggleType.Switch : ToggleType.Checkbox,
|
|
93
|
-
isOn: this.value,
|
|
94
|
-
})
|
|
95
|
-
.defaultEvent()
|
|
96
|
-
.styles(getNormalAttributes(this.node))
|
|
97
|
-
.attrs(getAttributes(this.node))
|
|
98
|
-
.themeStyles(!!this.node._attrs.disabled)
|
|
99
|
-
.onChange((isOn: boolean) => {
|
|
100
|
-
if (!this.node._attrs.disabled) {
|
|
101
|
-
this.value = isOn
|
|
102
|
-
const event: TaroEvent = createTaroEvent('change', { detail: { value: this.value } }, this.node)
|
|
57
|
+
this.node.updateCheckedValue(isOn)
|
|
103
58
|
eventHandler(event, 'change', this.node)
|
|
104
59
|
} else {
|
|
105
|
-
|
|
106
|
-
this.value = !this.value
|
|
107
|
-
this.value = !this.value
|
|
60
|
+
this.node.updateComponent()
|
|
108
61
|
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
65
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
66
|
+
if (this.node) {
|
|
67
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
68
|
+
}
|
|
69
|
+
}))
|
|
70
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
112
71
|
}
|
|
113
72
|
}
|
|
@@ -35,6 +35,8 @@ export const TaroAdTagName = 'ad'
|
|
|
35
35
|
export const TaroWebViewTagName = 'web-view'
|
|
36
36
|
export const TaroBlockTagName = 'block'
|
|
37
37
|
export const TaroMapTagName = 'map'
|
|
38
|
+
export const TaroPageMetaTagName = 'page-meta'
|
|
39
|
+
export const TaroNavigationBarTagName = 'navigation-bar'
|
|
38
40
|
export const TaroSlotTagName = 'slot'
|
|
39
41
|
export const TaroNativeSlotTagName = 'native-slot'
|
|
40
42
|
export const TaroCustomWrapperTagName = 'custom-wrapper'
|
|
@@ -47,3 +49,7 @@ export const TaroListTagName = 'list'
|
|
|
47
49
|
export const TaroListItemTagName = 'list-item'
|
|
48
50
|
export const TaroOpenDataTagName = 'open-data'
|
|
49
51
|
export const TaroIgnoreTagName = 'ignore'
|
|
52
|
+
|
|
53
|
+
export const TaroStickySectionTagName = 'sticky-section'
|
|
54
|
+
export const TaroStickyHeaderTagName = 'sticky-header'
|
|
55
|
+
export const TaroListViewTagName = 'list-view'
|
|
@@ -1,97 +1,152 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isString } from '@tarojs/shared'
|
|
2
|
+
import { eventHandler, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, NodeType } from '@tarojs/runtime'
|
|
2
3
|
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
4
|
+
import { textModify, setNormalTextAttributeIntoInstance } from './style'
|
|
5
|
+
import { getButtonColor } from './button'
|
|
6
|
+
import { getImageMode } from './image'
|
|
7
|
+
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
8
|
+
import { getNodeThresholds, getStyleAttr, shouldBindEvent, getNormalAttributes } from './utils/helper'
|
|
5
9
|
|
|
6
|
-
import type { TaroTextElement } from '
|
|
7
|
-
import type { TaroStyleType, TaroTextStyleType } from '@tarojs/runtime'
|
|
10
|
+
import type { TaroButtonElement, TaroElement, TaroTextElement, TaroAny, HarmonyStyle } from '@tarojs/runtime'
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.padding(style.padding)
|
|
14
|
-
.margin(style.margin)
|
|
15
|
-
.width(style.width)
|
|
16
|
-
.height(style.height)
|
|
17
|
-
.constraintSize(style.constraintSize)
|
|
18
|
-
.flexGrow(style.flexGrow)
|
|
19
|
-
.flexShrink(style.flexShrink)
|
|
20
|
-
.flexBasis(style.flexBasis)
|
|
21
|
-
.alignSelf(style.alignSelf)
|
|
22
|
-
.backgroundColor(style.backgroundColor)
|
|
23
|
-
.backgroundImage(style.backgroundImage, style.backgroundRepeat)
|
|
24
|
-
.backgroundImageSize(style.backgroundImageSize)
|
|
25
|
-
.rotate(style.rotate)
|
|
26
|
-
.scale(style.scale)
|
|
27
|
-
.translate(style.translate)
|
|
28
|
-
.transform(style.transform)
|
|
29
|
-
.borderStyle(style.borderStyle)
|
|
30
|
-
.borderWidth(style.borderWidth)
|
|
31
|
-
.borderColor(style.borderColor)
|
|
32
|
-
.borderRadius(style.borderRadius)
|
|
33
|
-
.linearGradient(style.linearGradient)
|
|
34
|
-
.zIndex(style.zIndex)
|
|
35
|
-
.opacity(style.opacity)
|
|
36
|
-
.clip(style.clip)
|
|
37
|
-
.fontColor(style.color)
|
|
38
|
-
.fontSize(style.fontSize)
|
|
39
|
-
.fontWeight(style.fontWeight)
|
|
40
|
-
.fontStyle(style.fontStyle)
|
|
41
|
-
.fontFamily(style.fontFamily)
|
|
42
|
-
.lineHeight(style.lineHeight)
|
|
43
|
-
.decoration({
|
|
44
|
-
type: style.decoration,
|
|
45
|
-
color: style.color
|
|
46
|
-
})
|
|
12
|
+
function getButtonFontSize (node: TaroButtonElement): string | number {
|
|
13
|
+
const isMini = node._attrs.size === 'mini'
|
|
14
|
+
|
|
15
|
+
return isMini ? convertNumber2VP(26) : convertNumber2VP(36)
|
|
47
16
|
}
|
|
48
17
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
18
|
+
function getTextInViewWidth (node: TaroElement | null): TaroAny {
|
|
19
|
+
if (node) {
|
|
20
|
+
const hmStyle = node.hmStyle || {}
|
|
21
|
+
const isFlexView = hmStyle.display === 'flex'
|
|
22
|
+
const width: TaroAny = getStyleAttr(node, 'width')
|
|
23
|
+
const isPercentWidth = isString(width) && width.includes('%')
|
|
24
|
+
|
|
25
|
+
return isFlexView || isPercentWidth ? null : getStyleAttr(node, 'width')
|
|
26
|
+
}
|
|
55
27
|
}
|
|
56
28
|
|
|
57
29
|
|
|
58
30
|
@Component
|
|
59
31
|
export default struct TaroText {
|
|
60
|
-
|
|
32
|
+
@Builder customBuilder() {}
|
|
33
|
+
@BuilderParam createLazyChildren: (node: TaroTextElement) => void = this.customBuilder
|
|
34
|
+
@ObjectLink node: TaroTextElement
|
|
35
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
61
36
|
|
|
62
|
-
|
|
63
|
-
|
|
37
|
+
aboutToAppear(): void {
|
|
38
|
+
if (this.node) {
|
|
39
|
+
this.node._instance = this
|
|
40
|
+
}
|
|
64
41
|
}
|
|
65
42
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
43
|
+
build () {
|
|
44
|
+
if (this.node.nodeType === NodeType.TEXT_NODE) {
|
|
45
|
+
if (this.node.parentNode) {
|
|
46
|
+
if ((this.node.parentNode as TaroElement).tagName === 'BUTTON') {
|
|
47
|
+
Text(this.node.textContent)
|
|
48
|
+
.attributeModifier(textModify.setNode(this.node?.parentElement as TaroElement, {
|
|
49
|
+
fontSize: getButtonFontSize(this.node.parentNode as TaroButtonElement),
|
|
50
|
+
color: getButtonColor(this.node.parentNode as TaroButtonElement, BUTTON_THEME_COLOR.get((this.node.parentNode as TaroButtonElement)._attrs.type || '').text)
|
|
51
|
+
}))
|
|
52
|
+
} else {
|
|
53
|
+
Text(this.node.textContent)
|
|
54
|
+
.attributeModifier(textModify.setNode(this.node?.parentElement as TaroElement))
|
|
55
|
+
.width(getTextInViewWidth(this.node.parentElement))
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
Text(this.node.textContent) {
|
|
60
|
+
// text 下还有标签
|
|
61
|
+
if (this.node.childNodes.length > 1 || ((this.node.childNodes[0] && this.node.childNodes[0] as TaroElement)?.nodeType === NodeType.ELEMENT_NODE)) {
|
|
62
|
+
ForEach(this.node.childNodes, (item: TaroElement) => {
|
|
63
|
+
createTextChildNode(item)
|
|
64
|
+
}, (item: TaroElement) => `${item._nid}${this.node._updateTrigger}`)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
68
|
+
.attributeModifier(textModify.setNode(this.node).withNormalStyle().setAnimationStyle(this.overwriteStyle))
|
|
69
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
70
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
71
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
72
|
+
}))
|
|
73
|
+
}
|
|
73
74
|
}
|
|
75
|
+
}
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
@Builder
|
|
78
|
+
function createTextChildNode (item: TaroElement) {
|
|
79
|
+
if (item.tagName === 'IMAGE') {
|
|
80
|
+
ImageSpan(item.getAttribute('src'))
|
|
81
|
+
// .attributeModifier(commonStyleModify.setNode(item))
|
|
82
|
+
.objectFit(getImageMode(item.getAttribute('mode')))
|
|
83
|
+
// .verticalAlign(align)
|
|
84
|
+
.width(item._st.hmStyle.width)
|
|
85
|
+
.height(item._st.hmStyle.height)
|
|
86
|
+
.margin({
|
|
87
|
+
top: item._st.hmStyle.marginTop,
|
|
88
|
+
left: item._st.hmStyle.marginLeft,
|
|
89
|
+
right: item._st.hmStyle.marginRight,
|
|
90
|
+
bottom: item._st.hmStyle.marginBottom,
|
|
91
|
+
})
|
|
92
|
+
.padding({
|
|
93
|
+
top: item._st.hmStyle.paddingTop,
|
|
94
|
+
left: item._st.hmStyle.paddingLeft,
|
|
95
|
+
right: item._st.hmStyle.paddingRight,
|
|
96
|
+
bottom: item._st.hmStyle.paddingBottom,
|
|
97
|
+
})
|
|
98
|
+
.textBackgroundStyle({
|
|
99
|
+
color: item._st.hmStyle.backgroundColor,
|
|
100
|
+
radius: {
|
|
101
|
+
topLeft: item._st.hmStyle.borderTopLeftRadius,
|
|
102
|
+
topRight: item._st.hmStyle.borderTopRightRadius,
|
|
103
|
+
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
|
|
104
|
+
bottomRight: item._st.hmStyle.borderBottomRightRadius,
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
.borderRadius({
|
|
108
|
+
topLeft: item._st.hmStyle.borderTopLeftRadius,
|
|
109
|
+
topRight: item._st.hmStyle.borderTopRightRadius,
|
|
110
|
+
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
|
|
111
|
+
bottomRight: item._st.hmStyle.borderBottomRightRadius
|
|
112
|
+
})
|
|
113
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', item), item, ['click']))
|
|
114
|
+
} else if (item.nodeType === NodeType.TEXT_NODE) {
|
|
115
|
+
Span(item.textContent)
|
|
116
|
+
} else if (item.tagName === 'TEXT') {
|
|
117
|
+
Span(item.textContent)
|
|
118
|
+
.attributeModifier(spanModify.setNode(item))
|
|
119
|
+
.letterSpacing(item._st.hmStyle.letterSpacing)
|
|
120
|
+
.textBackgroundStyle({
|
|
121
|
+
color: item._st.hmStyle.backgroundColor,
|
|
122
|
+
radius: {
|
|
123
|
+
topLeft: item._st.hmStyle.borderTopLeftRadius,
|
|
124
|
+
topRight: item._st.hmStyle.borderTopRightRadius,
|
|
125
|
+
bottomLeft: item._st.hmStyle.borderBottomLeftRadius,
|
|
126
|
+
bottomRight: item._st.hmStyle.borderBottomRightRadius,
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', item), item, ['click']))
|
|
81
130
|
}
|
|
131
|
+
}
|
|
82
132
|
|
|
133
|
+
class SpanStyleModify implements AttributeModifier<SpanAttribute> {
|
|
134
|
+
node: TaroTextElement | null = null
|
|
135
|
+
style: HarmonyStyle | null = null
|
|
136
|
+
overwriteStyle: Record<string, TaroAny> = {}
|
|
137
|
+
withNormal = false
|
|
83
138
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
.visibleChangeEvent()
|
|
94
|
-
}
|
|
139
|
+
setNode (node: TaroTextElement) {
|
|
140
|
+
this.node = node
|
|
141
|
+
this.style = getNormalAttributes(this.node)
|
|
142
|
+
return this
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
applyNormalAttribute(instance: SpanAttribute): void {
|
|
146
|
+
if (this.node && this.style) {
|
|
147
|
+
setNormalTextAttributeIntoInstance(instance, this.style, this.node)
|
|
95
148
|
}
|
|
96
149
|
}
|
|
97
150
|
}
|
|
151
|
+
|
|
152
|
+
const spanModify = new SpanStyleModify()
|
|
@@ -1,44 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import common from '@ohos.app.ability.common'
|
|
3
|
-
import { isNumber, isUndefined } from '@tarojs/shared'
|
|
4
|
-
import { bindFocus, bindInstanceToNode, eventHandler, Current, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo,
|
|
5
|
-
TaroEvent, TaroAny } from '@tarojs/runtime'
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
|
|
6
2
|
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { getNodeThresholds, getNormalAttributes, getFontAttributes, parseStyles, shouldBindEvent, bindAnimation } from './utils/helper'
|
|
3
|
+
import commonStyleModify from './style'
|
|
4
|
+
import { getNodeThresholds, getFontAttributes, shouldBindEvent, parseStyles } from './utils/helper'
|
|
10
5
|
|
|
11
|
-
import type { TaroTextAreaElement } from '
|
|
12
|
-
|
|
6
|
+
import type { TaroAny, TaroStyleType, TaroTextStyleType, TaroTextAreaElement, TaroEvent } from '@tarojs/runtime'
|
|
7
|
+
|
|
8
|
+
interface TextareaAttrs extends TaroTextStyleType {
|
|
9
|
+
autoFocus?: boolean
|
|
10
|
+
}
|
|
13
11
|
|
|
14
12
|
@Extend(TextArea)
|
|
15
13
|
function textStyle (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
|
-
.rotate(style.rotate)
|
|
31
|
-
.scale(style.scale)
|
|
32
|
-
.translate(style.translate)
|
|
33
|
-
.transform(style.transform)
|
|
34
|
-
.borderStyle(style.borderStyle)
|
|
35
|
-
.borderWidth(style.borderWidth)
|
|
36
|
-
.borderColor(style.borderColor)
|
|
37
|
-
.borderRadius(style.borderRadius)
|
|
38
|
-
.linearGradient(style.linearGradient)
|
|
39
|
-
.zIndex(style.zIndex)
|
|
40
|
-
.opacity(style.opacity)
|
|
41
|
-
.clip(style.clip)
|
|
42
14
|
.fontColor(style.color)
|
|
43
15
|
.fontSize(style.fontSize)
|
|
44
16
|
.fontWeight(style.fontWeight)
|
|
@@ -47,123 +19,75 @@ function textStyle (style: TaroStyleType) {
|
|
|
47
19
|
}
|
|
48
20
|
|
|
49
21
|
@Extend(TextArea)
|
|
50
|
-
function textAttr(attr:
|
|
22
|
+
function textAttr(attr: TextareaAttrs) {
|
|
51
23
|
.textAlign(attr.textAlign)
|
|
52
|
-
.maxLines(attr.
|
|
24
|
+
.maxLines(attr.WebkitLineClamp)
|
|
25
|
+
.defaultFocus(attr.autoFocus)
|
|
53
26
|
}
|
|
54
27
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
@ObjectLink node: TaroTextAreaElement
|
|
62
|
-
|
|
63
|
-
controller: TextAreaController = new TextAreaController()
|
|
28
|
+
function getAttributes(node: TaroTextAreaElement): TextareaAttrs {
|
|
29
|
+
const attrs: TaroAny = getFontAttributes(node)
|
|
30
|
+
attrs.autoFocus = node._attrs.autoFocus || node._attrs.focus || false
|
|
31
|
+
return attrs
|
|
32
|
+
}
|
|
64
33
|
|
|
65
|
-
|
|
34
|
+
function getPlaceholderColor (node: TaroTextAreaElement): string {
|
|
35
|
+
const placeholderStyle: string = node._attrs.placeholderStyle || ''
|
|
66
36
|
|
|
67
|
-
|
|
37
|
+
return parseStyles(placeholderStyle)?.color
|
|
38
|
+
}
|
|
68
39
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
this.onKeyboardHeightChange(height)
|
|
73
|
-
this._height = height
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
40
|
+
@Component
|
|
41
|
+
export default struct TaroTextArea {
|
|
42
|
+
@State value: string = ''
|
|
77
43
|
|
|
78
|
-
@
|
|
79
|
-
|
|
80
|
-
|
|
44
|
+
@Builder customBuilder() {}
|
|
45
|
+
@BuilderParam createLazyChildren: (node: TaroTextAreaElement) => void = this.customBuilder
|
|
46
|
+
@ObjectLink node: TaroTextAreaElement
|
|
47
|
+
@State overwriteStyle: Record<string, TaroAny> = {}
|
|
81
48
|
|
|
82
49
|
aboutToAppear () {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// 绑定动画
|
|
87
|
-
bindAnimation(this.node)
|
|
50
|
+
if (this.node) {
|
|
51
|
+
this.value = this.node.value
|
|
52
|
+
this.node._instance = this
|
|
88
53
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Current.contextPromise
|
|
93
|
-
.then((context: common.BaseContext) => {
|
|
94
|
-
return window.getLastWindow(context, (err, windowClass: window.Window) => {
|
|
95
|
-
const errCode: number = err.code;
|
|
96
|
-
if (errCode) {
|
|
97
|
-
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err))
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
this.windowClass = windowClass
|
|
101
|
-
windowClass.on('keyboardHeightChange', this.heightChange)
|
|
102
|
-
})
|
|
103
|
-
})
|
|
104
|
-
} catch (exception) {
|
|
105
|
-
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(exception))
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
aboutToDisappear () {
|
|
110
|
-
if (this.windowClass) {
|
|
111
|
-
try {
|
|
112
|
-
this.windowClass.off('keyboardHeightChange', this.heightChange)
|
|
113
|
-
} catch (err) {
|
|
114
|
-
console.error('Failed to obtain the top window. Cause: ' + JSON.stringify(err))
|
|
54
|
+
if (!this.node._isInit) {
|
|
55
|
+
this.node._isInit = true
|
|
56
|
+
this.node._reset = this.node.value || ''
|
|
115
57
|
}
|
|
116
58
|
}
|
|
117
59
|
}
|
|
118
60
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
build() {
|
|
151
|
-
TaroComponentWrapper({ node: this.node }) {
|
|
152
|
-
TextArea({ text: this.getText(), placeholder: this.node._attrs?.placeholder || '', controller: this.controller })
|
|
153
|
-
.focusable(true)
|
|
154
|
-
.key(this.node._nid)
|
|
155
|
-
.placeholderColor(this.getPlaceholderColor(this.node))
|
|
156
|
-
.defaultEvent()
|
|
157
|
-
.textStyle(getNormalAttributes(this.node))
|
|
158
|
-
.textAttr(getFontAttributes(this.node))
|
|
159
|
-
.onChange((value: string) => {
|
|
160
|
-
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
161
|
-
eventHandler(event, 'input', this.node)
|
|
162
|
-
this.text = value
|
|
163
|
-
})
|
|
164
|
-
.visibleChangeEvent()
|
|
165
|
-
}
|
|
61
|
+
build () {
|
|
62
|
+
TextArea({ text: this.value, placeholder: this.node._attrs?.placeholder || '', controller: this.node.controller })
|
|
63
|
+
.key(this.node._nid)
|
|
64
|
+
.maxLength(Number(this.node._attrs?.maxlength) || null)
|
|
65
|
+
.placeholderColor(getPlaceholderColor(this.node))
|
|
66
|
+
.attributeModifier(commonStyleModify.setNode(this.node).setAnimationStyle(this.overwriteStyle))
|
|
67
|
+
.textStyle(this.node?.hmStyle)
|
|
68
|
+
.textAttr(getAttributes(this.node))
|
|
69
|
+
.onChange((value: string) => {
|
|
70
|
+
const event: TaroEvent = createTaroEvent('input', { detail: { value } }, this.node)
|
|
71
|
+
|
|
72
|
+
this.value = value
|
|
73
|
+
this.node?.updateFormWidgetValue(value)
|
|
74
|
+
eventHandler(event, 'input', this.node)
|
|
75
|
+
})
|
|
76
|
+
.onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
|
|
77
|
+
.onBlur(() => {
|
|
78
|
+
const event: TaroEvent = createTaroEvent('blur', { detail: { value: this.value } }, this.node)
|
|
79
|
+
eventHandler(event, 'blur', this.node)
|
|
80
|
+
})
|
|
81
|
+
.onFocus(() => {
|
|
82
|
+
const event: TaroEvent = createTaroEvent('focus', { detail: { value: this.value, height: this.node?._height } }, this.node)
|
|
83
|
+
|
|
84
|
+
eventHandler(event, 'focus', this.node)
|
|
85
|
+
})
|
|
86
|
+
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
87
|
+
if (this.node) {
|
|
88
|
+
this.node._nodeInfo.areaInfo = res[1]
|
|
89
|
+
}
|
|
90
|
+
}))
|
|
91
|
+
.onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
|
|
166
92
|
}
|
|
167
93
|
}
|
|
168
|
-
|
|
169
|
-
export default TaroTextArea
|
|
@@ -60,7 +60,7 @@ class AttributeManager {
|
|
|
60
60
|
const dataValue: string = AttributeManager.getNodeStyle(style, 'animation')
|
|
61
61
|
|
|
62
62
|
if (dataValue) {
|
|
63
|
-
let values: string[] = dataValue.trim().split(new RegExp("/\s+/"))
|
|
63
|
+
let values: string[] = dataValue.toString().trim().split(new RegExp("/\s+/"))
|
|
64
64
|
switch (values.length) {
|
|
65
65
|
case 4:
|
|
66
66
|
res = { duration: values[0], curve: values[1], delay: values[2] }
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { bindAnimation } from './helper'
|
|
1
|
+
import { TaroAny, TaroElement } from '@tarojs/runtime'
|
|
4
2
|
|
|
5
3
|
export class DynamicCenter {
|
|
6
|
-
|
|
7
4
|
install (node: TaroElement, parentNode: TaroElement) {
|
|
8
5
|
if (!parentNode._isCompileMode) return
|
|
9
6
|
|
|
@@ -14,7 +11,7 @@ export class DynamicCenter {
|
|
|
14
11
|
if (!node._isCompileMode || !node._instance) return
|
|
15
12
|
|
|
16
13
|
if (node._attrs?._dynamicID) {
|
|
17
|
-
node._instance[node._attrs._dynamicID] =
|
|
14
|
+
node._instance[node._attrs._dynamicID] = new TaroElement('Ignore')
|
|
18
15
|
}
|
|
19
16
|
node._instance = null
|
|
20
17
|
}
|
|
@@ -25,13 +22,7 @@ export class DynamicCenter {
|
|
|
25
22
|
const dynamicID = node._attrs?._dynamicID
|
|
26
23
|
|
|
27
24
|
// dynamicID 只是为了更新到精准的 node
|
|
28
|
-
|
|
29
|
-
initComponentNodeInfo(component, node)
|
|
30
|
-
bindInstanceToNode(node, component)
|
|
31
|
-
bindFocus(node)
|
|
32
|
-
bindAnimation(node)
|
|
33
|
-
bindScrollTo(node, component)
|
|
34
|
-
|
|
25
|
+
node._instance = component
|
|
35
26
|
node._isCompileMode = true
|
|
36
27
|
|
|
37
28
|
if (dynamicID) {
|
|
@@ -45,4 +36,4 @@ export class DynamicCenter {
|
|
|
45
36
|
this.bindComponentToNodeWithDFS(node.childNodes[i] as TaroElement, component)
|
|
46
37
|
}
|
|
47
38
|
}
|
|
48
|
-
}
|
|
39
|
+
}
|