@testing-library/user-event 14.0.0-beta.1 → 14.0.0-beta.12
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.
- package/README.md +5 -192
- package/dist/index.cjs +2878 -0
- package/dist/index.mjs +2949 -0
- package/dist/types/clipboard/copy.d.ts +2 -0
- package/dist/types/clipboard/cut.d.ts +2 -0
- package/dist/{clipboard → types/clipboard}/index.d.ts +0 -0
- package/dist/types/clipboard/paste.d.ts +2 -0
- package/dist/types/convenience/click.d.ts +4 -0
- package/dist/types/convenience/hover.d.ts +3 -0
- package/dist/{convenience → types/convenience}/index.d.ts +0 -0
- package/dist/types/convenience/tab.d.ts +4 -0
- package/dist/{document → types/document}/index.d.ts +0 -0
- package/dist/{document → types/document}/interceptor.d.ts +0 -0
- package/dist/{document → types/document}/selection.d.ts +0 -0
- package/dist/{document → types/document}/value.d.ts +0 -0
- package/dist/types/event/behavior/click.d.ts +1 -0
- package/dist/types/event/behavior/cut.d.ts +1 -0
- package/dist/types/event/behavior/index.d.ts +8 -0
- package/dist/types/event/behavior/keydown.d.ts +1 -0
- package/dist/types/event/behavior/keypress.d.ts +1 -0
- package/dist/types/event/behavior/keyup.d.ts +1 -0
- package/dist/types/event/behavior/paste.d.ts +1 -0
- package/dist/types/event/behavior/registry.d.ts +9 -0
- package/dist/types/event/createEvent.d.ts +8 -0
- package/dist/types/event/dispatchEvent.d.ts +2 -0
- package/dist/types/event/eventMap.d.ts +345 -0
- package/dist/types/event/eventTypes.d.ts +2 -0
- package/dist/types/event/index.d.ts +6 -0
- package/dist/types/event/types.d.ts +13 -0
- package/dist/types/event/wrapEvent.d.ts +1 -0
- package/dist/{index.d.ts → types/index.d.ts} +1 -0
- package/dist/{keyboard → types/keyboard}/index.d.ts +2 -2
- package/dist/{keyboard → types/keyboard}/keyMap.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/keyboardAction.d.ts +0 -0
- package/dist/types/keyboard/modifiers.d.ts +9 -0
- package/dist/{keyboard → types/keyboard}/parseKeyDef.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/types.d.ts +19 -10
- package/dist/{options.d.ts → types/options.d.ts} +23 -8
- package/dist/types/pointer/firePointerEvents.d.ts +11 -0
- package/dist/{pointer → types/pointer}/index.d.ts +2 -2
- package/dist/{pointer → types/pointer}/keyMap.d.ts +0 -0
- package/dist/{pointer → types/pointer}/parseKeyDef.d.ts +0 -0
- package/dist/{pointer → types/pointer}/pointerAction.d.ts +0 -0
- package/dist/types/pointer/pointerMove.d.ts +6 -0
- package/dist/{pointer → types/pointer}/pointerPress.d.ts +2 -2
- package/dist/{pointer → types/pointer}/resolveSelectionTarget.d.ts +0 -0
- package/dist/{pointer → types/pointer}/types.d.ts +2 -1
- package/dist/{setup → types/setup}/api.d.ts +0 -0
- package/dist/{setup → types/setup}/config.d.ts +0 -0
- package/dist/{setup → types/setup}/directApi.d.ts +1 -2
- package/dist/{setup → types/setup}/index.d.ts +8 -2
- package/dist/types/setup/setup.d.ts +20 -0
- package/dist/{setup → types/setup}/wrapAsync.d.ts +0 -0
- package/dist/types/utility/clear.d.ts +2 -0
- package/dist/{utility → types/utility}/index.d.ts +0 -0
- package/dist/types/utility/selectOptions.d.ts +3 -0
- package/dist/types/utility/type.d.ts +9 -0
- package/dist/types/utility/upload.d.ts +5 -0
- package/dist/{utils → types/utils}/click/isClickableInput.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/Blob.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/Clipboard.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/DataTransfer.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/FileList.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/buildTimeValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/getValue.d.ts +0 -0
- package/dist/types/utils/edit/input.d.ts +2 -0
- package/dist/{utils → types/utils}/edit/isContentEditable.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isEditable.d.ts +0 -0
- package/dist/types/utils/edit/isValidDateOrTimeValue.d.ts +3 -0
- package/dist/{utils → types/utils}/edit/maxLength.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/setFiles.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/blur.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/copySelection.d.ts +0 -0
- package/dist/types/utils/focus/cursor.d.ts +9 -0
- package/dist/{utils → types/utils}/focus/focus.d.ts +3 -0
- package/dist/{utils → types/utils}/focus/getActiveElement.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/getTabDestination.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/isFocusable.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selectAll.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selection.d.ts +4 -0
- package/dist/{utils → types/utils}/focus/selector.d.ts +0 -0
- package/dist/{utils → types/utils}/index.d.ts +7 -10
- package/dist/{utils → types/utils}/keyDef/readNextDescriptor.d.ts +0 -0
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +5 -0
- package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
- package/dist/types/utils/misc/cloneEvent.d.ts +1 -0
- package/dist/{utils → types/utils}/misc/eventWrapper.d.ts +0 -0
- package/dist/types/utils/misc/findClosest.d.ts +1 -0
- package/dist/{utils → types/utils}/misc/getDocumentFromNode.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isDescendantOrSelf.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isDisabled.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isElementType.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isVisible.d.ts +0 -0
- package/dist/types/utils/misc/level.d.ts +17 -0
- package/dist/{utils → types/utils}/misc/wait.d.ts +0 -0
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +15 -0
- package/dist/{utils → types/utils}/pointer/mouseButtons.d.ts +0 -0
- package/package.json +13 -30
- package/CHANGELOG.md +0 -5
- package/dist/clipboard/copy.d.ts +0 -2
- package/dist/clipboard/copy.js +0 -36
- package/dist/clipboard/cut.d.ts +0 -2
- package/dist/clipboard/cut.js +0 -42
- package/dist/clipboard/index.js +0 -44
- package/dist/clipboard/paste.d.ts +0 -2
- package/dist/clipboard/paste.js +0 -47
- package/dist/convenience/click.d.ts +0 -4
- package/dist/convenience/click.js +0 -52
- package/dist/convenience/hover.d.ts +0 -3
- package/dist/convenience/hover.js +0 -31
- package/dist/convenience/index.js +0 -44
- package/dist/convenience/tab.d.ts +0 -4
- package/dist/convenience/tab.js +0 -12
- package/dist/document/index.js +0 -100
- package/dist/document/interceptor.js +0 -37
- package/dist/document/selection.js +0 -90
- package/dist/document/value.js +0 -77
- package/dist/index.js +0 -13
- package/dist/keyboard/getEventProps.d.ts +0 -15
- package/dist/keyboard/getEventProps.js +0 -27
- package/dist/keyboard/index.js +0 -42
- package/dist/keyboard/keyMap.js +0 -119
- package/dist/keyboard/keyboardAction.js +0 -156
- package/dist/keyboard/parseKeyDef.js +0 -61
- package/dist/keyboard/plugins/arrow.d.ts +0 -6
- package/dist/keyboard/plugins/arrow.js +0 -28
- package/dist/keyboard/plugins/character.d.ts +0 -5
- package/dist/keyboard/plugins/character.js +0 -173
- package/dist/keyboard/plugins/combination.d.ts +0 -5
- package/dist/keyboard/plugins/combination.js +0 -19
- package/dist/keyboard/plugins/control.d.ts +0 -6
- package/dist/keyboard/plugins/control.js +0 -52
- package/dist/keyboard/plugins/functional.d.ts +0 -11
- package/dist/keyboard/plugins/functional.js +0 -158
- package/dist/keyboard/plugins/index.d.ts +0 -7
- package/dist/keyboard/plugins/index.js +0 -33
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -3
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
- package/dist/keyboard/shared/index.d.ts +0 -1
- package/dist/keyboard/shared/index.js +0 -18
- package/dist/keyboard/types.js +0 -19
- package/dist/options.js +0 -36
- package/dist/pointer/index.js +0 -56
- package/dist/pointer/keyMap.js +0 -29
- package/dist/pointer/parseKeyDef.js +0 -34
- package/dist/pointer/pointerAction.js +0 -46
- package/dist/pointer/pointerMove.d.ts +0 -6
- package/dist/pointer/pointerMove.js +0 -136
- package/dist/pointer/pointerPress.js +0 -330
- package/dist/pointer/resolveSelectionTarget.js +0 -75
- package/dist/pointer/types.js +0 -1
- package/dist/setup/api.js +0 -111
- package/dist/setup/config.js +0 -8
- package/dist/setup/directApi.js +0 -95
- package/dist/setup/index.js +0 -27
- package/dist/setup/setup.d.ts +0 -74
- package/dist/setup/setup.js +0 -98
- package/dist/setup/wrapAsync.js +0 -15
- package/dist/utility/clear.d.ts +0 -2
- package/dist/utility/clear.js +0 -30
- package/dist/utility/index.js +0 -57
- package/dist/utility/selectOptions.d.ts +0 -3
- package/dist/utility/selectOptions.js +0 -132
- package/dist/utility/type.d.ts +0 -9
- package/dist/utility/type.js +0 -37
- package/dist/utility/upload.d.ts +0 -5
- package/dist/utility/upload.js +0 -64
- package/dist/utils/click/isClickableInput.js +0 -14
- package/dist/utils/dataTransfer/Blob.js +0 -21
- package/dist/utils/dataTransfer/Clipboard.js +0 -188
- package/dist/utils/dataTransfer/DataTransfer.js +0 -158
- package/dist/utils/dataTransfer/FileList.js +0 -23
- package/dist/utils/edit/buildTimeValue.js +0 -44
- package/dist/utils/edit/calculateNewValue.d.ts +0 -14
- package/dist/utils/edit/calculateNewValue.js +0 -46
- package/dist/utils/edit/editInputElement.d.ts +0 -16
- package/dist/utils/edit/editInputElement.js +0 -53
- package/dist/utils/edit/getValue.js +0 -23
- package/dist/utils/edit/isContentEditable.js +0 -25
- package/dist/utils/edit/isEditable.js +0 -42
- package/dist/utils/edit/isValidDateValue.d.ts +0 -3
- package/dist/utils/edit/isValidDateValue.js +0 -12
- package/dist/utils/edit/isValidInputTimeValue.d.ts +0 -3
- package/dist/utils/edit/isValidInputTimeValue.js +0 -12
- package/dist/utils/edit/maxLength.js +0 -50
- package/dist/utils/edit/prepareInput.d.ts +0 -7
- package/dist/utils/edit/prepareInput.js +0 -77
- package/dist/utils/edit/setFiles.js +0 -72
- package/dist/utils/focus/blur.js +0 -19
- package/dist/utils/focus/copySelection.js +0 -36
- package/dist/utils/focus/focus.js +0 -22
- package/dist/utils/focus/getActiveElement.js +0 -26
- package/dist/utils/focus/getTabDestination.js +0 -71
- package/dist/utils/focus/isFocusable.js +0 -12
- package/dist/utils/focus/selectAll.js +0 -51
- package/dist/utils/focus/selection.js +0 -190
- package/dist/utils/focus/selector.js +0 -8
- package/dist/utils/index.js +0 -499
- package/dist/utils/keyDef/readNextDescriptor.js +0 -102
- package/dist/utils/misc/eventWrapper.js +0 -16
- package/dist/utils/misc/findClosest.d.ts +0 -1
- package/dist/utils/misc/findClosest.js +0 -20
- package/dist/utils/misc/getDocumentFromNode.js +0 -14
- package/dist/utils/misc/hasFormSubmit.d.ts +0 -1
- package/dist/utils/misc/hasFormSubmit.js +0 -10
- package/dist/utils/misc/hasPointerEvents.d.ts +0 -15
- package/dist/utils/misc/hasPointerEvents.js +0 -24
- package/dist/utils/misc/isDescendantOrSelf.js +0 -20
- package/dist/utils/misc/isDisabled.js +0 -12
- package/dist/utils/misc/isElementType.js +0 -24
- package/dist/utils/misc/isVisible.js +0 -24
- package/dist/utils/misc/wait.js +0 -10
- package/dist/utils/pointer/firePointerEvents.d.ts +0 -25
- package/dist/utils/pointer/firePointerEvents.js +0 -112
- package/dist/utils/pointer/mouseButtons.js +0 -45
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.hasPointerEvents = hasPointerEvents;
|
|
7
|
-
|
|
8
|
-
var _helpers = require("@testing-library/dom/dist/helpers");
|
|
9
|
-
|
|
10
|
-
function hasPointerEvents(element) {
|
|
11
|
-
const window = (0, _helpers.getWindowFromNode)(element);
|
|
12
|
-
|
|
13
|
-
for (let el = element; (_el = el) != null && _el.ownerDocument; el = el.parentElement) {
|
|
14
|
-
var _el;
|
|
15
|
-
|
|
16
|
-
const pointerEvents = window.getComputedStyle(el).pointerEvents;
|
|
17
|
-
|
|
18
|
-
if (pointerEvents && !['inherit', 'unset'].includes(pointerEvents)) {
|
|
19
|
-
return pointerEvents !== 'none';
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isDescendantOrSelf = isDescendantOrSelf;
|
|
7
|
-
|
|
8
|
-
function isDescendantOrSelf(potentialDescendant, potentialAncestor) {
|
|
9
|
-
let el = potentialDescendant;
|
|
10
|
-
|
|
11
|
-
do {
|
|
12
|
-
if (el === potentialAncestor) {
|
|
13
|
-
return true;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
el = el.parentElement;
|
|
17
|
-
} while (el);
|
|
18
|
-
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isDisabled = isDisabled;
|
|
7
|
-
|
|
8
|
-
// This should probably be extended with checking the element type
|
|
9
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
|
|
10
|
-
function isDisabled(element) {
|
|
11
|
-
return Boolean(element && element.disabled);
|
|
12
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isElementType = isElementType;
|
|
7
|
-
|
|
8
|
-
function isElementType(element, tag, props) {
|
|
9
|
-
if (element.namespaceURI && element.namespaceURI !== 'http://www.w3.org/1999/xhtml') {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
tag = Array.isArray(tag) ? tag : [tag]; // tagName is uppercase in HTMLDocument and lowercase in XMLDocument
|
|
14
|
-
|
|
15
|
-
if (!tag.includes(element.tagName.toLowerCase())) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (props) {
|
|
20
|
-
return Object.entries(props).every(([k, v]) => element[k] === v);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isVisible = isVisible;
|
|
7
|
-
|
|
8
|
-
var _helpers = require("@testing-library/dom/dist/helpers");
|
|
9
|
-
|
|
10
|
-
function isVisible(element) {
|
|
11
|
-
const window = (0, _helpers.getWindowFromNode)(element);
|
|
12
|
-
|
|
13
|
-
for (let el = element; (_el = el) != null && _el.ownerDocument; el = el.parentElement) {
|
|
14
|
-
var _el;
|
|
15
|
-
|
|
16
|
-
const display = window.getComputedStyle(el).display;
|
|
17
|
-
|
|
18
|
-
if (display === 'none') {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return true;
|
|
24
|
-
}
|
package/dist/utils/misc/wait.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { pointerState } from '../../pointer/types';
|
|
2
|
-
import type { keyboardState } from '../../keyboard/types';
|
|
3
|
-
import { MouseButton } from './mouseButtons';
|
|
4
|
-
export declare function firePointerEvent(target: Element, type: string, { pointerState, keyboardState, pointerType, button, coords, pointerId, isPrimary, clickCount, }: {
|
|
5
|
-
pointerState: pointerState;
|
|
6
|
-
keyboardState: keyboardState;
|
|
7
|
-
pointerType?: 'mouse' | 'pen' | 'touch';
|
|
8
|
-
button?: MouseButton;
|
|
9
|
-
coords?: PointerCoords;
|
|
10
|
-
pointerId?: number;
|
|
11
|
-
isPrimary?: boolean;
|
|
12
|
-
clickCount?: number;
|
|
13
|
-
}): boolean;
|
|
14
|
-
export interface PointerCoords {
|
|
15
|
-
x?: number;
|
|
16
|
-
y?: number;
|
|
17
|
-
clientX?: number;
|
|
18
|
-
clientY?: number;
|
|
19
|
-
offsetX?: number;
|
|
20
|
-
offsetY?: number;
|
|
21
|
-
pageX?: number;
|
|
22
|
-
pageY?: number;
|
|
23
|
-
screenX?: number;
|
|
24
|
-
screenY?: number;
|
|
25
|
-
}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.firePointerEvent = firePointerEvent;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _eventMap = require("@testing-library/dom/dist/event-map");
|
|
11
|
-
|
|
12
|
-
var _mouseButtons = require("./mouseButtons");
|
|
13
|
-
|
|
14
|
-
function firePointerEvent(target, type, {
|
|
15
|
-
pointerState,
|
|
16
|
-
keyboardState,
|
|
17
|
-
pointerType,
|
|
18
|
-
button,
|
|
19
|
-
coords,
|
|
20
|
-
pointerId,
|
|
21
|
-
isPrimary,
|
|
22
|
-
clickCount
|
|
23
|
-
}) {
|
|
24
|
-
const init = { ...coords,
|
|
25
|
-
altKey: keyboardState.modifiers.alt,
|
|
26
|
-
ctrlKey: keyboardState.modifiers.ctrl,
|
|
27
|
-
metaKey: keyboardState.modifiers.meta,
|
|
28
|
-
shiftKey: keyboardState.modifiers.shift
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
if (type === 'click' || type.startsWith('pointer')) {
|
|
32
|
-
init.pointerId = pointerId;
|
|
33
|
-
init.pointerType = pointerType;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (['pointerdown', 'pointerup'].includes(type)) {
|
|
37
|
-
init.isPrimary = isPrimary;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (['mousedown', 'mouseup', 'pointerdown', 'pointerup', 'click'].includes(type)) {
|
|
41
|
-
init.button = (0, _mouseButtons.getMouseButton)(button != null ? button : 0);
|
|
42
|
-
init.buttons = (0, _mouseButtons.getMouseButtons)(...pointerState.pressed.filter(p => p.keyDef.pointerType === pointerType).map(p => {
|
|
43
|
-
var _p$keyDef$button;
|
|
44
|
-
|
|
45
|
-
return (_p$keyDef$button = p.keyDef.button) != null ? _p$keyDef$button : 0;
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (['mousedown', 'mouseup', 'click', 'dblclick'].includes(type)) {
|
|
50
|
-
init.detail = clickCount;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const eventKey = Object.keys(_eventMap.eventMap).find(k => k.toLowerCase() === type);
|
|
54
|
-
|
|
55
|
-
const event = _dom.createEvent[eventKey](target, init); // see https://github.com/testing-library/react-testing-library/issues/268
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
assignPositionInit(event, init);
|
|
59
|
-
assignPointerInit(event, init);
|
|
60
|
-
return (0, _dom.fireEvent)(target, event);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function assignProps(obj, props) {
|
|
64
|
-
for (const [key, value] of Object.entries(props)) {
|
|
65
|
-
Object.defineProperty(obj, key, {
|
|
66
|
-
get: () => value
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function assignPositionInit(obj, {
|
|
72
|
-
x,
|
|
73
|
-
y,
|
|
74
|
-
clientX,
|
|
75
|
-
clientY,
|
|
76
|
-
offsetX,
|
|
77
|
-
offsetY,
|
|
78
|
-
pageX,
|
|
79
|
-
pageY,
|
|
80
|
-
screenX,
|
|
81
|
-
screenY
|
|
82
|
-
}) {
|
|
83
|
-
var _ref, _ref2, _ref3, _ref4;
|
|
84
|
-
|
|
85
|
-
assignProps(obj, {
|
|
86
|
-
/* istanbul ignore start */
|
|
87
|
-
x: (_ref = x != null ? x : clientX) != null ? _ref : 0,
|
|
88
|
-
y: (_ref2 = y != null ? y : clientY) != null ? _ref2 : 0,
|
|
89
|
-
clientX: (_ref3 = x != null ? x : clientX) != null ? _ref3 : 0,
|
|
90
|
-
clientY: (_ref4 = y != null ? y : clientY) != null ? _ref4 : 0,
|
|
91
|
-
offsetX: offsetX != null ? offsetX : 0,
|
|
92
|
-
offsetY: offsetY != null ? offsetY : 0,
|
|
93
|
-
pageX: pageX != null ? pageX : 0,
|
|
94
|
-
pageY: pageY != null ? pageY : 0,
|
|
95
|
-
screenX: screenX != null ? screenX : 0,
|
|
96
|
-
screenY: screenY != null ? screenY : 0
|
|
97
|
-
/* istanbul ignore end */
|
|
98
|
-
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function assignPointerInit(obj, {
|
|
103
|
-
isPrimary,
|
|
104
|
-
pointerId,
|
|
105
|
-
pointerType
|
|
106
|
-
}) {
|
|
107
|
-
assignProps(obj, {
|
|
108
|
-
isPrimary,
|
|
109
|
-
pointerId,
|
|
110
|
-
pointerType
|
|
111
|
-
});
|
|
112
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MouseButton = void 0;
|
|
7
|
-
exports.getMouseButton = getMouseButton;
|
|
8
|
-
exports.getMouseButtons = getMouseButtons;
|
|
9
|
-
const MouseButton = {
|
|
10
|
-
primary: 0,
|
|
11
|
-
secondary: 1,
|
|
12
|
-
auxiliary: 2,
|
|
13
|
-
back: 3,
|
|
14
|
-
X1: 3,
|
|
15
|
-
forward: 4,
|
|
16
|
-
X2: 4
|
|
17
|
-
};
|
|
18
|
-
exports.MouseButton = MouseButton;
|
|
19
|
-
// Some legacy...
|
|
20
|
-
const MouseButtonFlip = {
|
|
21
|
-
auxiliary: 1,
|
|
22
|
-
secondary: 2,
|
|
23
|
-
1: 2,
|
|
24
|
-
2: 1
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
function getMouseButton(button) {
|
|
28
|
-
if (button in MouseButtonFlip) {
|
|
29
|
-
return MouseButtonFlip[button];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return typeof button === 'number' ? button : MouseButton[button];
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function getMouseButtons(...buttons) {
|
|
36
|
-
let v = 0;
|
|
37
|
-
|
|
38
|
-
for (const t of buttons) {
|
|
39
|
-
const pos = typeof t === 'number' ? t : MouseButton[t]; // eslint-disable-next-line no-bitwise
|
|
40
|
-
|
|
41
|
-
v |= 2 ** pos;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return v;
|
|
45
|
-
}
|