Skip to content

Commit

Permalink
refactor(types): sync components types
Browse files Browse the repository at this point in the history
  • Loading branch information
FE92star authored Dec 23, 2023
1 parent 40c1583 commit 9a1c20d
Show file tree
Hide file tree
Showing 36 changed files with 470 additions and 100 deletions.
2 changes: 1 addition & 1 deletion packages/taro-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"esbuild": "^0.14.27",
"jquery": "^3.4.1",
"lodash": "^4.17.21",
"miniapp-types": "1.4.4",
"miniapp-types": "1.6.0",
"puppeteer": "^19.2.0",
"stencil-vue2-output-target": "0.0.4",
"ts-node": "^10.9.1",
Expand Down
82 changes: 73 additions & 9 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,28 @@ 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
/** 打开 APP 时,向 APP 传递的参数
Expand All @@ -109,7 +109,7 @@ interface ButtonProps extends StandardProps {
/** 显示会话内消息卡片
*
* 生效时机:`open-type="contact"`
* @supported weapp
* @supported weapp, swan
* @default false
*/
showMessageCard?: boolean
Expand All @@ -127,7 +127,9 @@ interface ButtonProps extends StandardProps {
* @supported swan
*/
subscribeId?: string
/** 打开群资料卡时,传递的群号
/** 群聊 id
* @qq 打开群资料卡时,传递的群号
* @tt 通过创建聊天群、查询群信息获取
* @supported qq
*/
groupId?: string
Expand Down Expand Up @@ -185,7 +187,7 @@ interface ButtonProps extends StandardProps {
onContact?: CommonEventFunction<ButtonProps.onContactEventDetail>
/** 获取用户手机号回调
*
* 生效时机:`open-type="getphonenumber"`
* 生效时机:`open-type="getPhoneNumber"`
* @supported weapp, alipay, swan, tt, jd
*/
onGetPhoneNumber?: CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>
Expand All @@ -198,7 +200,7 @@ interface ButtonProps extends StandardProps {
/** 在打开授权设置页后回调
*
* 生效时机:`open-type="openSetting"`
* @supported weapp, swan, qq, jd
* @supported weapp, swan, tt, qq, jd
*/
onOpenSetting?: CommonEventFunction<ButtonProps.onOpenSettingEventDetail>
/** 打开 APP 成功的回调
Expand Down Expand Up @@ -277,7 +279,11 @@ declare namespace ButtonProps {
reset
}
/** 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 {
weapp: {
Expand All @@ -293,6 +299,11 @@ declare namespace ButtonProps {
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getPhoneNumber.html
*/
getPhoneNumber
/**
* 手机号实时验证,向用户申请,并在用户同意后,快速填写和实时验证手机号。(*小程序插件中不能使用*)
* @see https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/getRealtimePhoneNumber.html
*/
getRealtimePhoneNumber
/** 获取用户信息,可以从回调中获取到用户信息 */
getUserInfo
/** 打开APP,可以通过 app-parameter 属性设定向APP传的参数
Expand All @@ -305,6 +316,25 @@ declare namespace ButtonProps {
feedback
/** 获取用户头像,可以从回调中获得具体信息 */
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 合法值
* @see https://opendocs.alipay.com/mini/component/button
Expand Down Expand Up @@ -350,6 +380,35 @@ 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 的合法值 */
interface Lang {
Expand Down Expand Up @@ -426,6 +485,9 @@ declare namespace ButtonProps {
*/
sign: string
}
interface onGetRealTimePhoneNumberEventDetail {
code: string
}
interface onOpenSettingEventDetail {
/* 打开授权设置页的调用状态 */
errMsg: string
Expand Down Expand Up @@ -504,6 +566,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 @@ -529,6 +592,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
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
6 changes: 5 additions & 1 deletion 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,6 +29,10 @@ 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
/** 视频播放出错时触发
* @supported weapp
*/
Expand Down
5 changes: 5 additions & 0 deletions packages/taro-components/types/Checkbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ interface CheckboxProps extends StandardProps {
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
*/
color?: string
/**
* Checkbox 的名字
* @supported h5, harmony
*/
name?: string
/** 用于透传 `WebComponents` 上的属性到内部 H5 标签上
* @supported h5
*/
Expand Down
11 changes: 11 additions & 0 deletions packages/taro-components/types/Form.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ interface FormProps extends StandardProps {
* @supported swan
*/
subscribeId?: string
/** 用于分发目的。取值:0 或 1,其中 0 表示默认,1 表示留资目标,需要和留资分发配置一起使用,详情见留资分发配置
* @supported tt
* @default 0
*/
conversionTarget?: number
/** 用于分发目的。开发者在【小程序开发者后台 -> 进入目标小程序 -> 运营 -> 流量配置 -> 抖音 -> 留资分发配置】复制创建的配置 ID,需要和留资分发配置一起使用,详情见留资分发配置
*
* @supported tt
* @default ""
*/
clueComponentId?: string
/** 携带 form 中的数据触发 submit 事件
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
*/
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
5 changes: 5 additions & 0 deletions packages/taro-components/types/Image.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ interface ImageProps extends StandardProps {
* @supported qq
*/
ariaLabel?: string
/** 是否渐显
* @supported weapp
* @default false
*/
fadeIn?: boolean
/** 当错误发生时,发布到 AppService 的事件名,事件对象
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
*/
Expand Down
8 changes: 6 additions & 2 deletions packages/taro-components/types/Input.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ interface InputProps extends StandardProps, FormItemProps {
* @supported qq
*/
ariaLabel?: string
/** 用于分发目的。取值:0 和 1,其中 0 表示默认,1 表示手机号,需要和留资分发配置一起使用,详情见留资分发配置。
* @supported tt
* @default 0
*/
clueType?: number
/** 当键盘输入时,触发input事件,event.detail = {value, cursor, keyCode},处理函数可以直接 return 一个字符串,将替换输入框的内容。
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
*/
Expand All @@ -174,11 +179,10 @@ interface InputProps extends StandardProps, FormItemProps {
onBlur?: CommonEventFunction<InputProps.inputValueEventDetail>
/** 点击完成按钮时触发
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
* @h5 借用[Form 组件](./form)的`onSubmit`事件来替代
*/
onConfirm?: CommonEventFunction<InputProps.inputValueEventDetail>
/** 键盘高度发生变化的时候触发此事件
* @supported weapp, qq
* @supported weapp, tt, qq
*/
onKeyboardHeightChange?: CommonEventFunction<InputProps.onKeyboardHeightChangeEventDetail>
/** 用户昵称审核完毕后触发,仅在 type 为 "nickname" 时有效,event.detail = { pass, timeout }
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
28 changes: 26 additions & 2 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 All @@ -85,6 +87,11 @@ interface LivePlayerProps extends StandardProps {
* @default false
*/
enableAutoRotation?: boolean
/** 是否支持投屏。开启后,可以通过 LivePlayerContext 上相关方法进行操作。
* @supported weapp
* @default false
*/
enableCasting?: boolean
/** 播放状态变化事件,detail = {code}
* @supported weapp, swan, tt, qq, jd
*/
Expand Down Expand Up @@ -117,6 +124,23 @@ interface LivePlayerProps extends StandardProps {
* @supported qq
*/
onMetaDataChange?: CommonEventFunction
/** 用户选择投屏设备时触发 detail = { state: "success"/"fail" }
* @supported weapp
*/
onCastingUserSelect?: CommonEventFunction<{
state: 'success' | 'fail'
}>
/** 投屏成功/失败时触发 detail = { type, state: "success"/"fail" }
* @supported weapp
*/
onCastingStateChange?: CommonEventFunction<{
type: any
state: 'success' | 'fail'
}>
/** 投屏被中断时触发
* @supported weapp
*/
onCastingInterrupt?: CommonEventFunction
}
declare namespace LivePlayerProps {
/** mode 的合法值 */
Expand Down
Loading

0 comments on commit 9a1c20d

Please sign in to comment.