Skip to content
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

refactor(types): sync components types #1

Merged
merged 1 commit into from
Mar 10, 2024
Merged
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
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
2 changes: 1 addition & 1 deletion packages/taro-components/types/Audio.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ declare namespace AudioProps {
/** 音频。1.6.0版本开始,该组件不再维护。建议使用能力更强的 Taro.createInnerAudioContext 接口
* @classification media
* @deprecated
* @supported weapp, swan, qq, h5
* @supported weapp, swan, qq, h5, harmony_hybrid
* @example_react
* ```tsx
* export default class PageView extends Component {
Expand Down
113 changes: 103 additions & 10 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 All @@ -149,7 +150,9 @@ interface ButtonProps extends StandardProps {
*/
subscribeId?: string

/** 打开群资料卡时,传递的群号
/** 群聊 id
* @qq 打开群资料卡时,传递的群号
* @tt 通过创建聊天群、查询群信息获取
* @supported qq
*/
groupId?: string
Expand Down Expand Up @@ -219,7 +222,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 +237,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 +333,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 +357,12 @@ declare namespace ButtonProps {
*/
getPhoneNumber

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

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

Expand All @@ -366,6 +379,29 @@ declare namespace ButtonProps {

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

/**
* 用户同意隐私协议按钮。可通过 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 合法值
Expand Down Expand Up @@ -426,6 +462,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 +521,14 @@ declare namespace ButtonProps {
/** 昵称 */
nickName: string

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

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

/** 性别 */
gender: keyof Gender

Expand Down Expand Up @@ -514,6 +596,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 +617,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, harmony_hybrid
* @example_react
* ```tsx
* export default class PageButton extends Component {
Expand Down Expand Up @@ -595,6 +686,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 +712,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
30 changes: 15 additions & 15 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 All @@ -17,49 +17,49 @@ interface CanvasProps extends StandardProps<any, CanvasTouchEvent> {
*/
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 之后触发,触发了长按事件后进行移动不会触发屏幕的滚动
* @supported weapp, alipay, swan, qq, jd
* @supported weapp, alipay, swan, qq, jd, h5
*/
onLongTap?: CommonEventFunction

Expand Down Expand Up @@ -88,7 +88,7 @@ declare namespace CanvasProps {
*
* `<Canvas />` 组件的 RN 版本尚未实现。
* @classification canvas
* @supported weapp, alipay, swan, tt, qq, jd, h5
* @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid
* @example_react
* ```tsx
* class App extends Components {
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 }
Loading
Loading