[Improvement] add type definition files (#361)

This commit is contained in:
neverland 2017-11-29 18:00:08 +08:00 committed by GitHub
parent c8915d3984
commit 121e2de375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 153 additions and 4 deletions

View File

@ -5,6 +5,7 @@
"main": "lib/vant.js",
"style": "lib/vant-css/index.css",
"unpkg": "lib/index.js",
"typings": "types/index.d.ts",
"files": [
"lib",
"src",

View File

@ -7,8 +7,11 @@ const defaultConfig = {
value: true,
title: '',
message: '',
overlay: true,
lockOnScroll: true,
confirmButtonText: '',
cancelButtonText: '',
showConfirmButton: true,
showCancelButton: false,
closeOnClickOverlay: false,
callback: action => {

View File

@ -15,7 +15,7 @@ export default {
props: {
zIndex: Number,
className: String,
customStyle: Object,
customStyle: Object
},
computed: {
@ -23,7 +23,7 @@ export default {
return {
zIndex: this.zIndex,
...this.customStyle
}
};
}
}
};

View File

@ -4,11 +4,11 @@ import VueToast from './toast';
let instance;
const defaultOptions = {
visible: true,
type: 'text',
mask: false,
position: 'middle',
visible: true,
duration: 3000,
position: 'middle',
forbidClick: false,
clear: () => {
instance.visible = false;

3
types/component.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
export class VanComponent {
static name: string;
}

20
types/dialog.d.ts vendored Normal file
View File

@ -0,0 +1,20 @@
export type DialogOptions = {
title?: string;
message?: string;
overlay?: boolean;
lockOnScroll?: boolean;
confirmButtonText?: string;
cancelButtonText?: string;
showConfirmButton?: boolean;
showCancelButton?: boolean;
closeOnClickOverlay?: boolean;
}
export interface Dialog {
(options: DialogOptions): Promise<any>;
alert(options: DialogOptions): Promise<any>;
confirm(options: DialogOptions): Promise<any>;
close(): void;
}
export const Dialog: Dialog;

12
types/image-preview.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
import { VanPopupMixin } from './mixins/popup';
export class VanImagePreview extends VanPopupMixin {
images: string[];
startPosition: number;
}
export interface ImagePreview {
(images: string[], startPosition?: number): VanImagePreview;
}
export const ImagePreview: ImagePreview;

73
types/index.d.ts vendored Normal file
View File

@ -0,0 +1,73 @@
import Vue from 'vue';
import { VanComponent } from './component';
import { Toast } from './toast';
import { Dialog } from './dialog';
import { Lazyload } from './lazyload';
import { Waterfall } from './waterfall';
import { ImagePreview } from './image-preview';
export const version: string
export function install (vue: typeof Vue): void
export class Actionsheet extends VanComponent {}
export class AddressEdit extends VanComponent {}
export class AddressList extends VanComponent {}
export class Area extends VanComponent {}
export class Badge extends VanComponent {}
export class BadgeGroup extends VanComponent {}
export class Button extends VanComponent {}
export class Card extends VanComponent {}
export class Cell extends VanComponent {}
export class CellGroup extends VanComponent {}
export class CellSwipe extends VanComponent {}
export class Checkbox extends VanComponent {}
export class CheckboxGroup extends VanComponent {}
export class Col extends VanComponent {}
export class ContactCard extends VanComponent {}
export class ContactEdit extends VanComponent {}
export class ContactList extends VanComponent {}
export class CouponCell extends VanComponent {}
export class CouponList extends VanComponent {}
export class DatetimePicker extends VanComponent {}
export class Field extends VanComponent {}
export class GoodsAction extends VanComponent {}
export class GoodsActionBigBtn extends VanComponent {}
export class GoodsActionMiniBtn extends VanComponent {}
export class Icon extends VanComponent {}
export class Loading extends VanComponent {}
export class NavBar extends VanComponent {}
export class NoticeBar extends VanComponent {}
export class NumberKeyboard extends VanComponent {}
export class Pagination extends VanComponent {}
export class Panel extends VanComponent {}
export class PasswordInput extends VanComponent {}
export class Picker extends VanComponent {}
export class Popup extends VanComponent {}
export class Progress extends VanComponent {}
export class PullRefresh extends VanComponent {}
export class Radio extends VanComponent {}
export class RadioGroup extends VanComponent {}
export class Row extends VanComponent {}
export class Search extends VanComponent {}
export class Sku extends VanComponent {}
export class Step extends VanComponent {}
export class Stepper extends VanComponent {}
export class Steps extends VanComponent {}
export class SubmitBar extends VanComponent {}
export class Swipe extends VanComponent {}
export class SwipeItem extends VanComponent {}
export class Switch extends VanComponent {}
export class SwitchCell extends VanComponent {}
export class Tab extends VanComponent {}
export class Tabbar extends VanComponent {}
export class TabbarItem extends VanComponent {}
export class Tabs extends VanComponent {}
export class Tag extends VanComponent {}
export class TreeSelect extends VanComponent {}
export class Uploader extends VanComponent {}
export {
Toast,
Dialog,
Lazyload,
Waterfall,
ImagePreview
}

7
types/lazyload.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import Vue, { PluginFunction } from 'vue';
export interface Lazyload {
install: PluginFunction<void>
}
export const Lazyload: Lazyload;

4
types/mixins/popup.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
export class VanPopupMixin {
open(): void;
close(): void;
}

18
types/toast.d.ts vendored Normal file
View File

@ -0,0 +1,18 @@
export type ToastOptions = {
type?: string;
mask?: boolean;
message?: string;
position?: string;
duration?: number;
forbidClick?: boolean;
}
export interface Toast {
(message: ToastOptions | string, options?: ToastOptions): void;
loading(options?: ToastOptions): void;
success(options?: ToastOptions): void;
fail(options?: ToastOptions): void;
clear(): void;
}
export const Toast: Toast;

8
types/waterfall.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
import Vue, { DirectiveFunction, PluginFunction } from 'vue';
export interface Waterfall {
(type: string): DirectiveFunction;
install: PluginFunction<void>
}
export const Waterfall: Waterfall;