Skip to content

Commit

Permalink
refactor(types): sync components types
Browse files Browse the repository at this point in the history
  • Loading branch information
learner-pm authored Sep 9, 2023
1 parent 6b09635 commit 1345cc6
Show file tree
Hide file tree
Showing 54 changed files with 824 additions and 183 deletions.
2 changes: 1 addition & 1 deletion packages/taro-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"jquery": "^3.4.1",
"karmatic": "^2.1.0",
"lodash": "^4.17.21",
"miniapp-types": "1.1.21",
"miniapp-types": "1.6.0",
"simulant": "^0.2.2",
"style-loader": "1.3.0",
"ts-node": "^10.9.1",
Expand Down
2 changes: 2 additions & 0 deletions packages/taro-components/types/Ad.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ interface AdProps extends StandardProps {
/** 广告类型:banner、feed ,需和百青藤平台上的代码位类型相匹配
* @supported swan, tt, qq
* @default feed
* @swan 支持 banner、feed
* @qq 支持 banner、card、feeds、block
*/
type?: string

Expand Down
91 changes: 82 additions & 9 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,31 @@ interface ButtonProps extends StandardProps {
/** 会话来源
*
* 生效时机:`open-type="contact"`
* @supported weapp
* @supported weapp, swan
*/
sessionFrom?: string

/** 会话内消息卡片标题
*
* 生效时机:`open-type="contact"`
* @default 当前标题
* @supported weapp
* @supported weapp, swan
*/
sendMessageTitle?: string

/** 会话内消息卡片点击跳转小程序路径
*
* 生效时机:`open-type="contact"`
* @default 当前标题
* @supported weapp
* @supported weapp, swan
*/
sendMessagePath?: string

/** 会话内消息卡片图片
*
* 生效时机:`open-type="contact"`
* @default 截图
* @supported weapp
* @supported weapp, swan
*/
sendMessageImg?: string

Expand All @@ -128,6 +128,7 @@ interface ButtonProps extends StandardProps {
/** 显示会话内消息卡片
*
* 生效时机:`open-type="contact"`
* @supported weapp, swan
* @default false
*/
showMessageCard?: boolean
Expand Down Expand Up @@ -219,7 +220,7 @@ interface ButtonProps extends StandardProps {

/** 获取用户手机号回调
*
* 生效时机:`open-type="getphonenumber"`
* 生效时机:`open-type="getPhoneNumber"`
* @supported weapp, alipay, swan, tt, jd
*/
onGetPhoneNumber?: CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>
Expand All @@ -234,7 +235,7 @@ interface ButtonProps extends StandardProps {
/** 在打开授权设置页后回调
*
* 生效时机:`open-type="openSetting"`
* @supported weapp, swan, qq, jd
* @supported weapp, swan, tt, qq, jd
*/
onOpenSetting?: CommonEventFunction<ButtonProps.onOpenSettingEventDetail>

Expand Down Expand Up @@ -330,7 +331,11 @@ declare namespace ButtonProps {
}

/** open-type 的合法值 */
type OpenType = keyof openTypeKeys['weapp'] | keyof openTypeKeys['alipay'] | keyof openTypeKeys['qq']
type OpenType =
| keyof openTypeKeys['weapp']
| keyof openTypeKeys['alipay']
| keyof openTypeKeys['qq']
| keyof openTypeKeys['tt']

/** open-type 的合法值 */
interface openTypeKeys {
Expand All @@ -350,6 +355,12 @@ declare namespace ButtonProps {
*/
getPhoneNumber

/**
* 手机号实时验证,向用户申请,并在用户同意后,快速填写和实时验证手机号。(*小程序插件中不能使用*)
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getRealtimePhoneNumber.html
*/
getRealtimePhoneNumber

/** 获取用户信息,可以从回调中获取到用户信息 */
getUserInfo

Expand All @@ -366,6 +377,11 @@ declare namespace ButtonProps {

/** 获取用户头像,可以从回调中获得具体信息 */
chooseAvatar

/**
* 用户同意隐私协议按钮。可通过 bindagreeprivacyauthorization 监听用户同意隐私协议事件
*/
agreePrivacyAuthorization
}

/** 支付宝小程序专属的 open-type 合法值
Expand Down Expand Up @@ -426,6 +442,47 @@ declare namespace ButtonProps {
/** 在自定义开放数据域组件中,向指定好友发起分享据 */
shareMessageToFriend
}

/** TT 小程序专属的 open-type 合法值
* @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
*/
tt: {
/** 触发用户转发, 可以配合 data-channel 属性来设置分享的 channel,具体请参考 ShareParam */
share

/** 获取用户手机号,可以从 bindgetphonenumber 回调中获取到用户信息,详情请参见获取手机号 */
getPhoneNumber

/** 跳转到抖音IM客服,详情请参见抖音IM客服能力 */
im

/** 跳转到抖音平台客服,详情请参见平台客服能力 */
platformIm

/** 跳转视频播放页,详情请参见跳转视频播放页 */
navigateToVideoView

/** 跳转抖音号个人页,详情请参见跳转抖音号个人页 */
openAwemeUserProfile

/** 跳转抖音直播间,详情请参见跳转抖音直播间 */
openWebcastRoom

/** 写入系统日历,详情请参见写入系统日历 */
addCalendarEvent

/** 添加到桌面,详情请参见添加到桌面 */
addShortcut

/** 加群,详情请参见加群 */
joinGroup

/** 私信,详情请参见私信 */
privateMessage

/** 主动授权私信,详情请参见主动授权私信 */
authorizePrivateMessage
}
}

/** lang 的合法值 */
Expand All @@ -444,9 +501,14 @@ declare namespace ButtonProps {
/** 昵称 */
nickName: string

/** 头像 */
/** 头像链接 */
avatarUrl: string

/** 头像
* @supported alipay
*/
avatar: string

/** 性别 */
gender: keyof Gender

Expand Down Expand Up @@ -514,6 +576,15 @@ declare namespace ButtonProps {
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html#%E4%BD%BF%E7%94%A8%E6%8C%87%E5%BC%95
*/
code?: string

/**
* 签名信息,如果在开放平台后台配置了加签方式后有此字段
* @supported alipay
*/
sign: string
}
interface onGetRealTimePhoneNumberEventDetail {
code: string
}
interface onOpenSettingEventDetail {
/* 打开授权设置页的调用状态 */
Expand All @@ -526,7 +597,7 @@ declare namespace ButtonProps {

/** 按钮
* @classification forms
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony
* @example_react
* ```tsx
* export default class PageButton extends Component {
Expand Down Expand Up @@ -595,6 +666,7 @@ declare namespace ButtonProps {
* <Button size='mini' type='primary'>按钮</Button>
* <Button size='mini' >按钮</Button>
* <Button size='mini' type='warn'>按钮</Button>
* <Button openType='getPhoneNumber' onGetPhoneNumber="callback">按钮</Button>
* </View>
* )
* }
Expand All @@ -620,6 +692,7 @@ declare namespace ButtonProps {
* <button size="mini" type="primary">按钮</button>
* <button size="mini" >按钮</button>
* <button size="mini" type="warn">按钮</button>
* <button open-type="getPhoneNumber" `@getphonenumber="callback">按钮</button>
* </view>
* </template>
*
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/Camera.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ declare namespace CameraProps {

/** 系统相机
* @classification media
* @supported weapp, alipay, swan, tt, qq, jd, rn
* @supported weapp, alipay, swan, tt, qq, jd, rn, harmony
* @see https://developers.weixin.qq.com/miniprogram/dev/component/camera.html
*/
declare const Camera: ComponentType<CameraProps>
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-components/types/Canvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ interface CanvasProps extends StandardProps<any, CanvasTouchEvent> {
type?: string

/** canvas 组件的唯一标识符,若指定了 type 则无需再指定该属性
* @supported weapp, swan, tt, qq, jd
* @supported weapp, swan, tt, qq, jd, h5
*/
canvasId?: string

Expand Down Expand Up @@ -59,7 +59,7 @@ interface CanvasProps extends StandardProps<any, CanvasTouchEvent> {
onTouchCancel?: CanvasTouchEventFunction

/** 手指长按 500ms 之后触发,触发了长按事件后进行移动不会触发屏幕的滚动
* @supported weapp, alipay, swan, qq, jd
* @supported weapp, alipay, swan, qq, jd, h5
*/
onLongTap?: CommonEventFunction

Expand Down
22 changes: 22 additions & 0 deletions packages/taro-components/types/ChannelLive.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'
interface ChannelLiveProps extends StandardProps {
/** 视频 feedId
* @supported weapp
*/
feedId: string

/** 视频号 id,以“sph”开头的id,可在视频号助手获取。视频号必须与当前小程序相同主体。
* @supported weapp
*/
finderUserName: string
}

/**
* 小程序内嵌视频号直播组件,展示视频号直播状态和封面,并无弹窗跳转至视频号。注意:使用该组件打开的视频号视频需要与小程序的主体一致。
* @classification media
* @supported weapp
* @see https://developers.weixin.qq.com/miniprogram/dev/component/channel-live.html
*/
declare const ChannelLive: ComponentType<ChannelLiveProps>
export { ChannelLive, ChannelLiveProps }
56 changes: 56 additions & 0 deletions packages/taro-components/types/ChannelVideo.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { ComponentType } from 'react'
import { StandardProps, CommonEventFunction } from './common'
interface ChannelVideoProps extends StandardProps {
/** 视频 feedId
* @supported weapp
*/
feedId: string

/** 视频号 id,以“sph”开头的id,可在视频号助手获取。视频号必须与当前小程序相同主体。
* @supported weapp
*/
finderUserName: string

/** 是否循环播放
* @supported weapp
* @default false
*/
loop?: boolean

/** 是否静音播放
* @supported weapp
* @default false
*/
muted?: boolean

/** 当视频大小与 video 容器大小不一致时,视频的表现形式
* @supported weapp
* @default "contain"
*/
objectFit?: 'fill' | 'contain' | 'cover'

/** 是否自动播放
* @supported weapp
* @default false
*/
autoplay?: boolean

/** 仅内嵌小程序非同主体视频号视频时使用,获取方式参考本指引。
* @supported weapp
*/
feedToken?: string

/** 视频播放出错时触发
* @supported weapp
*/
onError?: CommonEventFunction
}

/**
* 小程序内嵌视频号视频组件,支持在小程序中播放视频号视频,并无弹窗跳转至视频号。注意:使用该组件打开的视频号视频需要与小程序相同主体或关联主体。
* @classification media
* @supported weapp
* @see https://developers.weixin.qq.com/miniprogram/dev/component/channel-video.html
*/
declare const ChannelVideo: ComponentType<ChannelVideoProps>
export { ChannelVideo, ChannelVideoProps }
4 changes: 2 additions & 2 deletions packages/taro-components/types/Checkbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ComponentType } from 'react'
import { StandardProps, CommonEventFunction, FormItemProps } from './common'
interface CheckboxProps extends StandardProps {
/** `<Checkbox/>`标识,选中时触发`<CheckboxGroup/>`的 change 事件,并携带 `<Checkbox/>` 的 value
* @supported weapp, alipay, swan, tt, qq, jd, rn
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
*/
value: string

Expand Down Expand Up @@ -43,7 +43,7 @@ interface CheckboxProps extends StandardProps {

/** 多选项目
* @classification forms
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony
* @example_react
* ```tsx
* export default class PageCheckbox extends Component {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/CheckboxGroup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface CheckboxGroupProps extends StandardProps, FormItemProps {

/** 多项选择器,内部由多个checkbox组成
* @classification forms
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony
* @example
* ```tsx
* export default class PageCheckbox extends Component {
Expand Down
5 changes: 5 additions & 0 deletions packages/taro-components/types/CommentDetail.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ interface CommentDetailProps extends StandardProps {
* @supported swan
*/
onDelete?: CommonEventFunction

/** 评论发布成功时触发,返回数据为 {status, data:{srid}}
* @supported swan
*/
onReply?: CommonEventFunction
}
namespace CommentDetailProps {
interface ICommentParam {
Expand Down
5 changes: 5 additions & 0 deletions packages/taro-components/types/CommentList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ interface CommentListProps extends StandardProps {
* @supported swan
*/
onViewMore?: CommonEventFunction

/** 评论发布成功时触发,返回数据为 {status, data:{srid}}
* @supported swan
*/
onReply?: CommonEventFunction
}
namespace CommentListProps {
interface ICommentParam {
Expand Down
Loading

0 comments on commit 1345cc6

Please sign in to comment.