// package/index.js
import XyTable from './xy-table' // 引入封装好的组件
import XyTableSearchForm from './xy-table-search-form'
import XyPagination from './xy-pagination'
import XyStatusIndicator from './xy-status-indicator'
import XyForm from './xy-form'
import XyRenderComp from './xy-render-comp'

// 将来如果有其它组件,都可以写到这个数组里
const components = [
  XyTable,
  XyTableSearchForm,
  XyPagination,
  XyStatusIndicator,
  XyForm,
  XyRenderComp
]

// 批量组件注册
const install = function(Vue) {
  if (install.installed) return
  install.installed = true
  components.forEach((component) => {
    Vue.component(component.name, component)
  })
}

// 判断是否是直接引入文件
if (typeof window !== 'undefined' && window.Vue) {
  install(window.Vue) // window中有Vue时去install()
}

export default {
  ...components, // 按需引入
  // 导出的对象必须具有install, 才能被Vue.use()方法安装
  install
}
