handsontable 0.0.0-next-b914b0f-20230828 → 0.0.0-next-c8688e9-20230828
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/base.js +2 -2
- package/base.mjs +2 -2
- package/dist/handsontable.css +2 -2
- package/dist/handsontable.full.css +2 -2
- package/dist/handsontable.full.js +38 -36
- package/dist/handsontable.full.min.css +2 -2
- package/dist/handsontable.full.min.js +4 -4
- package/dist/handsontable.js +38 -36
- package/dist/handsontable.min.css +2 -2
- package/dist/handsontable.min.js +4 -4
- package/helpers/dom/event.d.ts +1 -0
- package/helpers/dom/event.js +25 -0
- package/helpers/dom/event.mjs +24 -0
- package/helpers/mixed.js +1 -1
- package/helpers/mixed.mjs +1 -1
- package/package.json +1 -1
- package/plugins/manualColumnMove/manualColumnMove.js +4 -12
- package/plugins/manualColumnMove/manualColumnMove.mjs +4 -12
- package/plugins/manualRowMove/manualRowMove.js +4 -19
- package/plugins/manualRowMove/manualRowMove.mjs +4 -19
package/helpers/dom/event.d.ts
CHANGED
@@ -2,3 +2,4 @@ export function stopImmediatePropagation(event: Event): void;
|
|
2
2
|
export function isImmediatePropagationStopped(event: Event): boolean;
|
3
3
|
export function isRightClick(event: Event): boolean;
|
4
4
|
export function isLeftClick(event: Event): boolean;
|
5
|
+
export function offsetRelativeTo(event: Event, untilElement: HTMLElement | undefined): { x: number, y: number };
|
package/helpers/dom/event.js
CHANGED
@@ -4,6 +4,7 @@ exports.__esModule = true;
|
|
4
4
|
exports.isImmediatePropagationStopped = isImmediatePropagationStopped;
|
5
5
|
exports.isLeftClick = isLeftClick;
|
6
6
|
exports.isRightClick = isRightClick;
|
7
|
+
exports.offsetRelativeTo = offsetRelativeTo;
|
7
8
|
exports.stopImmediatePropagation = stopImmediatePropagation;
|
8
9
|
/**
|
9
10
|
* Prevent other listeners of the same event from being called.
|
@@ -43,4 +44,28 @@ function isRightClick(event) {
|
|
43
44
|
*/
|
44
45
|
function isLeftClick(event) {
|
45
46
|
return event.button === 0;
|
47
|
+
}
|
48
|
+
|
49
|
+
/**
|
50
|
+
* Calculates the event offset until reaching the element defined by `relativeElement` argument.
|
51
|
+
*
|
52
|
+
* @param {Event} event The mouse event object.
|
53
|
+
* @param {HTMLElement|undefined} [untilElement] The element to which the offset will be calculated.
|
54
|
+
* @returns {{ x: number, y: number }}
|
55
|
+
*/
|
56
|
+
function offsetRelativeTo(event, untilElement) {
|
57
|
+
const offset = {
|
58
|
+
x: event.offsetX,
|
59
|
+
y: event.offsetY
|
60
|
+
};
|
61
|
+
let element = event.target;
|
62
|
+
if (!(untilElement instanceof HTMLElement) || element !== untilElement && element.contains(untilElement)) {
|
63
|
+
return offset;
|
64
|
+
}
|
65
|
+
while (element !== untilElement) {
|
66
|
+
offset.x += element.offsetLeft;
|
67
|
+
offset.y += element.offsetTop;
|
68
|
+
element = element.offsetParent;
|
69
|
+
}
|
70
|
+
return offset;
|
46
71
|
}
|
package/helpers/dom/event.mjs
CHANGED
@@ -36,4 +36,28 @@ export function isRightClick(event) {
|
|
36
36
|
*/
|
37
37
|
export function isLeftClick(event) {
|
38
38
|
return event.button === 0;
|
39
|
+
}
|
40
|
+
|
41
|
+
/**
|
42
|
+
* Calculates the event offset until reaching the element defined by `relativeElement` argument.
|
43
|
+
*
|
44
|
+
* @param {Event} event The mouse event object.
|
45
|
+
* @param {HTMLElement|undefined} [untilElement] The element to which the offset will be calculated.
|
46
|
+
* @returns {{ x: number, y: number }}
|
47
|
+
*/
|
48
|
+
export function offsetRelativeTo(event, untilElement) {
|
49
|
+
const offset = {
|
50
|
+
x: event.offsetX,
|
51
|
+
y: event.offsetY
|
52
|
+
};
|
53
|
+
let element = event.target;
|
54
|
+
if (!(untilElement instanceof HTMLElement) || element !== untilElement && element.contains(untilElement)) {
|
55
|
+
return offset;
|
56
|
+
}
|
57
|
+
while (element !== untilElement) {
|
58
|
+
offset.x += element.offsetLeft;
|
59
|
+
offset.y += element.offsetTop;
|
60
|
+
element = element.offsetParent;
|
61
|
+
}
|
62
|
+
return offset;
|
39
63
|
}
|
package/helpers/mixed.js
CHANGED
@@ -134,7 +134,7 @@ const domMessages = {
|
|
134
134
|
function _injectProductInfo(key, element) {
|
135
135
|
const hasValidType = !isEmpty(key);
|
136
136
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
137
|
-
const hotVersion = "0.0.0-next-
|
137
|
+
const hotVersion = "0.0.0-next-c8688e9-20230828";
|
138
138
|
let keyValidityDate;
|
139
139
|
let consoleMessageState = 'invalid';
|
140
140
|
let domMessageState = 'invalid';
|
package/helpers/mixed.mjs
CHANGED
@@ -124,7 +124,7 @@ const domMessages = {
|
|
124
124
|
export function _injectProductInfo(key, element) {
|
125
125
|
const hasValidType = !isEmpty(key);
|
126
126
|
const isNonCommercial = typeof key === 'string' && key.toLowerCase() === 'non-commercial-and-evaluation';
|
127
|
-
const hotVersion = "0.0.0-next-
|
127
|
+
const hotVersion = "0.0.0-next-c8688e9-20230828";
|
128
128
|
let keyValidityDate;
|
129
129
|
let consoleMessageState = 'invalid';
|
130
130
|
let 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-
|
13
|
+
"version": "0.0.0-next-c8688e9-20230828",
|
14
14
|
"main": "index",
|
15
15
|
"module": "index.mjs",
|
16
16
|
"jsnext:main": "index.mjs",
|
@@ -6,6 +6,7 @@ var _base = require("../base");
|
|
6
6
|
var _pluginHooks = _interopRequireDefault(require("../../pluginHooks"));
|
7
7
|
var _array = require("../../helpers/array");
|
8
8
|
var _element = require("../../helpers/dom/element");
|
9
|
+
var _event = require("../../helpers/dom/event");
|
9
10
|
var _number = require("../../helpers/number");
|
10
11
|
var _eventManager = _interopRequireDefault(require("../../eventManager"));
|
11
12
|
var _backlight = _interopRequireDefault(require("./ui/backlight"));
|
@@ -513,8 +514,8 @@ class ManualColumnMove extends _base.BasePlugin {
|
|
513
514
|
if (coords.row < 0 && coords.col >= start && coords.col <= end) {
|
514
515
|
controller.column = true;
|
515
516
|
priv.pressed = true;
|
517
|
+
const eventOffsetX = TD.firstChild ? (0, _event.offsetRelativeTo)(event, TD.firstChild).x : event.offsetX;
|
516
518
|
priv.target.eventPageX = event.pageX;
|
517
|
-
priv.target.eventOffsetX = event.offsetX;
|
518
519
|
priv.hoveredColumn = coords.col;
|
519
520
|
priv.target.TD = TD;
|
520
521
|
priv.target.col = coords.col;
|
@@ -526,8 +527,8 @@ class ManualColumnMove extends _base.BasePlugin {
|
|
526
527
|
const countColumnsFrom = priv.hasRowHeaders ? -1 : 0;
|
527
528
|
const topPos = wtTable.holder.scrollTop + wtTable.getColumnHeaderHeight(0) + 1;
|
528
529
|
const fixedColumnsStart = coords.col < priv.fixedColumnsStart;
|
529
|
-
const horizontalScrollPosition =
|
530
|
-
const offsetX = Math.abs(
|
530
|
+
const horizontalScrollPosition = this.hot.view._wt.wtOverlays.inlineStartOverlay.getOverlayOffset();
|
531
|
+
const offsetX = Math.abs(eventOffsetX - (this.hot.isRtl() ? TD.offsetWidth : 0));
|
531
532
|
const inlineOffset = this.getColumnsWidth(start, coords.col - 1) + offsetX;
|
532
533
|
const inlinePos = this.getColumnsWidth(countColumnsFrom, start - 1) + (fixedColumnsStart ? horizontalScrollPosition : 0) + inlineOffset;
|
533
534
|
this.backlight.setPosition(topPos, inlinePos);
|
@@ -552,15 +553,6 @@ class ManualColumnMove extends _base.BasePlugin {
|
|
552
553
|
if (!priv.pressed) {
|
553
554
|
return;
|
554
555
|
}
|
555
|
-
|
556
|
-
// callback for browser which doesn't supports CSS pointer-event: none
|
557
|
-
if (event.target === this.backlight.element) {
|
558
|
-
const width = this.backlight.getSize().width;
|
559
|
-
this.backlight.setSize(0);
|
560
|
-
setTimeout(function () {
|
561
|
-
this.backlight.setPosition(width);
|
562
|
-
});
|
563
|
-
}
|
564
556
|
priv.target.eventPageX = event.pageX;
|
565
557
|
this.refreshPositions();
|
566
558
|
}
|
@@ -3,6 +3,7 @@ import { BasePlugin } from "../base/index.mjs";
|
|
3
3
|
import Hooks from "../../pluginHooks.mjs";
|
4
4
|
import { arrayReduce } from "../../helpers/array.mjs";
|
5
5
|
import { addClass, removeClass, offset, hasClass, outerWidth } from "../../helpers/dom/element.mjs";
|
6
|
+
import { offsetRelativeTo } from "../../helpers/dom/event.mjs";
|
6
7
|
import { rangeEach } from "../../helpers/number.mjs";
|
7
8
|
import EventManager from "../../eventManager.mjs";
|
8
9
|
import BacklightUI from "./ui/backlight.mjs";
|
@@ -507,8 +508,8 @@ export class ManualColumnMove extends BasePlugin {
|
|
507
508
|
if (coords.row < 0 && coords.col >= start && coords.col <= end) {
|
508
509
|
controller.column = true;
|
509
510
|
priv.pressed = true;
|
511
|
+
const eventOffsetX = TD.firstChild ? offsetRelativeTo(event, TD.firstChild).x : event.offsetX;
|
510
512
|
priv.target.eventPageX = event.pageX;
|
511
|
-
priv.target.eventOffsetX = event.offsetX;
|
512
513
|
priv.hoveredColumn = coords.col;
|
513
514
|
priv.target.TD = TD;
|
514
515
|
priv.target.col = coords.col;
|
@@ -520,8 +521,8 @@ export class ManualColumnMove extends BasePlugin {
|
|
520
521
|
const countColumnsFrom = priv.hasRowHeaders ? -1 : 0;
|
521
522
|
const topPos = wtTable.holder.scrollTop + wtTable.getColumnHeaderHeight(0) + 1;
|
522
523
|
const fixedColumnsStart = coords.col < priv.fixedColumnsStart;
|
523
|
-
const horizontalScrollPosition =
|
524
|
-
const offsetX = Math.abs(
|
524
|
+
const horizontalScrollPosition = this.hot.view._wt.wtOverlays.inlineStartOverlay.getOverlayOffset();
|
525
|
+
const offsetX = Math.abs(eventOffsetX - (this.hot.isRtl() ? TD.offsetWidth : 0));
|
525
526
|
const inlineOffset = this.getColumnsWidth(start, coords.col - 1) + offsetX;
|
526
527
|
const inlinePos = this.getColumnsWidth(countColumnsFrom, start - 1) + (fixedColumnsStart ? horizontalScrollPosition : 0) + inlineOffset;
|
527
528
|
this.backlight.setPosition(topPos, inlinePos);
|
@@ -546,15 +547,6 @@ export class ManualColumnMove extends BasePlugin {
|
|
546
547
|
if (!priv.pressed) {
|
547
548
|
return;
|
548
549
|
}
|
549
|
-
|
550
|
-
// callback for browser which doesn't supports CSS pointer-event: none
|
551
|
-
if (event.target === this.backlight.element) {
|
552
|
-
const width = this.backlight.getSize().width;
|
553
|
-
this.backlight.setSize(0);
|
554
|
-
setTimeout(function () {
|
555
|
-
this.backlight.setPosition(width);
|
556
|
-
});
|
557
|
-
}
|
558
550
|
priv.target.eventPageX = event.pageX;
|
559
551
|
this.refreshPositions();
|
560
552
|
}
|
@@ -416,14 +416,7 @@ class ManualRowMove extends _base.BasePlugin {
|
|
416
416
|
const rootElementOffset = (0, _element.offset)(rootElement);
|
417
417
|
const trimmingContainer = (0, _element.getTrimmingContainer)(rootElement);
|
418
418
|
const tableScroll = wtTable.holder.scrollTop;
|
419
|
-
|
420
|
-
|
421
|
-
// Trimming container is the `window` element.
|
422
|
-
if (this.hot.rootWindow === trimmingContainer) {
|
423
|
-
trimmingContainerScroll = trimmingContainer.scrollY;
|
424
|
-
} else {
|
425
|
-
trimmingContainerScroll = trimmingContainer.scrollTop;
|
426
|
-
}
|
419
|
+
const trimmingContainerScroll = this.hot.rootWindow !== trimmingContainer ? trimmingContainer.scrollTop : 0;
|
427
420
|
const pixelsAbove = rootElementOffset.top - trimmingContainerScroll;
|
428
421
|
const pixelsRelToTableStart = priv.target.eventPageY - pixelsAbove + tableScroll;
|
429
422
|
const hiderHeight = wtTable.hider.offsetHeight;
|
@@ -435,7 +428,7 @@ class ManualRowMove extends _base.BasePlugin {
|
|
435
428
|
let tdStartPixel = this.hot.view.THEAD.offsetHeight + this.getRowsHeight(0, coords.row - 1);
|
436
429
|
const isBelowTable = pixelsRelToTableStart >= tdStartPixel + tdMiddle;
|
437
430
|
if (this.isFixedRowTop(coords.row)) {
|
438
|
-
tdStartPixel +=
|
431
|
+
tdStartPixel += this.hot.view._wt.wtOverlays.topOverlay.getOverlayOffset();
|
439
432
|
}
|
440
433
|
if (coords.row < 0) {
|
441
434
|
// if hover on colHeader
|
@@ -532,9 +525,10 @@ class ManualRowMove extends _base.BasePlugin {
|
|
532
525
|
priv.target.TD = TD;
|
533
526
|
priv.rowsToMove = this.prepareRowsToMoving();
|
534
527
|
const leftPos = wtTable.holder.scrollLeft + wtViewport.getRowHeaderWidth();
|
528
|
+
const topOffset = this.getRowsHeight(start, coords.row - 1) + event.offsetY;
|
535
529
|
this.backlight.setPosition(null, leftPos);
|
536
530
|
this.backlight.setSize(wtTable.hider.offsetWidth - leftPos, this.getRowsHeight(start, end));
|
537
|
-
this.backlight.setOffset(
|
531
|
+
this.backlight.setOffset(-topOffset, null);
|
538
532
|
(0, _element.addClass)(this.hot.rootElement, CSS_ON_MOVING);
|
539
533
|
this.refreshPositions();
|
540
534
|
} else {
|
@@ -555,15 +549,6 @@ class ManualRowMove extends _base.BasePlugin {
|
|
555
549
|
if (!priv.pressed) {
|
556
550
|
return;
|
557
551
|
}
|
558
|
-
|
559
|
-
// callback for browser which doesn't supports CSS pointer-event: none
|
560
|
-
if (event.target === this.backlight.element) {
|
561
|
-
const height = this.backlight.getSize().height;
|
562
|
-
this.backlight.setSize(null, 0);
|
563
|
-
setTimeout(function () {
|
564
|
-
this.backlight.setPosition(null, height);
|
565
|
-
});
|
566
|
-
}
|
567
552
|
priv.target.eventPageY = event.pageY;
|
568
553
|
this.refreshPositions();
|
569
554
|
}
|
@@ -410,14 +410,7 @@ export class ManualRowMove extends BasePlugin {
|
|
410
410
|
const rootElementOffset = offset(rootElement);
|
411
411
|
const trimmingContainer = getTrimmingContainer(rootElement);
|
412
412
|
const tableScroll = wtTable.holder.scrollTop;
|
413
|
-
|
414
|
-
|
415
|
-
// Trimming container is the `window` element.
|
416
|
-
if (this.hot.rootWindow === trimmingContainer) {
|
417
|
-
trimmingContainerScroll = trimmingContainer.scrollY;
|
418
|
-
} else {
|
419
|
-
trimmingContainerScroll = trimmingContainer.scrollTop;
|
420
|
-
}
|
413
|
+
const trimmingContainerScroll = this.hot.rootWindow !== trimmingContainer ? trimmingContainer.scrollTop : 0;
|
421
414
|
const pixelsAbove = rootElementOffset.top - trimmingContainerScroll;
|
422
415
|
const pixelsRelToTableStart = priv.target.eventPageY - pixelsAbove + tableScroll;
|
423
416
|
const hiderHeight = wtTable.hider.offsetHeight;
|
@@ -429,7 +422,7 @@ export class ManualRowMove extends BasePlugin {
|
|
429
422
|
let tdStartPixel = this.hot.view.THEAD.offsetHeight + this.getRowsHeight(0, coords.row - 1);
|
430
423
|
const isBelowTable = pixelsRelToTableStart >= tdStartPixel + tdMiddle;
|
431
424
|
if (this.isFixedRowTop(coords.row)) {
|
432
|
-
tdStartPixel +=
|
425
|
+
tdStartPixel += this.hot.view._wt.wtOverlays.topOverlay.getOverlayOffset();
|
433
426
|
}
|
434
427
|
if (coords.row < 0) {
|
435
428
|
// if hover on colHeader
|
@@ -526,9 +519,10 @@ export class ManualRowMove extends BasePlugin {
|
|
526
519
|
priv.target.TD = TD;
|
527
520
|
priv.rowsToMove = this.prepareRowsToMoving();
|
528
521
|
const leftPos = wtTable.holder.scrollLeft + wtViewport.getRowHeaderWidth();
|
522
|
+
const topOffset = this.getRowsHeight(start, coords.row - 1) + event.offsetY;
|
529
523
|
this.backlight.setPosition(null, leftPos);
|
530
524
|
this.backlight.setSize(wtTable.hider.offsetWidth - leftPos, this.getRowsHeight(start, end));
|
531
|
-
this.backlight.setOffset(
|
525
|
+
this.backlight.setOffset(-topOffset, null);
|
532
526
|
addClass(this.hot.rootElement, CSS_ON_MOVING);
|
533
527
|
this.refreshPositions();
|
534
528
|
} else {
|
@@ -549,15 +543,6 @@ export class ManualRowMove extends BasePlugin {
|
|
549
543
|
if (!priv.pressed) {
|
550
544
|
return;
|
551
545
|
}
|
552
|
-
|
553
|
-
// callback for browser which doesn't supports CSS pointer-event: none
|
554
|
-
if (event.target === this.backlight.element) {
|
555
|
-
const height = this.backlight.getSize().height;
|
556
|
-
this.backlight.setSize(null, 0);
|
557
|
-
setTimeout(function () {
|
558
|
-
this.backlight.setPosition(null, height);
|
559
|
-
});
|
560
|
-
}
|
561
546
|
priv.target.eventPageY = event.pageY;
|
562
547
|
this.refreshPositions();
|
563
548
|
}
|