UNPKG

6.1 kBJavaScriptView Raw
1var _Handsontable$cellTyp, _Handsontable$editors, _Handsontable$rendere, _Handsontable$validat, _Handsontable$plugins;
2import Handsontable, { CellCoords, CellRange } from "./base.mjs";
3import { registerAllModules } from "./registry.mjs";
4import EventManager, { getListenersCounter } from "./eventManager.mjs";
5import { getRegisteredMapsCounter } from "./translations/index.mjs";
6import jQueryWrapper from "./helpers/wrappers/jquery.mjs";
7import GhostTable from "./utils/ghostTable.mjs";
8import * as parseTableHelpers from "./utils/parseTable.mjs";
9import * as arrayHelpers from "./helpers/array.mjs";
10import * as browserHelpers from "./helpers/browser.mjs";
11import * as dataHelpers from "./helpers/data.mjs";
12import * as dateHelpers from "./helpers/date.mjs";
13import * as featureHelpers from "./helpers/feature.mjs";
14import * as functionHelpers from "./helpers/function.mjs";
15import * as mixedHelpers from "./helpers/mixed.mjs";
16import * as numberHelpers from "./helpers/number.mjs";
17import * as objectHelpers from "./helpers/object.mjs";
18import * as stringHelpers from "./helpers/string.mjs";
19import * as unicodeHelpers from "./helpers/unicode.mjs";
20import * as domHelpers from "./helpers/dom/element.mjs";
21import * as domEventHelpers from "./helpers/dom/event.mjs";
22import { getRegisteredEditorNames, getEditor, registerEditor } from "./editors/registry.mjs";
23import { getRegisteredRendererNames, getRenderer, registerRenderer } from "./renderers/registry.mjs";
24import { getRegisteredValidatorNames, getValidator, registerValidator } from "./validators/registry.mjs";
25import { getRegisteredCellTypeNames, getCellType, registerCellType } from "./cellTypes/registry.mjs";
26import { getPluginsNames, getPlugin, registerPlugin } from "./plugins/registry.mjs";
27import { BasePlugin } from "./plugins/base/index.mjs";
28registerAllModules();
29jQueryWrapper(Handsontable);
30
31// TODO: Remove this exports after rewrite tests about this module
32Handsontable.__GhostTable = GhostTable;
33Handsontable._getListenersCounter = getListenersCounter; // For MemoryLeak tests
34Handsontable._getRegisteredMapsCounter = getRegisteredMapsCounter; // For MemoryLeak tests
35Handsontable.EventManager = EventManager;
36
37// Export all helpers to the Handsontable object
38const HELPERS = [arrayHelpers, browserHelpers, dataHelpers, dateHelpers, featureHelpers, functionHelpers, mixedHelpers, numberHelpers, objectHelpers, stringHelpers, unicodeHelpers, parseTableHelpers];
39const DOM = [domHelpers, domEventHelpers];
40Handsontable.helper = {};
41Handsontable.dom = {};
42
43// Fill general helpers.
44arrayHelpers.arrayEach(HELPERS, helper => {
45 arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), key => {
46 if (key.charAt(0) !== '_') {
47 Handsontable.helper[key] = helper[key];
48 }
49 });
50});
51
52// Fill DOM helpers.
53arrayHelpers.arrayEach(DOM, helper => {
54 arrayHelpers.arrayEach(Object.getOwnPropertyNames(helper), key => {
55 if (key.charAt(0) !== '_') {
56 Handsontable.dom[key] = helper[key];
57 }
58 });
59});
60
61// Export cell types.
62Handsontable.cellTypes = (_Handsontable$cellTyp = Handsontable.cellTypes) !== null && _Handsontable$cellTyp !== void 0 ? _Handsontable$cellTyp : {};
63arrayHelpers.arrayEach(getRegisteredCellTypeNames(), cellTypeName => {
64 Handsontable.cellTypes[cellTypeName] = getCellType(cellTypeName);
65});
66Handsontable.cellTypes.registerCellType = registerCellType;
67Handsontable.cellTypes.getCellType = getCellType;
68
69// Export all registered editors from the Handsontable.
70Handsontable.editors = (_Handsontable$editors = Handsontable.editors) !== null && _Handsontable$editors !== void 0 ? _Handsontable$editors : {};
71arrayHelpers.arrayEach(getRegisteredEditorNames(), editorName => {
72 Handsontable.editors[`${stringHelpers.toUpperCaseFirst(editorName)}Editor`] = getEditor(editorName);
73});
74Handsontable.editors.registerEditor = registerEditor;
75Handsontable.editors.getEditor = getEditor;
76
77// Export all registered renderers from the Handsontable.
78Handsontable.renderers = (_Handsontable$rendere = Handsontable.renderers) !== null && _Handsontable$rendere !== void 0 ? _Handsontable$rendere : {};
79arrayHelpers.arrayEach(getRegisteredRendererNames(), rendererName => {
80 const renderer = getRenderer(rendererName);
81 if (rendererName === 'base') {
82 Handsontable.renderers.cellDecorator = renderer;
83 }
84 Handsontable.renderers[`${stringHelpers.toUpperCaseFirst(rendererName)}Renderer`] = renderer;
85});
86Handsontable.renderers.registerRenderer = registerRenderer;
87Handsontable.renderers.getRenderer = getRenderer;
88
89// Export all registered validators from the Handsontable.
90Handsontable.validators = (_Handsontable$validat = Handsontable.validators) !== null && _Handsontable$validat !== void 0 ? _Handsontable$validat : {};
91arrayHelpers.arrayEach(getRegisteredValidatorNames(), validatorName => {
92 Handsontable.validators[`${stringHelpers.toUpperCaseFirst(validatorName)}Validator`] = getValidator(validatorName);
93});
94Handsontable.validators.registerValidator = registerValidator;
95Handsontable.validators.getValidator = getValidator;
96
97// Export all registered plugins from the Handsontable.
98// Make sure to initialize the plugin dictionary as an empty object. Otherwise, while
99// transpiling the files into ES and CommonJS format, the injected CoreJS helper
100// `import "core-js/modules/es.object.get-own-property-names";` won't be processed
101// by the `./config/plugin/babel/add-import-extension` babel plugin. Thus, the distribution
102// files will be broken. The reason is not known right now (probably it's caused by bug in
103// the Babel or missing something in the plugin).
104Handsontable.plugins = (_Handsontable$plugins = Handsontable.plugins) !== null && _Handsontable$plugins !== void 0 ? _Handsontable$plugins : {};
105arrayHelpers.arrayEach(getPluginsNames(), pluginName => {
106 Handsontable.plugins[pluginName] = getPlugin(pluginName);
107});
108Handsontable.plugins[`${stringHelpers.toUpperCaseFirst(BasePlugin.PLUGIN_KEY)}Plugin`] = BasePlugin;
109Handsontable.plugins.registerPlugin = registerPlugin;
110Handsontable.plugins.getPlugin = getPlugin;
111export { CellCoords, CellRange };
112export default Handsontable;
\No newline at end of file