@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.2
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 +1 -1
- 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 +18 -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 +1 -1
- 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 +5 -6
- package/dist/apis/index.ts +2 -0
- 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} +3 -2
- 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 +20 -18
- package/dist/apis/ui/{animation.ts → animation/animation.ts} +2 -2
- package/dist/apis/ui/animation/index.ts +7 -0
- package/dist/apis/ui/background.ts +2 -18
- 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 +3 -0
- 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 +1 -1
- package/dist/apis/{page → ui/scroll}/index.ts +27 -22
- package/dist/apis/ui/sticky.ts +4 -0
- package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +3 -5
- package/dist/apis/ui/window.ts +20 -0
- package/dist/apis/utils/handler.ts +4 -4
- package/dist/apis/worker/index.ts +4 -0
- package/dist/apis/wxml/IntersectionObserver.ts +12 -21
- package/dist/apis/wxml/index.ts +7 -2
- package/dist/apis/wxml/nodesRef.ts +2 -2
- package/dist/apis/wxml/selectorQuery.ts +3 -4
- package/dist/components-harmony-ets/button.ets +97 -85
- package/dist/components-harmony-ets/checkbox.ets +68 -142
- package/dist/components-harmony-ets/form.ets +31 -140
- package/dist/components-harmony-ets/icon.ets +60 -75
- package/dist/components-harmony-ets/image.ets +14 -69
- package/dist/components-harmony-ets/innerHtml.ets +6 -74
- package/dist/components-harmony-ets/input.ets +62 -152
- package/dist/components-harmony-ets/label.ets +63 -96
- package/dist/components-harmony-ets/picker.ets +168 -198
- package/dist/components-harmony-ets/radio.ets +69 -146
- package/dist/components-harmony-ets/richText.ets +14 -70
- package/dist/components-harmony-ets/scrollView.ets +84 -156
- package/dist/components-harmony-ets/slider.ets +40 -88
- package/dist/components-harmony-ets/style.ets +154 -0
- package/dist/components-harmony-ets/swiper.ets +25 -166
- package/dist/components-harmony-ets/switch.ets +29 -72
- package/dist/components-harmony-ets/text.ets +37 -68
- package/dist/components-harmony-ets/textArea.ets +44 -132
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
- package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
- package/dist/components-harmony-ets/utils/flexManager.ets +45 -92
- package/dist/components-harmony-ets/utils/helper.ets +4 -64
- package/dist/components-harmony-ets/utils/index.ts +1 -1
- package/dist/components-harmony-ets/utils/styles.ets +62 -27
- package/dist/components-harmony-ets/video.ets +63 -122
- package/dist/components-harmony-ets/view.ets +52 -69
- package/dist/components-harmony-ets/webView.ets +50 -0
- package/dist/index.js +135 -8
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/getComputedStyle.ts +1 -1
- package/dist/runtime-ets/bom/window.ts +2 -2
- package/dist/runtime-ets/dom/bind.ts +80 -0
- package/dist/runtime-ets/dom/class-list.ts +2 -4
- package/dist/runtime-ets/dom/comment.ts +1 -2
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +31 -7
- package/dist/runtime-ets/dom/dataSource.ts +64 -0
- package/dist/runtime-ets/dom/document.ts +35 -47
- package/dist/runtime-ets/dom/element/element.ts +163 -0
- package/dist/runtime-ets/dom/element/form.ts +406 -0
- package/dist/runtime-ets/dom/element/index.ts +92 -0
- package/dist/runtime-ets/dom/element/normal.ts +76 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +14 -0
- package/dist/runtime-ets/dom/element/text.ts +17 -0
- package/dist/runtime-ets/dom/element/video.ts +49 -0
- package/dist/runtime-ets/dom/element/webView.ts +61 -0
- package/dist/runtime-ets/dom/event.ts +24 -1
- package/dist/runtime-ets/dom/eventTarget.ts +2 -1
- package/dist/runtime-ets/dom/node.ts +87 -44
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +263 -288
- package/dist/runtime-ets/dom/stylesheet/type.ts +47 -11
- package/dist/runtime-ets/dom/stylesheet/util.ts +129 -7
- package/dist/runtime-ets/index.ts +1 -3
- package/dist/runtime-ets/interface/event.ts +2 -1
- package/dist/runtime-ets/utils/index.ts +18 -8
- package/dist/runtime-ets/utils/info.ts +22 -48
- package/dist/runtime-framework/react/app.ts +14 -27
- package/dist/runtime-framework/react/hooks.ts +3 -3
- package/dist/runtime-framework/react/index.ts +1 -0
- package/dist/runtime-framework/react/native-page.ts +344 -0
- package/dist/runtime-framework/react/page.ts +4 -11
- package/dist/runtime-framework/solid/hooks.ts +3 -3
- package/dist/runtime-framework/solid/page.ts +0 -6
- package/dist/runtime-utils.js +1216 -349
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +1216 -349
- package/dist/runtime.js.map +1 -1
- package/package.json +12 -11
- 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/runtime.d.ts +6 -0
- 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
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-nocheck
|
|
2
1
|
/**
|
|
3
2
|
* 鸿蒙SDK API Version 6
|
|
4
3
|
* 将页面滚动到目标位置
|
|
@@ -9,26 +8,31 @@
|
|
|
9
8
|
import { AREA_CHANGE_EVENT_NAME, Current, findChildNodeWithDFS, getPageScrollerOrNode, setNodeEventCallbackAndTriggerComponentUpdate } from '@tarojs/runtime'
|
|
10
9
|
import { pxTransformHelper } from '@tarojs/taro'
|
|
11
10
|
|
|
12
|
-
import {
|
|
11
|
+
import { MethodHandler } from '../../utils/handler'
|
|
13
12
|
|
|
14
|
-
import type Taro from '@tarojs/
|
|
15
|
-
|
|
16
|
-
// TODO
|
|
17
|
-
export const getCurrentPages = () => []
|
|
13
|
+
import type Taro from '@tarojs/taro/types'
|
|
18
14
|
|
|
15
|
+
/**
|
|
16
|
+
* 将页面滚动到目标位置
|
|
17
|
+
*/
|
|
19
18
|
export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
|
|
19
|
+
const { scrollTop, selector = '', duration = 300, offsetTop = 0, success, fail, complete } = options || {}
|
|
20
|
+
const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete })
|
|
20
21
|
// eslint-disable-next-line no-async-promise-executor
|
|
21
22
|
return new Promise(async (resolve, reject) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (scrollTop === undefined && !selector) {
|
|
24
|
+
return handle.fail({
|
|
25
|
+
errMsg: 'scrollTop" 或 "selector" 需要其之一'
|
|
26
|
+
}, { resolve, reject })
|
|
27
|
+
}
|
|
27
28
|
|
|
28
29
|
if (scrollTop && selector) {
|
|
29
30
|
console.warn('"scrollTop" 或 "selector" 建议只设一个值,全部设置会忽略selector')
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
const taro = (Current as any).taro
|
|
34
|
+
const page = taro.getCurrentInstance().page
|
|
35
|
+
|
|
32
36
|
let scrollValue = -1
|
|
33
37
|
let scroller = page.scroller
|
|
34
38
|
const currentPageNode = getPageScrollerOrNode(page.node, page)
|
|
@@ -38,20 +42,17 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
|
|
|
38
42
|
} else if (selector) {
|
|
39
43
|
const node = findChildNodeWithDFS(currentPageNode, selector)
|
|
40
44
|
|
|
41
|
-
if (!node
|
|
42
|
-
|
|
43
|
-
const instance = node._instance
|
|
44
|
-
const id = node?._nid
|
|
45
|
+
if (!node) return
|
|
45
46
|
|
|
46
47
|
// 获取 areaInfo,需要先调用 setNodeEventCallbackAndTriggerComponentUpdate 更新一次组件并获取组件信息
|
|
47
48
|
await setNodeEventCallbackAndTriggerComponentUpdate(node, AREA_CHANGE_EVENT_NAME, null, true)
|
|
48
49
|
|
|
49
|
-
const { areaInfo } =
|
|
50
|
+
const { areaInfo } = node._nodeInfo || {}
|
|
50
51
|
|
|
51
52
|
let parent = node?.parentNode
|
|
52
53
|
while (!!parent && parent !== currentPageNode) {
|
|
53
|
-
if (parent?.
|
|
54
|
-
scroller = parent.
|
|
54
|
+
if (parent?.scroller) {
|
|
55
|
+
scroller = parent.scroller
|
|
55
56
|
break
|
|
56
57
|
}
|
|
57
58
|
parent = parent?.parentNode
|
|
@@ -68,7 +69,9 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
|
|
|
68
69
|
const { xOffset } = scroller.currentOffset()
|
|
69
70
|
|
|
70
71
|
if (scrollValue === -1) {
|
|
71
|
-
return
|
|
72
|
+
return handle.fail({
|
|
73
|
+
errMsg: '请检查传入的 scrollTop 或 selector 是否合法'
|
|
74
|
+
}, { resolve, reject })
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
try {
|
|
@@ -83,10 +86,12 @@ export const pageScrollTo: typeof Taro.pageScrollTo = (options) => {
|
|
|
83
86
|
})
|
|
84
87
|
|
|
85
88
|
setTimeout(() => {
|
|
86
|
-
|
|
89
|
+
handle.success({}, { resolve, reject })
|
|
87
90
|
}, duration)
|
|
88
|
-
} catch (
|
|
89
|
-
|
|
91
|
+
} catch (err) {
|
|
92
|
+
return handle.fail({
|
|
93
|
+
errMsg: err.message
|
|
94
|
+
}, { resolve, reject })
|
|
90
95
|
}
|
|
91
96
|
})
|
|
92
97
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
// eslint-disable-
|
|
2
|
-
import {
|
|
3
|
-
// eslint-disable-next-line import/no-duplicates
|
|
4
|
-
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
|
|
1
|
+
import { Current } from '@tarojs/runtime' // eslint-disable-line import/no-duplicates
|
|
2
|
+
import { eventCenter } from '@tarojs/runtime/dist/runtime.esm' // eslint-disable-line import/no-duplicates
|
|
5
3
|
|
|
6
4
|
import { callAsyncFail, callAsyncSuccess } from '../utils'
|
|
7
5
|
|
|
8
|
-
import type Taro from '@tarojs/
|
|
6
|
+
import type Taro from '@tarojs/taro/types'
|
|
9
7
|
|
|
10
8
|
interface ShowTabBar {
|
|
11
9
|
type: 'show'
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
import type Taro from '@tarojs/taro/types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 设置窗口大小,该接口仅适用于 PC 平台,使用细则请参见指南
|
|
7
|
+
*/
|
|
8
|
+
export const setWindowSize = /* @__PURE__ */ temporarilyNotSupport('setWindowSize')
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 监听窗口尺寸变化事件
|
|
12
|
+
*/
|
|
13
|
+
export const onWindowResize: typeof Taro.onWindowResize = /* @__PURE__ */ temporarilyNotSupport('onWindowResize')
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 取消监听窗口尺寸变化事件
|
|
17
|
+
*/
|
|
18
|
+
export const offWindowResize: typeof Taro.offWindowResize = /* @__PURE__ */ temporarilyNotSupport('offWindowResize')
|
|
19
|
+
|
|
20
|
+
export const checkIsPictureInPictureActive = /* @__PURE__ */ temporarilyNotSupport('checkIsPictureInPictureActive')
|
|
@@ -11,7 +11,7 @@ interface IMethodParam<T = Partial<ICallbackResult>> {
|
|
|
11
11
|
name: string
|
|
12
12
|
success?: TCallback<T & ICallbackResult>
|
|
13
13
|
fail?: TCallback
|
|
14
|
-
complete?: TCallback
|
|
14
|
+
complete?: TCallback<T | ICallbackResult>
|
|
15
15
|
}
|
|
16
16
|
interface IMockPromise {
|
|
17
17
|
resolve?: typeof Promise.resolve | TFunc
|
|
@@ -23,7 +23,7 @@ export class MethodHandler<T = Partial<ICallbackResult>> {
|
|
|
23
23
|
|
|
24
24
|
protected __success?: TCallback<T>
|
|
25
25
|
protected __fail?: TCallback
|
|
26
|
-
protected __complete?: TCallback
|
|
26
|
+
protected __complete?: TCallback<T | ICallbackResult>
|
|
27
27
|
|
|
28
28
|
protected isHandlerError = false
|
|
29
29
|
|
|
@@ -41,7 +41,7 @@ export class MethodHandler<T = Partial<ICallbackResult>> {
|
|
|
41
41
|
res.errMsg = `${this.methodName}:ok`
|
|
42
42
|
}
|
|
43
43
|
isFunction(this.__success) && this.__success(res as T)
|
|
44
|
-
isFunction(this.__complete) && this.__complete(res)
|
|
44
|
+
isFunction(this.__complete) && this.__complete(res as T)
|
|
45
45
|
|
|
46
46
|
const { resolve = Promise.resolve.bind(Promise) } = promise
|
|
47
47
|
return resolve(res as Required<T & U & ICallbackResult>)
|
|
@@ -54,7 +54,7 @@ export class MethodHandler<T = Partial<ICallbackResult>> {
|
|
|
54
54
|
res.errMsg = `${this.methodName}:fail ${res.errMsg}`
|
|
55
55
|
}
|
|
56
56
|
isFunction(this.__fail) && this.__fail(res)
|
|
57
|
-
isFunction(this.__complete) && this.__complete(res)
|
|
57
|
+
isFunction(this.__complete) && this.__complete(res as ICallbackResult)
|
|
58
58
|
|
|
59
59
|
const {
|
|
60
60
|
resolve = Promise.resolve.bind(Promise),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import Taro from '@tarojs/api'
|
|
2
|
-
// @ts-ignore
|
|
3
1
|
import { Current, disconnectEvent, findChildNodeWithDFS, getPageScrollerOrNode, setNodeEventCallbackAndTriggerComponentUpdate, TaroElement, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
4
2
|
|
|
5
3
|
import { temporarilyNotSupport } from '../utils'
|
|
6
4
|
|
|
5
|
+
import type Taro from '@tarojs/taro/types'
|
|
6
|
+
|
|
7
7
|
export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
8
8
|
// 自定义组件实例
|
|
9
9
|
private _component: any
|
|
@@ -29,17 +29,15 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
29
29
|
if (this._observerNodes instanceof Array) {
|
|
30
30
|
this._observerNodes.forEach((n: TaroElement & any) => {
|
|
31
31
|
disconnectEvent(n, VISIBLE_CHANGE_EVENT_NAME)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
n._instance?.nodeInfoMap?.[n._nid]?.thresholds = null
|
|
35
|
-
}
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
n._nodeInfo?.thresholds = null
|
|
36
34
|
})
|
|
37
35
|
} else {
|
|
38
36
|
disconnectEvent(this._observerNodes, VISIBLE_CHANGE_EVENT_NAME)
|
|
39
37
|
// @ts-ignore
|
|
40
|
-
if (this._observerNodes.
|
|
38
|
+
if (this._observerNodes._nodeInfo) {
|
|
41
39
|
// @ts-ignore
|
|
42
|
-
this._observerNodes.
|
|
40
|
+
this._observerNodes._nodeInfo?.thresholds = null
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
}
|
|
@@ -50,29 +48,22 @@ export class IntersectionObserver implements Taro.IntersectionObserver {
|
|
|
50
48
|
const node = findChildNodeWithDFS(this._component, targetSelector, observeAll)
|
|
51
49
|
this._observerNodes = node
|
|
52
50
|
|
|
53
|
-
|
|
54
51
|
if (node) {
|
|
55
52
|
if (node instanceof Array) {
|
|
56
53
|
node.forEach(n => {
|
|
57
54
|
// @ts-ignore
|
|
58
|
-
n.
|
|
59
|
-
// @ts-ignore
|
|
60
|
-
n._instance?.nodeInfoMap?.[n._nid]?.thresholds = thresholds
|
|
55
|
+
n._nodeInfo?.thresholds = thresholds
|
|
61
56
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
})
|
|
57
|
+
setNodeEventCallbackAndTriggerComponentUpdate(n, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
|
|
58
|
+
callback(this.handleResult(isVisible, currentRatio))
|
|
65
59
|
})
|
|
66
60
|
})
|
|
67
61
|
} else {
|
|
68
62
|
// @ts-ignore
|
|
69
|
-
node.
|
|
70
|
-
// @ts-ignore
|
|
71
|
-
node._instance?.nodeInfoMap?.[node._nid]?.thresholds = thresholds
|
|
63
|
+
node._nodeInfo?.thresholds = thresholds
|
|
72
64
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
})
|
|
65
|
+
setNodeEventCallbackAndTriggerComponentUpdate(node, VISIBLE_CHANGE_EVENT_NAME, (isVisible: boolean, currentRatio: number) => {
|
|
66
|
+
callback(this.handleResult(isVisible, currentRatio))
|
|
76
67
|
})
|
|
77
68
|
}
|
|
78
69
|
}
|
package/dist/apis/wxml/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
3
2
|
import { IntersectionObserver } from './IntersectionObserver'
|
|
4
3
|
import { SelectorQuery } from './selectorQuery'
|
|
5
4
|
|
|
5
|
+
import type Taro from '@tarojs/taro/types'
|
|
6
|
+
|
|
6
7
|
export const createSelectorQuery = () => {
|
|
7
8
|
return new SelectorQuery()
|
|
8
9
|
}
|
|
@@ -10,3 +11,7 @@ export const createSelectorQuery = () => {
|
|
|
10
11
|
export const createIntersectionObserver: typeof Taro.createIntersectionObserver = (component, options) => {
|
|
11
12
|
return new IntersectionObserver(component, options)
|
|
12
13
|
}
|
|
14
|
+
|
|
15
|
+
export const createMediaQueryObserver = /* @__PURE__ */ temporarilyNotSupport('createMediaQueryObserver')
|
|
16
|
+
|
|
17
|
+
export { IntersectionObserver }
|
|
@@ -2,7 +2,7 @@ import { AREA_CHANGE_EVENT_NAME, Current, getPageScrollerOrNode, setNodeEventCal
|
|
|
2
2
|
|
|
3
3
|
import { NodesRef } from './nodesRef'
|
|
4
4
|
|
|
5
|
-
import type Taro from '@tarojs/
|
|
5
|
+
import type Taro from '@tarojs/taro/types'
|
|
6
6
|
|
|
7
7
|
interface ISelectorQueryQueue {
|
|
8
8
|
component: any
|
|
@@ -135,8 +135,7 @@ function filter (fields, dom) {
|
|
|
135
135
|
// if (dataset) res.dataset = Object.assign({}, dom.dataset)
|
|
136
136
|
|
|
137
137
|
if (rect || size) {
|
|
138
|
-
const
|
|
139
|
-
const { areaInfo } = dom?._instance?.nodeInfoMap?.[id] || {}
|
|
138
|
+
const { areaInfo } = dom?._nodeInfo || {}
|
|
140
139
|
|
|
141
140
|
if (areaInfo) {
|
|
142
141
|
if (rect) {
|
|
@@ -153,7 +152,7 @@ function filter (fields, dom) {
|
|
|
153
152
|
}
|
|
154
153
|
}
|
|
155
154
|
if (scrollOffset) {
|
|
156
|
-
const scroller = dom.
|
|
155
|
+
const scroller = dom.scroller
|
|
157
156
|
|
|
158
157
|
if (scroller) {
|
|
159
158
|
const { xOffset, yOffset } = scroller.currentOffset()
|
|
@@ -1,56 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { createTaroEvent } from './utils/events'
|
|
1
|
+
import { eventHandler, createTaroEvent, convertNumber2VP, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
|
+
import { createLazyChildren } from './render'
|
|
3
|
+
import commonStyleModify from './style'
|
|
5
4
|
import { BUTTON_THEME_COLOR } from './utils/constant/style'
|
|
6
|
-
import { AttributeManager } from './utils/AttributeManager'
|
|
7
5
|
import { TOUCH_EVENT_MAP } from './utils/constant/event'
|
|
8
|
-
import {
|
|
6
|
+
import { shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
9
7
|
|
|
10
|
-
import type { TaroAny, TaroEvent } from '@tarojs/runtime'
|
|
11
|
-
import type { TaroButtonElement, TaroElement } from './element'
|
|
12
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
8
|
+
import type { TaroAny, TaroEvent, TaroButtonElement, TaroStyleType } from '@tarojs/runtime'
|
|
13
9
|
|
|
14
10
|
@Extend(Button)
|
|
15
|
-
function
|
|
16
|
-
.
|
|
17
|
-
.
|
|
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)
|
|
11
|
+
function themeStyles(style: TaroStyleType) {
|
|
12
|
+
.fontColor(style.color)
|
|
13
|
+
.opacity(style.opacity)
|
|
36
14
|
.borderColor(style.borderColor)
|
|
15
|
+
.borderWidth(style.borderWidth)
|
|
37
16
|
.borderRadius(style.borderRadius)
|
|
38
|
-
.
|
|
39
|
-
.zIndex(style.zIndex)
|
|
40
|
-
.opacity(style.opacity)
|
|
41
|
-
.clip(style.clip)
|
|
17
|
+
.backgroundColor(style.backgroundColor)
|
|
42
18
|
}
|
|
43
19
|
|
|
20
|
+
export function getButtonColor (node: TaroButtonElement, color: ResourceColor) {
|
|
21
|
+
const _attrs = node._attrs
|
|
22
|
+
const isDisabled: boolean = _attrs.disabled || false
|
|
23
|
+
const isPlain: boolean = _attrs.plain || false
|
|
24
|
+
const type: string = _attrs.type || 'default'
|
|
44
25
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
26
|
+
if (isDisabled && isPlain) {
|
|
27
|
+
return Color.Black
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (isPlain) {
|
|
31
|
+
return BUTTON_THEME_COLOR.get(type).plainText
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return color
|
|
54
35
|
}
|
|
55
36
|
|
|
56
37
|
function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
|
|
@@ -61,59 +42,90 @@ function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
|
|
|
61
42
|
const type: string = _attrs.type || 'default'
|
|
62
43
|
|
|
63
44
|
return {
|
|
64
|
-
|
|
45
|
+
borderColor: {
|
|
46
|
+
top: hmStyle.borderTopColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
|
|
47
|
+
right: hmStyle.borderRightColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
|
|
48
|
+
bottom: hmStyle.borderBottomColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background),
|
|
49
|
+
left: hmStyle.borderLeftColor || getButtonColor(node, BUTTON_THEME_COLOR.get(type).background)
|
|
50
|
+
},
|
|
51
|
+
borderWidth: {
|
|
52
|
+
top: hmStyle.borderTopWidth || 1,
|
|
53
|
+
right: hmStyle.borderRightWidth || 1,
|
|
54
|
+
bottom: hmStyle.borderBottomWidth || 1,
|
|
55
|
+
left: hmStyle.borderLeftWidth || 1
|
|
56
|
+
},
|
|
57
|
+
borderRadius: {
|
|
58
|
+
topLeft: hmStyle.borderTopLeftRadius || convertNumber2VP(10),
|
|
59
|
+
topRight: hmStyle.borderTopRightRadius || convertNumber2VP(10),
|
|
60
|
+
bottomLeft: hmStyle.borderBottomLeftRadius || convertNumber2VP(10),
|
|
61
|
+
bottomRight: hmStyle.borderBottomRightRadius || convertNumber2VP(10)
|
|
62
|
+
},
|
|
63
|
+
opacity: isDisabled ? 0.4 : hmStyle.opacity,
|
|
65
64
|
backgroundColor: isPlain ? Color.Transparent : (hmStyle.backgroundColor || BUTTON_THEME_COLOR.get(type).background),
|
|
66
|
-
color: hmStyle.color || BUTTON_THEME_COLOR.get(type).text,
|
|
65
|
+
color: hmStyle.color || getButtonColor(node, BUTTON_THEME_COLOR.get(type).text),
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
function getButtonWidth (node: TaroButtonElement) {
|
|
70
|
+
const isMini = node._attrs.size === 'mini'
|
|
71
|
+
|
|
72
|
+
return isMini ? convertNumber2VP(120) : '100%'
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function getButtonHeight (node: TaroButtonElement) {
|
|
76
|
+
const isMini = node._attrs.size === 'mini'
|
|
73
77
|
|
|
74
|
-
|
|
78
|
+
return isMini ? convertNumber2VP(60) : convertNumber2VP(92)
|
|
79
|
+
}
|
|
75
80
|
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
function getButtonMinWidth (node: TaroButtonElement): string | number | undefined {
|
|
82
|
+
if (node.hmStyle.width) {
|
|
83
|
+
return undefined
|
|
78
84
|
}
|
|
79
85
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
return getButtonWidth(node)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getButtonMinHeight (node: TaroButtonElement): string | number | undefined {
|
|
90
|
+
if (node.hmStyle.height) {
|
|
91
|
+
return undefined
|
|
85
92
|
}
|
|
86
93
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}, (item: TaroElement) => item._nid)
|
|
99
|
-
}
|
|
94
|
+
return getButtonHeight(node)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@Builder
|
|
98
|
+
export default function TaroButton (node: TaroButtonElement) {
|
|
99
|
+
Button({ stateEffect: !node._attrs.disabled }) {
|
|
100
|
+
Row() {
|
|
101
|
+
if (node._attrs.loading) {
|
|
102
|
+
LoadingProgress()
|
|
103
|
+
.width(20).height(20)
|
|
104
|
+
.color(getThemeAttributes(node).color)
|
|
100
105
|
}
|
|
101
|
-
|
|
102
|
-
.themeStyles(getThemeAttributes(this.node))
|
|
103
|
-
.onClick((e: ClickEvent) => {
|
|
104
|
-
if (['submit', 'reset'].includes(this.node._attrs.formType)) {
|
|
105
|
-
const eventName = this.node._attrs.formType + '-btn'
|
|
106
|
-
const event: TaroEvent = createTaroEvent(eventName, {}, this.node)
|
|
107
|
-
eventHandler(event, eventName, this.node)
|
|
108
|
-
}
|
|
109
|
-
eventHandler(e, 'click', this.node)
|
|
110
|
-
})
|
|
111
|
-
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
|
|
112
|
-
.onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
|
|
113
|
-
const eventResult: TaroAny = res.eventResult
|
|
114
|
-
this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
|
|
115
|
-
}))
|
|
116
|
-
.visibleChangeEvent()
|
|
106
|
+
createLazyChildren(node)
|
|
117
107
|
}
|
|
118
108
|
}
|
|
109
|
+
.themeStyles(getThemeAttributes(node))
|
|
110
|
+
.attributeModifier(commonStyleModify.setNode(node))
|
|
111
|
+
.constraintSize({
|
|
112
|
+
minWidth: node.hmStyle?.minWidth || getButtonMinWidth(node),
|
|
113
|
+
minHeight: node.hmStyle?.minHeight || getButtonMinHeight(node),
|
|
114
|
+
maxWidth: node.hmStyle?.maxWidth,
|
|
115
|
+
maxHeight: node.hmStyle?.maxHeight,
|
|
116
|
+
})
|
|
117
|
+
.type(ButtonType.Normal)
|
|
118
|
+
.onClick((e: ClickEvent) => {
|
|
119
|
+
if (node._attrs.formType && ['submit', 'reset'].includes(node._attrs.formType)) {
|
|
120
|
+
const eventName = node._attrs.formType + '-btn'
|
|
121
|
+
const event: TaroEvent = createTaroEvent(eventName, {}, node)
|
|
122
|
+
eventHandler(event, eventName, node)
|
|
123
|
+
}
|
|
124
|
+
eventHandler(e, 'click', node)
|
|
125
|
+
})
|
|
126
|
+
.onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
|
|
127
|
+
.onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
|
|
128
|
+
node._nodeInfo.areaInfo = res[1]
|
|
129
|
+
}))
|
|
130
|
+
.onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
|
|
119
131
|
}
|