Skip to content

Commit 899e648

Browse files
authored
refactor(types): sync components types
1 parent d1171ac commit 899e648

File tree

16 files changed

+141
-73
lines changed

16 files changed

+141
-73
lines changed

packages/taro-components/types/Button.d.ts

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,9 @@ interface ButtonProps extends StandardProps {
127127
* @supported swan
128128
*/
129129
subscribeId?: string
130-
/** 打开群资料卡时,传递的群号
130+
/** 群聊 id
131+
* @qq 打开群资料卡时,传递的群号
132+
* @tt 通过创建聊天群、查询群信息获取
131133
* @supported qq
132134
*/
133135
groupId?: string
@@ -165,10 +167,6 @@ interface ButtonProps extends StandardProps {
165167
* @supported qq
166168
*/
167169
shareMessageImg?: string
168-
/** 跳转抖音号个人页,只支持小程序绑定的品牌号、员工号、合作号
169-
* @supported tt
170-
*/
171-
dataAwemeId?: string
172170
/** 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与 Taro.getUserInfo 返回的一致
173171
*
174172
* 生效时机: `open-type="getUserInfo"`
@@ -193,11 +191,6 @@ interface ButtonProps extends StandardProps {
193191
* @supported weapp, alipay, swan, tt, jd
194192
*/
195193
onGetPhoneNumber?: CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>
196-
/**
197-
* 手机号实时验证回调,`open-type="getRealtimePhoneNumber"` 时有效
198-
* @supported weapp
199-
*/
200-
onGetRealTimePhoneNumber?: CommonEventFunction<ButtonProps.onGetRealTimePhoneNumberEventDetail>
201194
/** 当使用开放能力时,发生错误的回调
202195
*
203196
* 生效时机:`open-type="launchApp"`
@@ -222,11 +215,6 @@ interface ButtonProps extends StandardProps {
222215
* @supported weapp
223216
*/
224217
onChooseAvatar?: CommonEventFunction
225-
/**
226-
* 用户同意隐私协议事件回调,`open-type="agreePrivacyAuthorization"`时有效
227-
* @supported weapp
228-
*/
229-
onAgreePrivacyAuthorization?: CommonEventFunction
230218
/** 点击。
231219
* 说明: 每点击一次会触发一次事件,建议自行使用代码防止重复点击,可以使用 js 防抖和节流实现。
232220
* @supported alipay
@@ -265,12 +253,6 @@ interface ButtonProps extends StandardProps {
265253
* @supported qq
266254
*/
267255
onAddGroupApp?: CommonEventFunction
268-
/** 监听跳转抖音号个人页的回调
269-
*
270-
* 生效时机:`open-type="openAwemeUserProfile"`
271-
* @supported tt
272-
*/
273-
onOpenAwemeUserProfile?: CommonEventFunction
274256
}
275257
declare namespace ButtonProps {
276258
/** size 的合法值 */
@@ -297,7 +279,11 @@ declare namespace ButtonProps {
297279
reset
298280
}
299281
/** open-type 的合法值 */
300-
type OpenType = keyof openTypeKeys['weapp'] | keyof openTypeKeys['alipay'] | keyof openTypeKeys['qq'] | keyof openTypeKeys['tt']
282+
type OpenType =
283+
| keyof openTypeKeys['weapp']
284+
| keyof openTypeKeys['alipay']
285+
| keyof openTypeKeys['qq']
286+
| keyof openTypeKeys['tt']
301287
/** open-type 的合法值 */
302288
interface openTypeKeys {
303289
weapp: {
@@ -334,6 +320,21 @@ declare namespace ButtonProps {
334320
* 用户同意隐私协议按钮。可通过 bindagreeprivacyauthorization 监听用户同意隐私协议事件
335321
*/
336322
agreePrivacyAuthorization
323+
/**
324+
* 从基础库 2.32.3 版本起,隐私同意按钮支持与手机号快速验证组件耦合使用,调用方式为:
325+
* <button open-type="getPhoneNumber|agreePrivacyAuthorization">
326+
*/
327+
['getPhoneNumber|agreePrivacyAuthorization']
328+
/**
329+
* 从基础库 2.32.3 版本起,支持隐私同意按钮与手机号实时验证组件耦合使用,调用方式为:
330+
* <button open-type="getRealtimePhoneNumber|agreePrivacyAuthorization">
331+
*/
332+
['getRealtimePhoneNumber|agreePrivacyAuthorization']
333+
/**
334+
* 从基础库 2.32.3 版本起,支持隐私同意按钮与获取用户信息组件耦合使用,调用方式为:
335+
* <button open-type="getUserInfo|agreePrivacyAuthorization">
336+
*/
337+
['getUserInfo|agreePrivacyAuthorization']
337338
}
338339
/** 支付宝小程序专属的 open-type 合法值
339340
* @see https://opendocs.alipay.com/mini/component/button

packages/taro-components/types/Canvas.d.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,37 @@ interface CanvasProps extends StandardProps<any, CanvasTouchEvent> {
1414
* @supported weapp, alipay, swan, qq, jd
1515
*/
1616
disableScroll?: boolean
17-
/** 用于透传 `WebComponents` 上的属性到内部 H5 标签上
18-
* @supported h5
19-
*/
20-
nativeProps?: Record<string, unknown>
2117
/** 组件唯一标识符。
2218
* 注意:同一页面中的 id 不可重复。
23-
* @supported alipay
19+
* @supported alipay, h5
2420
*/
2521
id?: string
2622
/**
27-
* @supported alipay
23+
* @supported alipay, h5
2824
*/
2925
width?: string
3026
/**
31-
* @supported alipay
27+
* @supported alipay, h5
3228
*/
3329
height?: string
30+
/** 用于透传 `WebComponents` 上的属性到内部 H5 标签上
31+
* @supported h5
32+
*/
33+
nativeProps?: Record<string, unknown>
3434
/** 手指触摸动作开始
35-
* @supported weapp, alipay, swan, tt, qq, jd
35+
* @supported weapp, alipay, swan, tt, qq, jd, h5
3636
*/
3737
onTouchStart?: CanvasTouchEventFunction
3838
/** 手指触摸后移动
39-
* @supported weapp, alipay, swan, tt, qq, jd
39+
* @supported weapp, alipay, swan, tt, qq, jd, h5
4040
*/
4141
onTouchMove?: CanvasTouchEventFunction
4242
/** 手指触摸动作结束
43-
* @supported weapp, alipay, swan, tt, qq, jd
43+
* @supported weapp, alipay, swan, tt, qq, jd, h5
4444
*/
4545
onTouchEnd?: CanvasTouchEventFunction
4646
/** 手指触摸动作被打断,如来电提醒,弹窗
47-
* @supported weapp, alipay, swan, tt, qq, jd
47+
* @supported weapp, alipay, swan, tt, qq, jd, h5
4848
*/
4949
onTouchCancel?: CanvasTouchEventFunction
5050
/** 手指长按 500ms 之后触发,触发了长按事件后进行移动不会触发屏幕的滚动

packages/taro-components/types/CoverImage.d.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,15 @@ interface CoverImageProps extends StandardProps {
5555
* class App extends Components {
5656
* render () {
5757
* return (
58-
* <View className='container'>
59-
* <Video id='myVideo' src='src'>
60-
* <CoverView className='controls'>
61-
* <CoverView className='play' onClick='play'>
62-
* <CoverImage className='img' src='src' />
63-
* </CoverView>
64-
* </CoverView>
65-
* </Video>
58+
* <View className='container'>
59+
* <Video id='myVideo' src='src'>
60+
* <CoverView className='controls'>
61+
* <CoverView className='play' onClick='play'>
62+
* <CoverImage className='img' src='src' />
63+
* </CoverView>
64+
* </CoverView>
65+
* </Video>
66+
* </View>
6667
* )
6768
* }
6869
* }

packages/taro-components/types/GridView.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ interface GridViewProps extends StandardProps {
2929
}
3030
/**
3131
* 网格布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
32-
* @classification viewContainer
32+
* @classification skyline
3333
* @supported weapp
3434
* @see https://developers.weixin.qq.com/miniprogram/dev/component/grid-view.html
3535
*/

packages/taro-components/types/ListView.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ interface ListViewProps extends StandardProps {}
44

55
/**
66
* 列表布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
7-
* @classification viewContainer
7+
* @classification skyline
88
* @supported weapp
99
* @see https://developers.weixin.qq.com/miniprogram/dev/component/list-view.html
1010
*/

packages/taro-components/types/NativeSlot.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { ComponentType } from 'react'
1+
import { StandardProps } from './common'
22

3-
interface NativeSlotProps {
3+
import type { ComponentType, ReactNode } from 'react'
4+
5+
interface NativeSlotProps extends StandardProps {
46
/** 指定插入的 slot 位置
57
* @default none
68
* @supported weapp, swan, alipay, tt, jd, qq
@@ -10,7 +12,7 @@ interface NativeSlotProps {
1012

1113
/** 编译的原生组件支持使用 slot 插槽
1214
* @classification viewContainer
13-
* @supported weapp, swan, alipay, tt, jd, qq
15+
* @supported weapp, swan, alipay, tt, jd, qq, h5
1416
* @version 3.5.7+
1517
* @example
1618
* ```tsx

packages/taro-components/types/ScrollView.d.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ interface ScrollViewProps extends StandardProps {
130130
* @supported weapp
131131
* @default false
132132
*/
133-
enablePassive?: string
133+
enablePassive?: boolean
134134
/** 渲染模式
135135
* list - 列表模式。只会渲染在屏节点,会根据直接子节点是否在屏来按需渲染,若只有一个直接子节点则性能会退化
136136
* custom - 自定义模式。只会渲染在屏节点,子节点可以是 sticky-section list-view grid-view 等组件
@@ -252,6 +252,30 @@ declare namespace ScrollViewProps {
252252
/** 滚动速度 */
253253
velocity: number
254254
}
255+
interface RefresherStatusChange {
256+
status: RefreshStatus
257+
dy: number
258+
}
259+
const enum RefreshStatus {
260+
// 空闲
261+
Idle,
262+
// 超过下拉刷新阈值,同 bind:refresherwillRefresh 触发时机
263+
CanRefresh,
264+
// 下拉刷新,同 bind:refresherrefresh 触发时机
265+
Refreshing,
266+
// 下拉刷新完成,同 bind:refresherrestore 触发时机
267+
Completed,
268+
// 下拉刷新失败
269+
Failed,
270+
// 超过下拉二级阈值
271+
CanTwoLevel,
272+
// 开始打开二级
273+
TwoLevelOpening,
274+
// 打开二级
275+
TwoLeveling,
276+
// 开始关闭二级
277+
TwoLevelClosing,
278+
}
255279
}
256280
/** 可滚动视图区域。使用竖向滚动时,需要给scroll-view一个固定高度,通过 WXSS 设置 height。组件属性的长度单位默认为 px
257281
*

packages/taro-components/types/ShareElement.d.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ interface ShareElementProps extends StandardProps {
66
* @deprecated 使用mapkey替换key
77
*/
88
key?: string
9-
/** 映射标记
10-
* @supported weapp
11-
*/
12-
mapkey?: string
139
/** 映射标记
1410
* @supported alipay
1511
*/
@@ -68,7 +64,7 @@ interface ShareElementProps extends StandardProps {
6864
*
6965
* 共享元素是一种动画形式,类似于 [`flutter Hero`](https://flutterchina.club/animations/hero-animations/) 动画,表现为元素像是在页面间穿越一样。该组件需与 [`PageContainer`](/docs/components/viewContainer/page-container) 组件结合使用。
7066
* 使用时需在当前页放置 `ShareElement` 组件,同时在 `PageContainer` 容器中放置对应的 `ShareElement` 组件,对应关系通过属性值 key 映射。当设置 `PageContainer` `显示时,transform` 属性为 `true` 的共享元素会产生动画。当前页面容器退出时,会产生返回动画。
71-
* @classification viewContainer
67+
* @classification skyline
7268
* @supported weapp, alipay
7369
* @example_react
7470
* ```tsx

packages/taro-components/types/Slot.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import { ComponentType } from 'react'
1+
import { StandardProps } from './common'
22

3-
interface SlotProps {
3+
import type { ComponentType, ReactNode } from 'react'
4+
5+
interface SlotProps extends StandardProps {
46
/** 指定插入的 slot 位置
57
* @default none
68
* @supported weapp, swan, alipay, tt, jd, qq
@@ -15,7 +17,7 @@ interface SlotProps {
1517

1618
/** slot 插槽
1719
* @classification viewContainer
18-
* @supported weapp, swan, alipay, tt, jd, qq, harmony
20+
* @supported weapp, swan, alipay, tt, jd, qq, harmony, h5
1921
* @example
2022
* ```tsx
2123
* import { Slot, View, Text } from '@tarojs/components'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ComponentType } from 'react'
2+
3+
import { StandardProps } from './common'
4+
5+
interface SnapshotProps extends StandardProps {
6+
id: string
7+
}
8+
9+
/** 截图组件。
10+
* 支持将其子节点的渲染结果导出成图片,该组件需配合 snapshot 接口使用。 目前仅在 Skyline 渲染引擎 下支持。
11+
* @classification skyline
12+
* @supported weapp
13+
* @see https://developers.weixin.qq.com/miniprogram/dev/component/snapshot.html
14+
*/
15+
declare const Snapshot: ComponentType<SnapshotProps>
16+
export { Snapshot, SnapshotProps }

0 commit comments

Comments
 (0)