handsontable 0.0.0-next-7026906-20231107 → 0.0.0-next-7b93b7d-20231107
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/SheetClip/SheetClip.js +2 -2
- package/3rdparty/SheetClip/SheetClip.mjs +2 -2
- package/3rdparty/autoResize/autoResize.js +2 -2
- package/3rdparty/autoResize/autoResize.mjs +2 -2
- package/3rdparty/walkontable/src/calculator/viewportColumns.js +108 -85
- package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +108 -85
- package/3rdparty/walkontable/src/calculator/viewportRows.js +60 -52
- package/3rdparty/walkontable/src/calculator/viewportRows.mjs +60 -52
- package/3rdparty/walkontable/src/core/clone.js +6 -0
- package/3rdparty/walkontable/src/core/clone.mjs +6 -0
- package/3rdparty/walkontable/src/event.js +125 -74
- package/3rdparty/walkontable/src/event.mjs +125 -74
- package/3rdparty/walkontable/src/filter/column.js +16 -0
- package/3rdparty/walkontable/src/filter/column.mjs +16 -0
- package/3rdparty/walkontable/src/filter/row.js +16 -0
- package/3rdparty/walkontable/src/filter/row.mjs +16 -0
- package/3rdparty/walkontable/src/overlay/bottom.js +1 -1
- package/3rdparty/walkontable/src/overlay/bottom.mjs +1 -1
- package/3rdparty/walkontable/src/overlay/top.js +1 -1
- package/3rdparty/walkontable/src/overlay/top.mjs +1 -1
- package/3rdparty/walkontable/src/renderer/_base.js +12 -5
- package/3rdparty/walkontable/src/renderer/_base.mjs +12 -5
- package/3rdparty/walkontable/src/renderer/cells.js +6 -2
- package/3rdparty/walkontable/src/renderer/cells.mjs +6 -2
- package/3rdparty/walkontable/src/renderer/rowHeaders.js +6 -2
- package/3rdparty/walkontable/src/renderer/rowHeaders.mjs +6 -2
- package/3rdparty/walkontable/src/renderer/rows.js +5 -0
- package/3rdparty/walkontable/src/renderer/rows.mjs +5 -0
- package/3rdparty/walkontable/src/renderer/table.js +24 -17
- package/3rdparty/walkontable/src/renderer/table.mjs +24 -17
- package/3rdparty/walkontable/src/scroll.js +2 -2
- package/3rdparty/walkontable/src/scroll.mjs +2 -2
- package/3rdparty/walkontable/src/selection/border/border.js +1 -1
- package/3rdparty/walkontable/src/selection/border/border.mjs +1 -1
- package/3rdparty/walkontable/src/settings.js +10 -10
- package/3rdparty/walkontable/src/settings.mjs +10 -10
- package/3rdparty/walkontable/src/table.js +3 -3
- package/3rdparty/walkontable/src/table.mjs +3 -3
- package/3rdparty/walkontable/src/utils/column.js +19 -4
- package/3rdparty/walkontable/src/utils/column.mjs +19 -4
- package/3rdparty/walkontable/src/utils/nodesPool.js +5 -0
- package/3rdparty/walkontable/src/utils/nodesPool.mjs +5 -0
- package/3rdparty/walkontable/src/utils/orderView/view.js +13 -6
- package/3rdparty/walkontable/src/utils/orderView/view.mjs +13 -6
- package/3rdparty/walkontable/src/utils/orderView/viewSize.js +9 -6
- package/3rdparty/walkontable/src/utils/orderView/viewSize.mjs +9 -6
- package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.js +7 -4
- package/3rdparty/walkontable/src/utils/orderView/viewSizeSet.mjs +7 -4
- package/3rdparty/walkontable/src/utils/row.js +14 -2
- package/3rdparty/walkontable/src/utils/row.mjs +14 -2
- package/3rdparty/walkontable/src/viewport.js +9 -9
- package/3rdparty/walkontable/src/viewport.mjs +9 -9
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core.js +25 -25
- package/core.mjs +25 -25
- package/dataMap/dataMap.js +99 -90
- package/dataMap/dataMap.mjs +99 -90
- package/dataMap/dataSource.js +14 -8
- package/dataMap/dataSource.mjs +14 -8
- package/dataMap/metaManager/lazyFactoryMap.js +19 -7
- package/dataMap/metaManager/lazyFactoryMap.mjs +19 -7
- package/dataMap/metaManager/metaLayers/cellMeta.js +8 -3
- package/dataMap/metaManager/metaLayers/cellMeta.mjs +8 -3
- package/dataMap/metaManager/metaLayers/columnMeta.js +7 -1
- package/dataMap/metaManager/metaLayers/columnMeta.mjs +7 -1
- package/dataMap/metaManager/metaLayers/globalMeta.js +6 -1
- package/dataMap/metaManager/metaLayers/globalMeta.mjs +6 -1
- package/dataMap/metaManager/metaLayers/tableMeta.js +6 -2
- package/dataMap/metaManager/metaLayers/tableMeta.mjs +6 -2
- package/dataMap/metaManager/metaSchema.js +55 -55
- package/dataMap/metaManager/metaSchema.mjs +55 -55
- package/dataMap/metaManager/mods/dynamicCellMeta.js +7 -2
- package/dataMap/metaManager/mods/dynamicCellMeta.mjs +7 -2
- package/dataMap/metaManager/mods/extendMetaProperties.js +8 -4
- package/dataMap/metaManager/mods/extendMetaProperties.mjs +8 -4
- package/dataMap/metaManager/utils.js +2 -2
- package/dataMap/metaManager/utils.mjs +2 -2
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +7244 -6347
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +120 -120
- package/dist/handsontable.js +7243 -6346
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +28 -28
- package/editorManager.js +105 -95
- package/editorManager.mjs +105 -95
- package/editors/autocompleteEditor/autocompleteEditor.js +47 -46
- package/editors/autocompleteEditor/autocompleteEditor.mjs +46 -45
- package/editors/baseEditor/baseEditor.js +23 -26
- package/editors/baseEditor/baseEditor.mjs +23 -26
- package/editors/dateEditor/dateEditor.js +24 -15
- package/editors/dateEditor/dateEditor.mjs +24 -15
- package/editors/dropdownEditor/dropdownEditor.js +1 -1
- package/editors/dropdownEditor/dropdownEditor.mjs +1 -1
- package/editors/handsontableEditor/handsontableEditor.js +4 -4
- package/editors/handsontableEditor/handsontableEditor.mjs +4 -4
- package/editors/textEditor/textEditor.js +23 -17
- package/editors/textEditor/textEditor.mjs +24 -18
- package/eventManager.js +8 -0
- package/eventManager.mjs +8 -0
- package/helpers/array.js +2 -2
- package/helpers/array.mjs +2 -2
- package/helpers/dom/element.js +7 -7
- package/helpers/dom/element.mjs +7 -7
- package/helpers/function.js +1 -1
- package/helpers/function.mjs +1 -1
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/helpers/object.js +4 -4
- package/helpers/object.mjs +4 -4
- package/helpers/string.js +1 -1
- package/helpers/string.mjs +1 -1
- package/package.json +1 -1
- package/pluginHooks.d.ts +0 -2
- package/pluginHooks.js +12 -3
- package/pluginHooks.mjs +12 -3
- package/plugins/autoColumnSize/autoColumnSize.js +141 -130
- package/plugins/autoColumnSize/autoColumnSize.mjs +140 -129
- package/plugins/autoRowSize/autoRowSize.js +112 -125
- package/plugins/autoRowSize/autoRowSize.mjs +110 -123
- package/plugins/autofill/autofill.js +97 -102
- package/plugins/autofill/autofill.mjs +96 -101
- package/plugins/base/base.js +57 -22
- package/plugins/base/base.mjs +56 -22
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.js +29 -24
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.mjs +28 -23
- package/plugins/collapsibleColumns/collapsibleColumns.js +104 -107
- package/plugins/collapsibleColumns/collapsibleColumns.mjs +102 -104
- package/plugins/columnSorting/columnSorting.js +105 -98
- package/plugins/columnSorting/columnSorting.mjs +104 -97
- package/plugins/columnSorting/columnStatesManager.js +12 -6
- package/plugins/columnSorting/columnStatesManager.mjs +12 -6
- package/plugins/columnSummary/columnSummary.js +71 -58
- package/plugins/columnSummary/columnSummary.mjs +70 -57
- package/plugins/columnSummary/endpoints.js +20 -14
- package/plugins/columnSummary/endpoints.mjs +20 -14
- package/plugins/comments/commentEditor.js +30 -2
- package/plugins/comments/commentEditor.mjs +30 -2
- package/plugins/comments/comments.js +158 -169
- package/plugins/comments/comments.mjs +157 -168
- package/plugins/comments/displaySwitch.js +7 -3
- package/plugins/comments/displaySwitch.mjs +7 -3
- package/plugins/contextMenu/commandExecutor.js +15 -2
- package/plugins/contextMenu/commandExecutor.mjs +15 -2
- package/plugins/contextMenu/contextMenu.js +91 -101
- package/plugins/contextMenu/contextMenu.mjs +90 -100
- package/plugins/contextMenu/itemsFactory.js +19 -4
- package/plugins/contextMenu/itemsFactory.mjs +19 -4
- package/plugins/contextMenu/menu/cursor.js +36 -0
- package/plugins/contextMenu/menu/cursor.mjs +36 -0
- package/plugins/contextMenu/menu/menu.js +57 -5
- package/plugins/contextMenu/menu/menu.mjs +57 -5
- package/plugins/copyPaste/copyPaste.js +74 -75
- package/plugins/copyPaste/copyPaste.mjs +74 -75
- package/plugins/customBorders/customBorders.js +49 -48
- package/plugins/customBorders/customBorders.mjs +48 -47
- package/plugins/dragToScroll/dragToScroll.js +50 -54
- package/plugins/dragToScroll/dragToScroll.mjs +49 -52
- package/plugins/dropdownMenu/dropdownMenu.js +132 -129
- package/plugins/dropdownMenu/dropdownMenu.mjs +132 -129
- package/plugins/exportFile/dataProvider.js +7 -2
- package/plugins/exportFile/dataProvider.mjs +7 -2
- package/plugins/exportFile/exportFile.js +1 -1
- package/plugins/exportFile/exportFile.mjs +1 -1
- package/plugins/exportFile/types/_base.js +14 -6
- package/plugins/exportFile/types/_base.mjs +14 -6
- package/plugins/filters/component/actionBar.js +9 -0
- package/plugins/filters/component/actionBar.mjs +9 -0
- package/plugins/filters/component/condition.js +13 -0
- package/plugins/filters/component/condition.mjs +13 -0
- package/plugins/filters/component/operators.js +9 -0
- package/plugins/filters/component/operators.mjs +9 -0
- package/plugins/filters/component/value.js +9 -0
- package/plugins/filters/component/value.mjs +9 -0
- package/plugins/filters/conditionCollection.js +9 -4
- package/plugins/filters/conditionCollection.mjs +9 -4
- package/plugins/filters/conditionUpdateObserver.js +53 -42
- package/plugins/filters/conditionUpdateObserver.mjs +53 -42
- package/plugins/filters/dataFilter.js +9 -3
- package/plugins/filters/dataFilter.mjs +9 -3
- package/plugins/filters/filters.js +184 -189
- package/plugins/filters/filters.mjs +182 -187
- package/plugins/filters/ui/_base.js +1 -1
- package/plugins/filters/ui/_base.mjs +1 -1
- package/plugins/filters/utils.js +1 -1
- package/plugins/filters/utils.mjs +1 -1
- package/plugins/formulas/engine/settings.js +1 -1
- package/plugins/formulas/engine/settings.mjs +1 -1
- package/plugins/formulas/formulas.js +684 -602
- package/plugins/formulas/formulas.mjs +682 -600
- package/plugins/hiddenColumns/hiddenColumns.js +174 -169
- package/plugins/hiddenColumns/hiddenColumns.mjs +173 -168
- package/plugins/hiddenRows/hiddenRows.js +170 -165
- package/plugins/hiddenRows/hiddenRows.mjs +169 -164
- package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.js +1 -1
- package/plugins/manualColumnFreeze/contextMenuItem/freezeColumn.mjs +1 -1
- package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.js +1 -1
- package/plugins/manualColumnFreeze/contextMenuItem/unfreezeColumn.mjs +1 -1
- package/plugins/manualColumnFreeze/manualColumnFreeze.js +67 -54
- package/plugins/manualColumnFreeze/manualColumnFreeze.mjs +64 -51
- package/plugins/manualColumnMove/manualColumnMove.js +287 -232
- package/plugins/manualColumnMove/manualColumnMove.mjs +286 -231
- package/plugins/manualColumnMove/ui/_base.js +9 -3
- package/plugins/manualColumnMove/ui/_base.mjs +9 -3
- package/plugins/manualColumnResize/manualColumnResize.js +291 -246
- package/plugins/manualColumnResize/manualColumnResize.mjs +290 -244
- package/plugins/manualRowMove/manualRowMove.js +223 -208
- package/plugins/manualRowMove/manualRowMove.mjs +222 -207
- package/plugins/manualRowMove/ui/_base.js +10 -5
- package/plugins/manualRowMove/ui/_base.mjs +10 -5
- package/plugins/manualRowResize/manualRowResize.js +254 -209
- package/plugins/manualRowResize/manualRowResize.mjs +253 -207
- package/plugins/mergeCells/calculations/autofill.js +9 -3
- package/plugins/mergeCells/calculations/autofill.mjs +9 -3
- package/plugins/mergeCells/calculations/selection.js +10 -4
- package/plugins/mergeCells/calculations/selection.mjs +10 -4
- package/plugins/mergeCells/cellCoords.js +16 -6
- package/plugins/mergeCells/cellCoords.mjs +16 -6
- package/plugins/mergeCells/cellsCollection.js +10 -4
- package/plugins/mergeCells/cellsCollection.mjs +10 -4
- package/plugins/mergeCells/mergeCells.js +582 -502
- package/plugins/mergeCells/mergeCells.mjs +580 -500
- package/plugins/multiColumnSorting/multiColumnSorting.js +13 -10
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +13 -10
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.js +16 -28
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.mjs +16 -27
- package/plugins/nestedHeaders/nestedHeaders.js +542 -499
- package/plugins/nestedHeaders/nestedHeaders.mjs +554 -511
- package/plugins/nestedHeaders/stateManager/index.js +1 -1
- package/plugins/nestedHeaders/stateManager/index.mjs +1 -1
- package/plugins/nestedRows/data/dataManager.js +21 -15
- package/plugins/nestedRows/data/dataManager.mjs +21 -15
- package/plugins/nestedRows/nestedRows.js +326 -278
- package/plugins/nestedRows/nestedRows.mjs +325 -277
- package/plugins/nestedRows/ui/_base.js +7 -1
- package/plugins/nestedRows/ui/_base.mjs +7 -1
- package/plugins/nestedRows/ui/collapsing.js +2 -2
- package/plugins/nestedRows/ui/collapsing.mjs +2 -2
- package/plugins/nestedRows/ui/contextMenu.js +28 -18
- package/plugins/nestedRows/ui/contextMenu.mjs +28 -18
- package/plugins/nestedRows/utils/rowMoveController.js +12 -4
- package/plugins/nestedRows/utils/rowMoveController.mjs +12 -4
- package/plugins/persistentState/persistentState.js +14 -11
- package/plugins/persistentState/persistentState.mjs +14 -11
- package/plugins/persistentState/storage.js +11 -6
- package/plugins/persistentState/storage.mjs +11 -6
- package/plugins/registry.js +2 -2
- package/plugins/registry.mjs +2 -2
- package/plugins/search/search.js +57 -46
- package/plugins/search/search.mjs +56 -45
- package/plugins/touchScroll/touchScroll.js +102 -100
- package/plugins/touchScroll/touchScroll.mjs +100 -98
- package/plugins/trimRows/trimRows.js +33 -28
- package/plugins/trimRows/trimRows.mjs +32 -27
- package/plugins/undoRedo/undoRedo.js +2 -2
- package/plugins/undoRedo/undoRedo.mjs +2 -2
- package/renderers/autocompleteRenderer/autocompleteRenderer.js +11 -11
- package/renderers/autocompleteRenderer/autocompleteRenderer.mjs +11 -11
- package/renderers/baseRenderer/baseRenderer.js +2 -2
- package/renderers/baseRenderer/baseRenderer.mjs +2 -2
- package/renderers/checkboxRenderer/checkboxRenderer.js +23 -23
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +23 -23
- package/renderers/dateRenderer/dateRenderer.js +4 -4
- package/renderers/dateRenderer/dateRenderer.mjs +4 -4
- package/renderers/handsontableRenderer/handsontableRenderer.js +4 -4
- package/renderers/handsontableRenderer/handsontableRenderer.mjs +4 -4
- package/renderers/htmlRenderer/htmlRenderer.js +4 -4
- package/renderers/htmlRenderer/htmlRenderer.mjs +4 -4
- package/renderers/numericRenderer/numericRenderer.js +3 -3
- package/renderers/numericRenderer/numericRenderer.mjs +3 -3
- package/renderers/passwordRenderer/passwordRenderer.js +3 -3
- package/renderers/passwordRenderer/passwordRenderer.mjs +3 -3
- package/renderers/selectRenderer/selectRenderer.js +4 -4
- package/renderers/selectRenderer/selectRenderer.mjs +4 -4
- package/renderers/textRenderer/textRenderer.js +5 -5
- package/renderers/textRenderer/textRenderer.mjs +5 -5
- package/renderers/timeRenderer/timeRenderer.js +3 -3
- package/renderers/timeRenderer/timeRenderer.mjs +3 -3
- package/selection/range.js +12 -2
- package/selection/range.mjs +12 -2
- package/selection/selection.js +3 -3
- package/selection/selection.mjs +3 -3
- package/tableView.js +208 -200
- package/tableView.mjs +208 -200
- package/translations/changesObservable/utils.js +2 -2
- package/translations/changesObservable/utils.mjs +2 -2
- package/translations/indexMapper.js +25 -22
- package/translations/indexMapper.mjs +25 -22
- package/translations/mapCollections/aggregatedCollection.js +8 -2
- package/translations/mapCollections/aggregatedCollection.mjs +8 -2
- package/translations/mapCollections/mapCollection.js +5 -2
- package/translations/mapCollections/mapCollection.mjs +5 -2
- package/translations/maps/indexMap.js +6 -1
- package/translations/maps/indexMap.mjs +6 -1
- package/translations/maps/utils/physicallyIndexed.js +2 -2
- package/translations/maps/utils/physicallyIndexed.mjs +2 -2
- package/utils/dataStructures/linkedList.js +10 -6
- package/utils/dataStructures/linkedList.mjs +10 -6
- package/utils/dataStructures/queue.js +1 -1
- package/utils/dataStructures/queue.mjs +1 -1
- package/utils/dataStructures/stack.js +1 -1
- package/utils/dataStructures/stack.mjs +1 -1
- package/utils/ghostTable.js +2 -2
- package/utils/ghostTable.mjs +2 -2
- package/utils/interval.js +73 -36
- package/utils/interval.mjs +73 -36
- package/utils/parseTable.js +1 -1
- package/utils/parseTable.mjs +1 -1
- package/validators/autocompleteValidator/autocompleteValidator.js +1 -1
- package/validators/autocompleteValidator/autocompleteValidator.mjs +1 -1
- package/validators/dateValidator/dateValidator.js +1 -1
- package/validators/dateValidator/dateValidator.mjs +1 -1
- package/validators/numericValidator/numericValidator.js +1 -1
- package/validators/numericValidator/numericValidator.mjs +1 -1
@@ -1,9 +1,15 @@
|
|
1
1
|
import "core-js/modules/es.array.push.js";
|
2
|
+
import "core-js/modules/es.error.cause.js";
|
3
|
+
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
4
|
+
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
6
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
7
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
8
|
+
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
2
9
|
import { BasePlugin } from "../base/index.mjs";
|
3
10
|
import Hooks from "../../pluginHooks.mjs";
|
4
11
|
import { offset, outerHeight, outerWidth } from "../../helpers/dom/element.mjs";
|
5
12
|
import { arrayEach, arrayMap } from "../../helpers/array.mjs";
|
6
|
-
import EventManager from "../../eventManager.mjs";
|
7
13
|
import { getDragDirectionAndRange, DIRECTIONS, getMappedFillHandleSetting } from "./utils.mjs";
|
8
14
|
Hooks.getSingleton().register('modifyAutofillRange');
|
9
15
|
Hooks.getSingleton().register('beforeAutofill');
|
@@ -28,69 +34,91 @@ const INTERVAL_FOR_ADDING_ROW = 200;
|
|
28
34
|
* @class Autofill
|
29
35
|
* @plugin Autofill
|
30
36
|
*/
|
31
|
-
|
37
|
+
var _onCellCornerDblClick = /*#__PURE__*/new WeakSet();
|
38
|
+
var _onAfterCellCornerMouseDown = /*#__PURE__*/new WeakSet();
|
39
|
+
var _onBeforeCellMouseOver = /*#__PURE__*/new WeakSet();
|
40
|
+
var _onMouseUp = /*#__PURE__*/new WeakSet();
|
41
|
+
var _onMouseMove = /*#__PURE__*/new WeakSet();
|
32
42
|
export class Autofill extends BasePlugin {
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
43
|
+
constructor() {
|
44
|
+
super(...arguments);
|
45
|
+
/**
|
46
|
+
* On mouse move listener.
|
47
|
+
*
|
48
|
+
* @param {MouseEvent} event `mousemove` event properties.
|
49
|
+
*/
|
50
|
+
_classPrivateMethodInitSpec(this, _onMouseMove);
|
51
|
+
/**
|
52
|
+
* On mouse up listener.
|
53
|
+
*/
|
54
|
+
_classPrivateMethodInitSpec(this, _onMouseUp);
|
44
55
|
/**
|
45
|
-
*
|
56
|
+
* On before cell mouse over listener.
|
57
|
+
*
|
58
|
+
* @param {CellCoords} coords `CellCoords` coord object.
|
59
|
+
*/
|
60
|
+
_classPrivateMethodInitSpec(this, _onBeforeCellMouseOver);
|
61
|
+
/**
|
62
|
+
* On after cell corner mouse down listener.
|
63
|
+
*/
|
64
|
+
_classPrivateMethodInitSpec(this, _onAfterCellCornerMouseDown);
|
65
|
+
/**
|
66
|
+
* On cell corner double click callback.
|
46
67
|
*
|
47
68
|
* @private
|
48
|
-
* @type {EventManager}
|
49
69
|
*/
|
50
|
-
this
|
70
|
+
_classPrivateMethodInitSpec(this, _onCellCornerDblClick);
|
51
71
|
/**
|
52
72
|
* Specifies if adding new row started.
|
53
73
|
*
|
54
74
|
* @private
|
55
75
|
* @type {boolean}
|
56
76
|
*/
|
57
|
-
this
|
77
|
+
_defineProperty(this, "addingStarted", false);
|
58
78
|
/**
|
59
79
|
* Specifies if there was mouse down on the cell corner.
|
60
80
|
*
|
61
81
|
* @private
|
62
82
|
* @type {boolean}
|
63
83
|
*/
|
64
|
-
this
|
84
|
+
_defineProperty(this, "mouseDownOnCellCorner", false);
|
65
85
|
/**
|
66
86
|
* Specifies if mouse was dragged outside Handsontable.
|
67
87
|
*
|
68
88
|
* @private
|
69
89
|
* @type {boolean}
|
70
90
|
*/
|
71
|
-
this
|
91
|
+
_defineProperty(this, "mouseDragOutside", false);
|
72
92
|
/**
|
73
93
|
* Specifies how many cell levels were dragged using the handle.
|
74
94
|
*
|
75
95
|
* @private
|
76
96
|
* @type {boolean}
|
77
97
|
*/
|
78
|
-
this
|
98
|
+
_defineProperty(this, "handleDraggedCells", 0);
|
79
99
|
/**
|
80
100
|
* Specifies allowed directions of drag (`'horizontal'` or '`vertical`').
|
81
101
|
*
|
82
102
|
* @private
|
83
103
|
* @type {string[]}
|
84
104
|
*/
|
85
|
-
this
|
105
|
+
_defineProperty(this, "directions", []);
|
86
106
|
/**
|
87
107
|
* Specifies if can insert new rows if needed.
|
88
108
|
*
|
89
109
|
* @type {boolean}
|
90
110
|
*/
|
91
|
-
this
|
111
|
+
_defineProperty(this, "autoInsertRow", false);
|
112
|
+
}
|
113
|
+
static get PLUGIN_KEY() {
|
114
|
+
return PLUGIN_KEY;
|
115
|
+
}
|
116
|
+
static get PLUGIN_PRIORITY() {
|
117
|
+
return PLUGIN_PRIORITY;
|
118
|
+
}
|
119
|
+
static get SETTING_KEYS() {
|
120
|
+
return [PLUGIN_KEY, ...SETTING_KEYS];
|
92
121
|
}
|
93
|
-
|
94
122
|
/**
|
95
123
|
* Checks if the plugin is enabled in the Handsontable settings.
|
96
124
|
*
|
@@ -109,9 +137,9 @@ export class Autofill extends BasePlugin {
|
|
109
137
|
}
|
110
138
|
this.mapSettings();
|
111
139
|
this.registerEvents();
|
112
|
-
this.addHook('afterOnCellCornerMouseDown', event => this.
|
113
|
-
this.addHook('afterOnCellCornerDblClick', event => this.
|
114
|
-
this.addHook('beforeOnCellMouseOver', (_, coords) => this.
|
140
|
+
this.addHook('afterOnCellCornerMouseDown', event => _classPrivateMethodGet(this, _onAfterCellCornerMouseDown, _onAfterCellCornerMouseDown2).call(this, event));
|
141
|
+
this.addHook('afterOnCellCornerDblClick', event => _classPrivateMethodGet(this, _onCellCornerDblClick, _onCellCornerDblClick2).call(this, event));
|
142
|
+
this.addHook('beforeOnCellMouseOver', (_, coords) => _classPrivateMethodGet(this, _onBeforeCellMouseOver, _onBeforeCellMouseOver2).call(this, coords));
|
115
143
|
super.enablePlugin();
|
116
144
|
}
|
117
145
|
|
@@ -322,7 +350,7 @@ export class Autofill extends BasePlugin {
|
|
322
350
|
*/
|
323
351
|
addRow() {
|
324
352
|
this.hot._registerTimeout(() => {
|
325
|
-
this.hot.alter(INSERT_ROW_ALTER_ACTION_NAME,
|
353
|
+
this.hot.alter(INSERT_ROW_ALTER_ACTION_NAME, undefined, 1, `${this.pluginName}.fill`);
|
326
354
|
this.addingStarted = false;
|
327
355
|
}, INTERVAL_FOR_ADDING_ROW);
|
328
356
|
}
|
@@ -402,7 +430,7 @@ export class Autofill extends BasePlugin {
|
|
402
430
|
selectAdjacent() {
|
403
431
|
const cornersOfSelectedCells = this.hot.getSelectedLast();
|
404
432
|
const lastFilledInRowIndex = this.getIndexOfLastAdjacentFilledInRow(cornersOfSelectedCells);
|
405
|
-
if (lastFilledInRowIndex === -1 || lastFilledInRowIndex ===
|
433
|
+
if (lastFilledInRowIndex === -1 || lastFilledInRowIndex === undefined) {
|
406
434
|
return false;
|
407
435
|
}
|
408
436
|
this.addSelectionFromStartAreaToSpecificRowIndex(cornersOfSelectedCells, lastFilledInRowIndex);
|
@@ -455,80 +483,9 @@ export class Autofill extends BasePlugin {
|
|
455
483
|
const {
|
456
484
|
documentElement
|
457
485
|
} = this.hot.rootDocument;
|
458
|
-
this.eventManager.addEventListener(documentElement, 'mouseup', () => this.
|
459
|
-
this.eventManager.addEventListener(documentElement, 'mousemove', event => this.
|
460
|
-
}
|
461
|
-
|
462
|
-
/**
|
463
|
-
* On cell corner double click callback.
|
464
|
-
*
|
465
|
-
* @private
|
466
|
-
*/
|
467
|
-
onCellCornerDblClick() {
|
468
|
-
const selectionApplied = this.selectAdjacent();
|
469
|
-
if (selectionApplied) {
|
470
|
-
this.fillIn();
|
471
|
-
}
|
486
|
+
this.eventManager.addEventListener(documentElement, 'mouseup', () => _classPrivateMethodGet(this, _onMouseUp, _onMouseUp2).call(this));
|
487
|
+
this.eventManager.addEventListener(documentElement, 'mousemove', event => _classPrivateMethodGet(this, _onMouseMove, _onMouseMove2).call(this, event));
|
472
488
|
}
|
473
|
-
|
474
|
-
/**
|
475
|
-
* On after cell corner mouse down listener.
|
476
|
-
*
|
477
|
-
* @private
|
478
|
-
*/
|
479
|
-
onAfterCellCornerMouseDown() {
|
480
|
-
this.handleDraggedCells = 1;
|
481
|
-
this.mouseDownOnCellCorner = true;
|
482
|
-
}
|
483
|
-
|
484
|
-
/**
|
485
|
-
* On before cell mouse over listener.
|
486
|
-
*
|
487
|
-
* @private
|
488
|
-
* @param {CellCoords} coords `CellCoords` coord object.
|
489
|
-
*/
|
490
|
-
onBeforeCellMouseOver(coords) {
|
491
|
-
if (this.mouseDownOnCellCorner && !this.hot.view.isMouseDown() && this.handleDraggedCells) {
|
492
|
-
this.handleDraggedCells += 1;
|
493
|
-
this.showBorder(coords);
|
494
|
-
this.addNewRowIfNeeded();
|
495
|
-
}
|
496
|
-
}
|
497
|
-
|
498
|
-
/**
|
499
|
-
* On mouse up listener.
|
500
|
-
*
|
501
|
-
* @private
|
502
|
-
*/
|
503
|
-
onMouseUp() {
|
504
|
-
if (this.handleDraggedCells) {
|
505
|
-
if (this.handleDraggedCells > 1) {
|
506
|
-
this.fillIn();
|
507
|
-
}
|
508
|
-
this.handleDraggedCells = 0;
|
509
|
-
this.mouseDownOnCellCorner = false;
|
510
|
-
}
|
511
|
-
}
|
512
|
-
|
513
|
-
/**
|
514
|
-
* On mouse move listener.
|
515
|
-
*
|
516
|
-
* @private
|
517
|
-
* @param {MouseEvent} event `mousemove` event properties.
|
518
|
-
*/
|
519
|
-
onMouseMove(event) {
|
520
|
-
const mouseWasDraggedOutside = this.getIfMouseWasDraggedOutside(event);
|
521
|
-
if (this.addingStarted === false && this.handleDraggedCells > 0 && mouseWasDraggedOutside) {
|
522
|
-
this.mouseDragOutside = true;
|
523
|
-
this.addingStarted = true;
|
524
|
-
} else {
|
525
|
-
this.mouseDragOutside = false;
|
526
|
-
}
|
527
|
-
if (this.mouseDragOutside && this.autoInsertRow) {
|
528
|
-
this.addRow();
|
529
|
-
}
|
530
|
-
}
|
531
|
-
|
532
489
|
/**
|
533
490
|
* Clears mapped settings.
|
534
491
|
*
|
@@ -556,4 +513,42 @@ export class Autofill extends BasePlugin {
|
|
556
513
|
destroy() {
|
557
514
|
super.destroy();
|
558
515
|
}
|
516
|
+
}
|
517
|
+
function _onCellCornerDblClick2() {
|
518
|
+
const selectionApplied = this.selectAdjacent();
|
519
|
+
if (selectionApplied) {
|
520
|
+
this.fillIn();
|
521
|
+
}
|
522
|
+
}
|
523
|
+
function _onAfterCellCornerMouseDown2() {
|
524
|
+
this.handleDraggedCells = 1;
|
525
|
+
this.mouseDownOnCellCorner = true;
|
526
|
+
}
|
527
|
+
function _onBeforeCellMouseOver2(coords) {
|
528
|
+
if (this.mouseDownOnCellCorner && !this.hot.view.isMouseDown() && this.handleDraggedCells) {
|
529
|
+
this.handleDraggedCells += 1;
|
530
|
+
this.showBorder(coords);
|
531
|
+
this.addNewRowIfNeeded();
|
532
|
+
}
|
533
|
+
}
|
534
|
+
function _onMouseUp2() {
|
535
|
+
if (this.handleDraggedCells) {
|
536
|
+
if (this.handleDraggedCells > 1) {
|
537
|
+
this.fillIn();
|
538
|
+
}
|
539
|
+
this.handleDraggedCells = 0;
|
540
|
+
this.mouseDownOnCellCorner = false;
|
541
|
+
}
|
542
|
+
}
|
543
|
+
function _onMouseMove2(event) {
|
544
|
+
const mouseWasDraggedOutside = this.getIfMouseWasDraggedOutside(event);
|
545
|
+
if (this.addingStarted === false && this.handleDraggedCells > 0 && mouseWasDraggedOutside) {
|
546
|
+
this.mouseDragOutside = true;
|
547
|
+
this.addingStarted = true;
|
548
|
+
} else {
|
549
|
+
this.mouseDragOutside = false;
|
550
|
+
}
|
551
|
+
if (this.mouseDragOutside && this.autoInsertRow) {
|
552
|
+
this.addRow();
|
553
|
+
}
|
559
554
|
}
|
package/plugins/base/base.js
CHANGED
@@ -10,20 +10,29 @@ var _registry2 = require("../../cellTypes/registry");
|
|
10
10
|
var _registry3 = require("../../editors/registry");
|
11
11
|
var _registry4 = require("../../renderers/registry");
|
12
12
|
var _registry5 = require("../../validators/registry");
|
13
|
+
var _eventManager = _interopRequireDefault(require("../../eventManager"));
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
13
15
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
16
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
14
17
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
18
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
19
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
20
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
15
21
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
22
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
23
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
24
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
16
25
|
const DEPS_TYPE_CHECKERS = new Map([['plugin', _registry.hasPlugin], ['cell-type', _registry2.hasCellType], ['editor', _registry3.hasEditor], ['renderer', _registry4.hasRenderer], ['validator', _registry5.hasValidator]]);
|
17
26
|
const PLUGIN_KEY = 'base';
|
18
27
|
exports.PLUGIN_KEY = PLUGIN_KEY;
|
19
|
-
const
|
20
|
-
const missingDependeciesMsgs = [];
|
28
|
+
const missingDepsMsgs = [];
|
21
29
|
let initializedPlugins = null;
|
22
30
|
|
23
31
|
/**
|
24
32
|
* @util
|
25
33
|
* @property {Core} hot Handsontable instance.
|
26
34
|
*/
|
35
|
+
var _hooks = /*#__PURE__*/new WeakMap();
|
27
36
|
var _isRelevantToSettings = /*#__PURE__*/new WeakSet();
|
28
37
|
class BasePlugin {
|
29
38
|
static get PLUGIN_KEY() {
|
@@ -43,6 +52,12 @@ class BasePlugin {
|
|
43
52
|
return [this.PLUGIN_KEY];
|
44
53
|
}
|
45
54
|
|
55
|
+
/**
|
56
|
+
* The instance of the {@link EventManager} class.
|
57
|
+
*
|
58
|
+
* @type {EventManager}
|
59
|
+
*/
|
60
|
+
|
46
61
|
/**
|
47
62
|
* @param {object} hotInstance Handsontable instance.
|
48
63
|
*/
|
@@ -57,6 +72,34 @@ class BasePlugin {
|
|
57
72
|
* @returns {boolean}
|
58
73
|
*/
|
59
74
|
_classPrivateMethodInitSpec(this, _isRelevantToSettings);
|
75
|
+
_defineProperty(this, "eventManager", new _eventManager.default(this));
|
76
|
+
/**
|
77
|
+
* @type {string}
|
78
|
+
*/
|
79
|
+
_defineProperty(this, "pluginName", null);
|
80
|
+
/**
|
81
|
+
* @type {Function[]}
|
82
|
+
*/
|
83
|
+
_defineProperty(this, "pluginsInitializedCallbacks", []);
|
84
|
+
/**
|
85
|
+
* @type {boolean}
|
86
|
+
*/
|
87
|
+
_defineProperty(this, "isPluginsReady", false);
|
88
|
+
/**
|
89
|
+
* @type {boolean}
|
90
|
+
*/
|
91
|
+
_defineProperty(this, "enabled", false);
|
92
|
+
/**
|
93
|
+
* @type {boolean}
|
94
|
+
*/
|
95
|
+
_defineProperty(this, "initialized", false);
|
96
|
+
/**
|
97
|
+
* Collection of the reference to the plugins hooks.
|
98
|
+
*/
|
99
|
+
_classPrivateFieldInitSpec(this, _hooks, {
|
100
|
+
writable: true,
|
101
|
+
value: {}
|
102
|
+
});
|
60
103
|
/**
|
61
104
|
* Handsontable instance.
|
62
105
|
*
|
@@ -65,15 +108,7 @@ class BasePlugin {
|
|
65
108
|
(0, _object.defineGetter)(this, 'hot', hotInstance, {
|
66
109
|
writable: false
|
67
110
|
});
|
68
|
-
privatePool.set(this, {
|
69
|
-
hooks: {}
|
70
|
-
});
|
71
111
|
initializedPlugins = null;
|
72
|
-
this.pluginName = null;
|
73
|
-
this.pluginsInitializedCallbacks = [];
|
74
|
-
this.isPluginsReady = false;
|
75
|
-
this.enabled = false;
|
76
|
-
this.initialized = false;
|
77
112
|
this.hot.addHook('afterPluginsInitialized', () => this.onAfterPluginsInitialized());
|
78
113
|
this.hot.addHook('afterUpdateSettings', newSettings => this.onUpdateSettings(newSettings));
|
79
114
|
this.hot.addHook('beforeInit', () => this.init());
|
@@ -81,10 +116,10 @@ class BasePlugin {
|
|
81
116
|
init() {
|
82
117
|
this.pluginName = this.hot.getPluginName(this);
|
83
118
|
const pluginDeps = this.constructor.PLUGIN_DEPS;
|
84
|
-
const
|
85
|
-
if (
|
119
|
+
const deps = Array.isArray(pluginDeps) ? pluginDeps : [];
|
120
|
+
if (deps.length > 0) {
|
86
121
|
const missingDependencies = [];
|
87
|
-
|
122
|
+
deps.forEach(dependency => {
|
88
123
|
const [type, moduleName] = dependency.split(':');
|
89
124
|
if (!DEPS_TYPE_CHECKERS.has(type)) {
|
90
125
|
throw new Error(`Unknown plugin dependency type "${type}" was found.`);
|
@@ -95,7 +130,7 @@ class BasePlugin {
|
|
95
130
|
});
|
96
131
|
if (missingDependencies.length > 0) {
|
97
132
|
const errorMsg = [`The ${this.pluginName} plugin requires the following modules:\n`, `${missingDependencies.join('\n')}\n`].join('');
|
98
|
-
|
133
|
+
missingDepsMsgs.push(errorMsg);
|
99
134
|
}
|
100
135
|
}
|
101
136
|
if (!initializedPlugins) {
|
@@ -118,8 +153,8 @@ class BasePlugin {
|
|
118
153
|
});
|
119
154
|
const isAllPluginsAreInitialized = initializedPlugins.length === 0;
|
120
155
|
if (isAllPluginsAreInitialized) {
|
121
|
-
if (
|
122
|
-
const errorMsg = [`${
|
156
|
+
if (missingDepsMsgs.length > 0) {
|
157
|
+
const errorMsg = [`${missingDepsMsgs.join('\n')}\n`, 'You have to import and register them manually.'].join('');
|
123
158
|
throw new Error(errorMsg);
|
124
159
|
}
|
125
160
|
this.hot.runHooks('afterPluginsInitialized');
|
@@ -152,11 +187,11 @@ class BasePlugin {
|
|
152
187
|
* @param {Function} callback The listener function to add.
|
153
188
|
*/
|
154
189
|
addHook(name, callback) {
|
155
|
-
|
156
|
-
const hooks =
|
190
|
+
_classPrivateFieldGet(this, _hooks)[name] = _classPrivateFieldGet(this, _hooks)[name] || [];
|
191
|
+
const hooks = _classPrivateFieldGet(this, _hooks)[name];
|
157
192
|
this.hot.addHook(name, callback);
|
158
193
|
hooks.push(callback);
|
159
|
-
|
194
|
+
_classPrivateFieldGet(this, _hooks)[name] = hooks;
|
160
195
|
}
|
161
196
|
|
162
197
|
/**
|
@@ -165,7 +200,7 @@ class BasePlugin {
|
|
165
200
|
* @param {string} name The hook name.
|
166
201
|
*/
|
167
202
|
removeHooks(name) {
|
168
|
-
(0, _array.arrayEach)(
|
203
|
+
(0, _array.arrayEach)(_classPrivateFieldGet(this, _hooks)[name] || [], callback => {
|
169
204
|
this.hot.removeHook(name, callback);
|
170
205
|
});
|
171
206
|
}
|
@@ -174,7 +209,7 @@ class BasePlugin {
|
|
174
209
|
* Clear all hooks.
|
175
210
|
*/
|
176
211
|
clearHooks() {
|
177
|
-
const hooks =
|
212
|
+
const hooks = _classPrivateFieldGet(this, _hooks);
|
178
213
|
(0, _object.objectEach)(hooks, (callbacks, name) => this.removeHooks(name));
|
179
214
|
hooks.length = 0;
|
180
215
|
}
|
@@ -262,7 +297,7 @@ function _isRelevantToSettings2(settings) {
|
|
262
297
|
return settingKeys;
|
263
298
|
}
|
264
299
|
for (let i = 0; i < settingKeys.length; i++) {
|
265
|
-
if (settings[settingKeys[i]] !==
|
300
|
+
if (settings[settingKeys[i]] !== undefined) {
|
266
301
|
return true;
|
267
302
|
}
|
268
303
|
}
|
package/plugins/base/base.mjs
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
2
2
|
import "core-js/modules/es.array.push.js";
|
3
3
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
4
|
+
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
4
5
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
6
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
7
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
8
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
5
9
|
function _classPrivateMethodGet(receiver, privateSet, fn) { if (!privateSet.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return fn; }
|
10
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
11
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
12
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
6
13
|
import { defineGetter, objectEach } from "../../helpers/object.mjs";
|
7
14
|
import { arrayEach } from "../../helpers/array.mjs";
|
8
15
|
import { getPluginsNames, hasPlugin } from "../registry.mjs";
|
@@ -10,16 +17,17 @@ import { hasCellType } from "../../cellTypes/registry.mjs";
|
|
10
17
|
import { hasEditor } from "../../editors/registry.mjs";
|
11
18
|
import { hasRenderer } from "../../renderers/registry.mjs";
|
12
19
|
import { hasValidator } from "../../validators/registry.mjs";
|
20
|
+
import EventManager from "../../eventManager.mjs";
|
13
21
|
const DEPS_TYPE_CHECKERS = new Map([['plugin', hasPlugin], ['cell-type', hasCellType], ['editor', hasEditor], ['renderer', hasRenderer], ['validator', hasValidator]]);
|
14
22
|
export const PLUGIN_KEY = 'base';
|
15
|
-
const
|
16
|
-
const missingDependeciesMsgs = [];
|
23
|
+
const missingDepsMsgs = [];
|
17
24
|
let initializedPlugins = null;
|
18
25
|
|
19
26
|
/**
|
20
27
|
* @util
|
21
28
|
* @property {Core} hot Handsontable instance.
|
22
29
|
*/
|
30
|
+
var _hooks = /*#__PURE__*/new WeakMap();
|
23
31
|
var _isRelevantToSettings = /*#__PURE__*/new WeakSet();
|
24
32
|
export class BasePlugin {
|
25
33
|
static get PLUGIN_KEY() {
|
@@ -39,6 +47,12 @@ export class BasePlugin {
|
|
39
47
|
return [this.PLUGIN_KEY];
|
40
48
|
}
|
41
49
|
|
50
|
+
/**
|
51
|
+
* The instance of the {@link EventManager} class.
|
52
|
+
*
|
53
|
+
* @type {EventManager}
|
54
|
+
*/
|
55
|
+
|
42
56
|
/**
|
43
57
|
* @param {object} hotInstance Handsontable instance.
|
44
58
|
*/
|
@@ -53,6 +67,34 @@ export class BasePlugin {
|
|
53
67
|
* @returns {boolean}
|
54
68
|
*/
|
55
69
|
_classPrivateMethodInitSpec(this, _isRelevantToSettings);
|
70
|
+
_defineProperty(this, "eventManager", new EventManager(this));
|
71
|
+
/**
|
72
|
+
* @type {string}
|
73
|
+
*/
|
74
|
+
_defineProperty(this, "pluginName", null);
|
75
|
+
/**
|
76
|
+
* @type {Function[]}
|
77
|
+
*/
|
78
|
+
_defineProperty(this, "pluginsInitializedCallbacks", []);
|
79
|
+
/**
|
80
|
+
* @type {boolean}
|
81
|
+
*/
|
82
|
+
_defineProperty(this, "isPluginsReady", false);
|
83
|
+
/**
|
84
|
+
* @type {boolean}
|
85
|
+
*/
|
86
|
+
_defineProperty(this, "enabled", false);
|
87
|
+
/**
|
88
|
+
* @type {boolean}
|
89
|
+
*/
|
90
|
+
_defineProperty(this, "initialized", false);
|
91
|
+
/**
|
92
|
+
* Collection of the reference to the plugins hooks.
|
93
|
+
*/
|
94
|
+
_classPrivateFieldInitSpec(this, _hooks, {
|
95
|
+
writable: true,
|
96
|
+
value: {}
|
97
|
+
});
|
56
98
|
/**
|
57
99
|
* Handsontable instance.
|
58
100
|
*
|
@@ -61,15 +103,7 @@ export class BasePlugin {
|
|
61
103
|
defineGetter(this, 'hot', hotInstance, {
|
62
104
|
writable: false
|
63
105
|
});
|
64
|
-
privatePool.set(this, {
|
65
|
-
hooks: {}
|
66
|
-
});
|
67
106
|
initializedPlugins = null;
|
68
|
-
this.pluginName = null;
|
69
|
-
this.pluginsInitializedCallbacks = [];
|
70
|
-
this.isPluginsReady = false;
|
71
|
-
this.enabled = false;
|
72
|
-
this.initialized = false;
|
73
107
|
this.hot.addHook('afterPluginsInitialized', () => this.onAfterPluginsInitialized());
|
74
108
|
this.hot.addHook('afterUpdateSettings', newSettings => this.onUpdateSettings(newSettings));
|
75
109
|
this.hot.addHook('beforeInit', () => this.init());
|
@@ -77,10 +111,10 @@ export class BasePlugin {
|
|
77
111
|
init() {
|
78
112
|
this.pluginName = this.hot.getPluginName(this);
|
79
113
|
const pluginDeps = this.constructor.PLUGIN_DEPS;
|
80
|
-
const
|
81
|
-
if (
|
114
|
+
const deps = Array.isArray(pluginDeps) ? pluginDeps : [];
|
115
|
+
if (deps.length > 0) {
|
82
116
|
const missingDependencies = [];
|
83
|
-
|
117
|
+
deps.forEach(dependency => {
|
84
118
|
const [type, moduleName] = dependency.split(':');
|
85
119
|
if (!DEPS_TYPE_CHECKERS.has(type)) {
|
86
120
|
throw new Error(`Unknown plugin dependency type "${type}" was found.`);
|
@@ -91,7 +125,7 @@ export class BasePlugin {
|
|
91
125
|
});
|
92
126
|
if (missingDependencies.length > 0) {
|
93
127
|
const errorMsg = [`The ${this.pluginName} plugin requires the following modules:\n`, `${missingDependencies.join('\n')}\n`].join('');
|
94
|
-
|
128
|
+
missingDepsMsgs.push(errorMsg);
|
95
129
|
}
|
96
130
|
}
|
97
131
|
if (!initializedPlugins) {
|
@@ -114,8 +148,8 @@ export class BasePlugin {
|
|
114
148
|
});
|
115
149
|
const isAllPluginsAreInitialized = initializedPlugins.length === 0;
|
116
150
|
if (isAllPluginsAreInitialized) {
|
117
|
-
if (
|
118
|
-
const errorMsg = [`${
|
151
|
+
if (missingDepsMsgs.length > 0) {
|
152
|
+
const errorMsg = [`${missingDepsMsgs.join('\n')}\n`, 'You have to import and register them manually.'].join('');
|
119
153
|
throw new Error(errorMsg);
|
120
154
|
}
|
121
155
|
this.hot.runHooks('afterPluginsInitialized');
|
@@ -148,11 +182,11 @@ export class BasePlugin {
|
|
148
182
|
* @param {Function} callback The listener function to add.
|
149
183
|
*/
|
150
184
|
addHook(name, callback) {
|
151
|
-
|
152
|
-
const hooks =
|
185
|
+
_classPrivateFieldGet(this, _hooks)[name] = _classPrivateFieldGet(this, _hooks)[name] || [];
|
186
|
+
const hooks = _classPrivateFieldGet(this, _hooks)[name];
|
153
187
|
this.hot.addHook(name, callback);
|
154
188
|
hooks.push(callback);
|
155
|
-
|
189
|
+
_classPrivateFieldGet(this, _hooks)[name] = hooks;
|
156
190
|
}
|
157
191
|
|
158
192
|
/**
|
@@ -161,7 +195,7 @@ export class BasePlugin {
|
|
161
195
|
* @param {string} name The hook name.
|
162
196
|
*/
|
163
197
|
removeHooks(name) {
|
164
|
-
arrayEach(
|
198
|
+
arrayEach(_classPrivateFieldGet(this, _hooks)[name] || [], callback => {
|
165
199
|
this.hot.removeHook(name, callback);
|
166
200
|
});
|
167
201
|
}
|
@@ -170,7 +204,7 @@ export class BasePlugin {
|
|
170
204
|
* Clear all hooks.
|
171
205
|
*/
|
172
206
|
clearHooks() {
|
173
|
-
const hooks =
|
207
|
+
const hooks = _classPrivateFieldGet(this, _hooks);
|
174
208
|
objectEach(hooks, (callbacks, name) => this.removeHooks(name));
|
175
209
|
hooks.length = 0;
|
176
210
|
}
|
@@ -257,7 +291,7 @@ function _isRelevantToSettings2(settings) {
|
|
257
291
|
return settingKeys;
|
258
292
|
}
|
259
293
|
for (let i = 0; i < settingKeys.length; i++) {
|
260
|
-
if (settings[settingKeys[i]] !==
|
294
|
+
if (settings[settingKeys[i]] !== undefined) {
|
261
295
|
return true;
|
262
296
|
}
|
263
297
|
}
|