import ToggleButton from './toggle-button';
import Transform from './transform';
import FastQuerySearch from './fastquery-search';
import AdvanceSearch from './advance-search';
import HongqiGrid from './hongqi-grid';
import HongqiTable, { BtnInTable, DivideLine } from './hongqi-table';
import ImageCropper from './image-cropper';
import OrganizationChart from './organization-chart';
import Calendar from './calendar';
import Location from './location';
import EditableSearch from './editable-search';
import TimeConvertor from './time-convertor';
import CommonCss from './commonCss';
const components = { ToggleButton, Transform, FastQuerySearch, AdvanceSearch, EditableSearch, HongqiGrid, HongqiTable, BtnInTable, DivideLine, ImageCropper, OrganizationChart, Calendar, Location, TimeConvertor, CommonCss };
const defaultOptions = {
	hongqiTable: {
		index: true,
		selection: false,
		exportExcel: false,
		page: true,
		pageSizeOpts: [10, 20, 50, 100],
		toolbar: true,
		toolbarButtonSize: 'default',
		size: 'default',
		headerTool: true,
		height: null,
		maxHeight: null,
		subtotal: null,
		stripe: false,
		border: true,
		showHeader: true,
		width: 'auto',
		disabledHover: false,
		noDataText: '暂无数据',
		allSortAble: true,
		draggable: false,
		tooltipTheme: 'light',
		rowKey: false
	}
};

const install = (Vue, opts) => {
	// 判断是否安装
	if (install.installed) return;
	Vue.prototype.$HqComponents = Object.assign({}, defaultOptions, opts);
	// 遍历注册全局组件
	Object.keys(components).forEach(key => {
		Vue.component(key, components[key]);
	});
};

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

const API = {
	version: process.env.VERSION, // eslint-disable-line no-undef,
	install,
	ToggleButton, Transform, FastQuerySearch, AdvanceSearch, EditableSearch, HongqiGrid, HongqiTable, BtnInTable, DivideLine, ImageCropper, OrganizationChart, Calendar, Location, TimeConvertor, CommonCss
};
// module.exports.default = module.exports = API;   // eslint-disable-line no-undef
export default API
export { install, ToggleButton, Transform, FastQuerySearch, AdvanceSearch, EditableSearch, HongqiGrid, HongqiTable, BtnInTable, DivideLine, ImageCropper, OrganizationChart, Calendar, Location, TimeConvertor, CommonCss }