@testing-library/user-event 14.0.0-beta.3 → 14.0.0-beta.4
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/dist/index.d.ts +1110 -3
- package/dist/index.js +2826 -8
- package/dist/package.json +1 -0
- package/package.json +6 -30
- 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.d.ts +0 -3
- 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.d.ts +0 -3
- 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.d.ts +0 -10
- package/dist/document/index.js +0 -100
- package/dist/document/interceptor.d.ts +0 -15
- package/dist/document/interceptor.js +0 -37
- package/dist/document/selection.d.ts +0 -27
- package/dist/document/selection.js +0 -90
- package/dist/document/value.d.ts +0 -18
- package/dist/document/value.js +0 -77
- package/dist/keyboard/getEventProps.d.ts +0 -15
- package/dist/keyboard/getEventProps.js +0 -27
- package/dist/keyboard/index.d.ts +0 -7
- package/dist/keyboard/index.js +0 -42
- package/dist/keyboard/keyMap.d.ts +0 -5
- package/dist/keyboard/keyMap.js +0 -119
- package/dist/keyboard/keyboardAction.d.ts +0 -10
- package/dist/keyboard/keyboardAction.js +0 -156
- package/dist/keyboard/parseKeyDef.d.ts +0 -17
- 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.d.ts +0 -64
- package/dist/keyboard/types.js +0 -19
- package/dist/options.d.ts +0 -102
- package/dist/options.js +0 -36
- package/dist/pointer/index.d.ts +0 -10
- package/dist/pointer/index.js +0 -56
- package/dist/pointer/keyMap.d.ts +0 -2
- package/dist/pointer/keyMap.js +0 -29
- package/dist/pointer/parseKeyDef.d.ts +0 -6
- package/dist/pointer/parseKeyDef.js +0 -34
- package/dist/pointer/pointerAction.d.ts +0 -7
- 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.d.ts +0 -8
- package/dist/pointer/pointerPress.js +0 -327
- package/dist/pointer/resolveSelectionTarget.d.ts +0 -5
- package/dist/pointer/resolveSelectionTarget.js +0 -75
- package/dist/pointer/types.d.ts +0 -61
- package/dist/pointer/types.js +0 -1
- package/dist/setup/api.d.ts +0 -5
- package/dist/setup/api.js +0 -111
- package/dist/setup/config.d.ts +0 -10
- package/dist/setup/config.js +0 -8
- package/dist/setup/directApi.d.ts +0 -20
- package/dist/setup/directApi.js +0 -95
- package/dist/setup/index.d.ts +0 -30
- 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.d.ts +0 -4
- 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.d.ts +0 -4
- 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.d.ts +0 -1
- package/dist/utils/click/isClickableInput.js +0 -14
- package/dist/utils/dataTransfer/Blob.d.ts +0 -1
- package/dist/utils/dataTransfer/Blob.js +0 -21
- package/dist/utils/dataTransfer/Clipboard.d.ts +0 -9
- package/dist/utils/dataTransfer/Clipboard.js +0 -188
- package/dist/utils/dataTransfer/DataTransfer.d.ts +0 -2
- package/dist/utils/dataTransfer/DataTransfer.js +0 -158
- package/dist/utils/dataTransfer/FileList.d.ts +0 -1
- package/dist/utils/dataTransfer/FileList.js +0 -23
- package/dist/utils/edit/buildTimeValue.d.ts +0 -1
- 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.d.ts +0 -1
- package/dist/utils/edit/getValue.js +0 -23
- package/dist/utils/edit/isContentEditable.d.ts +0 -7
- package/dist/utils/edit/isContentEditable.js +0 -25
- package/dist/utils/edit/isEditable.d.ts +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.d.ts +0 -1
- 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.d.ts +0 -12
- package/dist/utils/edit/setFiles.js +0 -72
- package/dist/utils/focus/blur.d.ts +0 -2
- package/dist/utils/focus/blur.js +0 -19
- package/dist/utils/focus/copySelection.d.ts +0 -1
- package/dist/utils/focus/copySelection.js +0 -36
- package/dist/utils/focus/focus.d.ts +0 -2
- package/dist/utils/focus/focus.js +0 -22
- package/dist/utils/focus/getActiveElement.d.ts +0 -1
- package/dist/utils/focus/getActiveElement.js +0 -26
- package/dist/utils/focus/getTabDestination.d.ts +0 -1
- package/dist/utils/focus/getTabDestination.js +0 -84
- package/dist/utils/focus/isFocusable.d.ts +0 -1
- package/dist/utils/focus/isFocusable.js +0 -12
- package/dist/utils/focus/selectAll.d.ts +0 -5
- package/dist/utils/focus/selectAll.js +0 -51
- package/dist/utils/focus/selection.d.ts +0 -42
- package/dist/utils/focus/selection.js +0 -190
- package/dist/utils/focus/selector.d.ts +0 -1
- package/dist/utils/focus/selector.js +0 -8
- package/dist/utils/index.d.ts +0 -38
- package/dist/utils/index.js +0 -499
- package/dist/utils/keyDef/readNextDescriptor.d.ts +0 -19
- package/dist/utils/keyDef/readNextDescriptor.js +0 -102
- package/dist/utils/misc/eventWrapper.d.ts +0 -1
- 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.d.ts +0 -1
- 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.d.ts +0 -1
- package/dist/utils/misc/isDescendantOrSelf.js +0 -20
- package/dist/utils/misc/isDisabled.d.ts +0 -1
- package/dist/utils/misc/isDisabled.js +0 -12
- package/dist/utils/misc/isElementType.d.ts +0 -5
- package/dist/utils/misc/isElementType.js +0 -24
- package/dist/utils/misc/isVisible.d.ts +0 -1
- package/dist/utils/misc/isVisible.js +0 -31
- package/dist/utils/misc/wait.d.ts +0 -1
- package/dist/utils/misc/wait.js +0 -10
- package/dist/utils/pointer/firePointerEvents.d.ts +0 -25
- package/dist/utils/pointer/firePointerEvents.js +0 -110
- package/dist/utils/pointer/mouseButtons.d.ts +0 -12
- package/dist/utils/pointer/mouseButtons.js +0 -45
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Options that can be passed to any event that relies
|
|
3
|
-
* on pointer-events property
|
|
4
|
-
*/
|
|
5
|
-
export declare interface PointerOptions {
|
|
6
|
-
/**
|
|
7
|
-
* When set to `true` the event skips checking if any element
|
|
8
|
-
* in the DOM-tree has `'pointer-events: none'` set. This check is
|
|
9
|
-
* costly in general and very costly when rendering large DOM-trees.
|
|
10
|
-
* Can be used to speed up tests.
|
|
11
|
-
* Default: `false`
|
|
12
|
-
* */
|
|
13
|
-
skipPointerEventsCheck?: boolean;
|
|
14
|
-
}
|
|
15
|
-
export declare function hasPointerEvents(element: Element): boolean;
|
|
@@ -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 +0,0 @@
|
|
|
1
|
-
export declare function isDescendantOrSelf(potentialDescendant: Element, potentialAncestor: Element): boolean;
|
|
@@ -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 +0,0 @@
|
|
|
1
|
-
export declare function isDisabled(element: Element | null): boolean;
|
|
@@ -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,5 +0,0 @@
|
|
|
1
|
-
declare type tag = keyof HTMLElementTagNameMap;
|
|
2
|
-
export declare function isElementType<T extends tag, P extends {
|
|
3
|
-
[k: string]: unknown;
|
|
4
|
-
} | undefined = undefined>(element: Element, tag: T | T[], props?: P): element is P extends undefined ? HTMLElementTagNameMap[T] : HTMLElementTagNameMap[T] & P;
|
|
5
|
-
export {};
|
|
@@ -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 +0,0 @@
|
|
|
1
|
-
export declare function isVisible(element: Element): boolean;
|
|
@@ -1,31 +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 {
|
|
17
|
-
display,
|
|
18
|
-
visibility
|
|
19
|
-
} = window.getComputedStyle(el);
|
|
20
|
-
|
|
21
|
-
if (display === 'none') {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (visibility === 'hidden') {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function wait(time?: number): Promise<void>;
|
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,110 +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
|
-
init.button = (0, _mouseButtons.getMouseButton)(button != null ? button : 0);
|
|
41
|
-
init.buttons = (0, _mouseButtons.getMouseButtons)(...pointerState.pressed.filter(p => p.keyDef.pointerType === pointerType).map(p => {
|
|
42
|
-
var _p$keyDef$button;
|
|
43
|
-
|
|
44
|
-
return (_p$keyDef$button = p.keyDef.button) != null ? _p$keyDef$button : 0;
|
|
45
|
-
}));
|
|
46
|
-
|
|
47
|
-
if (['mousedown', 'mouseup', 'click', 'dblclick', 'contextmenu'].includes(type)) {
|
|
48
|
-
init.detail = clickCount;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const eventKey = Object.keys(_eventMap.eventMap).find(k => k.toLowerCase() === type);
|
|
52
|
-
|
|
53
|
-
const event = _dom.createEvent[eventKey](target, init); // see https://github.com/testing-library/react-testing-library/issues/268
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
assignPositionInit(event, init);
|
|
57
|
-
assignPointerInit(event, init);
|
|
58
|
-
return (0, _dom.fireEvent)(target, event);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function assignProps(obj, props) {
|
|
62
|
-
for (const [key, value] of Object.entries(props)) {
|
|
63
|
-
Object.defineProperty(obj, key, {
|
|
64
|
-
get: () => value
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function assignPositionInit(obj, {
|
|
70
|
-
x,
|
|
71
|
-
y,
|
|
72
|
-
clientX,
|
|
73
|
-
clientY,
|
|
74
|
-
offsetX,
|
|
75
|
-
offsetY,
|
|
76
|
-
pageX,
|
|
77
|
-
pageY,
|
|
78
|
-
screenX,
|
|
79
|
-
screenY
|
|
80
|
-
}) {
|
|
81
|
-
var _ref, _ref2, _ref3, _ref4;
|
|
82
|
-
|
|
83
|
-
assignProps(obj, {
|
|
84
|
-
/* istanbul ignore start */
|
|
85
|
-
x: (_ref = x != null ? x : clientX) != null ? _ref : 0,
|
|
86
|
-
y: (_ref2 = y != null ? y : clientY) != null ? _ref2 : 0,
|
|
87
|
-
clientX: (_ref3 = x != null ? x : clientX) != null ? _ref3 : 0,
|
|
88
|
-
clientY: (_ref4 = y != null ? y : clientY) != null ? _ref4 : 0,
|
|
89
|
-
offsetX: offsetX != null ? offsetX : 0,
|
|
90
|
-
offsetY: offsetY != null ? offsetY : 0,
|
|
91
|
-
pageX: pageX != null ? pageX : 0,
|
|
92
|
-
pageY: pageY != null ? pageY : 0,
|
|
93
|
-
screenX: screenX != null ? screenX : 0,
|
|
94
|
-
screenY: screenY != null ? screenY : 0
|
|
95
|
-
/* istanbul ignore end */
|
|
96
|
-
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function assignPointerInit(obj, {
|
|
101
|
-
isPrimary,
|
|
102
|
-
pointerId,
|
|
103
|
-
pointerType
|
|
104
|
-
}) {
|
|
105
|
-
assignProps(obj, {
|
|
106
|
-
isPrimary,
|
|
107
|
-
pointerId,
|
|
108
|
-
pointerType
|
|
109
|
-
});
|
|
110
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare const MouseButton: {
|
|
2
|
-
readonly primary: 0;
|
|
3
|
-
readonly secondary: 1;
|
|
4
|
-
readonly auxiliary: 2;
|
|
5
|
-
readonly back: 3;
|
|
6
|
-
readonly X1: 3;
|
|
7
|
-
readonly forward: 4;
|
|
8
|
-
readonly X2: 4;
|
|
9
|
-
};
|
|
10
|
-
export declare type MouseButton = keyof typeof MouseButton | number;
|
|
11
|
-
export declare function getMouseButton(button: MouseButton): number;
|
|
12
|
-
export declare function getMouseButtons(...buttons: Array<MouseButton>): number;
|
|
@@ -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
|
-
}
|