Skip to content

refactor(types): sync components types #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ interface ButtonProps extends StandardProps {
* @supported swan
*/
subscribeId?: string
/** 打开群资料卡时,传递的群号
/** 群聊 id
* @qq 打开群资料卡时,传递的群号
* @tt 通过创建聊天群、查询群信息获取
* @supported qq
*/
groupId?: string
Expand Down Expand Up @@ -165,10 +167,6 @@ interface ButtonProps extends StandardProps {
* @supported qq
*/
shareMessageImg?: string
/** 跳转抖音号个人页,只支持小程序绑定的品牌号、员工号、合作号
* @supported tt
*/
dataAwemeId?: string
/** 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与 Taro.getUserInfo 返回的一致
*
* 生效时机: `open-type="getUserInfo"`
Expand All @@ -193,11 +191,6 @@ interface ButtonProps extends StandardProps {
* @supported weapp, alipay, swan, tt, jd
*/
onGetPhoneNumber?: CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>
/**
* 手机号实时验证回调,`open-type="getRealtimePhoneNumber"` 时有效
* @supported weapp
*/
onGetRealTimePhoneNumber?: CommonEventFunction<ButtonProps.onGetRealTimePhoneNumberEventDetail>
/** 当使用开放能力时,发生错误的回调
*
* 生效时机:`open-type="launchApp"`
Expand All @@ -222,11 +215,6 @@ interface ButtonProps extends StandardProps {
* @supported weapp
*/
onChooseAvatar?: CommonEventFunction
/**
* 用户同意隐私协议事件回调,`open-type="agreePrivacyAuthorization"`时有效
* @supported weapp
*/
onAgreePrivacyAuthorization?: CommonEventFunction
/** 点击。
* 说明: 每点击一次会触发一次事件,建议自行使用代码防止重复点击,可以使用 js 防抖和节流实现。
* @supported alipay
Expand Down Expand Up @@ -265,12 +253,6 @@ interface ButtonProps extends StandardProps {
* @supported qq
*/
onAddGroupApp?: CommonEventFunction
/** 监听跳转抖音号个人页的回调
*
* 生效时机:`open-type="openAwemeUserProfile"`
* @supported tt
*/
onOpenAwemeUserProfile?: CommonEventFunction
}
declare namespace ButtonProps {
/** size 的合法值 */
Expand All @@ -297,7 +279,11 @@ declare namespace ButtonProps {
reset
}
/** open-type 的合法值 */
type OpenType = keyof openTypeKeys['weapp'] | keyof openTypeKeys['alipay'] | keyof openTypeKeys['qq'] | keyof openTypeKeys['tt']
type OpenType =
| keyof openTypeKeys['weapp']
| keyof openTypeKeys['alipay']
| keyof openTypeKeys['qq']
| keyof openTypeKeys['tt']
/** open-type 的合法值 */
interface openTypeKeys {
weapp: {
Expand Down Expand Up @@ -334,6 +320,21 @@ declare namespace ButtonProps {
* 用户同意隐私协议按钮。可通过 bindagreeprivacyauthorization 监听用户同意隐私协议事件
*/
agreePrivacyAuthorization
/**
* 从基础库 2.32.3 版本起,隐私同意按钮支持与手机号快速验证组件耦合使用,调用方式为:
* <button open-type="getPhoneNumber|agreePrivacyAuthorization">
*/
['getPhoneNumber|agreePrivacyAuthorization']
/**
* 从基础库 2.32.3 版本起,支持隐私同意按钮与手机号实时验证组件耦合使用,调用方式为:
* <button open-type="getRealtimePhoneNumber|agreePrivacyAuthorization">
*/
['getRealtimePhoneNumber|agreePrivacyAuthorization']
/**
* 从基础库 2.32.3 版本起,支持隐私同意按钮与获取用户信息组件耦合使用,调用方式为:
* <button open-type="getUserInfo|agreePrivacyAuthorization">
*/
['getUserInfo|agreePrivacyAuthorization']
}
/** 支付宝小程序专属的 open-type 合法值
* @see https://opendocs.alipay.com/mini/component/button
Expand Down
22 changes: 11 additions & 11 deletions packages/taro-components/types/Canvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,37 @@ interface CanvasProps extends StandardProps<any, CanvasTouchEvent> {
* @supported weapp, alipay, swan, qq, jd
*/
disableScroll?: boolean
/** 用于透传 `WebComponents` 上的属性到内部 H5 标签上
* @supported h5
*/
nativeProps?: Record<string, unknown>
/** 组件唯一标识符。
* 注意:同一页面中的 id 不可重复。
* @supported alipay
* @supported alipay, h5
*/
id?: string
/**
* @supported alipay
* @supported alipay, h5
*/
width?: string
/**
* @supported alipay
* @supported alipay, h5
*/
height?: string
/** 用于透传 `WebComponents` 上的属性到内部 H5 标签上
* @supported h5
*/
nativeProps?: Record<string, unknown>
/** 手指触摸动作开始
* @supported weapp, alipay, swan, tt, qq, jd
* @supported weapp, alipay, swan, tt, qq, jd, h5
*/
onTouchStart?: CanvasTouchEventFunction
/** 手指触摸后移动
* @supported weapp, alipay, swan, tt, qq, jd
* @supported weapp, alipay, swan, tt, qq, jd, h5
*/
onTouchMove?: CanvasTouchEventFunction
/** 手指触摸动作结束
* @supported weapp, alipay, swan, tt, qq, jd
* @supported weapp, alipay, swan, tt, qq, jd, h5
*/
onTouchEnd?: CanvasTouchEventFunction
/** 手指触摸动作被打断,如来电提醒,弹窗
* @supported weapp, alipay, swan, tt, qq, jd
* @supported weapp, alipay, swan, tt, qq, jd, h5
*/
onTouchCancel?: CanvasTouchEventFunction
/** 手指长按 500ms 之后触发,触发了长按事件后进行移动不会触发屏幕的滚动
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-components/types/ChannelVideo.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ComponentType } from 'react'
import { StandardProps, CommonEventFunction } from './common'
interface ChannelVideoProps extends StandardProps {
/** 视频 feedId
/** 仅视频号视频与小程序同主体时生效。若内嵌非同主体视频,请使用 feed-token。
* @supported weapp
*/
feedId: string
Expand Down Expand Up @@ -29,7 +29,7 @@ interface ChannelVideoProps extends StandardProps {
* @default false
*/
autoplay?: boolean
/** 仅内嵌小程序非同主体视频号视频时使用,获取方式参考本指引
/** 仅内嵌小程序非同主体视频号视频时使用,获取方式参考[本指引](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/channels-activity.html#feed-token)
* @supported weapp
*/
feedToken?: string
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/GridView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface GridViewProps extends StandardProps {
}
/**
* 网格布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
* @classification viewContainer
* @classification skyline
* @supported weapp
* @see https://developers.weixin.qq.com/miniprogram/dev/component/grid-view.html
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/ListView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface ListViewProps extends StandardProps {}

/**
* 列表布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
* @classification viewContainer
* @classification skyline
* @supported weapp
* @see https://developers.weixin.qq.com/miniprogram/dev/component/list-view.html
*/
Expand Down
15 changes: 11 additions & 4 deletions packages/taro-components/types/LivePlayer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ interface LivePlayerProps extends StandardProps {
*/
pictureInPictureMode?: ('push' | 'pop')[] | 'push' | 'pop' | ''
/** 当跳转到其它微信原生页面时,是否自动暂停本页面的实时音视频播放
* @default true
* @supported weapp, qq
*/
autoPauseIfOpenNative?: string
/** 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本;
autoPauseIfOpenNative?: boolean
/** 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html ,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本;
* @default 'no-referrer'
* @supported weapp
*/
referrerPolicy?: 'origin' | 'no-referrer'
Expand Down Expand Up @@ -125,11 +127,16 @@ interface LivePlayerProps extends StandardProps {
/** 用户选择投屏设备时触发 detail = { state: "success"/"fail" }
* @supported weapp
*/
onCastingUserSelect?: CommonEventFunction
onCastingUserSelect?: CommonEventFunction<{
state: 'success' | 'fail'
}>
/** 投屏成功/失败时触发 detail = { type, state: "success"/"fail" }
* @supported weapp
*/
onCastingStateChange?: CommonEventFunction
onCastingStateChange?: CommonEventFunction<{
type: any
state: 'success' | 'fail'
}>
/** 投屏被中断时触发
* @supported weapp
*/
Expand Down
23 changes: 20 additions & 3 deletions packages/taro-components/types/Map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ interface MapProps extends StandardProps {
* @supported weapp, alipay, swan, tt, qq, jd
*/
markers?: MapProps.marker[]
/** 标记点
/** **即将移除,请使用 markers**
* @supported weapp
* @deprecated
*/
covers?: any[]
/** 路线
Expand Down Expand Up @@ -220,11 +221,11 @@ interface MapProps extends StandardProps {
/** 点击标记点对应的气泡时触发e.detail = {markerId}
* @supported weapp, swan, tt, jd
*/
onCallOutTap?: CommonEventFunction
onCallOutTap?: CommonEventFunction<MapProps.onCalloutTapEventDetail>
/** 点击定位标时触发,e.detail = {longitude, latitude}
* @supported weapp, tt
*/
onAnchorPointTap?: CommonEventFunction
onAnchorPointTap?: CommonEventFunction<MapProps.point>
/** 点击 panel 时触发。
* @supported alipay
*/
Expand Down Expand Up @@ -612,6 +613,22 @@ declare namespace MapProps {
longitude: number
latitude: number
}
interface onPolylineTapEventDetail {
polylineId: number
longitude: number
latitude: number
}
interface onAbilityEventDetail {
ability: string
errCode: number
errMsg: string
}
interface onInterpolatePointEventDetail {
markerId: number
longitude: number
latitude: number
animationStatus: 'interpolating' | 'complete'
}
}
/** 地图。相关api Taro.createMapContext。
* @classification maps
Expand Down
8 changes: 5 additions & 3 deletions packages/taro-components/types/NativeSlot.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'

interface NativeSlotProps {
import type { ComponentType, ReactNode } from 'react'

interface NativeSlotProps extends StandardProps {
/** 指定插入的 slot 位置
* @default none
* @supported weapp, swan, alipay, tt, jd, qq
Expand All @@ -10,7 +12,7 @@ interface NativeSlotProps {

/** 编译的原生组件支持使用 slot 插槽
* @classification viewContainer
* @supported weapp, swan, alipay, tt, jd, qq
* @supported weapp, swan, alipay, tt, jd, qq, h5
* @version 3.5.7+
* @example
* ```tsx
Expand Down
6 changes: 6 additions & 0 deletions packages/taro-components/types/NavigationBar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ interface NavigationBarProps extends StandardProps {
}
/** 页面导航条配置节点,用于指定导航栏的一些属性。只能是 PageMeta 组件内的第一个节点,需要配合它一同使用。
* 通过这个节点可以获得类似于调用 Taro.setNavigationBarTitle Taro.setNavigationBarColor 等接口调用的效果。
*
* :::info
* Taro v3.6.19 开始支持
* 需要配合 PageMeta 组件使用
* :::
*
* @classification navig
* @supported weapp, harmony
* @see https://developers.weixin.qq.com/miniprogram/dev/component/navigation-bar.html
Expand Down
40 changes: 40 additions & 0 deletions packages/taro-components/types/PageMeta.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,47 @@ declare namespace PageMetaProps {
}
/** 页面属性配置节点,用于指定页面的一些属性、监听页面事件。只能是页面内的第一个节点。可以配合 navigation-bar 组件一同使用。
* 通过这个节点可以获得类似于调用 Taro.setBackgroundTextStyle Taro.setBackgroundColor 等接口调用的效果。
*
* :::info
* Taro v3.6.19 开始支持
* 开发者需要在页面配置里添加:`enablePageMeta: true`
* :::
*
* @supported weapp, alipay
* @example_react
* ```tsx
* // page.config.ts
* export default definePageConfig({ enablePageMeta: true, ... })
*
* // page.tsx
* function Index () {
* return (
* <View>
* <PageMeta
* pageStyle={myPageStyle}
* onScroll={handleScroll}
* >
* <NavigationBar title={title} />
* </PageMeta>
* </View>
* )
* }
* ```
* @example_vue
* ```html
* <!-- page.config.ts -->
* <!-- export default definePageConfig({ enablePageMeta: true, ... }) -->
*
* <!-- page.vue -->
* <template>
* <page-meta
* :page-style="myPageStyle"
* `@scroll="handleScroll"
* >
* <navigation-bar :title="title" />
* </page-meta>
* </template>
* ```
* @see https://developers.weixin.qq.com/miniprogram/dev/component/page-meta.html
*/
declare const PageMeta: ComponentType<PageMetaProps>
Expand Down
26 changes: 25 additions & 1 deletion packages/taro-components/types/ScrollView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ interface ScrollViewProps extends StandardProps {
* @supported weapp
* @default false
*/
enablePassive?: string
enablePassive?: boolean
/** 渲染模式
* list - 列表模式。只会渲染在屏节点,会根据直接子节点是否在屏来按需渲染,若只有一个直接子节点则性能会退化
* custom - 自定义模式。只会渲染在屏节点,子节点可以是 sticky-section list-view grid-view 等组件
Expand Down Expand Up @@ -252,6 +252,30 @@ declare namespace ScrollViewProps {
/** 滚动速度 */
velocity: number
}
interface RefresherStatusChange {
status: RefreshStatus
dy: number
}
const enum RefreshStatus {
// 空闲
Idle,
// 超过下拉刷新阈值,同 bind:refresherwillRefresh 触发时机
CanRefresh,
// 下拉刷新,同 bind:refresherrefresh 触发时机
Refreshing,
// 下拉刷新完成,同 bind:refresherrestore 触发时机
Completed,
// 下拉刷新失败
Failed,
// 超过下拉二级阈值
CanTwoLevel,
// 开始打开二级
TwoLevelOpening,
// 打开二级
TwoLeveling,
// 开始关闭二级
TwoLevelClosing,
}
}
/** 可滚动视图区域。使用竖向滚动时,需要给scroll-view一个固定高度,通过 WXSS 设置 height。组件属性的长度单位默认为 px
*
Expand Down
Loading