Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Commit

Permalink
feat: add components types
Browse files Browse the repository at this point in the history
  • Loading branch information
pengshanglong committed May 14, 2020
1 parent 6b74def commit f234956
Show file tree
Hide file tree
Showing 51 changed files with 2,845 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"resolveJsonModule": true,
"typeRoots": [
"node_modules/@types",
"global.d.ts"
"global.d.ts",
"types"
]
},
"exclude": [
Expand Down
48 changes: 48 additions & 0 deletions types/accordion.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { MouseEvent, ComponentClass } from 'react'
import { CommonEvent } from '@tarojs/components/types/common'

import AtComponent, { AtIconBaseProps } from './base'

export interface AtAccordionProps extends AtComponent {
/**
* 是否默认开启
* @default false
*/
open?: boolean
/**
* 标题
*/
title?: string
/**
* 图标,仅支持 AtIcon 支持的类型,
* object 属性有 value color size prefixClass
*/
icon?: AtIconBaseProps
/**
* 是否开启动画
* @default true
* @since v2.0.0-beta.3
*/
isAnimation?: boolean
/**
* 是否有头部下划线
* @default true
*/
hasBorder?: boolean
/**
* 描述信息
*/
note?: string
/**
* 点击头部触发事件
*/
onClick?: (open: boolean, event: CommonEvent) => void
}

export interface AtAccordionState {
wrapperHeight: number
}

declare const AtAccordion: ComponentClass<AtAccordionProps>

export default AtAccordion
55 changes: 55 additions & 0 deletions types/action-sheet.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { MouseEvent, ComponentClass } from 'react'
import { CommonEvent } from '@tarojs/components/types/common'

import AtComponent from './base'

export interface AtActionSheetProps extends AtComponent {
/**
* 是否展示元素
* @default false
*/
isOpened: boolean
/**
* 元素的标题
*/
title?: string
/**
* 取消按钮的内容
*/
cancelText?: string
/**
* 元素被关闭触发的事件
*/
onClose?: (event?: CommonEvent) => void
/**
* 点击了底部取消按钮触发的事件
*/
onCancel?: (event?: CommonEvent) => void
}

export interface AtActionSheetState {
_isOpened: boolean
}

export interface AtActionSheetHeaderProps extends AtComponent {}

export interface AtActionSheetFooterProps extends AtComponent {
onClick?: Function
}

export interface AtActionSheetBodyProps extends AtComponent {}

export interface AtActionSheetItemProps extends AtComponent {
/**
* 点击 Item 触发的事件
*/
onClick?: (event?: CommonEvent) => void
}

declare const AtActionSheetItem: ComponentClass<AtActionSheetItemProps>

declare const AtActionSheet: ComponentClass<AtActionSheetProps>

export default AtActionSheet

export { AtActionSheetItem }
33 changes: 33 additions & 0 deletions types/activity-indicator.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { MouseEvent, ComponentClass } from 'react'

import AtComponent from './base'

export interface AtActivityIndicatorProps extends AtComponent{
/**
* loading 图的大小
* @default 24
*/
size?: number
/**
* 元素的类型
*/
mode?: 'center' | 'normal'
/**
* loading 图的颜色
* @default #6190E8
*/
color?: string
/**
* 元素的内容文本
*/
content?: string
/**
* 控制元素显示隐藏
* @default true
*/
isOpened?: boolean
}

declare const AtActivityIndicator: ComponentClass<AtActivityIndicatorProps>

export default AtActivityIndicator
38 changes: 38 additions & 0 deletions types/avatar.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { MouseEvent, ComponentClass } from 'react'

import AtComponent from './base'

export interface AtAvatarProps extends AtComponent{
/**
* 头像大小
* @default 'normal'
*/
size?: 'large' | 'normal' | 'small'
/**
* 头像是否圆形
* @default false
*/
circle?: boolean
/**
* 以文字形式展示头像
*/
text?: string
/**
* 头像图片地址
*/
image?: string
/**
* 参考微信[开放数据](https://developers.weixin.qq.com/miniprogram/dev/component/open-data.html)
*
* **注意:** openData 仅支持 type 为 userAvatarUrl
*/
openData?: { type: 'userAvatarUrl' }
}

export interface AtAvatarState {
isWEAPP: boolean
}

declare const AtAvatar: ComponentClass<AtAvatarProps>

export default AtAvatar
24 changes: 24 additions & 0 deletions types/badge.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { MouseEvent, ComponentClass } from 'react'

import AtComponent from './base'

export interface AtBadgeProps extends AtComponent {
/**
* 角标红点
* @default false
*/
dot?: boolean
/**
* 角标内容
*/
value?: string | number
/**
* 角标最大值
* @default 99
*/
maxValue?: number
}

declare const AtBadge: ComponentClass<AtBadgeProps>

export default AtBadge
25 changes: 25 additions & 0 deletions types/base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { CSSProperties } from 'react'

export interface AtComponent {
className?: string

customStyle?: string | CSSProperties
}

export interface AtIconBaseProps2 extends AtComponent {
value: string

color?: string
}

export interface AtIconBaseProps extends AtComponent {
value: string

color?: string

prefixClass?: string

size?: number | string
}

export default AtComponent
56 changes: 56 additions & 0 deletions types/button.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { MouseEvent, ComponentClass } from 'react'
import { CommonEventFunction } from '@tarojs/components/types/common'
import { ButtonProps } from '@tarojs/components/types/Button'

import AtComponent from './base'

type TaroButtonProps = Pick<ButtonProps, 'formType' | 'openType' |
'lang' | 'sessionFrom' | 'sendMessageTitle' | 'sendMessagePath' |
'sendMessageImg' | 'showMessageCard' | 'appParameter' | 'onContact' |
'onGetUserInfo' | 'onGetPhoneNumber' | 'onOpenSetting' | 'onError'>

export interface AtButtonProps extends AtComponent, TaroButtonProps {
/**
* 按钮的大小
* @default 'normal'
*/
size?: 'normal' | 'small'
/**
* 按钮的类型
*/
type?: 'primary' | 'secondary'
/**
* 设置按钮圆角
* @default false
*/
circle?: boolean
/**
* 是否通栏样式(即按钮宽度为屏幕宽度时的样式)
* @default false
*/
full?: boolean
/**
* 设置按钮的载入状态
* @default false
*/
loading?: boolean
/**
* 设置按钮为禁用态(不可点击)
* @default false
*/
disabled?: boolean
/**
* 点击按钮时触发
*/
onClick?: CommonEventFunction
}

export interface AtButtonState {
isWEB: boolean
isWEAPP: boolean
isALIPAY: boolean
}

declare const AtButton: ComponentClass<AtButtonProps>

export default AtButton
Loading

0 comments on commit f234956

Please sign in to comment.