Skip to content

Commit

Permalink
refactor(component): 重构各个组件的 typings 为单文件
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Jun 5, 2018
1 parent 1b5746f commit 66caf36
Show file tree
Hide file tree
Showing 5 changed files with 432 additions and 405 deletions.
85 changes: 85 additions & 0 deletions packages/taro-components/types/ScrollView.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'

interface ScrollViewProps extends StandardProps {

/**
* 允许横向滚动
*
* 默认值:`fasle`
*/
scrollX?: boolean,

/**
* 允许纵向滚动
*
* 默认值:`false`
*/
scrollY?: boolean,

/**
* 距顶部/左边多远时(单位px),触发 scrolltoupper 事件
*
* 默认值:`50`
*/
upperThreshold?: number,

/**
* 距底部/右边多远时(单位px),触发 scrolltolower 事件
*
* 默认值:`50`
*/
lowerThreshold?: number,

/**
* 设置竖向滚动条位置
*/
scrollTop?: number,

/**
* 设置横向滚动条位置
*/
scrollLeft?: number,

/**
* 值应为某子元素id(id不能以数字开头)。设置哪个方向可滚动,则在哪个方向滚动到该元素
*/
scrollIntoView?: string,

/**
* iOS点击顶部状态栏、安卓双击标题栏时,滚动条返回顶部,只支持竖向
*
* 默认值:`false`
*/
enableBackToTop?: boolean,

/**
* 在设置滚动条位置时使用动画过渡
*
* 默认值:`fasle`
*/
scrollWithAnimation?: boolean,

/**
* 滚动到顶部/左边,会触发 scrolltoupper 事件
*/
onScrollToUpper?: (event: BaseEvent) => any,

/**
* 滚动到底部/右边,会触发 scrolltolower 事件
*/
onScrollToLower?: (event: BaseEvent) => any,

/**
* 滚动时触发
*
* `event.detail = {scrollLeft, scrollTop, scrollHeight, scrollWidth, deltaX, deltaY}`
*/
onScroll?: (event: BaseEvent) => any
}

declare const ScrollView: ComponentType<ScrollViewProps>

export {
ScrollView
}
136 changes: 136 additions & 0 deletions packages/taro-components/types/Swiper.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'

interface SwiperProps extends StandardProps {

/**
* 是否显示面板指示点
*
* 默认值:`false`
*/
indicatorDots?: boolean,

/**
* 指示点颜色
*
* 默认值:`rgba(0, 0, 0, .3)`
*/
indicatorColor?: string,

/**
* 当前选中的指示点颜色
*
* 默认值:`#000000`
*/
indicatorActiveColor?: string,

/**
* 是否自动切换
*
* 默认值:`false`
*/
autoplay?: boolean,

/**
* 当前所在滑块的 index
*
* 默认值:`0`
*/
current?: number,

/**
* 当前所在滑块的 item-id ,不能与 current 被同时指定
*
* 默认值:`""`
*/
currentItemId?: string,

/**
* 自动切换时间间隔
*
* 默认值:`5000`
*/
interval?: number,

/**
* 滑动动画时长
*
* 默认值:`500`
*/
duration?: number,

/**
* 是否采用衔接滑动
*
* 默认值:`false`
*/
circular?: boolean,

/**
* 滑动方向是否为纵向
*
* 默认值:`false`
*/
vertical?: boolean,

/**
* 前边距,可用于露出前一项的一小部分,接受 px 和 rpx 值
*
* 默认值:`0px`
*/
previousMargin?: string,

/**
* 后边距,可用于露出后一项的一小部分,接受 px 和 rpx 值
*
* 默认值:`0px`
*/
nextMargin?: string,

/**
* 同时显示的滑块数量
*
* 默认值:`1`
*/
displayMultipleItems?: number,

/**
* 是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息
*
* 默认值:`false`
*/
skipHiddenItemLayout?: boolean


/**
* current 改变时会触发 change 事件
*
* `event.detail = {current: current, source: source}`
*/
onChange?: (event: BaseEvent) => any

/**
* 动画结束时会触发 animationfinish 事件
*
* `event.detail = {current: current, source: source}`
*/
onAnimationFinish?: (event: BaseEvent) => any
}

declare const Swiper: ComponentType<SwiperProps>

interface SwiperItemProps extends StandardProps {

/**
* 该 swiper-item 的标识符
*/
itemId: string
}

declare const SwiperItem: ComponentType<SwiperItemProps>


export {
Swiper,
SwiperItem
}
38 changes: 38 additions & 0 deletions packages/taro-components/types/View.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { ComponentType } from 'react'
import { StandardProps } from './common'

interface ViewProps extends StandardProps {
/**
* 指定按下去的样式类。当 `hover-class="none"` 时,没有点击态效果
*
* 默认值:`none`
*/
hoverClass?: string,

/**
* 指定是否阻止本节点的祖先节点出现点击态
*
* 默认值:`fasle`
*/
hoverStopPropagation?: boolean,

/**
* 按住后多久出现点击态,单位毫秒
*
* 默认值:`50`
*/
hoverStartTime?: number,

/**
* 手指松开后点击态保留时间,单位毫秒
*
* 默认值:`400`
*/
hoverStayTime?: number
}

declare const View: ComponentType<ViewProps>

export {
View
}
Loading

0 comments on commit 66caf36

Please sign in to comment.