handsontable 0.0.0-next-acb8c02-20230620 → 0.0.0-next-af5139c-20230620

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/helpers/mixed.js CHANGED
@@ -152,7 +152,7 @@ var domMessages = {
152
152
  function _injectProductInfo(key, element) {
153
153
  var hasValidType = !isEmpty(key);
154
154
  var isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
155
- var hotVersion = "0.0.0-next-acb8c02-20230620";
155
+ var hotVersion = "0.0.0-next-af5139c-20230620";
156
156
  var keyValidityDate;
157
157
  var consoleMessageState = 'invalid';
158
158
  var domMessageState = 'invalid';
package/helpers/mixed.mjs CHANGED
@@ -142,7 +142,7 @@ var domMessages = {
142
142
  export function _injectProductInfo(key, element) {
143
143
  var hasValidType = !isEmpty(key);
144
144
  var isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
145
- var hotVersion = "0.0.0-next-acb8c02-20230620";
145
+ var hotVersion = "0.0.0-next-af5139c-20230620";
146
146
  var keyValidityDate;
147
147
  var consoleMessageState = 'invalid';
148
148
  var domMessageState = 'invalid';
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "url": "https://github.com/handsontable/handsontable/issues"
11
11
  },
12
12
  "author": "Handsoncode <hello@handsontable.com>",
13
- "version": "0.0.0-next-acb8c02-20230620",
13
+ "version": "0.0.0-next-af5139c-20230620",
14
14
  "main": "index",
15
15
  "module": "index.mjs",
16
16
  "jsnext:main": "index.mjs",
@@ -5,7 +5,6 @@ exports.align = align;
5
5
  exports.checkSelectionConsistency = checkSelectionConsistency;
6
6
  exports.filterSeparators = filterSeparators;
7
7
  exports.getAlignmentClasses = getAlignmentClasses;
8
- exports.getDocumentOffsetByElement = getDocumentOffsetByElement;
9
8
  exports.getValidSelection = getValidSelection;
10
9
  exports.hasSubMenu = hasSubMenu;
11
10
  exports.isDisabled = isDisabled;
@@ -276,28 +275,4 @@ function filterSeparators(items) {
276
275
  result = popSeparators(result, separator);
277
276
  result = removeDuplicatedSeparators(result);
278
277
  return result;
279
- }
280
-
281
- /**
282
- * Returns document offset based on the passed element. If the document objects between element and the
283
- * base document are not the same the offset as top and left properties will be returned.
284
- *
285
- * @param {Element} elementToCheck The element to compare with Document object.
286
- * @param {Document} baseDocument The base Document object.
287
- * @returns {{ top: number, left: number }}
288
- */
289
- function getDocumentOffsetByElement(elementToCheck, baseDocument) {
290
- var offset = {
291
- top: 0,
292
- left: 0
293
- };
294
- if (baseDocument !== elementToCheck.ownerDocument) {
295
- var frameElement = baseDocument.defaultView.frameElement;
296
- var _frameElement$getBoun = frameElement.getBoundingClientRect(),
297
- top = _frameElement$getBoun.top,
298
- left = _frameElement$getBoun.left;
299
- offset.top = top;
300
- offset.left = left;
301
- }
302
- return offset;
303
278
  }
@@ -258,28 +258,4 @@ export function filterSeparators(items) {
258
258
  result = popSeparators(result, separator);
259
259
  result = removeDuplicatedSeparators(result);
260
260
  return result;
261
- }
262
-
263
- /**
264
- * Returns document offset based on the passed element. If the document objects between element and the
265
- * base document are not the same the offset as top and left properties will be returned.
266
- *
267
- * @param {Element} elementToCheck The element to compare with Document object.
268
- * @param {Document} baseDocument The base Document object.
269
- * @returns {{ top: number, left: number }}
270
- */
271
- export function getDocumentOffsetByElement(elementToCheck, baseDocument) {
272
- var offset = {
273
- top: 0,
274
- left: 0
275
- };
276
- if (baseDocument !== elementToCheck.ownerDocument) {
277
- var frameElement = baseDocument.defaultView.frameElement;
278
- var _frameElement$getBoun = frameElement.getBoundingClientRect(),
279
- top = _frameElement$getBoun.top,
280
- left = _frameElement$getBoun.left;
281
- offset.top = top;
282
- offset.left = left;
283
- }
284
- return offset;
285
261
  }
@@ -23,7 +23,6 @@ require("core-js/modules/es.object.get-prototype-of.js");
23
23
  var _base = require("../base");
24
24
  var _array = require("../../helpers/array");
25
25
  var _commandExecutor = _interopRequireDefault(require("../contextMenu/commandExecutor"));
26
- var _utils = require("../contextMenu/utils");
27
26
  var _eventManager = _interopRequireDefault(require("../../eventManager"));
28
27
  var _element = require("../../helpers/dom/element");
29
28
  var _itemsFactory = _interopRequireDefault(require("../contextMenu/itemsFactory"));
@@ -55,7 +54,6 @@ exports.PLUGIN_KEY = PLUGIN_KEY;
55
54
  var PLUGIN_PRIORITY = 230;
56
55
  exports.PLUGIN_PRIORITY = PLUGIN_PRIORITY;
57
56
  var BUTTON_CLASS_NAME = 'changeType';
58
- var SHORTCUTS_GROUP = PLUGIN_KEY;
59
57
 
60
58
  /* eslint-disable jsdoc/require-description-complete-sentence */
61
59
  /**
@@ -184,7 +182,6 @@ var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
184
182
  if (typeof settings.callback === 'function') {
185
183
  this.commandExecutor.setCommonCallback(settings.callback);
186
184
  }
187
- this.registerShortcuts();
188
185
  _get(_getPrototypeOf(DropdownMenu.prototype), "enablePlugin", this).call(this);
189
186
  this.callOnPluginsReady(function () {
190
187
  _this2.hot.runHooks('afterDropdownMenuDefaultOptions', predefinedItems);
@@ -248,71 +245,9 @@ var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
248
245
  if (this.menu) {
249
246
  this.menu.destroy();
250
247
  }
251
- this.unregisterShortcuts();
252
248
  _get(_getPrototypeOf(DropdownMenu.prototype), "disablePlugin", this).call(this);
253
249
  }
254
250
 
255
- /**
256
- * Register shortcuts responsible for toggling dropdown menu.
257
- *
258
- * @private
259
- */
260
- }, {
261
- key: "registerShortcuts",
262
- value: function registerShortcuts() {
263
- var _this3 = this;
264
- var context = this.hot.getShortcutManager().getContext('grid');
265
- var callback = function callback() {
266
- var _this3$hot$getSelecte = _this3.hot.getSelectedRangeLast(),
267
- highlight = _this3$hot$getSelecte.highlight;
268
- if ((highlight.isHeader() && highlight.row === -1 || highlight.isCell()) && highlight.col >= 0) {
269
- _this3.hot.selectColumns(highlight.col, highlight.col, -1);
270
- var _this3$hot$getSelecte2 = _this3.hot.getSelectedRangeLast(),
271
- from = _this3$hot$getSelecte2.from;
272
- var offset = (0, _utils.getDocumentOffsetByElement)(_this3.menu.container, _this3.hot.rootDocument);
273
- var target = _this3.hot.getCell(-1, from.col, true);
274
- var rect = target.getBoundingClientRect();
275
- _this3.open({
276
- left: rect.left + offset.left,
277
- top: rect.top + target.offsetHeight + offset.top,
278
- width: rect.width,
279
- height: rect.height
280
- });
281
- _this3.hot._registerTimeout(function () {
282
- _this3.menu.selectFirstCell();
283
- });
284
- }
285
- };
286
- context.addShortcuts([{
287
- keys: [['Shift', 'Alt', 'ArrowDown'], ['Shift', 'Enter']],
288
- callback: callback,
289
- runOnlyIf: function runOnlyIf() {
290
- var _this3$hot$getSelecte3;
291
- return ((_this3$hot$getSelecte3 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte3 === void 0 ? void 0 : _this3$hot$getSelecte3.highlight.isHeader()) && !_this3.menu.isOpened();
292
- },
293
- group: SHORTCUTS_GROUP
294
- }, {
295
- keys: [['Shift', 'Alt', 'ArrowDown']],
296
- callback: callback,
297
- runOnlyIf: function runOnlyIf() {
298
- var _this3$hot$getSelecte4;
299
- return ((_this3$hot$getSelecte4 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte4 === void 0 ? void 0 : _this3$hot$getSelecte4.highlight.isCell()) && !_this3.menu.isOpened();
300
- },
301
- group: SHORTCUTS_GROUP
302
- }]);
303
- }
304
-
305
- /**
306
- * Unregister shortcuts responsible for toggling dropdown menu.
307
- *
308
- * @private
309
- */
310
- }, {
311
- key: "unregisterShortcuts",
312
- value: function unregisterShortcuts() {
313
- this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
314
- }
315
-
316
251
  /**
317
252
  * Registers the DOM listeners.
318
253
  *
@@ -321,27 +256,27 @@ var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
321
256
  }, {
322
257
  key: "registerEvents",
323
258
  value: function registerEvents() {
324
- var _this4 = this;
259
+ var _this3 = this;
325
260
  this.eventManager.addEventListener(this.hot.rootElement, 'click', function (event) {
326
- return _this4.onTableClick(event);
261
+ return _this3.onTableClick(event);
327
262
  });
328
263
  }
329
264
 
330
265
  /**
331
266
  * Opens menu and re-position it based on the passed coordinates.
332
267
  *
333
- * @param {{ top: number, left: number }|Event} position An object with `top` and `left` properties
334
- * which contains coordinates relative to the browsers viewport (without included scroll offsets).
335
- * Or if the native event is passed the menu will be positioned based on the `pageX` and `pageY`
336
- * coordinates.
268
+ * @param {object|Event} position An object with `pageX` and `pageY` properties which contains values relative to
269
+ * the top left of the fully rendered content area in the browser or with `clientX`
270
+ * and `clientY` properties which contains values relative to the upper left edge
271
+ * of the content area (the viewport) of the browser window. This object is structurally
272
+ * compatible with native mouse event so it can be used either.
337
273
  * @fires Hooks#beforeDropdownMenuShow
338
274
  * @fires Hooks#afterDropdownMenuShow
339
275
  */
340
276
  }, {
341
277
  key: "open",
342
278
  value: function open(position) {
343
- var _this$menu;
344
- if ((_this$menu = this.menu) !== null && _this$menu !== void 0 && _this$menu.isOpened()) {
279
+ if (!this.menu) {
345
280
  return;
346
281
  }
347
282
  this.menu.open();
@@ -357,8 +292,10 @@ var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
357
292
  }, {
358
293
  key: "close",
359
294
  value: function close() {
360
- var _this$menu2;
361
- (_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
295
+ if (!this.menu) {
296
+ return;
297
+ }
298
+ this.menu.close();
362
299
  }
363
300
 
364
301
  /**
@@ -430,12 +367,21 @@ var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
430
367
  key: "onTableClick",
431
368
  value: function onTableClick(event) {
432
369
  event.stopPropagation();
433
- if ((0, _element.hasClass)(event.target, BUTTON_CLASS_NAME)) {
434
- var offset = (0, _utils.getDocumentOffsetByElement)(this.menu.container, this.hot.rootDocument);
370
+ if ((0, _element.hasClass)(event.target, BUTTON_CLASS_NAME) && !this.menu.isOpened()) {
371
+ var offsetTop = 0;
372
+ var offsetLeft = 0;
373
+ if (this.hot.rootDocument !== this.menu.container.ownerDocument) {
374
+ var frameElement = this.hot.rootWindow.frameElement;
375
+ var _frameElement$getBoun = frameElement.getBoundingClientRect(),
376
+ top = _frameElement$getBoun.top,
377
+ left = _frameElement$getBoun.left;
378
+ offsetTop = top;
379
+ offsetLeft = left;
380
+ }
435
381
  var rect = event.target.getBoundingClientRect();
436
382
  this.open({
437
- left: rect.left + offset.left,
438
- top: rect.top + event.target.offsetHeight + 3 + offset.top,
383
+ left: rect.left + offsetLeft,
384
+ top: rect.top + event.target.offsetHeight + 3 + offsetTop,
439
385
  width: rect.width,
440
386
  height: rect.height
441
387
  });
@@ -33,7 +33,6 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
33
33
  import { BasePlugin } from "../base/index.mjs";
34
34
  import { arrayEach } from "../../helpers/array.mjs";
35
35
  import CommandExecutor from "../contextMenu/commandExecutor.mjs";
36
- import { getDocumentOffsetByElement } from "../contextMenu/utils.mjs";
37
36
  import EventManager from "../../eventManager.mjs";
38
37
  import { hasClass } from "../../helpers/dom/element.mjs";
39
38
  import ItemsFactory from "../contextMenu/itemsFactory.mjs";
@@ -48,7 +47,6 @@ Hooks.getSingleton().register('afterDropdownMenuExecute');
48
47
  export var PLUGIN_KEY = 'dropdownMenu';
49
48
  export var PLUGIN_PRIORITY = 230;
50
49
  var BUTTON_CLASS_NAME = 'changeType';
51
- var SHORTCUTS_GROUP = PLUGIN_KEY;
52
50
 
53
51
  /* eslint-disable jsdoc/require-description-complete-sentence */
54
52
  /**
@@ -178,7 +176,6 @@ export var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
178
176
  if (typeof settings.callback === 'function') {
179
177
  this.commandExecutor.setCommonCallback(settings.callback);
180
178
  }
181
- this.registerShortcuts();
182
179
  _get(_getPrototypeOf(DropdownMenu.prototype), "enablePlugin", this).call(this);
183
180
  this.callOnPluginsReady(function () {
184
181
  _this2.hot.runHooks('afterDropdownMenuDefaultOptions', predefinedItems);
@@ -242,71 +239,9 @@ export var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
242
239
  if (this.menu) {
243
240
  this.menu.destroy();
244
241
  }
245
- this.unregisterShortcuts();
246
242
  _get(_getPrototypeOf(DropdownMenu.prototype), "disablePlugin", this).call(this);
247
243
  }
248
244
 
249
- /**
250
- * Register shortcuts responsible for toggling dropdown menu.
251
- *
252
- * @private
253
- */
254
- }, {
255
- key: "registerShortcuts",
256
- value: function registerShortcuts() {
257
- var _this3 = this;
258
- var context = this.hot.getShortcutManager().getContext('grid');
259
- var callback = function callback() {
260
- var _this3$hot$getSelecte = _this3.hot.getSelectedRangeLast(),
261
- highlight = _this3$hot$getSelecte.highlight;
262
- if ((highlight.isHeader() && highlight.row === -1 || highlight.isCell()) && highlight.col >= 0) {
263
- _this3.hot.selectColumns(highlight.col, highlight.col, -1);
264
- var _this3$hot$getSelecte2 = _this3.hot.getSelectedRangeLast(),
265
- from = _this3$hot$getSelecte2.from;
266
- var offset = getDocumentOffsetByElement(_this3.menu.container, _this3.hot.rootDocument);
267
- var target = _this3.hot.getCell(-1, from.col, true);
268
- var rect = target.getBoundingClientRect();
269
- _this3.open({
270
- left: rect.left + offset.left,
271
- top: rect.top + target.offsetHeight + offset.top,
272
- width: rect.width,
273
- height: rect.height
274
- });
275
- _this3.hot._registerTimeout(function () {
276
- _this3.menu.selectFirstCell();
277
- });
278
- }
279
- };
280
- context.addShortcuts([{
281
- keys: [['Shift', 'Alt', 'ArrowDown'], ['Shift', 'Enter']],
282
- callback: callback,
283
- runOnlyIf: function runOnlyIf() {
284
- var _this3$hot$getSelecte3;
285
- return ((_this3$hot$getSelecte3 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte3 === void 0 ? void 0 : _this3$hot$getSelecte3.highlight.isHeader()) && !_this3.menu.isOpened();
286
- },
287
- group: SHORTCUTS_GROUP
288
- }, {
289
- keys: [['Shift', 'Alt', 'ArrowDown']],
290
- callback: callback,
291
- runOnlyIf: function runOnlyIf() {
292
- var _this3$hot$getSelecte4;
293
- return ((_this3$hot$getSelecte4 = _this3.hot.getSelectedRangeLast()) === null || _this3$hot$getSelecte4 === void 0 ? void 0 : _this3$hot$getSelecte4.highlight.isCell()) && !_this3.menu.isOpened();
294
- },
295
- group: SHORTCUTS_GROUP
296
- }]);
297
- }
298
-
299
- /**
300
- * Unregister shortcuts responsible for toggling dropdown menu.
301
- *
302
- * @private
303
- */
304
- }, {
305
- key: "unregisterShortcuts",
306
- value: function unregisterShortcuts() {
307
- this.hot.getShortcutManager().getContext('grid').removeShortcutsByGroup(SHORTCUTS_GROUP);
308
- }
309
-
310
245
  /**
311
246
  * Registers the DOM listeners.
312
247
  *
@@ -315,27 +250,27 @@ export var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
315
250
  }, {
316
251
  key: "registerEvents",
317
252
  value: function registerEvents() {
318
- var _this4 = this;
253
+ var _this3 = this;
319
254
  this.eventManager.addEventListener(this.hot.rootElement, 'click', function (event) {
320
- return _this4.onTableClick(event);
255
+ return _this3.onTableClick(event);
321
256
  });
322
257
  }
323
258
 
324
259
  /**
325
260
  * Opens menu and re-position it based on the passed coordinates.
326
261
  *
327
- * @param {{ top: number, left: number }|Event} position An object with `top` and `left` properties
328
- * which contains coordinates relative to the browsers viewport (without included scroll offsets).
329
- * Or if the native event is passed the menu will be positioned based on the `pageX` and `pageY`
330
- * coordinates.
262
+ * @param {object|Event} position An object with `pageX` and `pageY` properties which contains values relative to
263
+ * the top left of the fully rendered content area in the browser or with `clientX`
264
+ * and `clientY` properties which contains values relative to the upper left edge
265
+ * of the content area (the viewport) of the browser window. This object is structurally
266
+ * compatible with native mouse event so it can be used either.
331
267
  * @fires Hooks#beforeDropdownMenuShow
332
268
  * @fires Hooks#afterDropdownMenuShow
333
269
  */
334
270
  }, {
335
271
  key: "open",
336
272
  value: function open(position) {
337
- var _this$menu;
338
- if ((_this$menu = this.menu) !== null && _this$menu !== void 0 && _this$menu.isOpened()) {
273
+ if (!this.menu) {
339
274
  return;
340
275
  }
341
276
  this.menu.open();
@@ -351,8 +286,10 @@ export var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
351
286
  }, {
352
287
  key: "close",
353
288
  value: function close() {
354
- var _this$menu2;
355
- (_this$menu2 = this.menu) === null || _this$menu2 === void 0 ? void 0 : _this$menu2.close();
289
+ if (!this.menu) {
290
+ return;
291
+ }
292
+ this.menu.close();
356
293
  }
357
294
 
358
295
  /**
@@ -424,12 +361,21 @@ export var DropdownMenu = /*#__PURE__*/function (_BasePlugin) {
424
361
  key: "onTableClick",
425
362
  value: function onTableClick(event) {
426
363
  event.stopPropagation();
427
- if (hasClass(event.target, BUTTON_CLASS_NAME)) {
428
- var offset = getDocumentOffsetByElement(this.menu.container, this.hot.rootDocument);
364
+ if (hasClass(event.target, BUTTON_CLASS_NAME) && !this.menu.isOpened()) {
365
+ var offsetTop = 0;
366
+ var offsetLeft = 0;
367
+ if (this.hot.rootDocument !== this.menu.container.ownerDocument) {
368
+ var frameElement = this.hot.rootWindow.frameElement;
369
+ var _frameElement$getBoun = frameElement.getBoundingClientRect(),
370
+ top = _frameElement$getBoun.top,
371
+ left = _frameElement$getBoun.left;
372
+ offsetTop = top;
373
+ offsetLeft = left;
374
+ }
429
375
  var rect = event.target.getBoundingClientRect();
430
376
  this.open({
431
- left: rect.left + offset.left,
432
- top: rect.top + event.target.offsetHeight + 3 + offset.top,
377
+ left: rect.left + offsetLeft,
378
+ top: rect.top + event.target.offsetHeight + 3 + offsetTop,
433
379
  width: rect.width,
434
380
  height: rect.height
435
381
  });