Skip to content

Commit

Permalink
TS type declaration for supplementary basic components & vetur (didi#777
Browse files Browse the repository at this point in the history
)

* fix(types): complete ts type

* fix: complete ts type 1

* fix(types/ test/): complete ts types

* docs: test

* fix(test types): complete ts types test-dts

* docs: updata Partial EventsProps

* docs: update ts events

* docs: add ts development tooling

* docs: update ts development tooling docs

* chore: supplement the TS declaration of the basic component & vetur

Co-authored-by: shanchuntao <[email protected]>
  • Loading branch information
scTaoFelix and shanchuntao authored Aug 3, 2021
1 parent d4b743c commit 76e1f67
Show file tree
Hide file tree
Showing 34 changed files with 887 additions and 34 deletions.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@
"files": [
"src",
"lib",
"types"
"types",
"vetur"
],
"vetur": {
"tags": "vetur/tags.json",
"attributes": "vetur/attributes.json"
},
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
Expand Down
15 changes: 15 additions & 0 deletions types/components/Button.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import { CubeUIComponent } from '../component'

export type ButtonType = 'button' | 'submit'

export declare class CubeButton extends CubeUIComponent {
type?: ButtonType
active?: boolean
disabled?: boolean
icon?: string
light?: string
inline?: boolean
outline?: boolean
primary?: boolean
}
12 changes: 12 additions & 0 deletions types/components/Checkbox.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { CubeUIComponent } from '../component'
import { IRadioOptionData } from './common'

export declare class CubeCheckbox extends CubeUIComponent {
option?: IRadioOptionData | string | boolean
position?: 'left' | 'right'
shape?: 'circle' | 'square'
hollowStyle?: boolean
label?: string | boolean
value?: string | boolean
disabled?: boolean
}
13 changes: 13 additions & 0 deletions types/components/CheckboxGroup.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { IRadioOptionData } from './common'
import { CubeUIComponent } from '../component'

export declare class CubeCheckboxGroup extends CubeUIComponent {
value?: []
options?: IRadioOptionData[] | string
horizontal?: boolean
colNum?: number
shape?: 'circle' | 'square'
hollowStyle?: boolean
min?: number
max?: number
}
14 changes: 14 additions & 0 deletions types/components/Checker.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { CubeUIComponent } from '../component'

export interface ICheckerOptionData {
value?: string | number
text?: string
disabled?: boolean
}
export declare class CubeChecker extends CubeUIComponent {
value?: string | number | ICheckerOptionData[]
options?: ICheckerOptionData[]
type?: 'checkbox' | 'radio'
min?: number
max?: number
}
12 changes: 12 additions & 0 deletions types/components/Drawer.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

import { CubeUIComponent } from '../component'

export declare class CubeDrawer extends CubeUIComponent {
title?: string
data?: any[]
selectedIndex?: number[]
visible?: boolean
refill: (index?: number, data?: any[], item?: any[]) => void
show: () => void
hide: () => void
}
55 changes: 55 additions & 0 deletions types/components/Form.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { CubeUIComponent } from '../component'

interface IField {
type?: string
component?: string | object
modelKey?: string
label?: string
props?: object
events?: object
rules?: object
trigger?: 'blur' | 'change'
debounce?: number | boolean
messages?: string
key?: string
}

interface IFields {
fields: IField[]
}

interface IGroups {
groups: {
legend?: string
fields?: IField[]
}
}

interface IValidity {
valid?: boolean | undefined
result?: {}
dirty?: boolean
}

interface IValidateParams {
validity?: IValidity
valid?: boolean | undefined
invalid?: boolean
dirty?: boolean
firstInvalidFieldIndex?: number
}

export declare class CubeForm extends CubeUIComponent {
model?: object
schema?: IFields | IGroups
immediateValidate?: boolean
action?: string | undefined
options?: {
scrollToInvalidField?: boolean
layout?: 'standard' | 'classic' | 'fresh'
}
submitAlwaysValidate?: boolean
submit: (skipValidate?: boolean) => void
reset: () => void
validate: (cb?: Function) => Promise<boolean | undefined> | undefined
}
21 changes: 21 additions & 0 deletions types/components/IndexList.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { VNode } from 'vue'
import { CubeUIComponent } from '../component'
import { BsOption } from 'better-scroll'

export interface IndexListSlots {
title: VNode[]
pulldown: VNode[]
pullup: VNode[]
[key: string]: VNode[]
}

export declare class CubeIndexList extends CubeUIComponent {
title?: string
data?: []
navbar?: boolean
speed?: number
options?: BsOption
pullUpLoad?: boolean | object
pullDownRefresh?: boolean | object
$slots: IndexListSlots
}
34 changes: 34 additions & 0 deletions types/components/Input.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { VNode } from 'vue'
import { CubeUIComponent } from '../component'

interface IClearable {
visible?: boolean
blurHidden?: boolean
}

interface IEye {
open?: boolean
reverse?: boolean
}

export interface InputSlots {
prepend: VNode[]
append: VNode[]
[key: string]: VNode[]
}

export declare class CubeInput extends CubeUIComponent {
value?: string | number
type?: 'text' | 'number' | 'password' | 'date'
disabled?: boolean
readonly?: boolean
maxlength?: number
placeholder?: string
autofocus?: boolean
autocomplete?: boolean
clearable?: boolean | IClearable
eye?: boolean | IEye
focus: (e?: FocusEvent) => void
blur: (e?: FocusEvent) => void
$slots: InputSlots
}
5 changes: 5 additions & 0 deletions types/components/Loading.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { CubeUIComponent } from '../component'

export declare class CubeLoading extends CubeUIComponent {
size?: number
}
9 changes: 9 additions & 0 deletions types/components/Radio.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { IRadioOptionData } from './common'
import { CubeUIComponent } from '../component'

export declare class CubeRadio extends CubeUIComponent {
value?: string | number
option?: IRadioOptionData | string
position?: 'left' | 'right'
hollowStyle?: boolean
}
11 changes: 11 additions & 0 deletions types/components/RadioGroup.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { IRadioOptionData } from './common'
import { CubeUIComponent } from '../component'

export declare class CubeRadioGroup extends CubeUIComponent {
value?: string | number
options?: IRadioOptionData[] | string
position?: 'left' | 'right'
horizontal?: boolean
colNum?: number
hollowStyle?: boolean
}
15 changes: 15 additions & 0 deletions types/components/Rate.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { VNode } from 'vue'
import { CubeUIComponent } from '../component'

export interface RateSlots {
default: VNode[]
[key: string]: VNode[]
}

export declare class CubeRate extends CubeUIComponent {
value?: number
max?: number
disabled?: boolean
justify?: boolean
$slots: RateSlots
}
20 changes: 20 additions & 0 deletions types/components/RecycleList.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { VNode } from 'vue'
import { CubeUIComponent } from '../component'

export interface RecycleListSlots {
default: VNode[]
tombstone: VNode[]
item: VNode[]
spinner: VNode[]
noMore: VNode[]
[key: string]: VNode[]
}

export declare class CubeRecycleList extends CubeUIComponent {
infinite?: boolean
size?: number
offset?: number
onFetch: Promise<any[] | false>
reset: () => void
$slots: RecycleListSlots
}
30 changes: 30 additions & 0 deletions types/components/Scroll.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { VNode } from 'vue'
import { CubeUIComponent } from '../component'
import { BsOption } from 'better-scroll'

type IScrollEvents = 'scroll' | 'before-scroll-start' | 'scroll-end'

export interface ScrollSlots {
default: VNode[]
pulldown: VNode[]
pullup: VNode[]
[key: string]: VNode[]
}

export declare class CubeScroll extends CubeUIComponent {
data?: []
direction?: 'vertical' | 'horizontal'
options?: BsOption
scrollEvents?: IScrollEvents[]
listenScroll?: boolean
listenBeforeScroll?: boolean
refreshDelay?: number
nestMode?: 'none' | 'native' | 'free'
scrollTo: (x?: number, y?: number, time?: number, ease?: object) => void
forceUpdate: (dirty?: boolean, nomore?: boolean) => void
disable: () => void
enable: () => void
resetPullUpTxt: () => void
refresh: () => void
$slots: ScrollSlots
}
21 changes: 21 additions & 0 deletions types/components/ScrollNav.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { VNode } from 'vue'
import { CubeUIComponent } from '../component'
import { BsOption } from 'better-scroll'

export interface ScrollNavSlots {
default: VNode[]
prepend: VNode[]
bar: VNode[]
[key: string]: VNode[]
}


export declare class CubeScrollNav extends CubeUIComponent {
data?: []
side?: boolean
current?: string | number
speed?: number
options?: BsOption
refresh: () => void
$slots: ScrollNavSlots
}
18 changes: 18 additions & 0 deletions types/components/ScrollNavBar.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { VNode } from 'vue'
import { CubeUIComponent } from '../component'
import { BsOption } from 'better-scroll'

export interface ScrollNavBarSlots {
default: VNode[]
[key: string]: VNode[]
}

export declare class CubeScrollNavBar extends CubeUIComponent {
direction?: 'horizontal' | 'vertical'
labels?: []
txts?: []
current?: string | number
options?: BsOption
refresh: () => void
$slots: ScrollNavBarSlots
}
16 changes: 16 additions & 0 deletions types/components/Select.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { CubeUIComponent } from '../component'

interface IOptItem {
value?: any
text?: string
}
export declare class CubeSelect extends CubeUIComponent {
value?: any
options?: IOptItem[]
placeholder?: string
autoPop?: boolean
disabled?: boolean
title?: string
cancelTxt?: string
confirmTxt?: string
}
32 changes: 32 additions & 0 deletions types/components/Slide.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { VNode } from 'vue'
import { CubeUIComponent } from '../component'
import { BsOption } from 'better-scroll'

interface SlideItem {
url?: string
image?: string
}

export interface SlideSlots {
default: VNode[]
dots: VNode[]
[key: string]: VNode[]
}

export declare class CubeSlide extends CubeUIComponent {
data?: SlideItem[]
initialIndex?: number
loop?: boolean
showDots?: boolean
autoPlay?: boolean
interval?: number
direction?: 'horizontal' | 'vertical'
options?: BsOption
threshold?: number
speed?: number
allowVertical?: boolean
stopPropagation?: boolean
refreshResetCurrent?: boolean
refresh: () => void
$slots: SlideSlots
}
Loading

0 comments on commit 76e1f67

Please sign in to comment.