Skip to content

Commit

Permalink
refactor(types): sync components types
Browse files Browse the repository at this point in the history
  • Loading branch information
PengBoUESTC authored Nov 18, 2023
1 parent adc3221 commit c936ff5
Show file tree
Hide file tree
Showing 11 changed files with 294 additions and 140 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
26 changes: 0 additions & 26 deletions packages/taro-components/types/Map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,30 +218,6 @@ interface MapProps extends StandardProps {
* @supported weapp, swan, qq
*/
onPoiTap?: CommonEventFunction<MapProps.onPoiTapEventDetail>
/** 点击地图路线时触发,e.detail = {longitude, latitude}
* @supported weapp, swan, qq
*/
onPolylineTap?: CommonEventFunction<MapProps.onPolylineTapEventDetail>
/** 地图能力生效时触发,e.detail = {ability, errCode, errMsg}
* @supported weapp
*/
onAbilitySuccess?: CommonEventFunction<MapProps.onAbilityEventDetail>
/** 地图能力失败时触发,e.detail = {ability, errCode, errMsg}
* @supported weapp
*/
onAbilityFailed?: CommonEventFunction<MapProps.onAbilityEventDetail>
/** 地图鉴权结果成功时触发,e.detail = {errCode, errMsg}
* @supported weapp
*/
onAuthSuccess?: CommonEventFunction<{ errCode: number; errMsg: string }>
/** MapContext.moveAlong 插值动画时触发。e.detail = {markerId, longitude, latitude, animationStatus: "interpolating" | "complete"}
* @supported weapp
*/
onInterpolatePoint?: CommonEventFunction<MapProps.onInterpolatePointEventDetail>
/** 组件错误时触发,例如创建或鉴权失败,e.detail = {longitude, latitude}
* @supported weapp
*/
onError: CommonEventFunction<MapProps.point>
/** 点击标记点对应的气泡时触发e.detail = {markerId}
* @supported weapp, swan, tt, jd
*/
Expand Down Expand Up @@ -637,7 +613,6 @@ declare namespace MapProps {
longitude: number
latitude: number
}

interface onPolylineTapEventDetail {
polylineId: number
longitude: number
Expand All @@ -648,7 +623,6 @@ declare namespace MapProps {
errCode: number
errMsg: string
}

interface onInterpolatePointEventDetail {
markerId: number
longitude: number
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/PageMeta.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ declare namespace PageMetaProps {
* <template>
* <page-meta
* :page-style="myPageStyle"
* @scroll="handleScroll"
* `@scroll="handleScroll"
* >
* <navigation-bar :title="title" />
* </page-meta>
Expand Down
54 changes: 0 additions & 54 deletions packages/taro-components/types/ScrollView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,25 +143,10 @@ interface ScrollViewProps extends StandardProps {
* @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 @@ -176,41 +161,6 @@ interface ScrollViewProps extends StandardProps {
* @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
2 changes: 1 addition & 1 deletion packages/taro-components/types/Video.d.ts
Original file line number Diff line number Diff line change
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
52 changes: 51 additions & 1 deletion packages/taro/types/api/data-analysis/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
import Taro from '../../index'

declare module '../../index' {
namespace getCommonConfig {
interface Option {
/** 需要获取的数据指标的对象数组,每个string的格式约定:配置类型_分表key */
keys?: string[]
/** 0:通用配置模式 1:实验模式, 参数与返回结果的使用等效于接口wx.getExptInfoSync */
mode: 0 | 1
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
complete?: (res: TaroGeneral.CallbackResult) => void
/** 接口调用失败的回调函数 */
fail?: (res: TaroGeneral.CallbackResult) => void
/** 接口调用成功的回调函数 */
success?: (res: SuccessCallbackResult) => void
}
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
/** 错误码 */
errcode: number
/** 错误信息 */
errmsg: string
/** 配置类型, 1-表类型 2-kv类型 */
conf_type: number
/** 根据conf_type来确定conf内容, conf_type为1时conf是一个json数组, 类似"[{xxx},{xxx}]", 每一项对应表类型每一行配置内容, 其中conf_type为2时conf是一个json对象,类似"{xxxx}" */
conf: string
/** 过期时间,单位秒. 0表示当次有效 */
expire_sec: number
}
}

interface TaroStatic {
/** 自定义业务数据监控上报接口。
*
Expand All @@ -21,7 +48,7 @@ declare module '../../index' {
): void

/** 自定义分析数据上报接口。使用前,需要在小程序管理后台自定义分析中新建事件,配置好事件名与字段。
* @supported weapp, tt
* @supported weapp, swan, tt
* @example
* ```tsx
* Taro.reportAnalytics('purchase', {
Expand Down Expand Up @@ -68,5 +95,28 @@ declare module '../../index' {
/** 实验参数数组,不填则获取所有实验参数 */
keys?: Array<string>
): TaroGeneral.IAnyObject

/** 给定实验参数数组,获取对应的实验参数值
* @supported weapp
* @example
* ```tsx
* Taro.getCommonConfig({
* keys:["key1", "key2"],
* mode: 0,
* success: (res) => {
* console.log("success")
* console.log(res)
* },
* fail: (res) => {
* console.log("fail")
* console.log(res)
* }
* })
* ```
* @see https://developers.weixin.qq.com/miniprogram/dev/api/data-analysis/wx.getCommonConfig.html
*/
getCommonConfig(
option: getCommonConfig.Option
): Promise<getCommonConfig.SuccessCallbackResult>
}
}
2 changes: 1 addition & 1 deletion packages/taro/types/api/files/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ declare module '../../index' {
/** 创建的目录路径 */
dirPath: string
/** 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。
* 如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。
* 如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。
* @default false
*/
recursive?: boolean
Expand Down
Loading

0 comments on commit c936ff5

Please sign in to comment.