Skip to content

Commit 53f661b

Browse files
authored
refactor(types): sync components types
1 parent 5bba1fc commit 53f661b

16 files changed

+172
-65
lines changed

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

Lines changed: 52 additions & 12 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
@@ -189,11 +191,6 @@ interface ButtonProps extends StandardProps {
189191
* @supported weapp, alipay, swan, tt, jd
190192
*/
191193
onGetPhoneNumber?: CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>
192-
/**
193-
* 手机号实时验证回调,`open-type="getRealtimePhoneNumber"` 时有效
194-
* @supported weapp
195-
*/
196-
onGetRealTimePhoneNumber?: CommonEventFunction<ButtonProps.onGetRealTimePhoneNumberEventDetail>
197194
/** 当使用开放能力时,发生错误的回调
198195
*
199196
* 生效时机:`open-type="launchApp"`
@@ -218,11 +215,6 @@ interface ButtonProps extends StandardProps {
218215
* @supported weapp
219216
*/
220217
onChooseAvatar?: CommonEventFunction
221-
/**
222-
* 用户同意隐私协议事件回调,`open-type="agreePrivacyAuthorization"`时有效
223-
* @supported weapp
224-
*/
225-
onAgreePrivacyAuthorization?: CommonEventFunction
226218
/** 点击。
227219
* 说明: 每点击一次会触发一次事件,建议自行使用代码防止重复点击,可以使用 js 防抖和节流实现。
228220
* @supported alipay
@@ -287,7 +279,11 @@ declare namespace ButtonProps {
287279
reset
288280
}
289281
/** open-type 的合法值 */
290-
type OpenType = keyof openTypeKeys['weapp'] | keyof openTypeKeys['alipay'] | keyof openTypeKeys['qq']
282+
type OpenType =
283+
| keyof openTypeKeys['weapp']
284+
| keyof openTypeKeys['alipay']
285+
| keyof openTypeKeys['qq']
286+
| keyof openTypeKeys['tt']
291287
/** open-type 的合法值 */
292288
interface openTypeKeys {
293289
weapp: {
@@ -324,6 +320,21 @@ declare namespace ButtonProps {
324320
* 用户同意隐私协议按钮。可通过 bindagreeprivacyauthorization 监听用户同意隐私协议事件
325321
*/
326322
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']
327338
}
328339
/** 支付宝小程序专属的 open-type 合法值
329340
* @see https://opendocs.alipay.com/mini/component/button
@@ -369,6 +380,35 @@ declare namespace ButtonProps {
369380
/** 在自定义开放数据域组件中,向指定好友发起分享据 */
370381
shareMessageToFriend
371382
}
383+
/** TT 小程序专属的 open-type 合法值
384+
* @see https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/component/list/button/#open-type-%E7%9A%84%E5%90%88%E6%B3%95%E5%80%BC
385+
*/
386+
tt: {
387+
/** 触发用户转发, 可以配合 data-channel 属性来设置分享的 channel,具体请参考 ShareParam */
388+
share
389+
/** 获取用户手机号,可以从 bindgetphonenumber 回调中获取到用户信息,详情请参见获取手机号 */
390+
getPhoneNumber
391+
/** 跳转到抖音IM客服,详情请参见抖音IM客服能力 */
392+
im
393+
/** 跳转到抖音平台客服,详情请参见平台客服能力 */
394+
platformIm
395+
/** 跳转视频播放页,详情请参见跳转视频播放页 */
396+
navigateToVideoView
397+
/** 跳转抖音号个人页,详情请参见跳转抖音号个人页 */
398+
openAwemeUserProfile
399+
/** 跳转抖音直播间,详情请参见跳转抖音直播间 */
400+
openWebcastRoom
401+
/** 写入系统日历,详情请参见写入系统日历 */
402+
addCalendarEvent
403+
/** 添加到桌面,详情请参见添加到桌面 */
404+
addShortcut
405+
/** 加群,详情请参见加群 */
406+
joinGroup
407+
/** 私信,详情请参见私信 */
408+
privateMessage
409+
/** 主动授权私信,详情请参见主动授权私信 */
410+
authorizePrivateMessage
411+
}
372412
}
373413
/** lang 的合法值 */
374414
interface Lang {

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: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ComponentType } from 'react'
2-
import { StandardProps, CommonEventFunction, BaseEventOrigFunction } from './common'
2+
import { BaseEventOrigFunction, CommonEventFunction, StandardProps } from './common'
33
interface ScrollViewProps extends StandardProps {
44
/** 允许横向滚动
55
* @default false
@@ -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 等组件
@@ -157,7 +157,7 @@ interface ScrollViewProps extends StandardProps {
157157
* center - 目标节点显示在视口中间
158158
* end - 目标节点显示在视口结束处
159159
* nearest - 目标节点在就近的视口边缘显示,若节点已在视口内则不触发滚动
160-
* @supported weapp
160+
* @supported weapp, h5
161161
* @default 'start'
162162
*/
163163
scrollIntoViewAlignment?: 'start' | 'center' | 'end' | 'nearest'
@@ -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)