Skip to content

Commit cf573c2

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

20 files changed

+211
-74
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/ChannelVideo.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { ComponentType } from 'react'
22
import { StandardProps, CommonEventFunction } from './common'
33
interface ChannelVideoProps extends StandardProps {
4-
/** 视频 feedId
4+
/** 仅视频号视频与小程序同主体时生效。若内嵌非同主体视频,请使用 feed-token。
55
* @supported weapp
66
*/
77
feedId: string
@@ -29,7 +29,7 @@ interface ChannelVideoProps extends StandardProps {
2929
* @default false
3030
*/
3131
autoplay?: boolean
32-
/** 仅内嵌小程序非同主体视频号视频时使用,获取方式参考本指引
32+
/** 仅内嵌小程序非同主体视频号视频时使用,获取方式参考[本指引](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/channels-activity.html#feed-token)
3333
* @supported weapp
3434
*/
3535
feedToken?: string

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/LivePlayer.d.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,12 @@ interface LivePlayerProps extends StandardProps {
6161
*/
6262
pictureInPictureMode?: ('push' | 'pop')[] | 'push' | 'pop' | ''
6363
/** 当跳转到其它微信原生页面时,是否自动暂停本页面的实时音视频播放
64+
* @default true
6465
* @supported weapp, qq
6566
*/
66-
autoPauseIfOpenNative?: string
67-
/** 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本;
67+
autoPauseIfOpenNative?: boolean
68+
/** 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html ,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本;
69+
* @default 'no-referrer'
6870
* @supported weapp
6971
*/
7072
referrerPolicy?: 'origin' | 'no-referrer'
@@ -125,11 +127,16 @@ interface LivePlayerProps extends StandardProps {
125127
/** 用户选择投屏设备时触发 detail = { state: "success"/"fail" }
126128
* @supported weapp
127129
*/
128-
onCastingUserSelect?: CommonEventFunction
130+
onCastingUserSelect?: CommonEventFunction<{
131+
state: 'success' | 'fail'
132+
}>
129133
/** 投屏成功/失败时触发 detail = { type, state: "success"/"fail" }
130134
* @supported weapp
131135
*/
132-
onCastingStateChange?: CommonEventFunction
136+
onCastingStateChange?: CommonEventFunction<{
137+
type: any
138+
state: 'success' | 'fail'
139+
}>
133140
/** 投屏被中断时触发
134141
* @supported weapp
135142
*/

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ interface MapProps extends StandardProps {
3030
* @supported weapp, alipay, swan, tt, qq, jd
3131
*/
3232
markers?: MapProps.marker[]
33-
/** 标记点
33+
/** **即将移除,请使用 markers**
3434
* @supported weapp
35+
* @deprecated
3536
*/
3637
covers?: any[]
3738
/** 路线
@@ -220,11 +221,11 @@ interface MapProps extends StandardProps {
220221
/** 点击标记点对应的气泡时触发e.detail = {markerId}
221222
* @supported weapp, swan, tt, jd
222223
*/
223-
onCallOutTap?: CommonEventFunction
224+
onCallOutTap?: CommonEventFunction<MapProps.onCalloutTapEventDetail>
224225
/** 点击定位标时触发,e.detail = {longitude, latitude}
225226
* @supported weapp, tt
226227
*/
227-
onAnchorPointTap?: CommonEventFunction
228+
onAnchorPointTap?: CommonEventFunction<MapProps.point>
228229
/** 点击 panel 时触发。
229230
* @supported alipay
230231
*/
@@ -612,6 +613,22 @@ declare namespace MapProps {
612613
longitude: number
613614
latitude: number
614615
}
616+
interface onPolylineTapEventDetail {
617+
polylineId: number
618+
longitude: number
619+
latitude: number
620+
}
621+
interface onAbilityEventDetail {
622+
ability: string
623+
errCode: number
624+
errMsg: string
625+
}
626+
interface onInterpolatePointEventDetail {
627+
markerId: number
628+
longitude: number
629+
latitude: number
630+
animationStatus: 'interpolating' | 'complete'
631+
}
615632
}
616633
/** 地图。相关api Taro.createMapContext。
617634
* @classification maps

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/NavigationBar.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ interface NavigationBarProps extends StandardProps {
3030
}
3131
/** 页面导航条配置节点,用于指定导航栏的一些属性。只能是 PageMeta 组件内的第一个节点,需要配合它一同使用。
3232
* 通过这个节点可以获得类似于调用 Taro.setNavigationBarTitle Taro.setNavigationBarColor 等接口调用的效果。
33+
*
34+
* :::info
35+
* Taro v3.6.19 开始支持
36+
* 需要配合 PageMeta 组件使用
37+
* :::
38+
*
3339
* @classification navig
3440
* @supported weapp, harmony
3541
* @see https://developers.weixin.qq.com/miniprogram/dev/component/navigation-bar.html

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,47 @@ declare namespace PageMetaProps {
8080
}
8181
/** 页面属性配置节点,用于指定页面的一些属性、监听页面事件。只能是页面内的第一个节点。可以配合 navigation-bar 组件一同使用。
8282
* 通过这个节点可以获得类似于调用 Taro.setBackgroundTextStyle Taro.setBackgroundColor 等接口调用的效果。
83+
*
84+
* :::info
85+
* Taro v3.6.19 开始支持
86+
* 开发者需要在页面配置里添加:`enablePageMeta: true`
87+
* :::
88+
*
8389
* @supported weapp, alipay
90+
* @example_react
91+
* ```tsx
92+
* // page.config.ts
93+
* export default definePageConfig({ enablePageMeta: true, ... })
94+
*
95+
* // page.tsx
96+
* function Index () {
97+
* return (
98+
* <View>
99+
* <PageMeta
100+
* pageStyle={myPageStyle}
101+
* onScroll={handleScroll}
102+
* >
103+
* <NavigationBar title={title} />
104+
* </PageMeta>
105+
* </View>
106+
* )
107+
* }
108+
* ```
109+
* @example_vue
110+
* ```html
111+
* <!-- page.config.ts -->
112+
* <!-- export default definePageConfig({ enablePageMeta: true, ... }) -->
113+
*
114+
* <!-- page.vue -->
115+
* <template>
116+
* <page-meta
117+
* :page-style="myPageStyle"
118+
* `@scroll="handleScroll"
119+
* >
120+
* <navigation-bar :title="title" />
121+
* </page-meta>
122+
* </template>
123+
* ```
84124
* @see https://developers.weixin.qq.com/miniprogram/dev/component/page-meta.html
85125
*/
86126
declare const PageMeta: ComponentType<PageMetaProps>

0 commit comments

Comments
 (0)