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 Jul 15, 2023
1 parent 6b09635 commit ca4d1ff
Show file tree
Hide file tree
Showing 54 changed files with 751 additions and 178 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
30 changes: 22 additions & 8 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 @@ -444,9 +445,14 @@ declare namespace ButtonProps {
/** 昵称 */
nickName: string

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

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

/** 性别 */
gender: keyof Gender

Expand Down Expand Up @@ -514,6 +520,12 @@ 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 onOpenSettingEventDetail {
/* 打开授权设置页的调用状态 */
Expand All @@ -526,7 +538,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 +607,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 +633,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
8 changes: 4 additions & 4 deletions packages/taro-components/types/CoverImage.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 } from './common'
interface CoverImageProps extends StandardProps {
/** 图标路径,支持临时路径、网络地址、云文件ID。暂不支持base64格式。
* @supported weapp, alipay, swan, qq, h5
* @supported weapp, alipay, swan, qq, jd, h5
*/
src: string

Expand Down Expand Up @@ -42,12 +42,12 @@ interface CoverImageProps extends StandardProps {
ariaLabel?: string

/** 图片加载成功时触发
* @supported weapp, swan, qq, h5
* @supported weapp, swan, qq, jd, h5
*/
onLoad?: CommonEventFunction

/** 图片加载失败时触发
* @supported weapp, swan, qq, h5
* @supported weapp, swan, qq, jd, h5
*/
onError?: CommonEventFunction

Expand All @@ -59,7 +59,7 @@ interface CoverImageProps extends StandardProps {

/** 覆盖在原生组件之上的图片视图。可覆盖的原生组件同cover-view,支持嵌套在cover-view里。
* @classification viewContainer
* @supported weapp, alipay, swan, qq, h5
* @supported weapp, alipay, swan, qq, jd, h5, harmony
* @example_react
* ```tsx
* // js
Expand Down
4 changes: 2 additions & 2 deletions packages/taro-components/types/CoverView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CommonEventFunction } from './common'
import { ViewProps } from './View'
interface CoverViewProps extends ViewProps {
/** 设置顶部滚动偏移量,仅在设置了 overflow-y: scroll 成为滚动元素后生效
* @supported weapp, alipay, swan, qq
* @supported weapp, alipay, swan, qq, jd
*/
scrollTop?: number

Expand Down Expand Up @@ -143,7 +143,7 @@ interface CoverViewProps extends ViewProps {

/** 覆盖在原生组件之上的文本视图。可覆盖的原生组件包括 map、video、canvas、camera、live-player、live-pusher 只支持嵌套 cover-view、cover-image,可在 cover-view 中使用 button。
* @classification viewContainer
* @supported weapp, alipay, swan, qq, h5
* @supported weapp, alipay, swan, qq, jd, h5
* @example_react
* ```tsx
* // js
Expand Down
1 change: 1 addition & 0 deletions packages/taro-components/types/CustomWrapper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ interface CustomWrapperProps extends StandardProps {

/** custom-wrapper 自定义组件包裹器
* 当数据更新层级较深时,可用此组件将需要更新的区域包裹起来,这样更新层级将大大减少
* @classification viewContainer
* @supported weapp, swan, alipay, tt, jd, qq, h5
* @example
* ```tsx
Expand Down
17 changes: 15 additions & 2 deletions packages/taro-components/types/Form.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,21 @@ interface FormProps extends StandardProps {
*/
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, rn
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
*/
onSubmit?: CommonEventFunction<FormProps.onSubmitEventDetail>

Expand Down Expand Up @@ -66,7 +79,7 @@ declare namespace FormProps {
*
* 当点击 form 表单中 form-type 为 submit 的 button 组件时,会将表单组件中的 value 值进行提交,需要在表单组件中加上 name 来作为 key。
* @classification forms
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony
* @example_react
* ```tsx
* class App extends Component {
Expand Down
Loading

0 comments on commit ca4d1ff

Please sign in to comment.