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 #4

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
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
66 changes: 64 additions & 2 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ interface ButtonProps extends StandardProps {
* @supported swan
*/
subscribeId?: string
/** 打开群资料卡时,传递的群号
/** 群聊 id
* @qq 打开群资料卡时,传递的群号
* @tt 通过创建聊天群、查询群信息获取
* @supported qq
*/
groupId?: string
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
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
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
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
8 changes: 5 additions & 3 deletions packages/taro-components/types/NativeSlot.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'

interface NativeSlotProps {
import type { ComponentType, ReactNode } from 'react'

interface NativeSlotProps extends StandardProps {
/** 指定插入的 slot 位置
* @default none
* @supported weapp, swan, alipay, tt, jd, qq
Expand All @@ -10,7 +12,7 @@ interface NativeSlotProps {

/** 编译的原生组件支持使用 slot 插槽
* @classification viewContainer
* @supported weapp, swan, alipay, tt, jd, qq
* @supported weapp, swan, alipay, tt, jd, qq, h5
* @version 3.5.7+
* @example
* ```tsx
Expand Down
30 changes: 27 additions & 3 deletions packages/taro-components/types/ScrollView.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentType } from 'react'
import { StandardProps, CommonEventFunction, BaseEventOrigFunction } from './common'
import { BaseEventOrigFunction, CommonEventFunction, StandardProps } from './common'
interface ScrollViewProps extends StandardProps {
/** 允许横向滚动
* @default false
Expand Down Expand Up @@ -130,7 +130,7 @@ interface ScrollViewProps extends StandardProps {
* @supported weapp
* @default false
*/
enablePassive?: string
enablePassive?: boolean
/** 渲染模式
* list - 列表模式。只会渲染在屏节点,会根据直接子节点是否在屏来按需渲染,若只有一个直接子节点则性能会退化
* custom - 自定义模式。只会渲染在屏节点,子节点可以是 sticky-section list-view grid-view 等组件
Expand All @@ -157,7 +157,7 @@ interface ScrollViewProps extends StandardProps {
* center - 目标节点显示在视口中间
* end - 目标节点显示在视口结束处
* nearest - 目标节点在就近的视口边缘显示,若节点已在视口内则不触发滚动
* @supported weapp
* @supported weapp, h5
* @default 'start'
*/
scrollIntoViewAlignment?: 'start' | 'center' | 'end' | 'nearest'
Expand Down Expand Up @@ -252,6 +252,30 @@ declare namespace ScrollViewProps {
/** 滚动速度 */
velocity: number
}
interface RefresherStatusChange {
status: RefreshStatus
dy: number
}
const enum RefreshStatus {
// 空闲
Idle,
// 超过下拉刷新阈值,同 bind:refresherwillRefresh 触发时机
CanRefresh,
// 下拉刷新,同 bind:refresherrefresh 触发时机
Refreshing,
// 下拉刷新完成,同 bind:refresherrestore 触发时机
Completed,
// 下拉刷新失败
Failed,
// 超过下拉二级阈值
CanTwoLevel,
// 开始打开二级
TwoLevelOpening,
// 打开二级
TwoLeveling,
// 开始关闭二级
TwoLevelClosing,
}
}
/** 可滚动视图区域。使用竖向滚动时,需要给scroll-view一个固定高度,通过 WXSS 设置 height。组件属性的长度单位默认为 px
*
Expand Down
6 changes: 1 addition & 5 deletions packages/taro-components/types/ShareElement.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ interface ShareElementProps extends StandardProps {
* @deprecated 使用mapkey替换key
*/
key?: string
/** 映射标记
* @supported weapp
*/
mapkey?: string
/** 映射标记
* @supported alipay
*/
Expand Down Expand Up @@ -68,7 +64,7 @@ interface ShareElementProps extends StandardProps {
*
* 共享元素是一种动画形式,类似于 [`flutter Hero`](https://flutterchina.club/animations/hero-animations/) 动画,表现为元素像是在页面间穿越一样。该组件需与 [`PageContainer`](/docs/components/viewContainer/page-container) 组件结合使用。
* 使用时需在当前页放置 `ShareElement` 组件,同时在 `PageContainer` 容器中放置对应的 `ShareElement` 组件,对应关系通过属性值 key 映射。当设置 `PageContainer` `显示时,transform` 属性为 `true` 的共享元素会产生动画。当前页面容器退出时,会产生返回动画。
* @classification viewContainer
* @classification skyline
* @supported weapp, alipay
* @example_react
* ```tsx
Expand Down
8 changes: 5 additions & 3 deletions packages/taro-components/types/Slot.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'

interface SlotProps {
import type { ComponentType, ReactNode } from 'react'

interface SlotProps extends StandardProps {
/** 指定插入的 slot 位置
* @default none
* @supported weapp, swan, alipay, tt, jd, qq
Expand All @@ -15,7 +17,7 @@ interface SlotProps {

/** slot 插槽
* @classification viewContainer
* @supported weapp, swan, alipay, tt, jd, qq, harmony
* @supported weapp, swan, alipay, tt, jd, qq, harmony, h5
* @example
* ```tsx
* import { Slot, View, Text } from '@tarojs/components'
Expand Down
16 changes: 16 additions & 0 deletions packages/taro-components/types/Snapshot.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ComponentType } from 'react'

import { StandardProps } from './common'

interface SnapshotProps extends StandardProps {
id: string
}

/** 截图组件。
* 支持将其子节点的渲染结果导出成图片,该组件需配合 snapshot 接口使用。 目前仅在 Skyline 渲染引擎 下支持。
* @classification skyline
* @supported weapp
* @see https://developers.weixin.qq.com/miniprogram/dev/component/snapshot.html
*/
declare const Snapshot: ComponentType<SnapshotProps>
export { Snapshot, SnapshotProps }
2 changes: 1 addition & 1 deletion packages/taro-components/types/StickyHeader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ interface StickyHeaderProps extends StandardProps {}

/**
* 吸顶布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。
* @classification viewContainer
* @classification skyline
* @supported weapp
* @see https://developers.weixin.qq.com/miniprogram/dev/component/sticky-header.html
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/StickySection.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface StickySectionProps extends StandardProps {
}
/**
* 吸顶布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点。仅 Skyline 支持。
* @classification viewContainer
* @classification skyline
* @supported weapp
* @see https://developers.weixin.qq.com/miniprogram/dev/component/sticky-section.html
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/types/Textarea.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ interface TextareaProps extends StandardProps, FormItemProps {
/** 点击键盘右下角按钮时是否保持键盘不收起
* @supported weapp, swan, tt
*/
confirmHold?: string
confirmHold?: boolean
/** 组件名字,用于表单提交获取数据。
* @supported alipay
*/
Expand Down
5 changes: 3 additions & 2 deletions packages/taro-components/types/Video.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ interface VideoProps extends StandardProps {
nativeProps?: Record<string, unknown>
/** 是否展示底部进度条
* @supported weapp
* @default true
*/
showBottomProgress?: string
showBottomProgress?: boolean
/** 是否在小窗模式下显示播放进度
* @supported weapp
*/
Expand All @@ -205,7 +206,7 @@ interface VideoProps extends StandardProps {
/** 是否是 DRM 视频源
* @supported weapp
*/
isDrm?: string
isDrm?: boolean
/** DRM 设备身份认证 url,仅 is-drm 为 true 时生效 (Android)
* @supported weapp
*/
Expand Down
13 changes: 8 additions & 5 deletions packages/taro-components/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@ export * from './props'
export { Block } from './Block'
export { CoverImage } from './CoverImage'
export { CoverView } from './CoverView'
export { GridView } from './GridView'
export { ListView } from './ListView'
export { MatchMedia } from './MatchMedia'
export { MovableArea } from './MovableArea'
export { MovableView } from './MovableView'
export { PageContainer } from './PageContainer'
export { RootPortal } from './RootPortal'
export { ScrollView } from './ScrollView'
export { ShareElement } from './ShareElement'
export { StickyHeader } from './StickyHeader'
export { StickySection } from './StickySection'
export { Swiper } from './Swiper'
export { SwiperItem } from './SwiperItem'
export { View } from './View'
Expand Down Expand Up @@ -45,6 +40,14 @@ export { Slider } from './Slider'
export { Switch } from './Switch'
export { Textarea } from './Textarea'

/** Skyline */
export { GridView } from './GridView'
export { ListView } from './ListView'
export { ShareElement } from './ShareElement'
export { Snapshot } from './SnapShot'
export { StickyHeader } from './StickyHeader'
export { StickySection } from './StickySection'

/** 导航 */
export { FunctionalPageNavigator } from './FunctionalPageNavigator'
export { Navigator } from './Navigator'
Expand Down
Loading