From 0c0d2c7376e1dff810c2b98985cbe7c1bb4f0816 Mon Sep 17 00:00:00 2001 From: Sergio Crisostomo Date: Thu, 9 Nov 2017 05:50:30 +0100 Subject: [PATCH] reorganize and DRY components list --- src/index.js | 99 ++++++++++++++++++++------------------------------------------------------------------------------- 1 file changed, 20 insertions(+), 79 deletions(-) diff --git a/src/index.js b/src/index.js index 84686cc..7ec125e 100644 --- a/src/index.js +++ b/src/index.js @@ -51,7 +51,7 @@ import {Row, Col} from './components/grid'; import {Select, Option, OptionGroup} from './components/select'; import locale from './locale/index'; -const iview = { +const components = { Affix, Alert, AutoComplete, @@ -60,7 +60,6 @@ const iview = { Badge, Breadcrumb, BreadcrumbItem: Breadcrumb.Item, - iButton: Button, Button, ButtonGroup: Button.Group, Card, @@ -69,9 +68,7 @@ const iview = { Cascader, Checkbox, CheckboxGroup: Checkbox.Group, - iCircle: Circle, Col, - iCol: Col, Collapse, ColorPicker, DatePicker, @@ -79,16 +76,13 @@ const iview = { DropdownItem: Dropdown.Item, DropdownMenu: Dropdown.Menu, Form, - iForm: Form, FormItem: Form.Item, Icon, Input, - iInput: Input, InputNumber, Scroll, LoadingBar, Menu, - iMenu: Menu, MenuGroup: Menu.Group, MenuItem: Menu.Item, Submenu: Menu.Sub, @@ -96,26 +90,20 @@ const iview = { Modal, Notice, Option: Option, - iOption: Option, OptionGroup, Page, Panel: Collapse.Panel, Poptip, Progress, - iProgress: Progress, Radio, RadioGroup: Radio.Group, Rate, Row, Select, - iSelect: Select, Slider, Spin, Step: Steps.Step, Steps, - // Switch, - iSwitch: Switch, - iTable: Table, Table, Tabs: Tabs, TabPane: Tabs.Pane, @@ -129,6 +117,21 @@ const iview = { Upload }; +const iview = { + ...components, + iButton: Button, + iCircle: Circle, + iCol: Col, + iForm: Form, + iInput: Input, + iMenu: Menu, + iOption: Option, + iProgress: Progress, + iSelect: Select, + iSwitch: Switch, + iTable: Table +}; + const install = function(Vue, opts = {}) { locale.use(opts.locale); locale.i18n(opts.i18n); @@ -149,82 +152,20 @@ if (typeof window !== 'undefined' && window.Vue) { install(window.Vue); } -module.exports = { // eslint-disable-line no-undef +const API = { version: '2.6.0', locale: locale.use, i18n: locale.i18n, install, - Affix, - Alert, - AutoComplete, - Avatar, - BackTop, - Badge, - Breadcrumb, - BreadcrumbItem: Breadcrumb.Item, - Button, - ButtonGroup: Button.Group, - Card, - Carousel, - CarouselItem: Carousel.Item, - Cascader, - Checkbox, - CheckboxGroup: Checkbox.Group, Circle, - Col, - Collapse, - ColorPicker, - DatePicker, - Dropdown, - DropdownItem: Dropdown.Item, - DropdownMenu: Dropdown.Menu, - Form, - FormItem: Form.Item, - Icon, - Input, - InputNumber, - Scroll, - LoadingBar, - Menu, - MenuGroup: Menu.Group, - MenuItem: Menu.Item, - Submenu: Menu.Sub, - Message, - Modal, - Notice, - Option: Option, - OptionGroup, - Page, - Panel: Collapse.Panel, - Poptip, - Progress, - Radio, - RadioGroup: Radio.Group, - Rate, - Row, - Select, - Slider, - Spin, - Step: Steps.Step, - Steps, Switch, - Table, - Tabs: Tabs, - TabPane: Tabs.Pane, - Tag, - Timeline, - TimelineItem: Timeline.Item, - TimePicker, - Tooltip, - Transfer, - Tree, - Upload + ...components }; -module.exports.lang = (code) => { // eslint-disable-line no-undef +API.lang = (code) => { const langObject = window['iview/locale'].default; if (code === langObject.i.locale) locale.use(langObject); else console.log(`The ${code} language pack is not loaded.`); // eslint-disable-line no-console }; -module.exports.default = module.exports; // eslint-disable-line no-undef +module.exports.default = module.exports = API; // eslint-disable-line no-undef -- libgit2 0.21.4