| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- import 'babel-polyfill';
- import './css/bootstrap.css';
- import './css/handsontable.css';
- import './css/mobile.handsontable.css';
- import {getRegisteredEditorNames, registerEditor, getEditor} from './editors';
- import {getRegisteredRendererNames, getRenderer, registerRenderer} from './renderers';
- import {getRegisteredValidatorNames, getValidator, registerValidator} from './validators';
- import {getRegisteredCellTypeNames, getCellType, registerCellType} from './cellTypes';
- import Core from './core';
- import jQueryWrapper from './helpers/wrappers/jquery';
- import EventManager, {getListenersCounter} from './eventManager';
- import Hooks from './pluginHooks';
- import GhostTable from './utils/ghostTable';
- import * as arrayHelpers from './helpers/array';
- import * as browserHelpers from './helpers/browser';
- import * as dataHelpers from './helpers/data';
- import * as dateHelpers from './helpers/date';
- import * as featureHelpers from './helpers/feature';
- import * as functionHelpers from './helpers/function';
- import * as mixedHelpers from './helpers/mixed';
- import * as numberHelpers from './helpers/number';
- import * as objectHelpers from './helpers/object';
- import * as settingHelpers from './helpers/setting';
- import * as stringHelpers from './helpers/string';
- import * as unicodeHelpers from './helpers/unicode';
- import * as domHelpers from './helpers/dom/element';
- import * as domEventHelpers from './helpers/dom/event';
- import * as plugins from './plugins/index';
- import {registerPlugin} from './plugins';
- import DefaultSettings from './defaultSettings';
- function Handsontable(rootElement, userSettings) {
- const instance = new Core(rootElement, userSettings || {});
- instance.init();
- return instance;
- }
- jQueryWrapper(Handsontable);
- Handsontable.Core = Core;
- Handsontable.DefaultSettings = DefaultSettings;
- Handsontable.EventManager = EventManager;
- Handsontable._getListenersCounter = getListenersCounter; // For MemoryLeak tests
- Handsontable.buildDate = __HOT_BUILD_DATE__;
- Handsontable.packageName = __HOT_PACKAGE_NAME__;
- Handsontable.version = __HOT_VERSION__;
- const baseVersion = __HOT_BASE_VERSION__;
- if (baseVersion) {
- Handsontable.baseVersion = baseVersion;
- }
- // Export Hooks singleton
- Handsontable.hooks = Hooks.getSingleton();
- // TODO: Remove this exports after rewrite tests about this module
- Handsontable.__GhostTable = GhostTable;
- //
- // Export all helpers to the Handsontable object
- const HELPERS = [
- arrayHelpers,
- browserHelpers,
- dataHelpers,
- dateHelpers,
- featureHelpers,
- functionHelpers,
- mixedHelpers,
- numberHelpers,
- objectHelpers,
- settingHelpers,
- stringHelpers,
- unicodeHelpers,
- ];
- const DOM = [
- domHelpers,
- domEventHelpers,
- ];
- Handsontable.helper = {};
- Handsontable.dom = {};
- // Fill general helpers.
- arrayHelpers.arrayEach(HELPERS, (helper) => {
- arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), (key) => {
- if (key.charAt(0) !== '_') {
- Handsontable.helper[key] = helper[key];
- }
- });
- });
- // Fill DOM helpers.
- arrayHelpers.arrayEach(DOM, (helper) => {
- arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), (key) => {
- if (key.charAt(0) !== '_') {
- Handsontable.dom[key] = helper[key];
- }
- });
- });
- // Export cell types.
- Handsontable.cellTypes = {};
- arrayHelpers.arrayEach(getRegisteredCellTypeNames(), (cellTypeName) => {
- Handsontable.cellTypes[cellTypeName] = getCellType(cellTypeName);
- });
- Handsontable.cellTypes.registerCellType = registerCellType;
- Handsontable.cellTypes.getCellType = getCellType;
- // Export all registered editors from the Handsontable.
- Handsontable.editors = {};
- arrayHelpers.arrayEach(getRegisteredEditorNames(), (editorName) => {
- Handsontable.editors[`${stringHelpers.toUpperCaseFirst(editorName)}Editor`] = getEditor(editorName);
- });
- Handsontable.editors.registerEditor = registerEditor;
- Handsontable.editors.getEditor = getEditor;
- // Export all registered renderers from the Handsontable.
- Handsontable.renderers = {};
- arrayHelpers.arrayEach(getRegisteredRendererNames(), (rendererName) => {
- const renderer = getRenderer(rendererName);
- if (rendererName === 'base') {
- Handsontable.renderers.cellDecorator = renderer;
- }
- Handsontable.renderers[`${stringHelpers.toUpperCaseFirst(rendererName)}Renderer`] = renderer;
- });
- Handsontable.renderers.registerRenderer = registerRenderer;
- Handsontable.renderers.getRenderer = getRenderer;
- // Export all registered validators from the Handsontable.
- Handsontable.validators = {};
- arrayHelpers.arrayEach(getRegisteredValidatorNames(), (validatorName) => {
- Handsontable.validators[`${stringHelpers.toUpperCaseFirst(validatorName)}Validator`] = getValidator(validatorName);
- });
- Handsontable.validators.registerValidator = registerValidator;
- Handsontable.validators.getValidator = getValidator;
- // Export all registered plugins from the Handsontable.
- Handsontable.plugins = {};
- arrayHelpers.arrayEach(Object.getOwnPropertyNames(plugins), (pluginName) => {
- const plugin = plugins[pluginName];
- if (pluginName === 'Base') {
- Handsontable.plugins[`${pluginName}Plugin`] = plugin;
- } else {
- Handsontable.plugins[pluginName] = plugin;
- }
- });
- Handsontable.plugins.registerPlugin = registerPlugin;
- // Export Handsontable
- module.exports = Handsontable;
|