handsontable 0.0.0-next-2c41c5b-20250814 → 0.0.0-next-fce5825-20250822
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/base.js +2 -2
- package/base.mjs +2 -2
- package/cellTypes/autocompleteType/autocompleteType.js +1 -4
- package/cellTypes/autocompleteType/autocompleteType.mjs +1 -4
- package/cellTypes/checkboxType/checkboxType.js +1 -3
- package/cellTypes/checkboxType/checkboxType.mjs +1 -3
- package/cellTypes/dropdownType/dropdownType.js +1 -4
- package/cellTypes/dropdownType/dropdownType.mjs +1 -4
- package/cellTypes/numericType/numericType.js +1 -3
- package/cellTypes/numericType/numericType.mjs +1 -3
- package/core/focusCatcher/index.js +37 -20
- package/core/focusCatcher/index.mjs +37 -20
- package/core/focusCatcher/utils.js +3 -64
- package/core/focusCatcher/utils.mjs +1 -60
- package/core/hooks/constants.js +58 -0
- package/core/hooks/constants.mjs +58 -0
- package/core/hooks/index.d.ts +7 -0
- package/core.d.ts +0 -1
- package/core.js +59 -55
- package/core.mjs +61 -57
- package/dataMap/dataMap.js +3 -13
- package/dataMap/dataMap.mjs +4 -14
- package/dataMap/dataSource.js +0 -16
- package/dataMap/dataSource.mjs +0 -16
- package/dataMap/metaManager/lazyFactoryMap.js +3 -4
- package/dataMap/metaManager/lazyFactoryMap.mjs +1 -2
- package/dataMap/metaManager/metaLayers/cellMeta.js +2 -3
- package/dataMap/metaManager/metaLayers/cellMeta.mjs +2 -3
- package/dataMap/metaManager/metaSchema.js +97 -68
- package/dataMap/metaManager/metaSchema.mjs +97 -68
- package/dataMap/metaManager/utils.js +11 -0
- package/dataMap/metaManager/utils.mjs +10 -0
- package/dist/handsontable.css +103 -5
- package/dist/handsontable.full.css +103 -5
- package/dist/handsontable.full.js +2770 -1954
- package/dist/handsontable.full.min.css +3 -3
- package/dist/handsontable.full.min.js +67 -67
- package/dist/handsontable.js +2772 -1956
- package/dist/handsontable.min.css +3 -3
- package/dist/handsontable.min.js +27 -27
- package/editors/autocompleteEditor/autocompleteEditor.js +8 -33
- package/editors/autocompleteEditor/autocompleteEditor.mjs +9 -34
- package/editors/baseEditor/baseEditor.js +2 -2
- package/editors/baseEditor/baseEditor.mjs +2 -2
- package/helpers/a11y.js +5 -1
- package/helpers/a11y.mjs +3 -1
- package/helpers/mixed.js +64 -1
- package/helpers/mixed.mjs +62 -1
- package/helpers/number.js +0 -28
- package/helpers/number.mjs +0 -26
- package/helpers/string.js +0 -19
- package/helpers/string.mjs +0 -18
- package/index.d.ts +9 -0
- package/package.json +6 -1
- package/plugins/autofill/autofill.js +3 -50
- package/plugins/autofill/autofill.mjs +3 -50
- package/plugins/base/base.js +75 -14
- package/plugins/base/base.mjs +75 -14
- package/plugins/contextMenu/contextMenu.js +1 -0
- package/plugins/contextMenu/contextMenu.mjs +1 -0
- package/plugins/copyPaste/copyPaste.js +28 -61
- package/plugins/copyPaste/copyPaste.mjs +29 -62
- package/plugins/dialog/dialog.d.ts +23 -0
- package/plugins/dialog/dialog.js +469 -0
- package/plugins/dialog/dialog.mjs +465 -0
- package/plugins/dialog/index.d.ts +1 -0
- package/plugins/dialog/index.js +7 -0
- package/plugins/dialog/index.mjs +1 -0
- package/plugins/dialog/ui.js +240 -0
- package/plugins/dialog/ui.mjs +235 -0
- package/plugins/dropdownMenu/dropdownMenu.js +1 -0
- package/plugins/dropdownMenu/dropdownMenu.mjs +1 -0
- package/plugins/index.d.ts +3 -0
- package/plugins/index.js +3 -0
- package/plugins/index.mjs +3 -1
- package/plugins/pagination/focusController.js +27 -0
- package/plugins/pagination/focusController.mjs +23 -0
- package/plugins/pagination/pagination.js +165 -18
- package/plugins/pagination/pagination.mjs +165 -18
- package/plugins/pagination/ui.js +101 -62
- package/plugins/pagination/ui.mjs +102 -63
- package/selection/range.js +11 -0
- package/selection/range.mjs +11 -0
- package/selection/selection.js +63 -2
- package/selection/selection.mjs +63 -2
- package/selection/utils.js +2 -1
- package/selection/utils.mjs +2 -1
- package/settings.d.ts +3 -3
- package/shortcuts/context.js +4 -1
- package/shortcuts/context.mjs +4 -1
- package/shortcuts/manager.js +17 -3
- package/shortcuts/manager.mjs +17 -3
- package/styles/handsontable.css +106 -22
- package/styles/handsontable.min.css +3 -3
- package/styles/ht-theme-horizon.css +24 -6
- package/styles/ht-theme-horizon.min.css +3 -3
- package/styles/ht-theme-main.css +52 -34
- package/styles/ht-theme-main.min.css +3 -3
- package/tableView.js +7 -2
- package/tableView.mjs +7 -2
- package/{core/focusCatcher → utils}/focusDetector.js +29 -11
- package/{core/focusCatcher → utils}/focusDetector.mjs +29 -11
- package/validators/autocompleteValidator/autocompleteValidator.js +1 -2
- package/validators/autocompleteValidator/autocompleteValidator.mjs +1 -2
- package/cellTypes/autocompleteType/accessors/index.js +0 -7
- package/cellTypes/autocompleteType/accessors/index.mjs +0 -2
- package/cellTypes/autocompleteType/accessors/valueGetter.js +0 -14
- package/cellTypes/autocompleteType/accessors/valueGetter.mjs +0 -10
- package/cellTypes/autocompleteType/accessors/valueSetter.js +0 -25
- package/cellTypes/autocompleteType/accessors/valueSetter.mjs +0 -21
- package/cellTypes/checkboxType/accessors/index.js +0 -5
- package/cellTypes/checkboxType/accessors/index.mjs +0 -1
- package/cellTypes/checkboxType/accessors/valueSetter.js +0 -26
- package/cellTypes/checkboxType/accessors/valueSetter.mjs +0 -22
- package/cellTypes/dropdownType/accessors/index.js +0 -7
- package/cellTypes/dropdownType/accessors/index.mjs +0 -2
- package/cellTypes/dropdownType/accessors/valueGetter.js +0 -14
- package/cellTypes/dropdownType/accessors/valueGetter.mjs +0 -10
- package/cellTypes/dropdownType/accessors/valueSetter.js +0 -17
- package/cellTypes/dropdownType/accessors/valueSetter.mjs +0 -13
- package/cellTypes/numericType/accessors/index.js +0 -5
- package/cellTypes/numericType/accessors/index.mjs +0 -1
- package/cellTypes/numericType/accessors/valueSetter.js +0 -19
- package/cellTypes/numericType/accessors/valueSetter.mjs +0 -15
- package/utils/valueAccessors.js +0 -45
- package/utils/valueAccessors.mjs +0 -40
|
@@ -3,12 +3,9 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
require("core-js/modules/es.error.cause.js");
|
|
5
5
|
require("core-js/modules/es.array.push.js");
|
|
6
|
-
require("core-js/modules/esnext.iterator.constructor.js");
|
|
7
|
-
require("core-js/modules/esnext.iterator.some.js");
|
|
8
6
|
var _base = require("../base");
|
|
9
7
|
var _hooks = require("../../core/hooks");
|
|
10
8
|
var _element = require("../../helpers/dom/element");
|
|
11
|
-
var _object = require("../../helpers/object");
|
|
12
9
|
var _array = require("../../helpers/array");
|
|
13
10
|
var _mixed = require("../../helpers/mixed");
|
|
14
11
|
var _utils = require("./utils");
|
|
@@ -46,13 +43,9 @@ class Autofill extends _base.BasePlugin {
|
|
|
46
43
|
constructor() {
|
|
47
44
|
super(...arguments);
|
|
48
45
|
/**
|
|
49
|
-
*
|
|
46
|
+
* On cell corner double click callback.
|
|
50
47
|
*
|
|
51
|
-
* @
|
|
52
|
-
* @param {Array} selectionSourceData The source data to extend the fill data with.
|
|
53
|
-
* @param {CellCoords} startOfDragCoords The start of the drag area.
|
|
54
|
-
* @param {CellCoords} endOfDragCoords The end of the drag area.
|
|
55
|
-
* @returns {Array} The extended fill data.
|
|
48
|
+
* @private
|
|
56
49
|
*/
|
|
57
50
|
_classPrivateMethodInitSpec(this, _Autofill_brand);
|
|
58
51
|
/**
|
|
@@ -156,11 +149,9 @@ class Autofill extends _base.BasePlugin {
|
|
|
156
149
|
* Gets selection data.
|
|
157
150
|
*
|
|
158
151
|
* @private
|
|
159
|
-
* @param {boolean} [useSource=false] If `true`, returns copyable source data instead of copyable data.
|
|
160
152
|
* @returns {object[]} Ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
|
|
161
153
|
*/
|
|
162
154
|
getSelectionData() {
|
|
163
|
-
let useSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
164
155
|
const selection = this.hot.getSelectedRangeLast();
|
|
165
156
|
const {
|
|
166
157
|
row: startRow,
|
|
@@ -194,12 +185,7 @@ class Autofill extends _base.BasePlugin {
|
|
|
194
185
|
(0, _array.arrayEach)(copyableRows, row => {
|
|
195
186
|
const rowSet = [];
|
|
196
187
|
(0, _array.arrayEach)(copyableColumns, column => {
|
|
197
|
-
|
|
198
|
-
if (useSource && (0, _object.isObject)(sourceDataAtSource)) {
|
|
199
|
-
rowSet.push(this.hot.getCopyableSourceData(row, column));
|
|
200
|
-
} else {
|
|
201
|
-
rowSet.push(this.hot.getCopyableData(row, column));
|
|
202
|
-
}
|
|
188
|
+
rowSet.push(this.hot.getCopyableData(row, column));
|
|
203
189
|
});
|
|
204
190
|
data.push(rowSet);
|
|
205
191
|
});
|
|
@@ -238,7 +224,6 @@ class Autofill extends _base.BasePlugin {
|
|
|
238
224
|
} = (0, _utils.getDragDirectionAndRange)(cornersOfSelectedCells, cornersOfSelectionAndDragAreas, (row, column) => this.hot._createCellCoords(row, column));
|
|
239
225
|
if (startOfDragCoords && startOfDragCoords.row > -1 && startOfDragCoords.col > -1) {
|
|
240
226
|
const selectionData = this.getSelectionData();
|
|
241
|
-
const selectionSourceData = this.getSelectionData(true);
|
|
242
227
|
const sourceRange = selectionRangeLast.clone();
|
|
243
228
|
const targetRange = this.hot._createCellRange(startOfDragCoords, startOfDragCoords, endOfDragCoords);
|
|
244
229
|
const beforeAutofillHookResult = this.hot.runHooks('beforeAutofill', selectionData, sourceRange, targetRange, directionOfDrag);
|
|
@@ -268,14 +253,6 @@ class Autofill extends _base.BasePlugin {
|
|
|
268
253
|
}
|
|
269
254
|
}
|
|
270
255
|
}
|
|
271
|
-
|
|
272
|
-
// If the source data contains objects, we need to check every taget cell for the data type.
|
|
273
|
-
if (selectionSourceData.some(row => row.some(cell => (0, _object.isObject)(cell)))) {
|
|
274
|
-
const fullFillData = _assertClassBrand(_Autofill_brand, this, _extendFillDataWithSourceData).call(this, fillData, selectionSourceData, startOfDragCoords, endOfDragCoords, directionOfDrag);
|
|
275
|
-
if (fullFillData.length) {
|
|
276
|
-
fillData = fullFillData;
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
256
|
this.hot.populateFromArray(startOfDragCoords.row, startOfDragCoords.col, fillData, endOfDragCoords.row, endOfDragCoords.col, `${this.pluginName}.fill`, null);
|
|
280
257
|
this.setSelection(cornersOfSelectionAndDragAreas);
|
|
281
258
|
this.hot.runHooks('afterAutofill', fillData, sourceRange, targetRange, directionOfDrag);
|
|
@@ -519,30 +496,6 @@ class Autofill extends _base.BasePlugin {
|
|
|
519
496
|
}
|
|
520
497
|
}
|
|
521
498
|
exports.Autofill = Autofill;
|
|
522
|
-
function _extendFillDataWithSourceData(fillData, selectionSourceData, startOfDragCoords, endOfDragCoords) {
|
|
523
|
-
const fullFillData = [];
|
|
524
|
-
for (let rowIndex = Math.min(startOfDragCoords.row, endOfDragCoords.row); rowIndex <= Math.max(startOfDragCoords.row, endOfDragCoords.row); rowIndex += 1) {
|
|
525
|
-
fullFillData.push([]);
|
|
526
|
-
for (let columnIndex = Math.min(startOfDragCoords.col, endOfDragCoords.col); columnIndex <= Math.max(startOfDragCoords.col, endOfDragCoords.col); columnIndex += 1) {
|
|
527
|
-
const sourceCell = this.hot.getSourceDataAtCell(rowIndex, columnIndex);
|
|
528
|
-
const relativeRowIndex = rowIndex - Math.min(startOfDragCoords.row, endOfDragCoords.row);
|
|
529
|
-
const relativeColumnIndex = columnIndex - Math.min(startOfDragCoords.col, endOfDragCoords.col);
|
|
530
|
-
const modRelativeRowIndex = relativeRowIndex % selectionSourceData.length;
|
|
531
|
-
const modRelativeColumnIndex = relativeColumnIndex % selectionSourceData[0].length;
|
|
532
|
-
if ((0, _object.isObject)(sourceCell)) {
|
|
533
|
-
fullFillData[relativeRowIndex][relativeColumnIndex] = selectionSourceData[modRelativeRowIndex][modRelativeColumnIndex];
|
|
534
|
-
} else {
|
|
535
|
-
fullFillData[relativeRowIndex][relativeColumnIndex] = fillData[modRelativeRowIndex][modRelativeColumnIndex];
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
return fullFillData;
|
|
540
|
-
}
|
|
541
|
-
/**
|
|
542
|
-
* On cell corner double click callback.
|
|
543
|
-
*
|
|
544
|
-
* @private
|
|
545
|
-
*/
|
|
546
499
|
function _onCellCornerDblClick() {
|
|
547
500
|
const selectionApplied = this.selectAdjacent();
|
|
548
501
|
if (selectionApplied) {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import "core-js/modules/es.error.cause.js";
|
|
2
2
|
import "core-js/modules/es.array.push.js";
|
|
3
|
-
import "core-js/modules/esnext.iterator.constructor.js";
|
|
4
|
-
import "core-js/modules/esnext.iterator.some.js";
|
|
5
3
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
6
4
|
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
7
5
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
@@ -11,7 +9,6 @@ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.h
|
|
|
11
9
|
import { BasePlugin } from "../base/index.mjs";
|
|
12
10
|
import { Hooks } from "../../core/hooks/index.mjs";
|
|
13
11
|
import { offset, outerHeight, outerWidth } from "../../helpers/dom/element.mjs";
|
|
14
|
-
import { isObject } from "../../helpers/object.mjs";
|
|
15
12
|
import { arrayEach, arrayMap } from "../../helpers/array.mjs";
|
|
16
13
|
import { isEmpty } from "../../helpers/mixed.mjs";
|
|
17
14
|
import { getDragDirectionAndRange, DIRECTIONS, getMappedFillHandleSetting } from "./utils.mjs";
|
|
@@ -43,13 +40,9 @@ export class Autofill extends BasePlugin {
|
|
|
43
40
|
constructor() {
|
|
44
41
|
super(...arguments);
|
|
45
42
|
/**
|
|
46
|
-
*
|
|
43
|
+
* On cell corner double click callback.
|
|
47
44
|
*
|
|
48
|
-
* @
|
|
49
|
-
* @param {Array} selectionSourceData The source data to extend the fill data with.
|
|
50
|
-
* @param {CellCoords} startOfDragCoords The start of the drag area.
|
|
51
|
-
* @param {CellCoords} endOfDragCoords The end of the drag area.
|
|
52
|
-
* @returns {Array} The extended fill data.
|
|
45
|
+
* @private
|
|
53
46
|
*/
|
|
54
47
|
_classPrivateMethodInitSpec(this, _Autofill_brand);
|
|
55
48
|
/**
|
|
@@ -153,11 +146,9 @@ export class Autofill extends BasePlugin {
|
|
|
153
146
|
* Gets selection data.
|
|
154
147
|
*
|
|
155
148
|
* @private
|
|
156
|
-
* @param {boolean} [useSource=false] If `true`, returns copyable source data instead of copyable data.
|
|
157
149
|
* @returns {object[]} Ranges Array of objects with properties `startRow`, `startCol`, `endRow` and `endCol`.
|
|
158
150
|
*/
|
|
159
151
|
getSelectionData() {
|
|
160
|
-
let useSource = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
161
152
|
const selection = this.hot.getSelectedRangeLast();
|
|
162
153
|
const {
|
|
163
154
|
row: startRow,
|
|
@@ -191,12 +182,7 @@ export class Autofill extends BasePlugin {
|
|
|
191
182
|
arrayEach(copyableRows, row => {
|
|
192
183
|
const rowSet = [];
|
|
193
184
|
arrayEach(copyableColumns, column => {
|
|
194
|
-
|
|
195
|
-
if (useSource && isObject(sourceDataAtSource)) {
|
|
196
|
-
rowSet.push(this.hot.getCopyableSourceData(row, column));
|
|
197
|
-
} else {
|
|
198
|
-
rowSet.push(this.hot.getCopyableData(row, column));
|
|
199
|
-
}
|
|
185
|
+
rowSet.push(this.hot.getCopyableData(row, column));
|
|
200
186
|
});
|
|
201
187
|
data.push(rowSet);
|
|
202
188
|
});
|
|
@@ -235,7 +221,6 @@ export class Autofill extends BasePlugin {
|
|
|
235
221
|
} = getDragDirectionAndRange(cornersOfSelectedCells, cornersOfSelectionAndDragAreas, (row, column) => this.hot._createCellCoords(row, column));
|
|
236
222
|
if (startOfDragCoords && startOfDragCoords.row > -1 && startOfDragCoords.col > -1) {
|
|
237
223
|
const selectionData = this.getSelectionData();
|
|
238
|
-
const selectionSourceData = this.getSelectionData(true);
|
|
239
224
|
const sourceRange = selectionRangeLast.clone();
|
|
240
225
|
const targetRange = this.hot._createCellRange(startOfDragCoords, startOfDragCoords, endOfDragCoords);
|
|
241
226
|
const beforeAutofillHookResult = this.hot.runHooks('beforeAutofill', selectionData, sourceRange, targetRange, directionOfDrag);
|
|
@@ -265,14 +250,6 @@ export class Autofill extends BasePlugin {
|
|
|
265
250
|
}
|
|
266
251
|
}
|
|
267
252
|
}
|
|
268
|
-
|
|
269
|
-
// If the source data contains objects, we need to check every taget cell for the data type.
|
|
270
|
-
if (selectionSourceData.some(row => row.some(cell => isObject(cell)))) {
|
|
271
|
-
const fullFillData = _assertClassBrand(_Autofill_brand, this, _extendFillDataWithSourceData).call(this, fillData, selectionSourceData, startOfDragCoords, endOfDragCoords, directionOfDrag);
|
|
272
|
-
if (fullFillData.length) {
|
|
273
|
-
fillData = fullFillData;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
253
|
this.hot.populateFromArray(startOfDragCoords.row, startOfDragCoords.col, fillData, endOfDragCoords.row, endOfDragCoords.col, `${this.pluginName}.fill`, null);
|
|
277
254
|
this.setSelection(cornersOfSelectionAndDragAreas);
|
|
278
255
|
this.hot.runHooks('afterAutofill', fillData, sourceRange, targetRange, directionOfDrag);
|
|
@@ -515,30 +492,6 @@ export class Autofill extends BasePlugin {
|
|
|
515
492
|
super.destroy();
|
|
516
493
|
}
|
|
517
494
|
}
|
|
518
|
-
function _extendFillDataWithSourceData(fillData, selectionSourceData, startOfDragCoords, endOfDragCoords) {
|
|
519
|
-
const fullFillData = [];
|
|
520
|
-
for (let rowIndex = Math.min(startOfDragCoords.row, endOfDragCoords.row); rowIndex <= Math.max(startOfDragCoords.row, endOfDragCoords.row); rowIndex += 1) {
|
|
521
|
-
fullFillData.push([]);
|
|
522
|
-
for (let columnIndex = Math.min(startOfDragCoords.col, endOfDragCoords.col); columnIndex <= Math.max(startOfDragCoords.col, endOfDragCoords.col); columnIndex += 1) {
|
|
523
|
-
const sourceCell = this.hot.getSourceDataAtCell(rowIndex, columnIndex);
|
|
524
|
-
const relativeRowIndex = rowIndex - Math.min(startOfDragCoords.row, endOfDragCoords.row);
|
|
525
|
-
const relativeColumnIndex = columnIndex - Math.min(startOfDragCoords.col, endOfDragCoords.col);
|
|
526
|
-
const modRelativeRowIndex = relativeRowIndex % selectionSourceData.length;
|
|
527
|
-
const modRelativeColumnIndex = relativeColumnIndex % selectionSourceData[0].length;
|
|
528
|
-
if (isObject(sourceCell)) {
|
|
529
|
-
fullFillData[relativeRowIndex][relativeColumnIndex] = selectionSourceData[modRelativeRowIndex][modRelativeColumnIndex];
|
|
530
|
-
} else {
|
|
531
|
-
fullFillData[relativeRowIndex][relativeColumnIndex] = fillData[modRelativeRowIndex][modRelativeColumnIndex];
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
return fullFillData;
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* On cell corner double click callback.
|
|
539
|
-
*
|
|
540
|
-
* @private
|
|
541
|
-
*/
|
|
542
495
|
function _onCellCornerDblClick() {
|
|
543
496
|
const selectionApplied = this.selectAdjacent();
|
|
544
497
|
if (selectionApplied) {
|
package/plugins/base/base.js
CHANGED
|
@@ -13,13 +13,15 @@ var _registry3 = require("../../editors/registry");
|
|
|
13
13
|
var _registry4 = require("../../renderers/registry");
|
|
14
14
|
var _registry5 = require("../../validators/registry");
|
|
15
15
|
var _eventManager = _interopRequireDefault(require("../../eventManager"));
|
|
16
|
+
var _console = require("../../helpers/console");
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
18
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
18
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
19
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
20
19
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
21
20
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
22
21
|
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); }
|
|
22
|
+
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
23
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
24
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
23
25
|
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
24
26
|
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
25
27
|
const DEPS_TYPE_CHECKERS = new Map([['plugin', _registry.hasPlugin], ['cell-type', _registry2.hasCellType], ['editor', _registry3.hasEditor], ['renderer', _registry4.hasRenderer], ['validator', _registry5.hasValidator]]);
|
|
@@ -32,6 +34,7 @@ let initializedPlugins = null;
|
|
|
32
34
|
* @util
|
|
33
35
|
* @property {Core} hot Handsontable instance.
|
|
34
36
|
*/
|
|
37
|
+
var _pluginSettings = /*#__PURE__*/new WeakMap();
|
|
35
38
|
var _hooks = /*#__PURE__*/new WeakMap();
|
|
36
39
|
var _BasePlugin_brand = /*#__PURE__*/new WeakSet();
|
|
37
40
|
class BasePlugin {
|
|
@@ -62,9 +65,18 @@ class BasePlugin {
|
|
|
62
65
|
}
|
|
63
66
|
|
|
64
67
|
/**
|
|
65
|
-
*
|
|
68
|
+
* Validators for plugin settings.
|
|
69
|
+
*
|
|
70
|
+
* @type {Function|object|null}
|
|
71
|
+
*/
|
|
72
|
+
static get SETTINGS_VALIDATORS() {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Plugin settings.
|
|
66
78
|
*
|
|
67
|
-
* @type {
|
|
79
|
+
* @type {object|null}
|
|
68
80
|
*/
|
|
69
81
|
|
|
70
82
|
/**
|
|
@@ -81,6 +93,12 @@ class BasePlugin {
|
|
|
81
93
|
* @returns {boolean}
|
|
82
94
|
*/
|
|
83
95
|
_classPrivateMethodInitSpec(this, _BasePlugin_brand);
|
|
96
|
+
_classPrivateFieldInitSpec(this, _pluginSettings, null);
|
|
97
|
+
/**
|
|
98
|
+
* The instance of the {@link EventManager} class.
|
|
99
|
+
*
|
|
100
|
+
* @type {EventManager}
|
|
101
|
+
*/
|
|
84
102
|
_defineProperty(this, "eventManager", new _eventManager.default(this));
|
|
85
103
|
/**
|
|
86
104
|
* @type {string}
|
|
@@ -121,6 +139,7 @@ class BasePlugin {
|
|
|
121
139
|
}
|
|
122
140
|
init() {
|
|
123
141
|
this.pluginName = this.hot.getPluginName(this);
|
|
142
|
+
this.updatePluginSettings(this.hot.getSettings()[this.constructor.PLUGIN_KEY]);
|
|
124
143
|
const pluginDeps = this.constructor.PLUGIN_DEPS;
|
|
125
144
|
const deps = Array.isArray(pluginDeps) ? pluginDeps : [];
|
|
126
145
|
if (deps.length > 0) {
|
|
@@ -188,25 +207,65 @@ class BasePlugin {
|
|
|
188
207
|
* @returns {*}
|
|
189
208
|
*/
|
|
190
209
|
getSetting(settingName) {
|
|
191
|
-
const pluginSettings = this.hot.getSettings()[this.constructor.PLUGIN_KEY];
|
|
192
210
|
if (settingName === undefined) {
|
|
193
|
-
return
|
|
211
|
+
return _classPrivateFieldGet(_pluginSettings, this);
|
|
194
212
|
}
|
|
195
213
|
const defaultSettings = this.constructor.DEFAULT_SETTINGS;
|
|
196
|
-
if ((Array.isArray(
|
|
197
|
-
var
|
|
198
|
-
if (Array.isArray(
|
|
199
|
-
return
|
|
214
|
+
if ((Array.isArray(_classPrivateFieldGet(_pluginSettings, this)) || (0, _object.isObject)(_classPrivateFieldGet(_pluginSettings, this))) && defaultSettings[defaultMainSettingSymbol] === settingName) {
|
|
215
|
+
var _classPrivateFieldGet2;
|
|
216
|
+
if (Array.isArray(_classPrivateFieldGet(_pluginSettings, this))) {
|
|
217
|
+
return _classPrivateFieldGet(_pluginSettings, this);
|
|
200
218
|
}
|
|
201
|
-
return (
|
|
219
|
+
return (_classPrivateFieldGet2 = _classPrivateFieldGet(_pluginSettings, this)[settingName]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : defaultSettings[settingName];
|
|
202
220
|
}
|
|
203
|
-
if ((0, _object.isObject)(
|
|
204
|
-
var
|
|
205
|
-
return (
|
|
221
|
+
if ((0, _object.isObject)(_classPrivateFieldGet(_pluginSettings, this))) {
|
|
222
|
+
var _classPrivateFieldGet3;
|
|
223
|
+
return (_classPrivateFieldGet3 = _classPrivateFieldGet(_pluginSettings, this)[settingName]) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : defaultSettings[settingName];
|
|
206
224
|
}
|
|
207
225
|
return defaultSettings[settingName];
|
|
208
226
|
}
|
|
209
227
|
|
|
228
|
+
/**
|
|
229
|
+
* Update plugin settings.
|
|
230
|
+
*
|
|
231
|
+
* @param {*} newSettings New settings.
|
|
232
|
+
* @returns {object} Updated settings object.
|
|
233
|
+
*/
|
|
234
|
+
updatePluginSettings(newSettings) {
|
|
235
|
+
const settingsValidators = this.constructor.SETTINGS_VALIDATORS;
|
|
236
|
+
if (settingsValidators && typeof settingsValidators === 'function' && typeof newSettings !== 'object') {
|
|
237
|
+
const isValid = settingsValidators(newSettings);
|
|
238
|
+
if (isValid === false) {
|
|
239
|
+
(0, _console.warn)(`${this.pluginName} Plugin: option is not valid and it will be ignored.`);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
_classPrivateFieldSet(_pluginSettings, this, newSettings);
|
|
243
|
+
return _classPrivateFieldGet(_pluginSettings, this);
|
|
244
|
+
}
|
|
245
|
+
if (settingsValidators && typeof settingsValidators === 'object' && typeof newSettings === 'object') {
|
|
246
|
+
if (_classPrivateFieldGet(_pluginSettings, this) === null || typeof _classPrivateFieldGet(_pluginSettings, this) !== 'object') {
|
|
247
|
+
_classPrivateFieldSet(_pluginSettings, this, {
|
|
248
|
+
...this.constructor.DEFAULT_SETTINGS
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
Object.keys(settingsValidators).forEach(key => {
|
|
252
|
+
if (!(key in newSettings)) {
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
const validator = settingsValidators[key];
|
|
256
|
+
const isValid = validator ? validator(newSettings[key]) : true;
|
|
257
|
+
if (isValid === false) {
|
|
258
|
+
(0, _console.warn)(`${this.pluginName} Plugin: "${key}" option is not valid and it will be ignored.`);
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
_classPrivateFieldGet(_pluginSettings, this)[key] = newSettings[key];
|
|
262
|
+
});
|
|
263
|
+
return _classPrivateFieldGet(_pluginSettings, this);
|
|
264
|
+
}
|
|
265
|
+
_classPrivateFieldSet(_pluginSettings, this, newSettings);
|
|
266
|
+
return newSettings;
|
|
267
|
+
}
|
|
268
|
+
|
|
210
269
|
/**
|
|
211
270
|
* Add listener to plugin hooks system.
|
|
212
271
|
*
|
|
@@ -284,6 +343,7 @@ class BasePlugin {
|
|
|
284
343
|
this.enablePlugin();
|
|
285
344
|
}
|
|
286
345
|
if (this.enabled && this.isEnabled() && relevantToSettings) {
|
|
346
|
+
this.updatePluginSettings(newSettings[this.constructor.PLUGIN_KEY]);
|
|
287
347
|
this.updatePlugin(newSettings);
|
|
288
348
|
}
|
|
289
349
|
}
|
|
@@ -301,6 +361,7 @@ class BasePlugin {
|
|
|
301
361
|
*/
|
|
302
362
|
destroy() {
|
|
303
363
|
var _this$eventManager2;
|
|
364
|
+
_classPrivateFieldSet(_pluginSettings, this, null);
|
|
304
365
|
(_this$eventManager2 = this.eventManager) === null || _this$eventManager2 === void 0 || _this$eventManager2.destroy();
|
|
305
366
|
this.clearHooks();
|
|
306
367
|
(0, _object.objectEach)(this, (value, property) => {
|
package/plugins/base/base.mjs
CHANGED
|
@@ -3,11 +3,12 @@ import "core-js/modules/es.array.push.js";
|
|
|
3
3
|
import "core-js/modules/esnext.iterator.constructor.js";
|
|
4
4
|
import "core-js/modules/esnext.iterator.for-each.js";
|
|
5
5
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
6
|
-
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
7
|
-
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
8
6
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
9
7
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
10
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 _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
10
|
+
function _checkPrivateRedeclaration(e, t) { if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object"); }
|
|
11
|
+
function _classPrivateFieldSet(s, a, r) { return s.set(_assertClassBrand(s, a), r), r; }
|
|
11
12
|
function _classPrivateFieldGet(s, a) { return s.get(_assertClassBrand(s, a)); }
|
|
12
13
|
function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n; throw new TypeError("Private element is not present on this object"); }
|
|
13
14
|
import { defineGetter, objectEach, isObject } from "../../helpers/object.mjs";
|
|
@@ -18,6 +19,7 @@ import { hasEditor } from "../../editors/registry.mjs";
|
|
|
18
19
|
import { hasRenderer } from "../../renderers/registry.mjs";
|
|
19
20
|
import { hasValidator } from "../../validators/registry.mjs";
|
|
20
21
|
import EventManager from "../../eventManager.mjs";
|
|
22
|
+
import { warn } from "../../helpers/console.mjs";
|
|
21
23
|
const DEPS_TYPE_CHECKERS = new Map([['plugin', hasPlugin], ['cell-type', hasCellType], ['editor', hasEditor], ['renderer', hasRenderer], ['validator', hasValidator]]);
|
|
22
24
|
export const defaultMainSettingSymbol = Symbol('mainSetting');
|
|
23
25
|
export const PLUGIN_KEY = 'base';
|
|
@@ -28,6 +30,7 @@ let initializedPlugins = null;
|
|
|
28
30
|
* @util
|
|
29
31
|
* @property {Core} hot Handsontable instance.
|
|
30
32
|
*/
|
|
33
|
+
var _pluginSettings = /*#__PURE__*/new WeakMap();
|
|
31
34
|
var _hooks = /*#__PURE__*/new WeakMap();
|
|
32
35
|
var _BasePlugin_brand = /*#__PURE__*/new WeakSet();
|
|
33
36
|
export class BasePlugin {
|
|
@@ -58,9 +61,18 @@ export class BasePlugin {
|
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
/**
|
|
61
|
-
*
|
|
64
|
+
* Validators for plugin settings.
|
|
65
|
+
*
|
|
66
|
+
* @type {Function|object|null}
|
|
67
|
+
*/
|
|
68
|
+
static get SETTINGS_VALIDATORS() {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Plugin settings.
|
|
62
74
|
*
|
|
63
|
-
* @type {
|
|
75
|
+
* @type {object|null}
|
|
64
76
|
*/
|
|
65
77
|
|
|
66
78
|
/**
|
|
@@ -77,6 +89,12 @@ export class BasePlugin {
|
|
|
77
89
|
* @returns {boolean}
|
|
78
90
|
*/
|
|
79
91
|
_classPrivateMethodInitSpec(this, _BasePlugin_brand);
|
|
92
|
+
_classPrivateFieldInitSpec(this, _pluginSettings, null);
|
|
93
|
+
/**
|
|
94
|
+
* The instance of the {@link EventManager} class.
|
|
95
|
+
*
|
|
96
|
+
* @type {EventManager}
|
|
97
|
+
*/
|
|
80
98
|
_defineProperty(this, "eventManager", new EventManager(this));
|
|
81
99
|
/**
|
|
82
100
|
* @type {string}
|
|
@@ -117,6 +135,7 @@ export class BasePlugin {
|
|
|
117
135
|
}
|
|
118
136
|
init() {
|
|
119
137
|
this.pluginName = this.hot.getPluginName(this);
|
|
138
|
+
this.updatePluginSettings(this.hot.getSettings()[this.constructor.PLUGIN_KEY]);
|
|
120
139
|
const pluginDeps = this.constructor.PLUGIN_DEPS;
|
|
121
140
|
const deps = Array.isArray(pluginDeps) ? pluginDeps : [];
|
|
122
141
|
if (deps.length > 0) {
|
|
@@ -184,25 +203,65 @@ export class BasePlugin {
|
|
|
184
203
|
* @returns {*}
|
|
185
204
|
*/
|
|
186
205
|
getSetting(settingName) {
|
|
187
|
-
const pluginSettings = this.hot.getSettings()[this.constructor.PLUGIN_KEY];
|
|
188
206
|
if (settingName === undefined) {
|
|
189
|
-
return
|
|
207
|
+
return _classPrivateFieldGet(_pluginSettings, this);
|
|
190
208
|
}
|
|
191
209
|
const defaultSettings = this.constructor.DEFAULT_SETTINGS;
|
|
192
|
-
if ((Array.isArray(
|
|
193
|
-
var
|
|
194
|
-
if (Array.isArray(
|
|
195
|
-
return
|
|
210
|
+
if ((Array.isArray(_classPrivateFieldGet(_pluginSettings, this)) || isObject(_classPrivateFieldGet(_pluginSettings, this))) && defaultSettings[defaultMainSettingSymbol] === settingName) {
|
|
211
|
+
var _classPrivateFieldGet2;
|
|
212
|
+
if (Array.isArray(_classPrivateFieldGet(_pluginSettings, this))) {
|
|
213
|
+
return _classPrivateFieldGet(_pluginSettings, this);
|
|
196
214
|
}
|
|
197
|
-
return (
|
|
215
|
+
return (_classPrivateFieldGet2 = _classPrivateFieldGet(_pluginSettings, this)[settingName]) !== null && _classPrivateFieldGet2 !== void 0 ? _classPrivateFieldGet2 : defaultSettings[settingName];
|
|
198
216
|
}
|
|
199
|
-
if (isObject(
|
|
200
|
-
var
|
|
201
|
-
return (
|
|
217
|
+
if (isObject(_classPrivateFieldGet(_pluginSettings, this))) {
|
|
218
|
+
var _classPrivateFieldGet3;
|
|
219
|
+
return (_classPrivateFieldGet3 = _classPrivateFieldGet(_pluginSettings, this)[settingName]) !== null && _classPrivateFieldGet3 !== void 0 ? _classPrivateFieldGet3 : defaultSettings[settingName];
|
|
202
220
|
}
|
|
203
221
|
return defaultSettings[settingName];
|
|
204
222
|
}
|
|
205
223
|
|
|
224
|
+
/**
|
|
225
|
+
* Update plugin settings.
|
|
226
|
+
*
|
|
227
|
+
* @param {*} newSettings New settings.
|
|
228
|
+
* @returns {object} Updated settings object.
|
|
229
|
+
*/
|
|
230
|
+
updatePluginSettings(newSettings) {
|
|
231
|
+
const settingsValidators = this.constructor.SETTINGS_VALIDATORS;
|
|
232
|
+
if (settingsValidators && typeof settingsValidators === 'function' && typeof newSettings !== 'object') {
|
|
233
|
+
const isValid = settingsValidators(newSettings);
|
|
234
|
+
if (isValid === false) {
|
|
235
|
+
warn(`${this.pluginName} Plugin: option is not valid and it will be ignored.`);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
_classPrivateFieldSet(_pluginSettings, this, newSettings);
|
|
239
|
+
return _classPrivateFieldGet(_pluginSettings, this);
|
|
240
|
+
}
|
|
241
|
+
if (settingsValidators && typeof settingsValidators === 'object' && typeof newSettings === 'object') {
|
|
242
|
+
if (_classPrivateFieldGet(_pluginSettings, this) === null || typeof _classPrivateFieldGet(_pluginSettings, this) !== 'object') {
|
|
243
|
+
_classPrivateFieldSet(_pluginSettings, this, {
|
|
244
|
+
...this.constructor.DEFAULT_SETTINGS
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
Object.keys(settingsValidators).forEach(key => {
|
|
248
|
+
if (!(key in newSettings)) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const validator = settingsValidators[key];
|
|
252
|
+
const isValid = validator ? validator(newSettings[key]) : true;
|
|
253
|
+
if (isValid === false) {
|
|
254
|
+
warn(`${this.pluginName} Plugin: "${key}" option is not valid and it will be ignored.`);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
_classPrivateFieldGet(_pluginSettings, this)[key] = newSettings[key];
|
|
258
|
+
});
|
|
259
|
+
return _classPrivateFieldGet(_pluginSettings, this);
|
|
260
|
+
}
|
|
261
|
+
_classPrivateFieldSet(_pluginSettings, this, newSettings);
|
|
262
|
+
return newSettings;
|
|
263
|
+
}
|
|
264
|
+
|
|
206
265
|
/**
|
|
207
266
|
* Add listener to plugin hooks system.
|
|
208
267
|
*
|
|
@@ -280,6 +339,7 @@ export class BasePlugin {
|
|
|
280
339
|
this.enablePlugin();
|
|
281
340
|
}
|
|
282
341
|
if (this.enabled && this.isEnabled() && relevantToSettings) {
|
|
342
|
+
this.updatePluginSettings(newSettings[this.constructor.PLUGIN_KEY]);
|
|
283
343
|
this.updatePlugin(newSettings);
|
|
284
344
|
}
|
|
285
345
|
}
|
|
@@ -297,6 +357,7 @@ export class BasePlugin {
|
|
|
297
357
|
*/
|
|
298
358
|
destroy() {
|
|
299
359
|
var _this$eventManager2;
|
|
360
|
+
_classPrivateFieldSet(_pluginSettings, this, null);
|
|
300
361
|
(_this$eventManager2 = this.eventManager) === null || _this$eventManager2 === void 0 || _this$eventManager2.destroy();
|
|
301
362
|
this.clearHooks();
|
|
302
363
|
objectEach(this, (value, property) => {
|
|
@@ -138,6 +138,7 @@ class ContextMenu extends _base.BasePlugin {
|
|
|
138
138
|
return _this.executeCommand.call(_this, ...params);
|
|
139
139
|
});
|
|
140
140
|
this.addHook('afterOnCellContextMenu', event => _assertClassBrand(_ContextMenu_brand, this, _onAfterOnCellContextMenu).call(this, event));
|
|
141
|
+
this.addHook('beforeDialogShow', () => this.close());
|
|
141
142
|
this.registerShortcuts();
|
|
142
143
|
super.enablePlugin();
|
|
143
144
|
}
|
|
@@ -135,6 +135,7 @@ export class ContextMenu extends BasePlugin {
|
|
|
135
135
|
return _this.executeCommand.call(_this, ...params);
|
|
136
136
|
});
|
|
137
137
|
this.addHook('afterOnCellContextMenu', event => _assertClassBrand(_ContextMenu_brand, this, _onAfterOnCellContextMenu).call(this, event));
|
|
138
|
+
this.addHook('beforeDialogShow', () => this.close());
|
|
138
139
|
this.registerShortcuts();
|
|
139
140
|
super.enablePlugin();
|
|
140
141
|
}
|