Skip to content

Commit

Permalink
feat: add component Vue.use method (#197)
Browse files Browse the repository at this point in the history
* feat: add Vue.use feat

* feat: Vue.use method

* docs: update docs
  • Loading branch information
tangjinzhou authored Sep 19, 2018
1 parent 2ed0d62 commit a6620cb
Show file tree
Hide file tree
Showing 55 changed files with 539 additions and 169 deletions.
8 changes: 7 additions & 1 deletion components/affix/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const AffixProps = {
prefixCls: PropTypes.string,
}

export default {
const Affix = {
name: 'AAffix',
props: AffixProps,
mixins: [BaseMixin],
Expand Down Expand Up @@ -264,3 +264,9 @@ export default {
},
}

/* istanbul ignore next */
Affix.install = function (Vue) {
Vue.component(Affix.name, Affix)
}

export default Affix
9 changes: 8 additions & 1 deletion components/alert/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const AlertProps = {
banner: PropTypes.bool,
}

export default {
const Alert = {
props: AlertProps,
mixins: [BaseMixin],
name: 'AAlert',
Expand Down Expand Up @@ -133,3 +133,10 @@ export default {
},
}

/* istanbul ignore next */
Alert.install = function (Vue) {
Vue.component(Alert.name, Alert)
}

export default Alert

7 changes: 7 additions & 0 deletions components/anchor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ export { AnchorProps } from './Anchor'
export { AnchorLinkProps } from './AnchorLink'

Anchor.Link = AnchorLink

/* istanbul ignore next */
Anchor.install = function (Vue) {
Vue.component(Anchor.name, Anchor)
Vue.component(Anchor.Link.name, Anchor.Link)
}

export default Anchor
11 changes: 10 additions & 1 deletion components/auto-complete/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const AutoCompleteProps = {
// onSelect?: (value: SelectValue, option: Object) => any;
}

export default {
const AutoComplete = {
name: 'AAutoComplete',
props: {
...AutoCompleteProps,
Expand Down Expand Up @@ -136,3 +136,12 @@ export default {
},
}

/* istanbul ignore next */
AutoComplete.install = function (Vue) {
Vue.component(AutoComplete.name, AutoComplete)
Vue.component(AutoComplete.Option.name, AutoComplete.Option)
Vue.component(AutoComplete.OptGroup.name, AutoComplete.OptGroup)
}

export default AutoComplete

5 changes: 5 additions & 0 deletions components/avatar/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import Avatar from './Avatar'

/* istanbul ignore next */
Avatar.install = function (Vue) {
Vue.component(Avatar.name, Avatar)
}

export default Avatar
8 changes: 7 additions & 1 deletion components/back-top/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const BackTopProps = {
prefixCls: PropTypes.string,
}

export default {
const BackTop = {
name: 'ABackTop',
mixins: [BaseMixin],
props: {
Expand Down Expand Up @@ -130,3 +130,9 @@ export default {
},
}

/* istanbul ignore next */
BackTop.install = function (Vue) {
Vue.component(BackTop.name, BackTop)
}

export default BackTop
6 changes: 6 additions & 0 deletions components/badge/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import Badge from './Badge'

/* istanbul ignore next */
Badge.install = function (Vue) {
Vue.component(Badge.name, Badge)
}

export default Badge

8 changes: 8 additions & 0 deletions components/breadcrumb/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ import Breadcrumb from './Breadcrumb'
import BreadcrumbItem from './BreadcrumbItem'

Breadcrumb.Item = BreadcrumbItem

/* istanbul ignore next */
Breadcrumb.install = function (Vue) {
Vue.component(Breadcrumb.name, Breadcrumb)
Vue.component(BreadcrumbItem.name, BreadcrumbItem)
}

export default Breadcrumb

1 change: 0 additions & 1 deletion components/button/button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,5 @@ export default {
)
}
},

}

7 changes: 7 additions & 0 deletions components/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ import Button from './button'
import ButtonGroup from './button-group'

Button.Group = ButtonGroup

/* istanbul ignore next */
Button.install = function (Vue) {
Vue.component(Button.name, Button)
Vue.component(ButtonGroup.name, ButtonGroup)
}

export default Button

9 changes: 8 additions & 1 deletion components/calendar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const CalendarProps = () => ({
validRange: PropTypes.custom(isMomentArray),
})

export default {
const Calendar = {
name: 'ACalendar',
mixins: [BaseMixin],
props: initDefaultProps(CalendarProps(), {
Expand Down Expand Up @@ -241,3 +241,10 @@ export default {
},
}

/* istanbul ignore next */
Calendar.install = function (Vue) {
Vue.component(Calendar.name, Calendar)
}

export default Calendar

8 changes: 8 additions & 0 deletions components/card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,12 @@ import Meta from './Meta'
import Grid from './Grid'
Card.Meta = Meta
Card.Grid = Grid

/* istanbul ignore next */
Card.install = function (Vue) {
Vue.component(Card.name, Card)
Vue.component(Meta.name, Meta)
Vue.component(Grid.name, Grid)
}

export default Card
9 changes: 8 additions & 1 deletion components/carousel/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const CarouselProps = {
slickGoTo: PropTypes.number,
}

export default {
const Carousel = {
name: 'ACarousel',
props: initDefaultProps(CarouselProps, {
dots: true,
Expand Down Expand Up @@ -157,3 +157,10 @@ export default {
)
},
}

/* istanbul ignore next */
Carousel.install = function (Vue) {
Vue.component(Carousel.name, Carousel)
}

export default Carousel
15 changes: 8 additions & 7 deletions components/cascader/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ const FieldNamesType = PropTypes.shape({
children: PropTypes.string,
}).loose

const FilledFieldNamesType = PropTypes.shape({
value: PropTypes.string,
label: PropTypes.string,
children: PropTypes.string,
}).loose

const CascaderExpandTrigger = PropTypes.oneOf(['click', 'hover'])

const ShowSearchType = PropTypes.shape({
Expand Down Expand Up @@ -105,7 +99,7 @@ function getFilledFieldNames (fieldNames = {}) {

const defaultDisplayRender = ({ labels }) => labels.join(' / ')

export default {
const Cascader = {
inheritAttrs: false,
name: 'ACascader',
mixins: [BaseMixin],
Expand Down Expand Up @@ -448,3 +442,10 @@ export default {
},
}

/* istanbul ignore next */
Cascader.install = function (Vue) {
Vue.component(Cascader.name, Cascader)
}

export default Cascader

7 changes: 7 additions & 0 deletions components/checkbox/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,12 @@ import Checkbox from './Checkbox'
import CheckboxGroup from './Group'

Checkbox.Group = CheckboxGroup

/* istanbul ignore next */
Checkbox.install = function (Vue) {
Vue.component(Checkbox.name, Checkbox)
Vue.component(CheckboxGroup.name, CheckboxGroup)
}

export default Checkbox

4 changes: 4 additions & 0 deletions components/col/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { Col } from '../grid'
/* istanbul ignore next */
Col.install = function (Vue) {
Vue.component(Col.name, Col)
}

export default Col
8 changes: 8 additions & 0 deletions components/collapse/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,12 @@ import Collapse from './Collapse'
import CollapsePanel from './CollapsePanel'

Collapse.Panel = CollapsePanel

/* istanbul ignore next */
Collapse.install = function (Vue) {
Vue.component(Collapse.name, Collapse)
Vue.component(CollapsePanel.name, CollapsePanel)
}

export default Collapse

8 changes: 8 additions & 0 deletions components/date-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ Object.assign(DatePicker, {
WeekPicker: wrapPicker(WeekPicker, WeekPickerProps(), 'gggg-wo'),
})

/* istanbul ignore next */
DatePicker.install = function (Vue) {
Vue.component(DatePicker.name, DatePicker)
Vue.component(DatePicker.RangePicker.name, DatePicker.RangePicker)
Vue.component(DatePicker.MonthPicker.name, DatePicker.MonthPicker)
Vue.component(DatePicker.WeekPicker.name, DatePicker.WeekPicker)
}

export default DatePicker
9 changes: 8 additions & 1 deletion components/divider/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import PropTypes from '../_util/vue-types'
export default {
const Divider = {
name: 'ADivider',
props: {
prefixCls: PropTypes.string.def('ant'),
Expand Down Expand Up @@ -30,3 +30,10 @@ export default {
},
}

/* istanbul ignore next */
Divider.install = function (Vue) {
Vue.component(Divider.name, Divider)
}

export default Divider

9 changes: 8 additions & 1 deletion components/drawer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PropTypes from '../_util/vue-types'
import BaseMixin from '../_util/BaseMixin'
import { getComponentFromProp, getOptionProps } from '../_util/props-util'

export default {
const Drawer = {
name: 'ADrawer',
props: {
closable: PropTypes.bool.def(true),
Expand Down Expand Up @@ -180,3 +180,10 @@ export default {
)
},
}

/* istanbul ignore next */
Drawer.install = function (Vue) {
Vue.component(Drawer.name, Drawer)
}

export default Drawer
7 changes: 7 additions & 0 deletions components/dropdown/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ export { DropdownProps } from './dropdown'
export { DropdownButtonProps } from './dropdown-button'

Dropdown.Button = DropdownButton

/* istanbul ignore next */
Dropdown.install = function (Vue) {
Vue.component(Dropdown.name, Dropdown)
Vue.component(DropdownButton.name, DropdownButton)
}

export default Dropdown
6 changes: 6 additions & 0 deletions components/form/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,10 @@ Vue.use(antRefDirective)
export { FormProps, FormCreateOption, ValidationRule } from './Form'
export { FormItemProps } from './FormItem'

/* istanbul ignore next */
Form.install = function (Vue) {
Vue.component(Form.name, Form)
Vue.component(Form.Item.name, Form.Item)
}

export default Form
7 changes: 6 additions & 1 deletion components/icon/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import Icon from './icon'
export default Icon

/* istanbul ignore next */
Icon.install = function (Vue) {
Vue.component(Icon.name, Icon)
}

export default Icon
8 changes: 8 additions & 0 deletions components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ const components = [
Anchor,
Anchor.Link,
AutoComplete,
AutoComplete.Option,
AutoComplete.OptGroup,
Alert,
Avatar,
BackTop,
Expand Down Expand Up @@ -203,6 +205,7 @@ const components = [
TreeSelect.TreeNode,
Tabs,
Tabs.TabPane,
Tabs.TabContent,
Tag,
Tag.CheckableTag,
TimePicker,
Expand All @@ -228,6 +231,11 @@ const install = function (Vue) {
Vue.prototype.$confirm = Modal.confirm
}

/* istanbul ignore if */
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue)
}

export {
version,
install,
Expand Down
9 changes: 8 additions & 1 deletion components/input-number/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const InputNumberProps = {
autoFocus: PropTypes.bool,
}

export default {
const InputNumber = {
name: 'AInputNumber',
model: {
prop: 'value',
Expand Down Expand Up @@ -64,3 +64,10 @@ export default {
return <VcInputNumber {...vcInputNumberprops} />
},
}

/* istanbul ignore next */
InputNumber.install = function (Vue) {
Vue.component(InputNumber.name, InputNumber)
}

export default InputNumber
Loading

0 comments on commit a6620cb

Please sign in to comment.