Skip to content

Commit

Permalink
refactor(types): sync components types
Browse files Browse the repository at this point in the history
  • Loading branch information
TheKonka authored Aug 10, 2024
1 parent 39dd83e commit 191eaad
Show file tree
Hide file tree
Showing 68 changed files with 294 additions and 543 deletions.
42 changes: 6 additions & 36 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ interface ButtonProps extends StandardProps {
*/
size?: keyof ButtonProps.Size
/** 按钮的样式类型
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
* @default default
*/
type?: keyof ButtonProps.Type
/** 按钮是否镂空,背景色透明
* @supported weapp, alipay, swan, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, qq, jd, h5, rn, harmony_hybrid
* @default false
*/
plain?: boolean
/** 是否禁用
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
* @default false
*/
disabled?: boolean
/** 名称前是否带 loading 图标
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
* @default false
*/
loading?: boolean
/** 用于 `<form/>` 组件,点击分别会触发 `<form/>` 组件的 submit/reset 事件
* @supported weapp, alipay, swan, tt, qq, jd, harmony
* @supported weapp, alipay, swan, tt, qq, jd
*/
formType?: keyof ButtonProps.FormType
/** 微信开放能力
Expand Down Expand Up @@ -130,7 +130,7 @@ interface ButtonProps extends StandardProps {
/** 群聊 id
* @qq 打开群资料卡时,传递的群号
* @tt 通过创建聊天群、查询群信息获取
* @supported qq, tt
* @supported qq
*/
groupId?: string
/** 打开频道页面时,传递的频道号
Expand Down Expand Up @@ -167,15 +167,6 @@ interface ButtonProps extends StandardProps {
* @supported qq
*/
shareMessageImg?: string
/** 跳转抖音号个人页,只支持小程序绑定的品牌号、员工号、合作号
* @supported tt
*/
dataAwemeId?: string
/**
* 是否开启半屏模式
* @supported tt
*/
dataIsHalfPage?: boolean
/** 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与 Taro.getUserInfo 返回的一致
*
* 生效时机: `open-type="getUserInfo"`
Expand All @@ -200,11 +191,6 @@ interface ButtonProps extends StandardProps {
* @supported weapp, alipay, swan, tt, jd
*/
onGetPhoneNumber?: CommonEventFunction<ButtonProps.onGetPhoneNumberEventDetail>
/**
* 手机号实时验证回调,`open-type="getRealtimePhoneNumber"` 时有效
* @supported weapp
*/
onGetRealTimePhoneNumber?: CommonEventFunction<ButtonProps.onGetRealTimePhoneNumberEventDetail>
/** 当使用开放能力时,发生错误的回调
*
* 生效时机:`open-type="launchApp"`
Expand All @@ -229,11 +215,6 @@ interface ButtonProps extends StandardProps {
* @supported weapp
*/
onChooseAvatar?: CommonEventFunction
/**
* 用户同意隐私协议事件回调,`open-type="agreePrivacyAuthorization"`时有效
* @supported weapp
*/
onAgreePrivacyAuthorization?: CommonEventFunction
/** 点击。
* 说明: 每点击一次会触发一次事件,建议自行使用代码防止重复点击,可以使用 js 防抖和节流实现。
* @supported alipay
Expand Down Expand Up @@ -272,17 +253,6 @@ interface ButtonProps extends StandardProps {
* @supported qq
*/
onAddGroupApp?: CommonEventFunction
/** 监听跳转抖音号个人页的回调
*
* 生效时机:`open-type="openAwemeUserProfile"`
* @supported tt
*/
onOpenAwemeUserProfile?: CommonEventFunction
/**
* 加群后触发
* @supported tt
*/
onJoinGroup?: CommonEventFunction<{ errMsg: string; errNo: number }>
}
declare namespace ButtonProps {
/** size 的合法值 */
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 @@ -121,7 +121,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
10 changes: 5 additions & 5 deletions packages/taro-components/types/Checkbox.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ 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, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
value: string
/** 是否禁用
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
* @default false
*/
disabled?: boolean
/** 当前是否选中,可用来设置默认选中
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
* @default false
*/
checked?: boolean
/** checkbox的颜色,同 css 的 color
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
color?: string
/**
Expand All @@ -33,7 +33,7 @@ interface CheckboxProps extends StandardProps {
*/
ariaLabel?: string
/** 选中项发生变化时触发 change 事件,小程序无此 API
* @supported alipay, h5, rn, harmony, harmony_hybrid
* @supported alipay, h5, rn, harmony_hybrid
*/
onChange?: CommonEventFunction<{
value: string[]
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/CoverImage.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ interface CoverImageProps extends StandardProps {
}
/** 覆盖在原生组件之上的图片视图。可覆盖的原生组件同cover-view,支持嵌套在cover-view里。
* @classification viewContainer
* @supported weapp, alipay, swan, qq, jd, h5, harmony_hybrid
* @supported weapp, alipay, swan, qq, jd, h5, harmony, harmony_hybrid
* @example_react
* ```tsx
* // js
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 @@ -43,11 +43,11 @@ interface FormProps extends StandardProps {
*/
clueComponentId?: string
/** 携带 form 中的数据触发 submit 事件
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
onSubmit?: CommonEventFunction<FormProps.onSubmitEventDetail>
/** 表单重置时会触发 reset 事件
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
onReset?: CommonEventFunction
}
Expand Down
7 changes: 0 additions & 7 deletions packages/taro-components/types/GridView.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ interface GridViewProps extends StandardProps {
* @default 0
*/
maxCrossAxisExtent?: number
/**
* 长度为 4 的数组,按 top、right、bottom、left 顺序指定内边距
* @supported weapp
* @default [0, 0, 0, 0]
*/
padding?: [number, number, number, number]
}

/**
* 网格布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
* @classification skyline
Expand Down
6 changes: 3 additions & 3 deletions packages/taro-components/types/Icon.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ import { ComponentType } from 'react'
import { StandardProps } from './common'
interface IconProps extends StandardProps {
/** icon 的类型
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
type: keyof IconProps.TIconType
/** icon 的大小,单位px
* @default 23
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
size?: number
size?: string
/** icon 的颜色,同 css 的 color
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
color?: string
/** 无障碍访问,(属性)元素的额外描述
Expand Down
5 changes: 2 additions & 3 deletions packages/taro-components/types/Image.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ import { ComponentType, ImgHTMLAttributes } from 'react'
import { StandardProps, CommonEventFunction } from './common'
interface ImageProps extends StandardProps {
/** 图片资源地址
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
src: string
/** 图片裁剪、缩放的模式
* @default "scaleToFill"
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
* @rn 部分支持 scaleToFill, aspectFit, aspectFill, widthFix
* @harmony 部分支持 scaleToFill, aspectFit, aspectFill, widthFix, heightFix
*/
mode?: keyof ImageProps.Mode
/** 默认不解析 webP 格式,只支持网络资源
Expand Down
30 changes: 15 additions & 15 deletions packages/taro-components/types/Input.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 InputProps extends StandardProps, FormItemProps {
/** 输入框的初始内容
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
value?: string
/** 设置 React 非受控输入框的初始内容
Expand All @@ -12,20 +12,20 @@ interface InputProps extends StandardProps, FormItemProps {
defaultValue?: string
/** input 的类型
* @default "text"
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
type?: keyof InputProps.Type
/** 是否是密码类型
* @default false
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
password?: boolean
/** 输入框为空时占位符
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
placeholder?: string
/** 指定 placeholder 的样式
* @supported weapp, alipay, swan, tt, qq, jd, rn, harmony
* @supported weapp, alipay, swan, tt, qq, jd, rn
*/
placeholderStyle?: string
/** 指定 placeholder 的样式类
Expand All @@ -34,7 +34,7 @@ interface InputProps extends StandardProps, FormItemProps {
*/
placeholderClass?: string
/** 指定 placeholder 的文本颜色
* @supported rn, harmony
* @supported rn
*/
placeholderTextColor?: string
/** 是否禁用
Expand All @@ -44,7 +44,7 @@ interface InputProps extends StandardProps, FormItemProps {
disabled?: boolean
/** 最大输入长度,设置为 -1 的时候不限制最大长度
* @default 140
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
maxlength?: number
/** 指定光标与键盘的距离,单位 px 。取 input 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离
Expand All @@ -66,7 +66,7 @@ interface InputProps extends StandardProps, FormItemProps {
/** 设置键盘右下角按钮的文字,仅在type='text'时生效
* @alipay confirm-type 与 enableNative 属性冲突,若希望 confirm-type 生效,enableNative 不能设定为 false,而且不能设定 always-system
* @default done
* @supported weapp, alipay, swan, tt, qq, jd, rn, harmony
* @supported weapp, alipay, swan, tt, qq, jd, rn
*/
confirmType?: keyof InputProps.ConfirmType
/** 点击键盘右下角按钮时是否保持键盘不收起
Expand All @@ -75,7 +75,7 @@ interface InputProps extends StandardProps, FormItemProps {
*/
confirmHold?: boolean
/** 指定focus时的光标位置
* @supported weapp, alipay, swan, tt, qq, jd, rn, harmony
* @supported weapp, alipay, swan, tt, qq, jd, rn
*/
cursor?: number
/** 光标起始位置,自动聚集时有效,需与selection-end搭配使用
Expand All @@ -90,7 +90,7 @@ interface InputProps extends StandardProps, FormItemProps {
selectionEnd?: number
/** 键盘弹起时,是否自动上推页面
* @default true
* @supported weapp, swan, tt, qq, jd, harmony
* @supported weapp, swan, tt, qq, jd
*/
adjustPosition?: boolean
/** focus 时,点击页面的时候不收起键盘
Expand Down Expand Up @@ -171,23 +171,23 @@ interface InputProps extends StandardProps, FormItemProps {
*/
clueType?: number
/** 当键盘输入时,触发input事件,event.detail = {value, cursor, keyCode},处理函数可以直接 return 一个字符串,将替换输入框的内容。
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
onInput?: CommonEventFunction<InputProps.inputEventDetail>
/** 输入框聚焦时触发,event.detail = { value, height },height 为键盘高度
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
onFocus?: CommonEventFunction<InputProps.inputForceEventDetail>
/** 输入框失去焦点时触发
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
onBlur?: CommonEventFunction<InputProps.inputValueEventDetail>
/** 点击完成按钮时触发
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid
*/
onConfirm?: CommonEventFunction<InputProps.inputValueEventDetail>
/** 键盘高度发生变化的时候触发此事件
* @supported weapp, tt, qq, harmony
* @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/Label.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ComponentType } from 'react'
import { StandardProps } from './common'
interface LabelProps extends StandardProps {
/** 绑定控件的 id
* @supported weapp, alipay, swan, tt, qq, jd, h5, harmony, harmony_hybrid
* @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid
*/
for?: string
}
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 @@ -12,7 +12,7 @@ interface ListViewProps extends StandardProps {
/**
* 列表布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
* @classification skyline
* @supported weapp, harmony
* @supported weapp
* @see https://developers.weixin.qq.com/miniprogram/dev/component/list-view.html
*/
declare const ListView: ComponentType<ListViewProps>
Expand Down
24 changes: 0 additions & 24 deletions packages/taro-components/types/Map.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,30 +218,6 @@ interface MapProps extends StandardProps {
* @supported weapp, swan, qq
*/
onPoiTap?: CommonEventFunction<MapProps.onPoiTapEventDetail>
/** 点击地图路线时触发,e.detail = {longitude, latitude}
* @supported weapp, swan, qq
*/
onPolylineTap?: CommonEventFunction<MapProps.onPolylineTapEventDetail>
/** 地图能力生效时触发,e.detail = {ability, errCode, errMsg}
* @supported weapp
*/
onAbilitySuccess?: CommonEventFunction<MapProps.onAbilityEventDetail>
/** 地图能力失败时触发,e.detail = {ability, errCode, errMsg}
* @supported weapp
*/
onAbilityFailed?: CommonEventFunction<MapProps.onAbilityEventDetail>
/** 地图鉴权结果成功时触发,e.detail = {errCode, errMsg}
* @supported weapp
*/
onAuthSuccess?: CommonEventFunction<{ errCode: number; errMsg: string }>
/** MapContext.moveAlong 插值动画时触发。e.detail = {markerId, longitude, latitude, animationStatus: "interpolating" | "complete"}
* @supported weapp
*/
onInterpolatePoint?: CommonEventFunction<MapProps.onInterpolatePointEventDetail>
/** 组件错误时触发,例如创建或鉴权失败,e.detail = {longitude, latitude}
* @supported weapp
*/
onError: CommonEventFunction<MapProps.point>
/** 点击标记点对应的气泡时触发e.detail = {markerId}
* @supported weapp, swan, tt, jd
*/
Expand Down
8 changes: 4 additions & 4 deletions packages/taro-components/types/NavigationBar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { ComponentType } from 'react'
import { StandardProps, CommonEventFunction } from './common'
interface NavigationBarProps extends StandardProps {
/** 导航条标题
* @supported weapp, harmony
* @supported weapp
*/
title?: string
/** 是否在导航条显示 loading 加载提示
* @supported weapp, harmony
* @supported weapp
*/
loading?: boolean
/** 导航条前景颜色值,包括按钮、标题、状态栏的颜色,仅支持 #ffffff 和 #000000
* @supported weapp, harmony
* @supported weapp
*/
frontColor?: string
/** 导航条背景颜色值,有效值为十六进制颜色
* @supported weapp, harmony
* @supported weapp
*/
backgroundColor?: string
/** 改变导航栏颜色时的动画时长,默认为 0 (即没有动画效果)
Expand Down
Loading

0 comments on commit 191eaad

Please sign in to comment.