handsontable 0.0.0-next-bfb0e3a-20240403 → 0.0.0-next-5a535ed-20240403
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of handsontable might be problematic. Click here for more details.
- package/3rdparty/walkontable/src/calculator/viewportColumns.js +17 -12
- package/3rdparty/walkontable/src/calculator/viewportColumns.mjs +17 -12
- package/3rdparty/walkontable/src/calculator/viewportRows.js +15 -10
- package/3rdparty/walkontable/src/calculator/viewportRows.mjs +15 -10
- package/3rdparty/walkontable/src/cell/coords.js +17 -12
- package/3rdparty/walkontable/src/cell/coords.mjs +17 -12
- package/3rdparty/walkontable/src/cell/range.d.ts +1 -2
- package/3rdparty/walkontable/src/cell/range.js +28 -40
- package/3rdparty/walkontable/src/cell/range.mjs +28 -40
- package/3rdparty/walkontable/src/core/_base.js +1 -1
- package/3rdparty/walkontable/src/core/_base.mjs +1 -1
- package/3rdparty/walkontable/src/event.js +104 -72
- package/3rdparty/walkontable/src/event.mjs +104 -72
- package/3rdparty/walkontable/src/overlays.js +1 -1
- package/3rdparty/walkontable/src/overlays.mjs +1 -1
- package/3rdparty/walkontable/src/scroll.js +17 -15
- package/3rdparty/walkontable/src/scroll.mjs +17 -15
- package/3rdparty/walkontable/src/selection/manager.js +69 -48
- package/3rdparty/walkontable/src/selection/manager.mjs +69 -48
- package/3rdparty/walkontable/src/selection/scanner.js +42 -33
- package/3rdparty/walkontable/src/selection/scanner.mjs +42 -33
- package/3rdparty/walkontable/src/utils/columnStretching.js +44 -27
- package/3rdparty/walkontable/src/utils/columnStretching.mjs +44 -27
- package/3rdparty/walkontable/src/utils/orderView/view.js +1 -1
- package/3rdparty/walkontable/src/utils/orderView/view.mjs +1 -1
- package/base.js +2 -2
- package/base.mjs +2 -2
- package/core/viewportScroll/index.js +1 -4
- package/core/viewportScroll/index.mjs +1 -4
- package/core.d.ts +3 -4
- package/core.js +22 -77
- package/core.mjs +22 -77
- package/dataMap/dataSource.js +1 -1
- package/dataMap/dataSource.mjs +1 -1
- package/dataMap/metaManager/metaLayers/cellMeta.js +1 -1
- package/dataMap/metaManager/metaLayers/cellMeta.mjs +1 -1
- package/dataMap/metaManager/metaSchema.js +1 -1
- package/dataMap/metaManager/metaSchema.mjs +1 -1
- package/dataMap/replaceData.js +1 -1
- package/dataMap/replaceData.mjs +1 -1
- package/dist/handsontable.css +4 -4
- package/dist/handsontable.full.css +4 -4
- package/dist/handsontable.full.js +9117 -8969
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +292 -292
- package/dist/handsontable.js +6569 -6874
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +25 -25
- package/dist/languages/all.min.js +1 -1
- package/dist/languages/ar-AR.min.js +1 -1
- package/dist/languages/cs-CZ.min.js +1 -1
- package/dist/languages/de-CH.min.js +1 -1
- package/dist/languages/de-DE.min.js +1 -1
- package/dist/languages/en-US.min.js +1 -1
- package/dist/languages/es-MX.min.js +1 -1
- package/dist/languages/fr-FR.min.js +1 -1
- package/dist/languages/hr-HR.min.js +1 -1
- package/dist/languages/it-IT.min.js +1 -1
- package/dist/languages/ja-JP.min.js +1 -1
- package/dist/languages/ko-KR.min.js +1 -1
- package/dist/languages/lv-LV.min.js +1 -1
- package/dist/languages/nb-NO.min.js +1 -1
- package/dist/languages/nl-NL.min.js +1 -1
- package/dist/languages/pl-PL.min.js +1 -1
- package/dist/languages/pt-BR.min.js +1 -1
- package/dist/languages/ru-RU.min.js +1 -1
- package/dist/languages/sr-SP.min.js +1 -1
- package/dist/languages/zh-CN.min.js +1 -1
- package/dist/languages/zh-TW.min.js +1 -1
- package/editorManager.js +23 -25
- package/editorManager.mjs +23 -25
- package/editors/autocompleteEditor/autocompleteEditor.js +10 -6
- package/editors/autocompleteEditor/autocompleteEditor.mjs +10 -6
- package/editors/selectEditor/selectEditor.js +19 -20
- package/editors/selectEditor/selectEditor.mjs +19 -20
- package/eventManager.js +1 -1
- package/eventManager.mjs +1 -1
- package/focusManager.js +82 -64
- package/focusManager.mjs +82 -64
- package/helpers/dom/element.js +1 -1
- package/helpers/dom/element.mjs +1 -1
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/helpers/object.js +2 -2
- package/helpers/object.mjs +2 -2
- package/index.d.ts +0 -10
- package/package.json +2 -7
- package/pluginHooks.d.ts +3 -4
- package/pluginHooks.js +38 -99
- package/pluginHooks.mjs +38 -99
- package/plugins/autoColumnSize/autoColumnSize.js +65 -49
- package/plugins/autoColumnSize/autoColumnSize.mjs +65 -49
- package/plugins/autoRowSize/autoRowSize.js +34 -28
- package/plugins/autoRowSize/autoRowSize.mjs +34 -28
- package/plugins/autofill/autofill.js +38 -30
- package/plugins/autofill/autofill.mjs +38 -30
- package/plugins/base/base.js +17 -12
- package/plugins/base/base.mjs +17 -12
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.js +5 -5
- package/plugins/bindRowsWithHeaders/bindRowsWithHeaders.mjs +5 -5
- package/plugins/collapsibleColumns/collapsibleColumns.js +50 -59
- package/plugins/collapsibleColumns/collapsibleColumns.mjs +50 -59
- package/plugins/columnSorting/columnSorting.js +45 -49
- package/plugins/columnSorting/columnSorting.mjs +45 -49
- package/plugins/columnSummary/columnSummary.js +26 -22
- package/plugins/columnSummary/columnSummary.mjs +26 -22
- package/plugins/comments/comments.js +158 -116
- package/plugins/comments/comments.mjs +158 -116
- package/plugins/contextMenu/contextMenu.js +26 -20
- package/plugins/contextMenu/contextMenu.mjs +26 -20
- package/plugins/contextMenu/itemsFactory.js +1 -1
- package/plugins/contextMenu/itemsFactory.mjs +1 -1
- package/plugins/contextMenu/menu/defaultShortcutsList.js +10 -26
- package/plugins/contextMenu/menu/defaultShortcutsList.mjs +10 -26
- package/plugins/contextMenu/menu/menu.js +21 -13
- package/plugins/contextMenu/menu/menu.mjs +21 -13
- package/plugins/contextMenu/menu/positioner.js +58 -41
- package/plugins/contextMenu/menu/positioner.mjs +58 -41
- package/plugins/copyPaste/copyPaste.js +157 -116
- package/plugins/copyPaste/copyPaste.mjs +157 -116
- package/plugins/copyPaste/copyableRanges.js +66 -43
- package/plugins/copyPaste/copyableRanges.mjs +66 -43
- package/plugins/customBorders/customBorders.js +13 -11
- package/plugins/customBorders/customBorders.mjs +13 -11
- package/plugins/dragToScroll/dragToScroll.js +6 -6
- package/plugins/dragToScroll/dragToScroll.mjs +6 -6
- package/plugins/dropdownMenu/dropdownMenu.js +106 -80
- package/plugins/dropdownMenu/dropdownMenu.mjs +106 -80
- package/plugins/exportFile/dataProvider.js +1 -1
- package/plugins/exportFile/dataProvider.mjs +1 -1
- package/plugins/filters/component/actionBar.js +9 -9
- package/plugins/filters/component/actionBar.mjs +8 -8
- package/plugins/filters/component/condition.js +15 -13
- package/plugins/filters/component/condition.mjs +15 -13
- package/plugins/filters/component/operators.js +6 -6
- package/plugins/filters/component/operators.mjs +6 -6
- package/plugins/filters/component/value.js +28 -24
- package/plugins/filters/component/value.mjs +28 -24
- package/plugins/filters/conditionUpdateObserver.js +24 -22
- package/plugins/filters/conditionUpdateObserver.mjs +24 -22
- package/plugins/filters/dataFilter.js +1 -1
- package/plugins/filters/dataFilter.mjs +1 -1
- package/plugins/filters/filters.js +95 -81
- package/plugins/filters/filters.mjs +95 -81
- package/plugins/filters/ui/input.js +19 -13
- package/plugins/filters/ui/input.mjs +19 -13
- package/plugins/filters/ui/link.js +13 -8
- package/plugins/filters/ui/link.mjs +13 -8
- package/plugins/filters/ui/multipleSelect.js +112 -85
- package/plugins/filters/ui/multipleSelect.mjs +112 -85
- package/plugins/filters/ui/radioInput.js +20 -12
- package/plugins/filters/ui/radioInput.mjs +20 -12
- package/plugins/filters/ui/select.js +72 -50
- package/plugins/filters/ui/select.mjs +71 -49
- package/plugins/formulas/formulas.js +326 -268
- package/plugins/formulas/formulas.mjs +327 -269
- package/plugins/formulas/indexSyncer/axisSyncer.js +61 -38
- package/plugins/formulas/indexSyncer/axisSyncer.mjs +61 -38
- package/plugins/formulas/indexSyncer/index.js +48 -25
- package/plugins/formulas/indexSyncer/index.mjs +48 -25
- package/plugins/hiddenColumns/hiddenColumns.js +83 -64
- package/plugins/hiddenColumns/hiddenColumns.mjs +83 -64
- package/plugins/hiddenRows/hiddenRows.js +82 -63
- package/plugins/hiddenRows/hiddenRows.mjs +82 -63
- package/plugins/manualColumnFreeze/manualColumnFreeze.js +32 -24
- package/plugins/manualColumnFreeze/manualColumnFreeze.mjs +33 -25
- package/plugins/manualColumnMove/manualColumnMove.js +170 -126
- package/plugins/manualColumnMove/manualColumnMove.mjs +170 -126
- package/plugins/manualColumnResize/manualColumnResize.js +230 -169
- package/plugins/manualColumnResize/manualColumnResize.mjs +230 -169
- package/plugins/manualRowMove/manualRowMove.js +128 -99
- package/plugins/manualRowMove/manualRowMove.mjs +128 -99
- package/plugins/manualRowResize/manualRowResize.js +209 -150
- package/plugins/manualRowResize/manualRowResize.mjs +209 -150
- package/plugins/mergeCells/calculations/selection.js +71 -2
- package/plugins/mergeCells/calculations/selection.mjs +71 -2
- package/plugins/mergeCells/cellsCollection.js +1 -117
- package/plugins/mergeCells/cellsCollection.mjs +1 -117
- package/plugins/mergeCells/contextMenuItem/toggleMerge.js +1 -11
- package/plugins/mergeCells/contextMenuItem/toggleMerge.mjs +1 -11
- package/plugins/mergeCells/mergeCells.js +397 -499
- package/plugins/mergeCells/mergeCells.mjs +397 -499
- package/plugins/multiColumnSorting/multiColumnSorting.js +2 -8
- package/plugins/multiColumnSorting/multiColumnSorting.mjs +2 -8
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.js +1 -1
- package/plugins/multipleSelectionHandles/multipleSelectionHandles.mjs +1 -1
- package/plugins/nestedHeaders/nestedHeaders.js +253 -205
- package/plugins/nestedHeaders/nestedHeaders.mjs +254 -206
- package/plugins/nestedHeaders/stateManager/headersTree.js +32 -21
- package/plugins/nestedHeaders/stateManager/headersTree.mjs +32 -21
- package/plugins/nestedHeaders/stateManager/index.js +41 -30
- package/plugins/nestedHeaders/stateManager/index.mjs +41 -30
- package/plugins/nestedHeaders/stateManager/sourceSettings.js +30 -19
- package/plugins/nestedHeaders/stateManager/sourceSettings.mjs +30 -19
- package/plugins/nestedRows/data/dataManager.js +1 -1
- package/plugins/nestedRows/data/dataManager.mjs +1 -1
- package/plugins/nestedRows/nestedRows.js +182 -151
- package/plugins/nestedRows/nestedRows.mjs +183 -152
- package/plugins/nestedRows/ui/contextMenu.js +15 -11
- package/plugins/nestedRows/ui/contextMenu.mjs +14 -10
- package/plugins/nestedRows/utils/rowMoveController.js +1 -1
- package/plugins/nestedRows/utils/rowMoveController.mjs +1 -1
- package/plugins/persistentState/storage.js +2 -2
- package/plugins/persistentState/storage.mjs +2 -2
- package/plugins/search/search.js +7 -7
- package/plugins/search/search.mjs +7 -7
- package/plugins/touchScroll/touchScroll.js +19 -15
- package/plugins/touchScroll/touchScroll.mjs +20 -16
- package/plugins/trimRows/trimRows.js +6 -6
- package/plugins/trimRows/trimRows.mjs +6 -6
- package/renderers/checkboxRenderer/checkboxRenderer.js +5 -8
- package/renderers/checkboxRenderer/checkboxRenderer.mjs +5 -8
- package/selection/highlight/highlight.js +14 -14
- package/selection/highlight/highlight.mjs +13 -13
- package/selection/highlight/visualSelection.js +0 -2
- package/selection/highlight/visualSelection.mjs +0 -2
- package/selection/selection.js +67 -225
- package/selection/selection.mjs +66 -224
- package/selection/transformation.js +118 -149
- package/selection/transformation.mjs +118 -149
- package/shortcutContexts/commands/editor/closeAndSave.js +2 -2
- package/shortcutContexts/commands/editor/closeAndSave.mjs +2 -2
- package/shortcutContexts/commands/editor/open.js +3 -18
- package/shortcutContexts/commands/editor/open.mjs +3 -18
- package/shortcutContexts/commands/extendCellsSelection/down.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/down.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/left.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/left.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/right.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/right.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toColumns.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toColumns.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.js +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostBottom.mjs +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.js +3 -9
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineEnd.mjs +3 -9
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.js +3 -10
- package/shortcutContexts/commands/extendCellsSelection/toMostInlineStart.mjs +3 -10
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.js +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostLeft.mjs +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.js +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostRight.mjs +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.js +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toMostTop.mjs +1 -3
- package/shortcutContexts/commands/extendCellsSelection/toRows.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/toRows.mjs +1 -1
- package/shortcutContexts/commands/extendCellsSelection/up.js +1 -1
- package/shortcutContexts/commands/extendCellsSelection/up.mjs +1 -1
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.js +1 -6
- package/shortcutContexts/commands/moveCellSelection/inlineEnd.mjs +1 -6
- package/shortcutContexts/commands/moveCellSelection/inlineStart.js +1 -6
- package/shortcutContexts/commands/moveCellSelection/inlineStart.mjs +1 -6
- package/shortcutContexts/grid.js +3 -9
- package/shortcutContexts/grid.mjs +3 -9
- package/shortcuts/context.js +1 -2
- package/shortcuts/context.mjs +1 -2
- package/tableView.js +78 -52
- package/tableView.mjs +78 -52
- package/translations/changesObservable/observable.js +38 -21
- package/translations/changesObservable/observable.mjs +38 -21
- package/translations/changesObservable/observer.js +12 -7
- package/translations/changesObservable/observer.mjs +11 -6
- package/translations/mapCollections/aggregatedCollection.js +1 -1
- package/translations/mapCollections/aggregatedCollection.mjs +1 -1
- package/translations/maps/indexMap.js +1 -1
- package/translations/maps/indexMap.mjs +1 -1
- package/utils/dataStructures/linkedList.js +1 -6
- package/utils/dataStructures/linkedList.mjs +1 -6
- package/utils/dataStructures/tree.js +1 -1
- package/utils/dataStructures/tree.mjs +1 -1
- package/utils/interval.js +44 -26
- package/utils/interval.mjs +44 -26
- package/core/viewportScroll/scrollStrategies/focusScroll.js +0 -15
- package/core/viewportScroll/scrollStrategies/focusScroll.mjs +0 -11
- package/i18n/languages/ar-AR.d.ts +0 -5
- package/i18n/languages/cs-CZ.d.ts +0 -5
- package/i18n/languages/hr-HR.d.ts +0 -5
- package/i18n/languages/sr-SP.d.ts +0 -5
- package/plugins/mergeCells/focusOrder.js +0 -305
- package/plugins/mergeCells/focusOrder.mjs +0 -300
package/tableView.mjs
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
-
import "core-js/modules/es.error.cause.js";
|
2
1
|
import "core-js/modules/es.array.push.js";
|
2
|
+
import "core-js/modules/es.error.cause.js";
|
3
3
|
function _classPrivateMethodInitSpec(obj, privateSet) { _checkPrivateRedeclaration(obj, privateSet); privateSet.add(obj); }
|
4
4
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
5
5
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
6
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
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
8
8
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
9
|
-
function
|
10
|
-
function
|
11
|
-
function
|
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 _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
12
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
13
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
14
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
12
15
|
import { addClass, clearTextSelection, empty, fastInnerHTML, fastInnerText, getScrollbarWidth, hasClass, isChildOf, isInput, isOutsideInput, isVisible, setAttribute, getParentWindow } from "./helpers/dom/element.mjs";
|
13
16
|
import EventManager from "./eventManager.mjs";
|
14
17
|
import { isImmediatePropagationStopped, isRightClick, isLeftClick } from "./helpers/dom/event.mjs";
|
@@ -27,18 +30,25 @@ var _mouseDown = /*#__PURE__*/new WeakMap();
|
|
27
30
|
var _table = /*#__PURE__*/new WeakMap();
|
28
31
|
var _lastWidth = /*#__PURE__*/new WeakMap();
|
29
32
|
var _lastHeight = /*#__PURE__*/new WeakMap();
|
30
|
-
var
|
33
|
+
var _getAriaColcount = /*#__PURE__*/new WeakSet();
|
34
|
+
var _updateAriaColcount = /*#__PURE__*/new WeakSet();
|
31
35
|
class TableView {
|
32
36
|
/**
|
33
37
|
* @param {Hanstontable} hotInstance Instance of {@link Handsontable}.
|
34
38
|
*/
|
35
39
|
constructor(hotInstance) {
|
40
|
+
/**
|
41
|
+
* Update the `aria-colcount` attribute by the provided value.
|
42
|
+
*
|
43
|
+
* @param {number} delta The number of columns to add or remove to the aria tag.
|
44
|
+
*/
|
45
|
+
_classPrivateMethodInitSpec(this, _updateAriaColcount);
|
36
46
|
/**
|
37
47
|
* Return the value of the `aria-colcount` attribute.
|
38
48
|
*
|
39
49
|
* @returns {number} The value of the `aria-colcount` attribute.
|
40
50
|
*/
|
41
|
-
_classPrivateMethodInitSpec(this,
|
51
|
+
_classPrivateMethodInitSpec(this, _getAriaColcount);
|
42
52
|
/**
|
43
53
|
* Instance of {@link Handsontable}.
|
44
54
|
*
|
@@ -93,14 +103,20 @@ class TableView {
|
|
93
103
|
*
|
94
104
|
* @type {number}
|
95
105
|
*/
|
96
|
-
_classPrivateFieldInitSpec(this, _columnHeadersCount,
|
106
|
+
_classPrivateFieldInitSpec(this, _columnHeadersCount, {
|
107
|
+
writable: true,
|
108
|
+
value: 0
|
109
|
+
});
|
97
110
|
/**
|
98
111
|
* The total number of the row header renderers applied to the table through the
|
99
112
|
* `afterGetRowHeaderRenderers` hook.
|
100
113
|
*
|
101
114
|
* @type {number}
|
102
115
|
*/
|
103
|
-
_classPrivateFieldInitSpec(this, _rowHeadersCount,
|
116
|
+
_classPrivateFieldInitSpec(this, _rowHeadersCount, {
|
117
|
+
writable: true,
|
118
|
+
value: 0
|
119
|
+
});
|
104
120
|
/**
|
105
121
|
* The flag determines if the `adjustElementsSize` method call was made during
|
106
122
|
* the render suspending. If true, the method has to be triggered once after render
|
@@ -115,29 +131,44 @@ class TableView {
|
|
115
131
|
*
|
116
132
|
* @type {boolean}
|
117
133
|
*/
|
118
|
-
_classPrivateFieldInitSpec(this, _selectionMouseDown,
|
134
|
+
_classPrivateFieldInitSpec(this, _selectionMouseDown, {
|
135
|
+
writable: true,
|
136
|
+
value: false
|
137
|
+
});
|
119
138
|
/**
|
120
139
|
* @type {boolean}
|
121
140
|
*/
|
122
|
-
_classPrivateFieldInitSpec(this, _mouseDown,
|
141
|
+
_classPrivateFieldInitSpec(this, _mouseDown, {
|
142
|
+
writable: true,
|
143
|
+
value: void 0
|
144
|
+
});
|
123
145
|
/**
|
124
146
|
* Main <TABLE> element.
|
125
147
|
*
|
126
148
|
* @type {HTMLTableElement}
|
127
149
|
*/
|
128
|
-
_classPrivateFieldInitSpec(this, _table,
|
150
|
+
_classPrivateFieldInitSpec(this, _table, {
|
151
|
+
writable: true,
|
152
|
+
value: void 0
|
153
|
+
});
|
129
154
|
/**
|
130
155
|
* Cached width of the rootElement.
|
131
156
|
*
|
132
157
|
* @type {number}
|
133
158
|
*/
|
134
|
-
_classPrivateFieldInitSpec(this, _lastWidth,
|
159
|
+
_classPrivateFieldInitSpec(this, _lastWidth, {
|
160
|
+
writable: true,
|
161
|
+
value: 0
|
162
|
+
});
|
135
163
|
/**
|
136
164
|
* Cached height of the rootElement.
|
137
165
|
*
|
138
166
|
* @type {number}
|
139
167
|
*/
|
140
|
-
_classPrivateFieldInitSpec(this, _lastHeight,
|
168
|
+
_classPrivateFieldInitSpec(this, _lastHeight, {
|
169
|
+
writable: true,
|
170
|
+
value: 0
|
171
|
+
});
|
141
172
|
this.hot = hotInstance;
|
142
173
|
this.eventManager = new EventManager(this.hot);
|
143
174
|
this.settings = this.hot.getSettings();
|
@@ -246,21 +277,21 @@ class TableView {
|
|
246
277
|
rootElement.setAttribute('data-originalstyle', originalStyle); // needed to retrieve original style in jsFiddle link generator in HT examples. may be removed in future versions
|
247
278
|
}
|
248
279
|
addClass(rootElement, 'handsontable');
|
249
|
-
_classPrivateFieldSet(
|
250
|
-
addClass(_classPrivateFieldGet(
|
280
|
+
_classPrivateFieldSet(this, _table, rootDocument.createElement('TABLE'));
|
281
|
+
addClass(_classPrivateFieldGet(this, _table), 'htCore');
|
251
282
|
if (this.hot.getSettings().tableClassName) {
|
252
|
-
addClass(_classPrivateFieldGet(
|
283
|
+
addClass(_classPrivateFieldGet(this, _table), this.hot.getSettings().tableClassName);
|
253
284
|
}
|
254
285
|
if (this.settings.ariaTags) {
|
255
|
-
setAttribute(_classPrivateFieldGet(
|
286
|
+
setAttribute(_classPrivateFieldGet(this, _table), [A11Y_PRESENTATION()]);
|
256
287
|
setAttribute(rootElement, [A11Y_TREEGRID(), A11Y_ROWCOUNT(-1), A11Y_COLCOUNT(this.hot.countCols()), A11Y_MULTISELECTABLE()]);
|
257
288
|
}
|
258
289
|
this.THEAD = rootDocument.createElement('THEAD');
|
259
|
-
_classPrivateFieldGet(
|
290
|
+
_classPrivateFieldGet(this, _table).appendChild(this.THEAD);
|
260
291
|
this.TBODY = rootDocument.createElement('TBODY');
|
261
|
-
_classPrivateFieldGet(
|
262
|
-
this.hot.table = _classPrivateFieldGet(
|
263
|
-
this.hot.container.insertBefore(_classPrivateFieldGet(
|
292
|
+
_classPrivateFieldGet(this, _table).appendChild(this.TBODY);
|
293
|
+
this.hot.table = _classPrivateFieldGet(this, _table);
|
294
|
+
this.hot.container.insertBefore(_classPrivateFieldGet(this, _table), this.hot.container.firstChild);
|
264
295
|
}
|
265
296
|
|
266
297
|
/**
|
@@ -277,7 +308,7 @@ class TableView {
|
|
277
308
|
} = this.hot;
|
278
309
|
const documentElement = rootDocument.documentElement;
|
279
310
|
this.eventManager.addEventListener(rootElement, 'mousedown', event => {
|
280
|
-
_classPrivateFieldSet(
|
311
|
+
_classPrivateFieldSet(this, _selectionMouseDown, true);
|
281
312
|
if (!this.isTextSelectionAllowed(event.target)) {
|
282
313
|
clearTextSelection(rootWindow);
|
283
314
|
event.preventDefault();
|
@@ -285,10 +316,10 @@ class TableView {
|
|
285
316
|
}
|
286
317
|
});
|
287
318
|
this.eventManager.addEventListener(rootElement, 'mouseup', () => {
|
288
|
-
_classPrivateFieldSet(
|
319
|
+
_classPrivateFieldSet(this, _selectionMouseDown, false);
|
289
320
|
});
|
290
321
|
this.eventManager.addEventListener(rootElement, 'mousemove', event => {
|
291
|
-
if (_classPrivateFieldGet(
|
322
|
+
if (_classPrivateFieldGet(this, _selectionMouseDown) && !this.isTextSelectionAllowed(event.target)) {
|
292
323
|
// Clear selection only when fragmentSelection is enabled, otherwise clearing selection breaks the IME editor.
|
293
324
|
if (this.settings.fragmentSelection) {
|
294
325
|
clearTextSelection(rootWindow);
|
@@ -306,7 +337,7 @@ class TableView {
|
|
306
337
|
if (selection.isInProgress() && isLeftClick(event)) {
|
307
338
|
selection.finish();
|
308
339
|
}
|
309
|
-
_classPrivateFieldSet(
|
340
|
+
_classPrivateFieldSet(this, _mouseDown, false);
|
310
341
|
const isOutsideInputElement = isOutsideInput(rootDocument.activeElement);
|
311
342
|
if (isInput(rootDocument.activeElement) && !isOutsideInputElement) {
|
312
343
|
return;
|
@@ -318,21 +349,21 @@ class TableView {
|
|
318
349
|
this.eventManager.addEventListener(documentElement, 'contextmenu', event => {
|
319
350
|
if (selection.isInProgress() && isRightClick(event)) {
|
320
351
|
selection.finish();
|
321
|
-
_classPrivateFieldSet(
|
352
|
+
_classPrivateFieldSet(this, _mouseDown, false);
|
322
353
|
}
|
323
354
|
});
|
324
355
|
this.eventManager.addEventListener(documentElement, 'touchend', () => {
|
325
356
|
if (selection.isInProgress()) {
|
326
357
|
selection.finish();
|
327
358
|
}
|
328
|
-
_classPrivateFieldSet(
|
359
|
+
_classPrivateFieldSet(this, _mouseDown, false);
|
329
360
|
});
|
330
361
|
this.eventManager.addEventListener(documentElement, 'mousedown', event => {
|
331
362
|
const originalTarget = event.target;
|
332
363
|
const eventX = event.x || event.clientX;
|
333
364
|
const eventY = event.y || event.clientY;
|
334
365
|
let next = event.target;
|
335
|
-
if (_classPrivateFieldGet(
|
366
|
+
if (_classPrivateFieldGet(this, _mouseDown) || !rootElement || !this.hot.view) {
|
336
367
|
return; // it must have been started in a cell
|
337
368
|
}
|
338
369
|
|
@@ -378,7 +409,7 @@ class TableView {
|
|
378
409
|
});
|
379
410
|
parentWindow = getParentWindow(parentWindow);
|
380
411
|
}
|
381
|
-
this.eventManager.addEventListener(_classPrivateFieldGet(
|
412
|
+
this.eventManager.addEventListener(_classPrivateFieldGet(this, _table), 'selectstart', event => {
|
382
413
|
if (this.settings.fragmentSelection || isInput(event.target)) {
|
383
414
|
return;
|
384
415
|
}
|
@@ -608,7 +639,7 @@ class TableView {
|
|
608
639
|
ariaTags: this.settings.ariaTags,
|
609
640
|
rtlMode: this.hot.isRtl(),
|
610
641
|
externalRowCalculator: this.hot.getPlugin('autoRowSize') && this.hot.getPlugin('autoRowSize').isEnabled(),
|
611
|
-
table: _classPrivateFieldGet(
|
642
|
+
table: _classPrivateFieldGet(this, _table),
|
612
643
|
isDataViewInstance: () => isRootInstance(this.hot),
|
613
644
|
preventOverflow: () => this.settings.preventOverflow,
|
614
645
|
preventWheel: () => this.settings.preventWheel,
|
@@ -650,12 +681,12 @@ class TableView {
|
|
650
681
|
});
|
651
682
|
}
|
652
683
|
this.hot.runHooks('afterGetRowHeaderRenderers', headerRenderers);
|
653
|
-
_classPrivateFieldSet(
|
684
|
+
_classPrivateFieldSet(this, _rowHeadersCount, headerRenderers.length);
|
654
685
|
if (this.hot.getSettings().ariaTags) {
|
655
686
|
// Update the aria-colcount attribute.
|
656
687
|
// Only needs to be done once after initialization/data update.
|
657
|
-
if (
|
658
|
-
|
688
|
+
if (_classPrivateMethodGet(this, _getAriaColcount, _getAriaColcount2).call(this) === this.hot.countCols()) {
|
689
|
+
_classPrivateMethodGet(this, _updateAriaColcount, _updateAriaColcount2).call(this, _classPrivateFieldGet(this, _rowHeadersCount));
|
659
690
|
}
|
660
691
|
}
|
661
692
|
return headerRenderers;
|
@@ -671,7 +702,7 @@ class TableView {
|
|
671
702
|
});
|
672
703
|
}
|
673
704
|
this.hot.runHooks('afterGetColumnHeaderRenderers', headerRenderers);
|
674
|
-
_classPrivateFieldSet(
|
705
|
+
_classPrivateFieldSet(this, _columnHeadersCount, headerRenderers.length);
|
675
706
|
return headerRenderers;
|
676
707
|
},
|
677
708
|
columnWidth: renderedColumnIndex => {
|
@@ -727,7 +758,7 @@ class TableView {
|
|
727
758
|
};
|
728
759
|
this.hot.listen();
|
729
760
|
this.activeWt = wt;
|
730
|
-
_classPrivateFieldSet(
|
761
|
+
_classPrivateFieldSet(this, _mouseDown, true);
|
731
762
|
this.hot.runHooks('beforeOnCellMouseDown', event, visualCoords, TD, controller);
|
732
763
|
if (isImmediatePropagationStopped(event)) {
|
733
764
|
return;
|
@@ -744,7 +775,7 @@ class TableView {
|
|
744
775
|
onCellContextMenu: (event, coords, TD, wt) => {
|
745
776
|
const visualCoords = this.translateFromRenderableToVisualCoords(coords);
|
746
777
|
this.activeWt = wt;
|
747
|
-
_classPrivateFieldSet(
|
778
|
+
_classPrivateFieldSet(this, _mouseDown, false);
|
748
779
|
if (this.hot.selection.isInProgress()) {
|
749
780
|
this.hot.selection.finish();
|
750
781
|
}
|
@@ -777,7 +808,7 @@ class TableView {
|
|
777
808
|
if (isImmediatePropagationStopped(event)) {
|
778
809
|
return;
|
779
810
|
}
|
780
|
-
if (_classPrivateFieldGet(
|
811
|
+
if (_classPrivateFieldGet(this, _mouseDown)) {
|
781
812
|
handleMouseEvent(event, {
|
782
813
|
coords: visualCoords,
|
783
814
|
selection: this.hot.selection,
|
@@ -1034,7 +1065,7 @@ class TableView {
|
|
1034
1065
|
* @returns {boolean}
|
1035
1066
|
*/
|
1036
1067
|
isMouseDown() {
|
1037
|
-
return _classPrivateFieldGet(
|
1068
|
+
return _classPrivateFieldGet(this, _mouseDown);
|
1038
1069
|
}
|
1039
1070
|
|
1040
1071
|
/**
|
@@ -1228,8 +1259,8 @@ class TableView {
|
|
1228
1259
|
* @param {number} height The table height.
|
1229
1260
|
*/
|
1230
1261
|
setLastSize(width, height) {
|
1231
|
-
_classPrivateFieldSet(
|
1232
|
-
_classPrivateFieldSet(
|
1262
|
+
_classPrivateFieldSet(this, _lastWidth, width);
|
1263
|
+
_classPrivateFieldSet(this, _lastHeight, height);
|
1233
1264
|
}
|
1234
1265
|
|
1235
1266
|
/**
|
@@ -1239,8 +1270,8 @@ class TableView {
|
|
1239
1270
|
*/
|
1240
1271
|
getLastSize() {
|
1241
1272
|
return {
|
1242
|
-
width: _classPrivateFieldGet(
|
1243
|
-
height: _classPrivateFieldGet(
|
1273
|
+
width: _classPrivateFieldGet(this, _lastWidth),
|
1274
|
+
height: _classPrivateFieldGet(this, _lastHeight)
|
1244
1275
|
};
|
1245
1276
|
}
|
1246
1277
|
|
@@ -1322,7 +1353,7 @@ class TableView {
|
|
1322
1353
|
* @returns {number}
|
1323
1354
|
*/
|
1324
1355
|
getColumnHeadersCount() {
|
1325
|
-
return _classPrivateFieldGet(
|
1356
|
+
return _classPrivateFieldGet(this, _columnHeadersCount);
|
1326
1357
|
}
|
1327
1358
|
|
1328
1359
|
/**
|
@@ -1331,7 +1362,7 @@ class TableView {
|
|
1331
1362
|
* @returns {number}
|
1332
1363
|
*/
|
1333
1364
|
getRowHeadersCount() {
|
1334
|
-
return _classPrivateFieldGet(
|
1365
|
+
return _classPrivateFieldGet(this, _rowHeadersCount);
|
1335
1366
|
}
|
1336
1367
|
|
1337
1368
|
/**
|
@@ -1383,16 +1414,11 @@ class TableView {
|
|
1383
1414
|
this.eventManager.destroy();
|
1384
1415
|
}
|
1385
1416
|
}
|
1386
|
-
function
|
1417
|
+
function _getAriaColcount2() {
|
1387
1418
|
return parseInt(this.hot.rootElement.getAttribute(A11Y_COLCOUNT()[0]), 10);
|
1388
1419
|
}
|
1389
|
-
|
1390
|
-
|
1391
|
-
*
|
1392
|
-
* @param {number} delta The number of columns to add or remove to the aria tag.
|
1393
|
-
*/
|
1394
|
-
function _updateAriaColcount(delta) {
|
1395
|
-
const colCount = _assertClassBrand(_TableView_brand, this, _getAriaColcount).call(this) + delta;
|
1420
|
+
function _updateAriaColcount2(delta) {
|
1421
|
+
const colCount = _classPrivateMethodGet(this, _getAriaColcount, _getAriaColcount2).call(this) + delta;
|
1396
1422
|
setAttribute(this.hot.rootElement, ...A11Y_COLCOUNT(colCount));
|
1397
1423
|
}
|
1398
1424
|
export default TableView;
|
@@ -6,9 +6,11 @@ var _observer = require("./observer");
|
|
6
6
|
var _utils = require("./utils");
|
7
7
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
8
8
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
9
|
-
function _classPrivateFieldGet(
|
10
|
-
function
|
11
|
-
function
|
9
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
10
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
11
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
12
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
13
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
12
14
|
/**
|
13
15
|
* The ChangesObservable module is an object that represents a resource that provides
|
14
16
|
* the ability to observe the changes that happened in the index map indexes during
|
@@ -32,7 +34,10 @@ class ChangesObservable {
|
|
32
34
|
*
|
33
35
|
* @type {ChangesObserver[]}
|
34
36
|
*/
|
35
|
-
_classPrivateFieldInitSpec(this, _observers,
|
37
|
+
_classPrivateFieldInitSpec(this, _observers, {
|
38
|
+
writable: true,
|
39
|
+
value: new Set()
|
40
|
+
});
|
36
41
|
/**
|
37
42
|
* An array with default values that act as a base array that will be compared with
|
38
43
|
* the last saved index state. The changes are generated and immediately send through
|
@@ -41,21 +46,30 @@ class ChangesObservable {
|
|
41
46
|
*
|
42
47
|
* @type {Array}
|
43
48
|
*/
|
44
|
-
_classPrivateFieldInitSpec(this, _indexMatrix,
|
49
|
+
_classPrivateFieldInitSpec(this, _indexMatrix, {
|
50
|
+
writable: true,
|
51
|
+
value: []
|
52
|
+
});
|
45
53
|
/**
|
46
54
|
* An array that holds the indexes state that is currently valid. The value is changed on every
|
47
55
|
* index mapper cache update.
|
48
56
|
*
|
49
57
|
* @type {Array}
|
50
58
|
*/
|
51
|
-
_classPrivateFieldInitSpec(this, _currentIndexState,
|
59
|
+
_classPrivateFieldInitSpec(this, _currentIndexState, {
|
60
|
+
writable: true,
|
61
|
+
value: []
|
62
|
+
});
|
52
63
|
/**
|
53
64
|
* The flag determines if the observable is initialized or not. Not initialized object creates
|
54
65
|
* index matrix once while emitting new changes.
|
55
66
|
*
|
56
67
|
* @type {boolean}
|
57
68
|
*/
|
58
|
-
_classPrivateFieldInitSpec(this, _isMatrixIndexesInitialized,
|
69
|
+
_classPrivateFieldInitSpec(this, _isMatrixIndexesInitialized, {
|
70
|
+
writable: true,
|
71
|
+
value: false
|
72
|
+
});
|
59
73
|
/**
|
60
74
|
* The initial index value allows control from what value the index matrix array will be created.
|
61
75
|
* Changing that value changes how the array diff generates the changes for the initial data
|
@@ -67,8 +81,11 @@ class ChangesObservable {
|
|
67
81
|
*
|
68
82
|
* @type {boolean}
|
69
83
|
*/
|
70
|
-
_classPrivateFieldInitSpec(this, _initialIndexValue,
|
71
|
-
|
84
|
+
_classPrivateFieldInitSpec(this, _initialIndexValue, {
|
85
|
+
writable: true,
|
86
|
+
value: false
|
87
|
+
});
|
88
|
+
_classPrivateFieldSet(this, _initialIndexValue, initialIndexValue !== null && initialIndexValue !== void 0 ? initialIndexValue : false);
|
72
89
|
}
|
73
90
|
|
74
91
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
@@ -97,11 +114,11 @@ class ChangesObservable {
|
|
97
114
|
/* eslint-enable jsdoc/require-description-complete-sentence */
|
98
115
|
createObserver() {
|
99
116
|
const observer = new _observer.ChangesObserver();
|
100
|
-
_classPrivateFieldGet(
|
117
|
+
_classPrivateFieldGet(this, _observers).add(observer);
|
101
118
|
observer.addLocalHook('unsubscribe', () => {
|
102
|
-
_classPrivateFieldGet(
|
119
|
+
_classPrivateFieldGet(this, _observers).delete(observer);
|
103
120
|
});
|
104
|
-
observer._writeInitialChanges((0, _utils.arrayDiff)(_classPrivateFieldGet(
|
121
|
+
observer._writeInitialChanges((0, _utils.arrayDiff)(_classPrivateFieldGet(this, _indexMatrix), _classPrivateFieldGet(this, _currentIndexState)));
|
105
122
|
return observer;
|
106
123
|
}
|
107
124
|
|
@@ -113,21 +130,21 @@ class ChangesObservable {
|
|
113
130
|
* @param {Array} indexesState An array with index map state.
|
114
131
|
*/
|
115
132
|
emit(indexesState) {
|
116
|
-
let currentIndexState = _classPrivateFieldGet(
|
117
|
-
if (!_classPrivateFieldGet(
|
133
|
+
let currentIndexState = _classPrivateFieldGet(this, _currentIndexState);
|
134
|
+
if (!_classPrivateFieldGet(this, _isMatrixIndexesInitialized) || _classPrivateFieldGet(this, _indexMatrix).length !== indexesState.length) {
|
118
135
|
if (indexesState.length === 0) {
|
119
|
-
indexesState = new Array(currentIndexState.length).fill(_classPrivateFieldGet(
|
136
|
+
indexesState = new Array(currentIndexState.length).fill(_classPrivateFieldGet(this, _initialIndexValue));
|
120
137
|
} else {
|
121
|
-
_classPrivateFieldSet(
|
138
|
+
_classPrivateFieldSet(this, _indexMatrix, new Array(indexesState.length).fill(_classPrivateFieldGet(this, _initialIndexValue)));
|
122
139
|
}
|
123
|
-
if (!_classPrivateFieldGet(
|
124
|
-
_classPrivateFieldSet(
|
125
|
-
currentIndexState = _classPrivateFieldGet(
|
140
|
+
if (!_classPrivateFieldGet(this, _isMatrixIndexesInitialized)) {
|
141
|
+
_classPrivateFieldSet(this, _isMatrixIndexesInitialized, true);
|
142
|
+
currentIndexState = _classPrivateFieldGet(this, _indexMatrix);
|
126
143
|
}
|
127
144
|
}
|
128
145
|
const changes = (0, _utils.arrayDiff)(currentIndexState, indexesState);
|
129
|
-
_classPrivateFieldGet(
|
130
|
-
_classPrivateFieldSet(
|
146
|
+
_classPrivateFieldGet(this, _observers).forEach(observer => observer._write(changes));
|
147
|
+
_classPrivateFieldSet(this, _currentIndexState, indexesState);
|
131
148
|
}
|
132
149
|
}
|
133
150
|
exports.ChangesObservable = ChangesObservable;
|
@@ -1,9 +1,11 @@
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
2
2
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
3
3
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
4
|
-
function _classPrivateFieldGet(
|
5
|
-
function
|
6
|
-
function
|
4
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
5
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
6
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
7
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
8
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
7
9
|
import { ChangesObserver } from "./observer.mjs";
|
8
10
|
import { arrayDiff } from "./utils.mjs";
|
9
11
|
/**
|
@@ -29,7 +31,10 @@ export class ChangesObservable {
|
|
29
31
|
*
|
30
32
|
* @type {ChangesObserver[]}
|
31
33
|
*/
|
32
|
-
_classPrivateFieldInitSpec(this, _observers,
|
34
|
+
_classPrivateFieldInitSpec(this, _observers, {
|
35
|
+
writable: true,
|
36
|
+
value: new Set()
|
37
|
+
});
|
33
38
|
/**
|
34
39
|
* An array with default values that act as a base array that will be compared with
|
35
40
|
* the last saved index state. The changes are generated and immediately send through
|
@@ -38,21 +43,30 @@ export class ChangesObservable {
|
|
38
43
|
*
|
39
44
|
* @type {Array}
|
40
45
|
*/
|
41
|
-
_classPrivateFieldInitSpec(this, _indexMatrix,
|
46
|
+
_classPrivateFieldInitSpec(this, _indexMatrix, {
|
47
|
+
writable: true,
|
48
|
+
value: []
|
49
|
+
});
|
42
50
|
/**
|
43
51
|
* An array that holds the indexes state that is currently valid. The value is changed on every
|
44
52
|
* index mapper cache update.
|
45
53
|
*
|
46
54
|
* @type {Array}
|
47
55
|
*/
|
48
|
-
_classPrivateFieldInitSpec(this, _currentIndexState,
|
56
|
+
_classPrivateFieldInitSpec(this, _currentIndexState, {
|
57
|
+
writable: true,
|
58
|
+
value: []
|
59
|
+
});
|
49
60
|
/**
|
50
61
|
* The flag determines if the observable is initialized or not. Not initialized object creates
|
51
62
|
* index matrix once while emitting new changes.
|
52
63
|
*
|
53
64
|
* @type {boolean}
|
54
65
|
*/
|
55
|
-
_classPrivateFieldInitSpec(this, _isMatrixIndexesInitialized,
|
66
|
+
_classPrivateFieldInitSpec(this, _isMatrixIndexesInitialized, {
|
67
|
+
writable: true,
|
68
|
+
value: false
|
69
|
+
});
|
56
70
|
/**
|
57
71
|
* The initial index value allows control from what value the index matrix array will be created.
|
58
72
|
* Changing that value changes how the array diff generates the changes for the initial data
|
@@ -64,8 +78,11 @@ export class ChangesObservable {
|
|
64
78
|
*
|
65
79
|
* @type {boolean}
|
66
80
|
*/
|
67
|
-
_classPrivateFieldInitSpec(this, _initialIndexValue,
|
68
|
-
|
81
|
+
_classPrivateFieldInitSpec(this, _initialIndexValue, {
|
82
|
+
writable: true,
|
83
|
+
value: false
|
84
|
+
});
|
85
|
+
_classPrivateFieldSet(this, _initialIndexValue, initialIndexValue !== null && initialIndexValue !== void 0 ? initialIndexValue : false);
|
69
86
|
}
|
70
87
|
|
71
88
|
/* eslint-disable jsdoc/require-description-complete-sentence */
|
@@ -94,11 +111,11 @@ export class ChangesObservable {
|
|
94
111
|
/* eslint-enable jsdoc/require-description-complete-sentence */
|
95
112
|
createObserver() {
|
96
113
|
const observer = new ChangesObserver();
|
97
|
-
_classPrivateFieldGet(
|
114
|
+
_classPrivateFieldGet(this, _observers).add(observer);
|
98
115
|
observer.addLocalHook('unsubscribe', () => {
|
99
|
-
_classPrivateFieldGet(
|
116
|
+
_classPrivateFieldGet(this, _observers).delete(observer);
|
100
117
|
});
|
101
|
-
observer._writeInitialChanges(arrayDiff(_classPrivateFieldGet(
|
118
|
+
observer._writeInitialChanges(arrayDiff(_classPrivateFieldGet(this, _indexMatrix), _classPrivateFieldGet(this, _currentIndexState)));
|
102
119
|
return observer;
|
103
120
|
}
|
104
121
|
|
@@ -110,20 +127,20 @@ export class ChangesObservable {
|
|
110
127
|
* @param {Array} indexesState An array with index map state.
|
111
128
|
*/
|
112
129
|
emit(indexesState) {
|
113
|
-
let currentIndexState = _classPrivateFieldGet(
|
114
|
-
if (!_classPrivateFieldGet(
|
130
|
+
let currentIndexState = _classPrivateFieldGet(this, _currentIndexState);
|
131
|
+
if (!_classPrivateFieldGet(this, _isMatrixIndexesInitialized) || _classPrivateFieldGet(this, _indexMatrix).length !== indexesState.length) {
|
115
132
|
if (indexesState.length === 0) {
|
116
|
-
indexesState = new Array(currentIndexState.length).fill(_classPrivateFieldGet(
|
133
|
+
indexesState = new Array(currentIndexState.length).fill(_classPrivateFieldGet(this, _initialIndexValue));
|
117
134
|
} else {
|
118
|
-
_classPrivateFieldSet(
|
135
|
+
_classPrivateFieldSet(this, _indexMatrix, new Array(indexesState.length).fill(_classPrivateFieldGet(this, _initialIndexValue)));
|
119
136
|
}
|
120
|
-
if (!_classPrivateFieldGet(
|
121
|
-
_classPrivateFieldSet(
|
122
|
-
currentIndexState = _classPrivateFieldGet(
|
137
|
+
if (!_classPrivateFieldGet(this, _isMatrixIndexesInitialized)) {
|
138
|
+
_classPrivateFieldSet(this, _isMatrixIndexesInitialized, true);
|
139
|
+
currentIndexState = _classPrivateFieldGet(this, _indexMatrix);
|
123
140
|
}
|
124
141
|
}
|
125
142
|
const changes = arrayDiff(currentIndexState, indexesState);
|
126
|
-
_classPrivateFieldGet(
|
127
|
-
_classPrivateFieldSet(
|
143
|
+
_classPrivateFieldGet(this, _observers).forEach(observer => observer._write(changes));
|
144
|
+
_classPrivateFieldSet(this, _currentIndexState, indexesState);
|
128
145
|
}
|
129
146
|
}
|
@@ -1,15 +1,17 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
exports.__esModule = true;
|
4
3
|
require("core-js/modules/es.error.cause.js");
|
4
|
+
exports.__esModule = true;
|
5
5
|
var _object = require("../../helpers/object");
|
6
6
|
var _localHooks = _interopRequireDefault(require("../../mixins/localHooks"));
|
7
7
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
8
8
|
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
9
9
|
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
10
|
-
function _classPrivateFieldSet(
|
11
|
-
function
|
12
|
-
function
|
10
|
+
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
11
|
+
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
12
|
+
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
13
|
+
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
14
|
+
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
13
15
|
/**
|
14
16
|
* The ChangesObserver module is an object that represents a disposable resource
|
15
17
|
* provided by the ChangesObservable module.
|
@@ -26,7 +28,10 @@ class ChangesObserver {
|
|
26
28
|
*
|
27
29
|
* @type {Array}
|
28
30
|
*/
|
29
|
-
_classPrivateFieldInitSpec(this, _currentInitialChanges,
|
31
|
+
_classPrivateFieldInitSpec(this, _currentInitialChanges, {
|
32
|
+
writable: true,
|
33
|
+
value: []
|
34
|
+
});
|
30
35
|
}
|
31
36
|
/**
|
32
37
|
* Subscribes to the observer.
|
@@ -36,7 +41,7 @@ class ChangesObserver {
|
|
36
41
|
*/
|
37
42
|
subscribe(callback) {
|
38
43
|
this.addLocalHook('change', callback);
|
39
|
-
this._write(_classPrivateFieldGet(
|
44
|
+
this._write(_classPrivateFieldGet(this, _currentInitialChanges));
|
40
45
|
return this;
|
41
46
|
}
|
42
47
|
|
@@ -75,7 +80,7 @@ class ChangesObserver {
|
|
75
80
|
* @param {object} initialChanges The chunk of changes produced by the ChangesObservable module.
|
76
81
|
*/
|
77
82
|
_writeInitialChanges(initialChanges) {
|
78
|
-
_classPrivateFieldSet(
|
83
|
+
_classPrivateFieldSet(this, _currentInitialChanges, initialChanges);
|
79
84
|
}
|
80
85
|
}
|
81
86
|
exports.ChangesObserver = ChangesObserver;
|