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 Apr 1, 2023
1 parent 6b09635 commit b066090
Show file tree
Hide file tree
Showing 53 changed files with 523 additions and 157 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.4.4",
"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
16 changes: 14 additions & 2 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ interface ButtonProps extends StandardProps {
/** 显示会话内消息卡片
*
* 生效时机:`open-type="contact"`
* @supported weapp
* @default false
*/
showMessageCard?: boolean
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
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 }
51 changes: 51 additions & 0 deletions packages/taro-components/types/ChannelVideo.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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
*/
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
4 changes: 2 additions & 2 deletions packages/taro-components/types/Form.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface FormProps extends StandardProps {
subscribeId?: 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 +66,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
42 changes: 42 additions & 0 deletions packages/taro-components/types/GridView.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'
interface GridViewProps extends StandardProps {
/** 布局方式。masonry - 瀑布流,根据子元素高度自动布局。 aligned - 每行高度由同一行中最大高度子节点决定。
* @supported weapp
* @default "aligned"
*/
type: string

/** 交叉轴元素数量
* @supported weapp
* @default 2
*/
crossAxisCount?: number

/** 主轴方向间隔
* @supported weapp
* @default 0
*/
mainAxisGap?: number

/** 交叉轴方向间隔
* @supported weapp
* @default 0
*/
crossAxisGap?: number

/** 交叉轴元素最大范围
* @supported weapp
* @default 0
*/
maxCrossAxisExtent?: number
}

/**
* 网格布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
* @classification viewContainer
* @supported weapp
* @see https://developers.weixin.qq.com/miniprogram/dev/component/grid-view.html
*/
declare const GridView: ComponentType<GridViewProps>
export { GridView, GridViewProps }
2 changes: 1 addition & 1 deletion packages/taro-components/types/Icon.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ declare namespace IconProps {

/** 图标。组件属性的长度单位默认为 px
* @classification base
* @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 PageView extends Component {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/Image.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ declare namespace ImageProps {
*
* **Note:** 为实现小程序的 `mode` 特性,在 H5 组件中使用一个 `div` 容器来对内部的 `img` 进行展示区域的裁剪,因此请勿使用元素选择器来重置 `img` 的样式!
* @classification media
* @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 PageView extends Component {
Expand Down
Loading

0 comments on commit b066090

Please sign in to comment.