@testing-library/user-event 14.0.0-alpha.7 → 14.0.0-beta.10
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 +3003 -0
- package/dist/index.mjs +3074 -0
- package/dist/types/clipboard/copy.d.ts +2 -0
- package/dist/types/clipboard/cut.d.ts +2 -0
- package/dist/types/clipboard/index.d.ts +3 -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/types/convenience/index.d.ts +3 -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/index.d.ts +3 -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/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/types/index.d.ts +4 -0
- package/dist/types/keyboard/index.d.ts +7 -0
- package/dist/{keyboard → types/keyboard}/keyMap.d.ts +0 -0
- package/dist/types/keyboard/keyboardAction.d.ts +10 -0
- package/dist/{keyboard/getNextKeyDef.d.ts → types/keyboard/parseKeyDef.d.ts} +4 -6
- package/dist/{keyboard → types/keyboard}/plugins/arrow.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/character.d.ts +0 -0
- package/dist/types/keyboard/plugins/combination.d.ts +5 -0
- package/dist/{keyboard → types/keyboard}/plugins/control.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/functional.d.ts +0 -3
- package/dist/{keyboard → types/keyboard}/plugins/index.d.ts +0 -1
- package/dist/types/keyboard/plugins/modifiers.d.ts +8 -0
- package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +4 -0
- package/dist/{keyboard → types/keyboard}/shared/index.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/types.d.ts +22 -24
- package/dist/types/options.d.ts +117 -0
- package/dist/types/pointer/firePointerEvents.d.ts +11 -0
- package/dist/types/pointer/index.d.ts +10 -0
- package/dist/{pointer → types/pointer}/keyMap.d.ts +0 -0
- package/dist/types/pointer/parseKeyDef.d.ts +6 -0
- package/dist/{pointer → types/pointer}/pointerAction.d.ts +3 -2
- package/dist/types/pointer/pointerMove.d.ts +6 -0
- package/dist/types/pointer/pointerPress.d.ts +8 -0
- package/dist/{pointer → types/pointer}/resolveSelectionTarget.d.ts +0 -0
- package/dist/{pointer → types/pointer}/types.d.ts +2 -12
- package/dist/types/setup/api.d.ts +5 -0
- package/dist/types/setup/config.d.ts +10 -0
- package/dist/types/setup/directApi.d.ts +19 -0
- package/dist/types/setup/index.d.ts +36 -0
- package/dist/types/setup/setup.d.ts +20 -0
- package/dist/types/setup/wrapAsync.d.ts +4 -0
- package/dist/types/utility/clear.d.ts +2 -0
- package/dist/types/utility/index.d.ts +4 -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/types/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +9 -0
- package/dist/types/utils/dataTransfer/DataTransfer.d.ts +2 -0
- package/dist/types/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/{utils → types/utils}/edit/buildTimeValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/calculateNewValue.d.ts +1 -3
- package/dist/types/utils/edit/editInputElement.d.ts +14 -0
- package/dist/{utils → types/utils}/edit/getValue.d.ts +0 -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/{utils → types/utils}/edit/isValidDateValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isValidInputTimeValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/maxLength.d.ts +0 -0
- package/dist/types/utils/edit/prepareInput.d.ts +8 -0
- package/dist/types/utils/edit/setFiles.d.ts +12 -0
- package/dist/{utils → types/utils}/focus/blur.d.ts +0 -0
- package/dist/types/utils/focus/copySelection.d.ts +1 -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/types/utils/focus/selectAll.d.ts +5 -0
- package/dist/{utils → types/utils}/focus/selection.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selector.d.ts +0 -0
- package/dist/{utils → types/utils}/index.d.ts +15 -4
- 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/types/utils/misc/getDocumentFromNode.d.ts +1 -0
- package/dist/{utils → types/utils}/misc/hasFormSubmit.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/clear.d.ts +0 -2
- package/dist/clear.js +0 -46
- package/dist/click.d.ts +0 -9
- package/dist/click.js +0 -62
- 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/hover.d.ts +0 -4
- package/dist/hover.js +0 -43
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -22
- package/dist/keyboard/getEventProps.d.ts +0 -17
- package/dist/keyboard/getEventProps.js +0 -33
- package/dist/keyboard/getNextKeyDef.js +0 -85
- package/dist/keyboard/index.d.ts +0 -19
- package/dist/keyboard/index.js +0 -78
- package/dist/keyboard/keyMap.js +0 -143
- package/dist/keyboard/keyboardImplementation.d.ts +0 -3
- package/dist/keyboard/keyboardImplementation.js +0 -169
- package/dist/keyboard/plugins/arrow.js +0 -28
- package/dist/keyboard/plugins/character.js +0 -166
- package/dist/keyboard/plugins/control.js +0 -52
- package/dist/keyboard/plugins/functional.js +0 -140
- package/dist/keyboard/plugins/index.js +0 -40
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -3
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
- package/dist/keyboard/shared/index.js +0 -18
- package/dist/keyboard/specialCharMap.d.ts +0 -22
- package/dist/keyboard/specialCharMap.js +0 -30
- package/dist/keyboard/types.js +0 -19
- package/dist/paste.d.ts +0 -7
- package/dist/paste.js +0 -60
- package/dist/pointer/index.d.ts +0 -18
- package/dist/pointer/index.js +0 -90
- package/dist/pointer/keyMap.js +0 -29
- package/dist/pointer/parseKeyDef.d.ts +0 -6
- package/dist/pointer/parseKeyDef.js +0 -36
- package/dist/pointer/pointerAction.js +0 -52
- package/dist/pointer/pointerMove.d.ts +0 -5
- package/dist/pointer/pointerMove.js +0 -136
- package/dist/pointer/pointerPress.d.ts +0 -7
- package/dist/pointer/pointerPress.js +0 -330
- package/dist/pointer/resolveSelectionTarget.js +0 -75
- package/dist/pointer/types.js +0 -1
- package/dist/selectOptions.d.ts +0 -4
- package/dist/selectOptions.js +0 -142
- package/dist/setup.d.ts +0 -92
- package/dist/setup.js +0 -203
- package/dist/tab.d.ts +0 -5
- package/dist/tab.js +0 -12
- package/dist/type.d.ts +0 -14
- package/dist/type.js +0 -74
- package/dist/upload.d.ts +0 -10
- package/dist/upload.js +0 -92
- package/dist/utils/click/isClickableInput.js +0 -14
- package/dist/utils/edit/buildTimeValue.js +0 -44
- package/dist/utils/edit/calculateNewValue.js +0 -50
- package/dist/utils/edit/fireInputEvent.d.ts +0 -11
- package/dist/utils/edit/fireInputEvent.js +0 -65
- 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.js +0 -12
- package/dist/utils/edit/isValidInputTimeValue.js +0 -12
- package/dist/utils/edit/maxLength.js +0 -50
- package/dist/utils/edit/prepareInput.d.ts +0 -4
- package/dist/utils/edit/prepareInput.js +0 -60
- package/dist/utils/focus/blur.js +0 -19
- 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/selection.js +0 -190
- package/dist/utils/focus/selector.js +0 -8
- package/dist/utils/index.js +0 -408
- 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/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/fakeEvent.d.ts +0 -20
- package/dist/utils/pointer/fakeEvent.js +0 -91
- package/dist/utils/pointer/firePointerEvents.d.ts +0 -14
- package/dist/utils/pointer/firePointerEvents.js +0 -55
- package/dist/utils/pointer/mouseButtons.js +0 -45
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.specialCharMap = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @deprecated This list of strings with special meaning is no longer necessary
|
|
10
|
-
* as we've introduced a standardized way to describe any keystroke for `userEvent`.
|
|
11
|
-
* @see https://testing-library.com/docs/ecosystem-user-event#keyboardtext-options
|
|
12
|
-
*/
|
|
13
|
-
const specialCharMap = {
|
|
14
|
-
arrowLeft: '{arrowleft}',
|
|
15
|
-
arrowRight: '{arrowright}',
|
|
16
|
-
arrowDown: '{arrowdown}',
|
|
17
|
-
arrowUp: '{arrowup}',
|
|
18
|
-
enter: '{enter}',
|
|
19
|
-
escape: '{esc}',
|
|
20
|
-
delete: '{del}',
|
|
21
|
-
backspace: '{backspace}',
|
|
22
|
-
home: '{home}',
|
|
23
|
-
end: '{end}',
|
|
24
|
-
selectAll: '{selectall}',
|
|
25
|
-
space: '{space}',
|
|
26
|
-
whitespace: ' ',
|
|
27
|
-
pageUp: '{pageUp}',
|
|
28
|
-
pageDown: '{pageDown}'
|
|
29
|
-
};
|
|
30
|
-
exports.specialCharMap = specialCharMap;
|
package/dist/keyboard/types.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DOM_KEY_LOCATION = void 0;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @internal Do not create/alter this by yourself as this type might be subject to changes.
|
|
10
|
-
*/
|
|
11
|
-
let DOM_KEY_LOCATION;
|
|
12
|
-
exports.DOM_KEY_LOCATION = DOM_KEY_LOCATION;
|
|
13
|
-
|
|
14
|
-
(function (DOM_KEY_LOCATION) {
|
|
15
|
-
DOM_KEY_LOCATION[DOM_KEY_LOCATION["STANDARD"] = 0] = "STANDARD";
|
|
16
|
-
DOM_KEY_LOCATION[DOM_KEY_LOCATION["LEFT"] = 1] = "LEFT";
|
|
17
|
-
DOM_KEY_LOCATION[DOM_KEY_LOCATION["RIGHT"] = 2] = "RIGHT";
|
|
18
|
-
DOM_KEY_LOCATION[DOM_KEY_LOCATION["NUMPAD"] = 3] = "NUMPAD";
|
|
19
|
-
})(DOM_KEY_LOCATION || (exports.DOM_KEY_LOCATION = DOM_KEY_LOCATION = {}));
|
package/dist/paste.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { UserEvent } from './setup';
|
|
2
|
-
interface pasteOptions {
|
|
3
|
-
initialSelectionStart?: number;
|
|
4
|
-
initialSelectionEnd?: number;
|
|
5
|
-
}
|
|
6
|
-
export declare function paste(this: UserEvent, element: HTMLElement, text: string, init?: ClipboardEventInit, { initialSelectionStart, initialSelectionEnd }?: pasteOptions): void;
|
|
7
|
-
export {};
|
package/dist/paste.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.paste = paste;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
|
|
12
|
-
function isSupportedElement(element) {
|
|
13
|
-
return (0, _utils.isElementType)(element, 'input') && Boolean(_utils.editableInputTypes[element.type]) || (0, _utils.isElementType)(element, 'textarea');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function paste(element, text, init, {
|
|
17
|
-
initialSelectionStart,
|
|
18
|
-
initialSelectionEnd
|
|
19
|
-
} = {}) {
|
|
20
|
-
var _prepareInput;
|
|
21
|
-
|
|
22
|
-
// TODO: implement for contenteditable
|
|
23
|
-
if (!isSupportedElement(element)) {
|
|
24
|
-
throw new TypeError(`The given ${element.tagName} element is currently unsupported.
|
|
25
|
-
A PR extending this implementation would be very much welcome at https://github.com/testing-library/user-event`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if ((0, _utils.isDisabled)(element)) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
(0, _utils.eventWrapper)(() => element.focus()); // by default, a new element has it's selection start and end at 0
|
|
33
|
-
// but most of the time when people call "paste", they expect it to paste
|
|
34
|
-
// at the end of the current input value. So, if the selection start
|
|
35
|
-
// and end are both the default of 0, then we'll go ahead and change
|
|
36
|
-
// them to the length of the current value.
|
|
37
|
-
// the only time it would make sense to pass the initialSelectionStart or
|
|
38
|
-
// initialSelectionEnd is if you have an input with a value and want to
|
|
39
|
-
// explicitely start typing with the cursor at 0. Not super common.
|
|
40
|
-
|
|
41
|
-
if (element.selectionStart === 0 && element.selectionEnd === 0) {
|
|
42
|
-
(0, _utils.setSelectionRange)(element, initialSelectionStart != null ? initialSelectionStart : element.value.length, initialSelectionEnd != null ? initialSelectionEnd : element.value.length);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_dom.fireEvent.paste(element, init);
|
|
46
|
-
|
|
47
|
-
if (element.readOnly) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
text = text.substr(0, (0, _utils.getSpaceUntilMaxLength)(element));
|
|
52
|
-
const inputRange = (0, _utils.getInputRange)(element);
|
|
53
|
-
/* istanbul ignore if */
|
|
54
|
-
|
|
55
|
-
if (!inputRange) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
(_prepareInput = (0, _utils.prepareInput)(text, element, 'insertFromPaste')) == null ? void 0 : _prepareInput.commit();
|
|
60
|
-
}
|
package/dist/pointer/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { PointerAction, PointerActionTarget } from './pointerAction';
|
|
2
|
-
import type { inputDeviceState, pointerOptions, pointerState } from './types';
|
|
3
|
-
export declare function pointer(input: PointerInput, options?: Partial<pointerOptions & {
|
|
4
|
-
delay: 0;
|
|
5
|
-
} & inputDeviceState>): pointerState;
|
|
6
|
-
export declare function pointer(input: PointerInput, options: Partial<pointerOptions & {
|
|
7
|
-
delay: number;
|
|
8
|
-
} & inputDeviceState>): Promise<pointerState>;
|
|
9
|
-
declare type PointerActionInput = string | ({
|
|
10
|
-
keys: string;
|
|
11
|
-
} & PointerActionTarget) | PointerAction;
|
|
12
|
-
declare type PointerInput = PointerActionInput | Array<PointerActionInput>;
|
|
13
|
-
export declare function pointerImplementationWrapper(input: PointerInput, config: Partial<pointerOptions & inputDeviceState>): {
|
|
14
|
-
promise: Promise<unknown[]>;
|
|
15
|
-
pointerState: pointerState;
|
|
16
|
-
};
|
|
17
|
-
export declare function createPointerState(): pointerState;
|
|
18
|
-
export {};
|
package/dist/pointer/index.js
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createPointerState = createPointerState;
|
|
7
|
-
exports.pointer = pointer;
|
|
8
|
-
exports.pointerImplementationWrapper = pointerImplementationWrapper;
|
|
9
|
-
|
|
10
|
-
var _dom = require("@testing-library/dom");
|
|
11
|
-
|
|
12
|
-
var _keyboard = require("../keyboard");
|
|
13
|
-
|
|
14
|
-
var _parseKeyDef = require("./parseKeyDef");
|
|
15
|
-
|
|
16
|
-
var _keyMap = require("./keyMap");
|
|
17
|
-
|
|
18
|
-
var _pointerAction = require("./pointerAction");
|
|
19
|
-
|
|
20
|
-
function pointer(input, options = {}) {
|
|
21
|
-
var _options$delay;
|
|
22
|
-
|
|
23
|
-
const {
|
|
24
|
-
promise,
|
|
25
|
-
pointerState
|
|
26
|
-
} = pointerImplementationWrapper(input, options);
|
|
27
|
-
|
|
28
|
-
if (((_options$delay = options.delay) != null ? _options$delay : 0) > 0) {
|
|
29
|
-
return (0, _dom.getConfig)().asyncWrapper(() => promise.then(() => pointerState));
|
|
30
|
-
} else {
|
|
31
|
-
// prevent users from dealing with UnhandledPromiseRejectionWarning in sync call
|
|
32
|
-
promise.catch(console.error);
|
|
33
|
-
return pointerState;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function pointerImplementationWrapper(input, config) {
|
|
38
|
-
const {
|
|
39
|
-
pointerState = createPointerState(),
|
|
40
|
-
keyboardState = (0, _keyboard.createKeyboardState)(),
|
|
41
|
-
delay = 0,
|
|
42
|
-
pointerMap = _keyMap.defaultKeyMap
|
|
43
|
-
} = config;
|
|
44
|
-
const options = {
|
|
45
|
-
delay,
|
|
46
|
-
pointerMap
|
|
47
|
-
};
|
|
48
|
-
const actions = [];
|
|
49
|
-
(Array.isArray(input) ? input : [input]).forEach(actionInput => {
|
|
50
|
-
if (typeof actionInput === 'string') {
|
|
51
|
-
actions.push(...(0, _parseKeyDef.parseKeyDef)(actionInput, options));
|
|
52
|
-
} else if ('keys' in actionInput) {
|
|
53
|
-
actions.push(...(0, _parseKeyDef.parseKeyDef)(actionInput.keys, options).map(i => ({ ...actionInput,
|
|
54
|
-
...i
|
|
55
|
-
})));
|
|
56
|
-
} else {
|
|
57
|
-
actions.push(actionInput);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return {
|
|
61
|
-
promise: (0, _pointerAction.pointerAction)(actions, options, {
|
|
62
|
-
pointerState,
|
|
63
|
-
keyboardState
|
|
64
|
-
}),
|
|
65
|
-
pointerState
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
function createPointerState() {
|
|
70
|
-
return {
|
|
71
|
-
pointerId: 1,
|
|
72
|
-
position: {
|
|
73
|
-
mouse: {
|
|
74
|
-
pointerType: 'mouse',
|
|
75
|
-
pointerId: 1,
|
|
76
|
-
coords: {
|
|
77
|
-
clientX: 0,
|
|
78
|
-
clientY: 0,
|
|
79
|
-
offsetX: 0,
|
|
80
|
-
offsetY: 0,
|
|
81
|
-
pageX: 0,
|
|
82
|
-
pageY: 0,
|
|
83
|
-
x: 0,
|
|
84
|
-
y: 0
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
pressed: []
|
|
89
|
-
};
|
|
90
|
-
}
|
package/dist/pointer/keyMap.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.defaultKeyMap = void 0;
|
|
7
|
-
const defaultKeyMap = [{
|
|
8
|
-
name: 'MouseLeft',
|
|
9
|
-
pointerType: 'mouse',
|
|
10
|
-
button: 'primary'
|
|
11
|
-
}, {
|
|
12
|
-
name: 'MouseRight',
|
|
13
|
-
pointerType: 'mouse',
|
|
14
|
-
button: 'secondary'
|
|
15
|
-
}, {
|
|
16
|
-
name: 'MouseMiddle',
|
|
17
|
-
pointerType: 'mouse',
|
|
18
|
-
button: 'auxiliary'
|
|
19
|
-
}, {
|
|
20
|
-
name: 'TouchA',
|
|
21
|
-
pointerType: 'touch'
|
|
22
|
-
}, {
|
|
23
|
-
name: 'TouchB',
|
|
24
|
-
pointerType: 'touch'
|
|
25
|
-
}, {
|
|
26
|
-
name: 'TouchC',
|
|
27
|
-
pointerType: 'touch'
|
|
28
|
-
}];
|
|
29
|
-
exports.defaultKeyMap = defaultKeyMap;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parseKeyDef = parseKeyDef;
|
|
7
|
-
|
|
8
|
-
var _utils = require("../utils");
|
|
9
|
-
|
|
10
|
-
function parseKeyDef(keys, {
|
|
11
|
-
pointerMap
|
|
12
|
-
}) {
|
|
13
|
-
const defs = [];
|
|
14
|
-
|
|
15
|
-
do {
|
|
16
|
-
const {
|
|
17
|
-
descriptor,
|
|
18
|
-
consumedLength,
|
|
19
|
-
releasePrevious,
|
|
20
|
-
releaseSelf = true
|
|
21
|
-
} = (0, _utils.readNextDescriptor)(keys);
|
|
22
|
-
const keyDef = pointerMap.find(p => p.name === descriptor);
|
|
23
|
-
|
|
24
|
-
if (keyDef) {
|
|
25
|
-
defs.push({
|
|
26
|
-
keyDef,
|
|
27
|
-
releasePrevious,
|
|
28
|
-
releaseSelf
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
keys = keys.slice(consumedLength);
|
|
33
|
-
} while (keys);
|
|
34
|
-
|
|
35
|
-
return defs;
|
|
36
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pointerAction = pointerAction;
|
|
7
|
-
|
|
8
|
-
var _utils = require("../utils");
|
|
9
|
-
|
|
10
|
-
var _pointerMove = require("./pointerMove");
|
|
11
|
-
|
|
12
|
-
var _pointerPress = require("./pointerPress");
|
|
13
|
-
|
|
14
|
-
async function pointerAction(actions, options, state) {
|
|
15
|
-
const ret = [];
|
|
16
|
-
|
|
17
|
-
for (let i = 0; i < actions.length; i++) {
|
|
18
|
-
var _action$target, _action$coords;
|
|
19
|
-
|
|
20
|
-
const action = actions[i];
|
|
21
|
-
const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? action.keyDef.pointerType === 'touch' ? action.keyDef.name : action.keyDef.pointerType : 'mouse';
|
|
22
|
-
const target = (_action$target = action.target) != null ? _action$target : getPrevTarget(pointerName, state.pointerState);
|
|
23
|
-
const coords = (_action$coords = action.coords) != null ? _action$coords : pointerName in state.pointerState.position ? state.pointerState.position[pointerName].coords : undefined;
|
|
24
|
-
const promise = 'keyDef' in action ? (0, _pointerPress.pointerPress)({ ...action,
|
|
25
|
-
target,
|
|
26
|
-
coords
|
|
27
|
-
}, state) : (0, _pointerMove.pointerMove)({ ...action,
|
|
28
|
-
target,
|
|
29
|
-
coords
|
|
30
|
-
}, state);
|
|
31
|
-
ret.push(promise);
|
|
32
|
-
|
|
33
|
-
if (options.delay > 0) {
|
|
34
|
-
await promise;
|
|
35
|
-
|
|
36
|
-
if (i < actions.length - 1) {
|
|
37
|
-
await (0, _utils.wait)(options.delay);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
delete state.pointerState.activeClickCount;
|
|
43
|
-
return Promise.all(ret);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
function getPrevTarget(pointerName, state) {
|
|
47
|
-
if (!(pointerName in state.position) || !state.position[pointerName].target) {
|
|
48
|
-
throw new Error('This pointer has no previous position. Provide a target property!');
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return state.position[pointerName].target;
|
|
52
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { inputDeviceState, PointerTarget, SelectionTarget } from './types';
|
|
2
|
-
export interface PointerMoveAction extends PointerTarget, SelectionTarget {
|
|
3
|
-
pointerName?: string;
|
|
4
|
-
}
|
|
5
|
-
export declare function pointerMove({ pointerName, target, coords, node, offset }: PointerMoveAction, { pointerState, keyboardState }: inputDeviceState): Promise<void>;
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pointerMove = pointerMove;
|
|
7
|
-
|
|
8
|
-
var _document = require("../document");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../utils");
|
|
11
|
-
|
|
12
|
-
var _resolveSelectionTarget = require("./resolveSelectionTarget");
|
|
13
|
-
|
|
14
|
-
async function pointerMove({
|
|
15
|
-
pointerName = 'mouse',
|
|
16
|
-
target,
|
|
17
|
-
coords,
|
|
18
|
-
node,
|
|
19
|
-
offset
|
|
20
|
-
}, {
|
|
21
|
-
pointerState,
|
|
22
|
-
keyboardState
|
|
23
|
-
}) {
|
|
24
|
-
if (!(pointerName in pointerState.position)) {
|
|
25
|
-
throw new Error(`Trying to move pointer "${pointerName}" which does not exist.`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const {
|
|
29
|
-
pointerId,
|
|
30
|
-
pointerType,
|
|
31
|
-
target: prevTarget,
|
|
32
|
-
coords: prevCoords,
|
|
33
|
-
selectionRange
|
|
34
|
-
} = pointerState.position[pointerName];
|
|
35
|
-
|
|
36
|
-
if (prevTarget && prevTarget !== target) {
|
|
37
|
-
// Here we could probably calculate a few coords to a fake boundary(?)
|
|
38
|
-
fireMove(prevTarget, prevCoords);
|
|
39
|
-
|
|
40
|
-
if (!(0, _utils.isDescendantOrSelf)(target, prevTarget)) {
|
|
41
|
-
fireLeave(prevTarget, prevCoords);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
pointerState.position[pointerName] = { ...pointerState.position[pointerName],
|
|
46
|
-
target,
|
|
47
|
-
coords
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
if (prevTarget !== target) {
|
|
51
|
-
if (!prevTarget || !(0, _utils.isDescendantOrSelf)(prevTarget, target)) {
|
|
52
|
-
fireEnter(target, coords);
|
|
53
|
-
}
|
|
54
|
-
} // TODO: drag if the target didn't change?
|
|
55
|
-
// Here we could probably calculate a few coords leading up to the final position
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
fireMove(target, coords);
|
|
59
|
-
|
|
60
|
-
if (selectionRange) {
|
|
61
|
-
// TODO: support extending range (shift)
|
|
62
|
-
const selectionFocus = (0, _resolveSelectionTarget.resolveSelectionTarget)({
|
|
63
|
-
target,
|
|
64
|
-
node,
|
|
65
|
-
offset
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
if ('node' in selectionRange) {
|
|
69
|
-
// When the mouse is dragged outside of an input/textarea,
|
|
70
|
-
// the selection is extended to the beginning or end of the input
|
|
71
|
-
// depending on pointer position.
|
|
72
|
-
// TODO: extend selection according to pointer position
|
|
73
|
-
|
|
74
|
-
/* istanbul ignore else */
|
|
75
|
-
if (selectionFocus.node === selectionRange.node) {
|
|
76
|
-
const anchorOffset = selectionFocus.offset < selectionRange.start ? selectionRange.end : selectionRange.start;
|
|
77
|
-
const focusOffset = selectionFocus.offset > selectionRange.end || selectionFocus.offset < selectionRange.start ? selectionFocus.offset : selectionRange.end;
|
|
78
|
-
(0, _document.setUISelection)(selectionRange.node, {
|
|
79
|
-
anchorOffset,
|
|
80
|
-
focusOffset
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
const range = selectionRange.cloneRange();
|
|
85
|
-
const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);
|
|
86
|
-
|
|
87
|
-
if (cmp < 0) {
|
|
88
|
-
range.setStart(selectionFocus.node, selectionFocus.offset);
|
|
89
|
-
} else if (cmp > 0) {
|
|
90
|
-
range.setEnd(selectionFocus.node, selectionFocus.offset);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const selection = target.ownerDocument.getSelection();
|
|
94
|
-
selection.removeAllRanges();
|
|
95
|
-
selection.addRange(range.cloneRange());
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function fireMove(eventTarget, eventCoords) {
|
|
100
|
-
fire(eventTarget, 'pointermove', eventCoords);
|
|
101
|
-
|
|
102
|
-
if (pointerType === 'mouse' && !(0, _utils.isDisabled)(eventTarget)) {
|
|
103
|
-
fire(eventTarget, 'mousemove', eventCoords);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function fireLeave(eventTarget, eventCoords) {
|
|
108
|
-
fire(eventTarget, 'pointerout', eventCoords);
|
|
109
|
-
fire(eventTarget, 'pointerleave', eventCoords);
|
|
110
|
-
|
|
111
|
-
if (pointerType === 'mouse' && !(0, _utils.isDisabled)(eventTarget)) {
|
|
112
|
-
fire(eventTarget, 'mouseout', eventCoords);
|
|
113
|
-
fire(eventTarget, 'mouseleave', eventCoords);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function fireEnter(eventTarget, eventCoords) {
|
|
118
|
-
fire(eventTarget, 'pointerover', eventCoords);
|
|
119
|
-
fire(eventTarget, 'pointerenter', eventCoords);
|
|
120
|
-
|
|
121
|
-
if (pointerType === 'mouse' && !(0, _utils.isDisabled)(eventTarget)) {
|
|
122
|
-
fire(eventTarget, 'mouseover', eventCoords);
|
|
123
|
-
fire(eventTarget, 'mouseenter', eventCoords);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function fire(eventTarget, type, eventCoords) {
|
|
128
|
-
return (0, _utils.firePointerEvent)(eventTarget, type, {
|
|
129
|
-
pointerState,
|
|
130
|
-
keyboardState,
|
|
131
|
-
coords: eventCoords,
|
|
132
|
-
pointerId,
|
|
133
|
-
pointerType
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { inputDeviceState, pointerKey, PointerTarget, SelectionTarget } from './types';
|
|
2
|
-
export interface PointerPressAction extends PointerTarget, SelectionTarget {
|
|
3
|
-
keyDef: pointerKey;
|
|
4
|
-
releasePrevious: boolean;
|
|
5
|
-
releaseSelf: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function pointerPress(action: PointerPressAction, state: inputDeviceState): Promise<void>;
|