Skip to content

Commit

Permalink
refactor(types): sync components types
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKonka authored Nov 11, 2023
1 parent ee423f5 commit 056b1f2
Show file tree
Hide file tree
Showing 10 changed files with 87 additions and 105 deletions.
32 changes: 1 addition & 31 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ interface ButtonProps extends StandardProps {
/** 群聊 id
* @qq 打开群资料卡时,传递的群号
* @tt 通过创建聊天群、查询群信息获取
* @supported qq, tt
* @supported qq
*/
groupId?: string
/** 打开频道页面时,传递的频道号
Expand Down Expand Up @@ -167,15 +167,6 @@ interface ButtonProps extends StandardProps {
* @supported qq
*/
shareMessageImg?: string
/** 跳转抖音号个人页,只支持小程序绑定的品牌号、员工号、合作号
* @supported tt
*/
dataAwemeId?: string
/**
* 是否开启半屏模式
* @supported tt
*/
dataIsHalfPage?: boolean
/** 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与 Taro.getUserInfo 返回的一致
*
* 生效时机: `open-type="getUserInfo"`
Expand All @@ -200,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 @@ -229,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 @@ -272,17 +253,6 @@ interface ButtonProps extends StandardProps {
* @supported qq
*/
onAddGroupApp?: CommonEventFunction
/** 监听跳转抖音号个人页的回调
*
* 生效时机:`open-type="openAwemeUserProfile"`
* @supported tt
*/
onOpenAwemeUserProfile?: CommonEventFunction
/**
* 加群后触发
* @supported tt
*/
onJoinGroup?: CommonEventFunction<{ errMsg: string; errNo: number }>
}
declare namespace ButtonProps {
/** size 的合法值 */
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/Form.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface FormProps extends StandardProps {
reportSubmitTimeout?: number
/** 模板消息的类型,report-submit 为 true 时填写有效
* 取值:default / subscribe
* @default 'default'
* @default "default"
* @supported swan
*/
reportType?: string
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
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
62 changes: 4 additions & 58 deletions packages/taro-components/types/ScrollView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ interface ScrollViewProps extends StandardProps {
refresherThreshold?: number
/** 设置自定义下拉刷新默认样式,支持设置 `black | white | none`, none 表示不使用默认样式
* @supported weapp
* @default 'black'
* @default "black"
*/
refresherDefaultStyle?: string
/** 设置自定义下拉刷新区域背景颜色
* @supported weapp
* @default '#FFF'
* @default "#FFF"
*/
refresherBackground?: string
/** 设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发
Expand Down Expand Up @@ -135,33 +135,18 @@ interface ScrollViewProps extends StandardProps {
* list - 列表模式。只会渲染在屏节点,会根据直接子节点是否在屏来按需渲染,若只有一个直接子节点则性能会退化
* custom - 自定义模式。只会渲染在屏节点,子节点可以是 sticky-section list-view grid-view 等组件
* @supported weapp
* @default 'list'
* @default "list"
*/
type?: 'list' | 'custom'
/** 是否反向滚动。一般初始滚动位置是在顶部,反向滚动则是在底部。
* @supported weapp
* @default false
*/
reverse?: boolean
/** 是否对溢出进行裁剪,默认开启
* @supported weapp
* @default true
*/
clip?: boolean
/** 指定视口外渲染区域的距离,默认情况下视口外节点不渲染。指定 cache-extent 可优化滚动体验和加载速度,但会提高内存占用且影响首屏速度,可按需启用。
* @supported weapp
*/
cacheExtent?: number
/** 指定 scroll-view 触发滚动的最小拖动距离。仅在 scroll-view 和其他组件存在手势冲突时使用,可通过调整该属性使得滚动更加灵敏。
* @supported weapp
* @default 18
*/
minDragDistance?: number
/** 长度为 4 的数组,按 top、right、bottom、left 顺序指定内边距
* @supported weapp
* @default [0,0,0,0]
*/
padding?: [number, number, number, number]
/** 只 scroll-into-view 到 cacheExtent 以内的目标节点,性能更佳
* @supported weapp
* @default false
Expand All @@ -173,44 +158,9 @@ interface ScrollViewProps extends StandardProps {
* end - 目标节点显示在视口结束处
* nearest - 目标节点在就近的视口边缘显示,若节点已在视口内则不触发滚动
* @supported weapp, h5
* @default 'start'
* @default "start"
*/
scrollIntoViewAlignment?: 'start' | 'center' | 'end' | 'nearest'
/** 开启下拉二级能力
* @supported weapp
* @default false
*/
refresherTwoLevelEnabled?: boolean
/** 设置打开/关闭二级
* @supported weapp
* @default false
*/
refresherTwoLevelTriggered?: boolean
/** 下拉二级阈值
* @supported weapp
* @default 150
*/
refresherTwoLevelThreshold?: number
/** 滑动返回时关闭二级的阈值
* @supported weapp
* @default 80
*/
refresherTwoLevelCloseThreshold?: number
/** 处于二级状态时是否可滑动
* @supported weapp
* @default false
*/
refresherTwoLevelScrollEnabled?: boolean
/** 惯性滚动是否触发下拉刷新
* @supported weapp
* @default false
*/
refresherBallisticRefreshEnabled?: boolean
/** 即将打开二级时否定住
* @supported weapp
* @default false
*/
refresherTwoLevelPinned?: boolean
/** 滚动到顶部/左边,会触发 scrolltoupper 事件
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
*/
Expand Down Expand Up @@ -251,10 +201,6 @@ interface ScrollViewProps extends StandardProps {
* @supported weapp
*/
onRefresherWillRefresh?: CommonEventFunction
/** 下拉刷新状态回调
* @supported weapp
*/
onRefresherStatusChange?: CommonEventFunction<ScrollViewProps.RefresherStatusChange>
/** 滑动开始事件 (同时开启 enhanced 属性后生效)
* @supported weapp
*/
Expand Down
4 changes: 0 additions & 4 deletions packages/taro-components/types/ShareElement.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ interface ShareElementProps extends StandardProps {
* @deprecated 使用mapkey替换key
*/
key?: string
/** 映射标记
* @supported weapp
*/
mapkey?: string
/** 映射标记
* @supported alipay
*/
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-components/types/Video.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ interface VideoProps extends StandardProps {
* - `bottom`: controls bar 上
* - `center`: 视频中间
*
* @default 'bottom'
* @default "bottom"
* @supported weapp, tt, qq
*/
playBtnPosition?: keyof VideoProps.PlayBtnPosition
Expand Down Expand Up @@ -315,7 +315,7 @@ interface VideoProps extends StandardProps {
onTimeUpdate?: CommonEventFunction<VideoProps.onTimeUpdateEventDetail>
/** 当视频进入和退出全屏时触发
*
* @supported h5, rn, alipay
* @supported h5, rn
*/
onFullscreenChange?: CommonEventFunction<VideoProps.onFullscreenChangeEventDetail>
/** 视频出现缓冲时触发
Expand Down

0 comments on commit 056b1f2

Please sign in to comment.