From 76e1f67ef5c431548bb39f9e519e0ee326d52156 Mon Sep 17 00:00:00 2001 From: scTaoFelix <460334480@qq.com> Date: Tue, 3 Aug 2021 23:02:58 +0800 Subject: [PATCH] TS type declaration for supplementary basic components & vetur (#777) * 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 --- package.json | 7 +- types/components/Button.d.ts | 15 +++ types/components/Checkbox.d.ts | 12 ++ types/components/CheckboxGroup.d.ts | 13 ++ types/components/Checker.d.ts | 14 +++ types/components/Drawer.d.ts | 12 ++ types/components/Form.d.ts | 55 +++++++++ types/components/IndexList.d.ts | 21 ++++ types/components/Input.d.ts | 34 ++++++ types/components/Loading.d.ts | 5 + types/components/Radio.d.ts | 9 ++ types/components/RadioGroup.d.ts | 11 ++ types/components/Rate.d.ts | 15 +++ types/components/RecycleList.d.ts | 20 ++++ types/components/Scroll.d.ts | 30 +++++ types/components/ScrollNav.d.ts | 21 ++++ types/components/ScrollNavBar.d.ts | 18 +++ types/components/Select.d.ts | 16 +++ types/components/Slide.d.ts | 32 +++++ types/components/Sticky.d.ts | 17 +++ types/components/Swipe.d.ts | 31 +++++ types/components/Switch.d.ts | 6 + types/components/TabBar.d.ts | 24 ++++ types/components/TabPanels.d.ts | 16 +++ types/components/Textarea.d.ts | 19 +++ types/components/Tip.d.ts | 15 +++ types/components/Toolbar.d.ts | 13 ++ types/components/Upload.d.ts | 28 +++++ types/components/Validator.d.ts | 35 ++++++ types/components/common.ts | 6 + types/components/index.ts | 31 +++++ types/cube-ui.d.ts | 118 ++++++++++++------ vetur/attributes.json | 24 ++++ vetur/tags.json | 178 ++++++++++++++++++++++++++++ 34 files changed, 887 insertions(+), 34 deletions(-) create mode 100644 types/components/Button.d.ts create mode 100644 types/components/Checkbox.d.ts create mode 100644 types/components/CheckboxGroup.d.ts create mode 100644 types/components/Checker.d.ts create mode 100644 types/components/Drawer.d.ts create mode 100644 types/components/Form.d.ts create mode 100644 types/components/IndexList.d.ts create mode 100644 types/components/Input.d.ts create mode 100644 types/components/Loading.d.ts create mode 100644 types/components/Radio.d.ts create mode 100644 types/components/RadioGroup.d.ts create mode 100644 types/components/Rate.d.ts create mode 100644 types/components/RecycleList.d.ts create mode 100644 types/components/Scroll.d.ts create mode 100644 types/components/ScrollNav.d.ts create mode 100644 types/components/ScrollNavBar.d.ts create mode 100644 types/components/Select.d.ts create mode 100644 types/components/Slide.d.ts create mode 100644 types/components/Sticky.d.ts create mode 100644 types/components/Swipe.d.ts create mode 100644 types/components/Switch.d.ts create mode 100644 types/components/TabBar.d.ts create mode 100644 types/components/TabPanels.d.ts create mode 100644 types/components/Textarea.d.ts create mode 100644 types/components/Tip.d.ts create mode 100644 types/components/Toolbar.d.ts create mode 100644 types/components/Upload.d.ts create mode 100644 types/components/Validator.d.ts create mode 100644 vetur/attributes.json create mode 100644 vetur/tags.json diff --git a/package.json b/package.json index fa71af99..5aca9117 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/types/components/Button.d.ts b/types/components/Button.d.ts new file mode 100644 index 00000000..6deb9429 --- /dev/null +++ b/types/components/Button.d.ts @@ -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 +} diff --git a/types/components/Checkbox.d.ts b/types/components/Checkbox.d.ts new file mode 100644 index 00000000..25c0c71c --- /dev/null +++ b/types/components/Checkbox.d.ts @@ -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 +} diff --git a/types/components/CheckboxGroup.d.ts b/types/components/CheckboxGroup.d.ts new file mode 100644 index 00000000..549b2d85 --- /dev/null +++ b/types/components/CheckboxGroup.d.ts @@ -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 +} diff --git a/types/components/Checker.d.ts b/types/components/Checker.d.ts new file mode 100644 index 00000000..56828396 --- /dev/null +++ b/types/components/Checker.d.ts @@ -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 +} diff --git a/types/components/Drawer.d.ts b/types/components/Drawer.d.ts new file mode 100644 index 00000000..98013258 --- /dev/null +++ b/types/components/Drawer.d.ts @@ -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 +} diff --git a/types/components/Form.d.ts b/types/components/Form.d.ts new file mode 100644 index 00000000..4a86e532 --- /dev/null +++ b/types/components/Form.d.ts @@ -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 | undefined +} diff --git a/types/components/IndexList.d.ts b/types/components/IndexList.d.ts new file mode 100644 index 00000000..e9aec408 --- /dev/null +++ b/types/components/IndexList.d.ts @@ -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 +} diff --git a/types/components/Input.d.ts b/types/components/Input.d.ts new file mode 100644 index 00000000..30bf454f --- /dev/null +++ b/types/components/Input.d.ts @@ -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 +} diff --git a/types/components/Loading.d.ts b/types/components/Loading.d.ts new file mode 100644 index 00000000..90057a01 --- /dev/null +++ b/types/components/Loading.d.ts @@ -0,0 +1,5 @@ +import { CubeUIComponent } from '../component' + +export declare class CubeLoading extends CubeUIComponent { + size?: number +} diff --git a/types/components/Radio.d.ts b/types/components/Radio.d.ts new file mode 100644 index 00000000..9fe10836 --- /dev/null +++ b/types/components/Radio.d.ts @@ -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 +} diff --git a/types/components/RadioGroup.d.ts b/types/components/RadioGroup.d.ts new file mode 100644 index 00000000..e9e39e8a --- /dev/null +++ b/types/components/RadioGroup.d.ts @@ -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 +} diff --git a/types/components/Rate.d.ts b/types/components/Rate.d.ts new file mode 100644 index 00000000..8c727b80 --- /dev/null +++ b/types/components/Rate.d.ts @@ -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 +} diff --git a/types/components/RecycleList.d.ts b/types/components/RecycleList.d.ts new file mode 100644 index 00000000..ee795d6e --- /dev/null +++ b/types/components/RecycleList.d.ts @@ -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 + reset: () => void + $slots: RecycleListSlots +} diff --git a/types/components/Scroll.d.ts b/types/components/Scroll.d.ts new file mode 100644 index 00000000..3f47e341 --- /dev/null +++ b/types/components/Scroll.d.ts @@ -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 +} diff --git a/types/components/ScrollNav.d.ts b/types/components/ScrollNav.d.ts new file mode 100644 index 00000000..feb5af87 --- /dev/null +++ b/types/components/ScrollNav.d.ts @@ -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 +} diff --git a/types/components/ScrollNavBar.d.ts b/types/components/ScrollNavBar.d.ts new file mode 100644 index 00000000..ed64e49e --- /dev/null +++ b/types/components/ScrollNavBar.d.ts @@ -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 +} diff --git a/types/components/Select.d.ts b/types/components/Select.d.ts new file mode 100644 index 00000000..39eaa96d --- /dev/null +++ b/types/components/Select.d.ts @@ -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 +} diff --git a/types/components/Slide.d.ts b/types/components/Slide.d.ts new file mode 100644 index 00000000..9f43f534 --- /dev/null +++ b/types/components/Slide.d.ts @@ -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 +} diff --git a/types/components/Sticky.d.ts b/types/components/Sticky.d.ts new file mode 100644 index 00000000..22eabaa3 --- /dev/null +++ b/types/components/Sticky.d.ts @@ -0,0 +1,17 @@ +import { VNode } from 'vue' +import { CubeUIComponent } from '../component' + +export interface StickySlots { + default: VNode[] + fixed: VNode[] + [key: string]: VNode[] +} + +export declare class CubeSticky extends CubeUIComponent { + pos?: number + checkTop?: boolean + fixedShowAni?: string + offset?: number + refresh: () => void + $slots: StickySlots +} diff --git a/types/components/Swipe.d.ts b/types/components/Swipe.d.ts new file mode 100644 index 00000000..52cc3781 --- /dev/null +++ b/types/components/Swipe.d.ts @@ -0,0 +1,31 @@ +import { CubeUIComponent } from '../component' + +interface IBtns { + [key: string]: string | number + text: string | number + color: string +} + +interface IItem { + [key: string]: string | number + value: string | number + text: string | number +} + +interface ISwipeItem { + item?: IItem + btns?: IBtns[] +} + +export declare class CubeSwipe extends CubeUIComponent { + data?: ISwipeItem[] + autoShrink?: boolean +} + +export declare class CubeSwipeItem extends CubeUIComponent { + item?: IItem + btns?: IBtns + index?: number + autoShrink?: boolean + shrink: () => void +} diff --git a/types/components/Switch.d.ts b/types/components/Switch.d.ts new file mode 100644 index 00000000..d0e88761 --- /dev/null +++ b/types/components/Switch.d.ts @@ -0,0 +1,6 @@ +import { CubeUIComponent } from '../component' + +export declare class CubeSwitch extends CubeUIComponent { + disabled?: boolean + value?: boolean +} diff --git a/types/components/TabBar.d.ts b/types/components/TabBar.d.ts new file mode 100644 index 00000000..95fe9ee4 --- /dev/null +++ b/types/components/TabBar.d.ts @@ -0,0 +1,24 @@ +import { VNode } from 'vue' +import { CubeUIComponent } from '../component' + +export interface ITabBarData { + label: string | number + value?: string | number + icon?: string +} + +export interface TabBarSlots { + default: VNode[] + icon: VNode[] + [key: string]: VNode[] +} + +export declare class CubeTabBar extends CubeUIComponent { + value?: string | number + data?: ITabBarData[] + showSlider?: boolean + inline?: boolean + useTransition?: boolean + setSliderTransform: (offset: string | number) => void + $slots: TabBarSlots +} diff --git a/types/components/TabPanels.d.ts b/types/components/TabPanels.d.ts new file mode 100644 index 00000000..fc9cd6b8 --- /dev/null +++ b/types/components/TabPanels.d.ts @@ -0,0 +1,16 @@ +import { CubeUIComponent } from '../component' + +interface ITabPanelsData { + label: string | number // 必选 + value?: string | number +} + +export declare class CubeTabPanels extends CubeUIComponent { + value?: string | number + data?: ITabPanelsData[] +} + +export declare class CubeTabPanel extends CubeUIComponent { + label?: string | number + value?: string | number +} \ No newline at end of file diff --git a/types/components/Textarea.d.ts b/types/components/Textarea.d.ts new file mode 100644 index 00000000..503313c0 --- /dev/null +++ b/types/components/Textarea.d.ts @@ -0,0 +1,19 @@ +import { CubeUIComponent } from '../component' + +interface IIndicator { + remain?: boolean + negative?: boolean +} + +export declare class CubeTextarea extends CubeUIComponent { + value?: string + disabled?: boolean + readonly?: boolean + maxlength?: number + placeholder?: string + autofocus?: boolean + indicator?: boolean | IIndicator + autoExpand: boolean + focus?: (e?: FocusEvent) => void + blur?: (e?: FocusEvent) => void +} diff --git a/types/components/Tip.d.ts b/types/components/Tip.d.ts new file mode 100644 index 00000000..6bf5c36b --- /dev/null +++ b/types/components/Tip.d.ts @@ -0,0 +1,15 @@ +import { CubeUIComponent } from '../component' + +export type DirectionType = 'top' | 'bottom' | 'left' | 'right' + +export declare class CubeTip extends CubeUIComponent { + direction?: DirectionType + offsetTop?: number | string + offsetBottom?: number | string + offsetLeft?: number | string + offsetRight?: number | string + visible?: boolean + close: () => void + show: () => void + hide: () => void +} diff --git a/types/components/Toolbar.d.ts b/types/components/Toolbar.d.ts new file mode 100644 index 00000000..c9b1abfc --- /dev/null +++ b/types/components/Toolbar.d.ts @@ -0,0 +1,13 @@ +import { CubeUIComponent } from '../component' + +interface IActions { + type?: 'button' | 'checkbox' + text?: string + checked?: boolean + action?: string + icon?: string +} +export declare class CubeToolbar extends CubeUIComponent { + actions?: IActions[] + moreActions?: IActions[] +} diff --git a/types/components/Upload.d.ts b/types/components/Upload.d.ts new file mode 100644 index 00000000..c166eaa6 --- /dev/null +++ b/types/components/Upload.d.ts @@ -0,0 +1,28 @@ +import { CubeUIComponent } from '../component' + +export interface IFile extends CubeUIComponent { + name?: string + size?: number + url?: string + base64?: string + status?: string + progress?: number + file?: File + response?: object | string | [] + responseHeaders?: string +} + +export declare class CubeUpload extends CubeUIComponent { + value?: IFile[] + action?: string | object + max?: number + auto?: boolean + simultaneousUploads?: number + multiple?: boolean + accept?: string + processFile?: (file?: File, next?: Function) => any + start?: () => void + pause?: () => void + retry?: () => void + removeFile?: (file: File) => void +} diff --git a/types/components/Validator.d.ts b/types/components/Validator.d.ts new file mode 100644 index 00000000..623035a9 --- /dev/null +++ b/types/components/Validator.d.ts @@ -0,0 +1,35 @@ +import { VNode } from 'vue' +import { CubeUIComponent } from '../component' + +type ValidatorType = 'string' | 'number' | 'array' | 'date' | 'email' | 'tel' | 'url' +export interface IValidatorRules { + required: boolean + type?: ValidatorType + min?: number + max?: number + len?: number + notWhitespace?: boolean + pattern?: RegExp + custom?: Function +} + +export interface ValidatorSlots { + default: VNode[] + message: VNode[] + [key: string]: VNode[] +} + +export declare class CubeValidator extends CubeUIComponent { + model?: any + value?: any + rules?: IValidatorRules + messages?: object | string + immediate?: boolean + disabled?: boolean + validate?: (cb?: Function) => any + addRule?: Function + addMessage?: Function + addType?: Function + addHelper?: Function + $slots: ValidatorSlots +} diff --git a/types/components/common.ts b/types/components/common.ts index cb687672..ab4ee1c4 100644 --- a/types/components/common.ts +++ b/types/components/common.ts @@ -18,3 +18,9 @@ export type TransformFnKeys = { } export type GetTransformFnKeys = TransformFnKeys>> + +export interface IRadioOptionData { + label?: string + value?: string | number + disabled?: boolean +} diff --git a/types/components/index.ts b/types/components/index.ts index 1deb8cd3..378f6118 100644 --- a/types/components/index.ts +++ b/types/components/index.ts @@ -7,6 +7,37 @@ export interface CreateAPIFn { (options: O, renderFn: IRenderFn, single: boolean):V } +// basic +export * from './Button' +export * from './Loading' +export * from './Tip' +export * from './Toolbar' +export * from './TabBar' +export * from './TabPanels' +export * from './Checkbox' +export * from './CheckboxGroup' +export * from './Radio' +export * from './RadioGroup' +export * from './Checker' +export * from './Input' +export * from './Textarea' +export * from './Select' +export * from './Switch' +export * from './Rate' +export * from './Validator' +export * from './Upload' +export * from './Form' +export * from './Drawer' +export * from './Scroll' +export * from './Slide' +export * from './IndexList' +export * from './Swipe' +export * from './Sticky' +export * from './ScrollNavBar' +export * from './ScrollNav' +export * from './RecycleList' + +// create-API export * from './Popup' export * from './ActionSheet' export * from './Toast' diff --git a/types/cube-ui.d.ts b/types/cube-ui.d.ts index 4bcf3517..d5d61a8f 100644 --- a/types/cube-ui.d.ts +++ b/types/cube-ui.d.ts @@ -1,6 +1,48 @@ import Vue from 'vue' import { CubeUIComponent } from './component' -import { IPopup, IToast, IPicker, ICascadePicker, IDatePicker, ITimePicker, ISegmentPicker, IDialog, IActionSheet, IImagePreview, CreateAPIFn } from './components' +import { + // basic + CubeButton, + CubeLoading, + CubeTip, + CubeToolbar, + CubeTabBar, + CubeTabPanels, + CubeCheckbox, + CubeCheckboxGroup, + CubeRadio, + CubeRadioGroup, + CubeChecker, + CubeInput, + CubeTextarea, + CubeSelect, + CubeSwitch, + CubeRate, + CubeValidator, + CubeUpload, + CubeForm, + CubeDrawer, + CubeScroll, + CubeSlide, + CubeIndexList, + CubeSwipe, + CubeSticky, + CubeScrollNavBar, + CubeScrollNav, + CubeRecycleList, + // create-API + IPopup, + IToast, + IPicker, + ICascadePicker, + IDatePicker, + ITimePicker, + ISegmentPicker, + IDialog, + IActionSheet, + IImagePreview, + CreateAPIFn +} from './components' /** * CubeUI 组件 * CubeUI component common definition @@ -46,44 +88,58 @@ export class Style {} // basic /** Button Component */ -export class Button extends CubeUIComponent {} +export class Button extends CubeButton {} /** Loading Component */ -export class Loading extends CubeUIComponent {} +export class Loading extends CubeLoading { +} /** Tip Component */ -export class Tip extends CubeUIComponent {} +export class Tip extends CubeTip {} /** Toolbar Component */ -export class Toolbar extends CubeUIComponent {} +export class Toolbar extends CubeToolbar { +} /** TabBar Component */ -export class TabBar extends CubeUIComponent {} +export class TabBar extends CubeTabBar { +} /** TabPanels Component */ -export class TabPanels extends CubeUIComponent {} +export class TabPanels extends CubeTabPanels {} // form /** Checkbox Component */ -export class Checkbox extends CubeUIComponent {} +export class Checkbox extends CubeCheckbox { + ICheckbox: CubeCheckbox +} /** Checkbox Group Component */ -export class CheckboxGroup extends CubeUIComponent {} +export class CheckboxGroup extends CubeCheckboxGroup { + ICheckboxGroup: CubeCheckboxGroup +} /** Checker Component */ -export class Checker extends CubeUIComponent {} +export class Checker extends CubeChecker { + IChecker: CubeChecker +} /** Radio Component */ -export class Radio extends CubeUIComponent {} +export class Radio extends CubeRadio { + IRadio: CubeRadio +} /** Radio Group Component */ -export class RadioGroup extends CubeUIComponent {} +export class RadioGroup extends CubeRadioGroup { + IRadioGroup: CubeRadioGroup +} /** Input Component */ -export class Input extends CubeUIComponent {} +export class Input extends CubeInput { +} /** Textarea Component */ -export class Textarea extends CubeUIComponent {} +export class Textarea extends CubeTextarea {} /** Select Component */ -export class Select extends CubeUIComponent {} +export class Select extends CubeSelect {} /** Switch Component */ -export class Switch extends CubeUIComponent {} +export class Switch extends CubeSwitch {} /** Rate Component */ -export class Rate extends CubeUIComponent {} +export class Rate extends CubeRate {} /** Validator Component */ -export class Validator extends CubeUIComponent {} +export class Validator extends CubeValidator {} /** Upload Component */ -export class Upload extends CubeUIComponent {} +export class Upload extends CubeUpload {} /** Form Component */ -export class Form extends CubeUIComponent {} +export class Form extends CubeForm {} /** base CreatApi CubeUIComponent */ export class CreateApiCubeUIComponent extends CubeUIComponent { @@ -142,28 +198,24 @@ export class ImagePreview extends CreateApiCubeUIComponent { static $create(options: IImagePreview): ImagePreview } /** Drawer Component */ -export class Drawer extends CubeUIComponent { - show(): void - hide(): void - static $create(options: object): Drawer -} +export class Drawer extends CubeDrawer {} // scroll /** Scroll Component */ -export class Scroll extends CubeUIComponent {} +export class Scroll extends CubeScroll {} /** Slide Component */ -export class Slide extends CubeUIComponent {} +export class Slide extends CubeSlide {} /** Index List Component */ -export class IndexList extends CubeUIComponent {} +export class IndexList extends CubeIndexList {} /** Swipe Component */ -export class Swipe extends CubeUIComponent {} +export class Swipe extends CubeSwipe {} /** Sticky Component */ -export class Sticky extends CubeUIComponent {} +export class Sticky extends CubeSticky {} /** ScrollNavBar Component */ -export class ScrollNavBar extends CubeUIComponent {} +export class ScrollNavBar extends CubeScrollNavBar {} /** ScrollNav Component */ -export class ScrollNav extends CubeUIComponent {} +export class ScrollNav extends CubeScrollNav {} /** RecycleList Component */ -export class RecycleList extends CubeUIComponent {} +export class RecycleList extends CubeRecycleList {} // Vue prototype $createXx declare module 'vue/types/vue' { diff --git a/vetur/attributes.json b/vetur/attributes.json new file mode 100644 index 00000000..09d51a3e --- /dev/null +++ b/vetur/attributes.json @@ -0,0 +1,24 @@ +{ + "cube-button/type": { "description": "cube-button type: 'button' | 'submit'", "type": "string", "options": ["button", "submit"] }, + "cube-checker/type": { "description": "cube-checker type: 'checkbox' | 'radio'", "type": "string", "defalut": "checkbox", "options": ["checkbox", "radio"] }, + "cube-input/type": { "description": "cube-input type: 'text' | 'number' | 'password' | 'date'", "type": "string", "options": ["text" , "number" , "password" , "date"] }, + "disabled": { "type": "boolean" }, + "cube-button/active": { "type": "boolean" }, + "cube-swipe-item/active": { "type": "method" }, + "icon": { "type": "string", "description": "the class of icon" }, + "light": { "type": "boolean", "description": "light style" }, + "inline": { "type": "boolean", "description": "inline style" }, + "outline": { "type": "boolean", "description": "outline style" }, + "primary": { "type": "boolean", "description": "primary style" }, + "size": { "type": "number" }, + "cube-tip/direction": { "type": "string", "description": "the direction of the small triangle, options: top | bottom | left | right", "options": ["top", "bottom", "left", "right"] }, + "cube-scroll/direction": { "type": "string", "description": "slide direction, options: horizontal | vertical", "options": ["horizontal", "vertical"] }, + "cube-slide/direction": { "type": "string", "description": "slide direction, options: horizontal | vertical", "options": ["horizontal", "vertical"] }, + "cube-scroll-nav-bar/direction": { "type": "string", "description": "slide direction, options: horizontal | vertical", "options": ["horizontal", "vertical"] }, + "cube-tip/offsetLeft": { "type": "number", "description": "the distance between the small triangle and the left part of x axis" }, + "cube-tip/offsetTop": { "type": "number", "description": "the distance between the small triangle and the origin of y axis" }, + "cube-tip/offsetRight": { "type": "number", "description": "the distance between the small triangle and the right part of x axis" }, + "cube-tip/offsetBottom": { "type": "number", "description": "the distance between the small triangle and the bottom part of y axis" }, + "cube-toolbar/actions": { "type": "array", "description": "actions description, type array" }, + "cube-toolbar/more-actions": { "type": "array", "description": "more actions, type array" } +} diff --git a/vetur/tags.json b/vetur/tags.json new file mode 100644 index 00000000..494b1c1f --- /dev/null +++ b/vetur/tags.json @@ -0,0 +1,178 @@ +{ + "cube-button": { + "attributes": ["type", "active", "disabled", "icon", "light", "inline", "outline", "primary"], + "defaults": [], + "description": "cube-button" + }, + "cube-loading": { + "attributes": ["size"], + "defaults": [], + "subtags": [], + "description": "cube-loading" + }, + "cube-tip": { + "attributes": ["direction", "offsetTop", "offsetBottom", "offsetLeft", "offsetRight", "visible", "close"], + "defaults": [], + "subtags": [], + "description": "cube-tip" + }, + "cube-toolbar": { + "attributes": ["actions", "more-actions", "more-click"], + "defaults": [], + "description": "cube-toolbar" + }, + "cube-tab-bar": { + "attributes": ["value", "data", "show-slider", "inline", "use-transition"], + "defaults": [], + "description": "cube-tab-bar" + }, + "cube-checkbox": { + "attributes": ["option", "position", "shape", "hollow-style", "label", "value", "disabled"], + "defaults": [], + "description": "cube-checkbox" + }, + "cube-checkbox-group": { + "attributes": ["value", "options", "horizontal", "colNum", "shape", "hollow-style", "min", "max", "checked", "cancel-checked", "input"], + "defaults": ["data"], + "description": "cube-checkbox-group" + }, + "cube-radio": { + "attributes": ["value", "option", "position", "hollow-style"], + "defaults": [], + "description": "cube-radio" + }, + "cube-radio-group": { + "attributes": ["value", "options", "position", "horizontal", "colNum", "hollow-style"], + "defaults": ["options"], + "description": "cube-radio-group" + }, + "cube-checker": { + "attributes": ["value", "options", "type", "min", "max"], + "defaults": ["options"], + "description": "cube-checker" + }, + "cube-input": { + "attributes": ["value", "type", "disabled", "readonly", "maxlength", "placeholder", "autofocus", "autocomplete", "clearable", "eye"], + "defaults": ["type"], + "description": "cube-input" + }, + "cube-textarea": { + "attributes": ["value", "disabled", "readonly", "maxlength", "placeholder", "autofocus", "indicator", "auto-expand"], + "defaults": [], + "description": "cube-textarea" + }, + "cube-select": { + "attributes": ["value", "options", "placeholder", "auto-pop", "disabled", "title", "cancelTxt", "confirmTxt", "picker-show", "picker-hide"], + "defaults": [], + "description": "cube-select" + }, + "cube-switch": { + "attributes": ["disabled", "value"], + "defaults": [], + "description": "cube-switch" + }, + "cube-rate": { + "attributes": ["value", "max", "disabled", "justify"], + "defaults": ["justify"], + "description": "cube-rate" + }, + "cube-validator": { + "attributes": ["model", "value", "rules", "messages", "immediate", "disabled", "validated", "validating", "msg-click", "input"], + "defaults": ["model"], + "description": "cube-validator" + }, + "cube-upload": { + "attributes": ["value", "action", "max", "auto", "simultaneousUploads", "multiple", "action", "files-added", "file-submitted", "file-removed", "file-success", "file-error", "file-click"], + "defaults": ["title"], + "description": "cube-upload" + }, + "cube-form": { + "attributes": ["model", "schema", "immediate-validate", "action", "options", "submit-always-validate", "submit", "reset", "validate", "valid", "invalid"], + "defaults": ["model"], + "subtags": ["cube-form-group"], + "description": "cube-form" + }, + "cube-form-group": { + "attributes": ["legend", "fields"], + "defaults": ["legend"], + "subtags": ["cube-form-item"], + "description": "cube-form-group" + }, + "cube-form-item": { + "attributes": ["field"], + "defaults": ["field"], + "subtags": [], + "description": "cube-formitem" + }, + "cube-drawer": { + "attributes": ["title", "data", "selected-index", "visible", "cancel"], + "defaults": ["title"], + "subtags": ["cube-drawer-panel"], + "description": "cube-drawer" + }, + "cube-drawer-panel": { + "attributes": ["data", "index"], + "defaults": ["data"], + "subtags": ["cube-drawer-item"], + "description": "cube-drawer-panel" + }, + "cube-drawer-item": { + "attributes": ["data", "index"], + "defaults": ["data"], + "description": "cube-drawer-item" + }, + "cube-scroll": { + "attributes": ["data", "direction", "options", "scroll-events", "listen-scroll", "listen-before-scroll", "refresh-delay", "nest-mode", "before-scroll-start", "scroll-end", "pulling-down", "pulling-up"], + "defaults": ["data"], + "description": "cube-scroll" + }, + "cube-slide": { + "attributes": ["data", "initial-index", "loop", "show-dots", "auto-play", "interval", "direction", "options", "threshold", "speed", "allow-vertical", "stop-propagation", "refresh-reset-current", "scroll-end"], + "defaults": ["data"], + "subtags": ["cube-slide-item"], + "description": "cube-slide" + }, + "cube-slide-item": { + "attributes": ["url", "image"], + "defaults": [], + "description": "cube-slide-item" + }, + "cube-index-list": { + "attributes": ["title", "data", "navbar", "speed", "options", "pull-up-load", "pull-down-refresh", "title-click", "pulling-up", "pulling-down"], + "defaults": [], + "description": "cube-index-list" + }, + "cube-swipe": { + "attributes": ["data", "auto-shrink", "item-click", "btn-click"], + "defaults": [], + "subtags": ["cube-swipe-item"], + "description": "cube-swipe" + }, + "cube-swipe-item": { + "attributes": ["item", "btns", "index", "auto-shrink", "item-click", "btn-click", "active"], + "defaults": ["item"], + "description": "cube-swipe-item" + }, + "cube-sticky": { + "attributes": ["pos", "check-top", "fixed-show-ani", "offset", "diff-change", "change"], + "defaults": [], + "subtags": ["cube-sticky-ele"], + "description": "cube-sticky" + }, + "cube-scroll-nav-bar": { + "attributes": ["direction", "labels", "txts", "current", "options"], + "defaults": [], + "description": "cube-scroll-nav-bar" + }, + "cube-scroll-nav": { + "attributes": ["data", "side", "current", "speed", "options", "sticky-change"], + "defaults": ["data"], + "subtags": ["cube-scroll-nav-panel"], + "description": "cube-scroll-nav" + }, + "cube-recycle-list": { + "attributes": ["infinite", "size", "offset", "on-fetch"], + "defaults": [], + "description": "cube-recycle-list" + } +} -- GitLab