@testing-library/user-event 13.5.0 → 14.0.0-alpha.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/README.md +3 -0
- package/dist/clear.d.ts +2 -2
- package/dist/clear.js +1 -3
- package/dist/click.d.ts +3 -3
- package/dist/click.js +13 -144
- package/dist/document/index.d.ts +9 -0
- package/dist/document/index.js +100 -0
- package/dist/document/interceptor.d.ts +15 -0
- package/dist/document/interceptor.js +37 -0
- package/dist/document/selection.d.ts +17 -0
- package/dist/document/selection.js +64 -0
- package/dist/document/value.d.ts +18 -0
- package/dist/document/value.js +77 -0
- package/dist/hover.d.ts +3 -3
- package/dist/hover.js +15 -57
- package/dist/index.d.ts +4 -21
- package/dist/index.js +4 -29
- package/dist/keyboard/getNextKeyDef.js +3 -92
- package/dist/keyboard/index.d.ts +1 -0
- package/dist/keyboard/index.js +4 -0
- package/dist/keyboard/keyMap.js +4 -0
- package/dist/keyboard/plugins/character.js +8 -18
- package/dist/keyboard/plugins/control.js +3 -6
- package/dist/keyboard/plugins/functional.js +20 -6
- package/dist/keyboard/plugins/index.js +2 -4
- package/dist/keyboard/shared/index.d.ts +0 -2
- package/dist/keyboard/shared/index.js +0 -26
- package/dist/keyboard/types.d.ts +3 -0
- package/dist/paste.d.ts +3 -2
- package/dist/pointer/index.d.ts +18 -0
- package/dist/pointer/index.js +90 -0
- package/dist/pointer/keyMap.d.ts +2 -0
- package/dist/pointer/keyMap.js +29 -0
- package/dist/pointer/parseKeyDef.d.ts +6 -0
- package/dist/pointer/parseKeyDef.js +36 -0
- package/dist/pointer/pointerAction.d.ts +6 -0
- package/dist/pointer/pointerAction.js +52 -0
- package/dist/pointer/pointerMove.d.ts +5 -0
- package/dist/pointer/pointerMove.js +125 -0
- package/dist/pointer/pointerPress.d.ts +7 -0
- package/dist/pointer/pointerPress.js +328 -0
- package/dist/pointer/resolveSelectionTarget.d.ts +5 -0
- package/dist/pointer/resolveSelectionTarget.js +74 -0
- package/dist/pointer/types.d.ts +72 -0
- package/dist/pointer/types.js +1 -0
- package/dist/selectOptions.d.ts +4 -0
- package/dist/{select-options.js → selectOptions.js} +18 -20
- package/dist/setup.d.ts +89 -0
- package/dist/setup.js +206 -0
- package/dist/tab.d.ts +3 -3
- package/dist/tab.js +18 -97
- package/dist/type.d.ts +14 -0
- package/dist/type.js +74 -0
- package/dist/upload.d.ts +4 -3
- package/dist/upload.js +3 -9
- package/dist/{keyboard/shared → utils/edit}/fireInputEvent.d.ts +0 -9
- package/dist/utils/edit/fireInputEvent.js +59 -0
- package/dist/utils/edit/getValue.d.ts +1 -1
- package/dist/utils/edit/getValue.js +3 -1
- package/dist/utils/edit/selectionRange.d.ts +0 -11
- package/dist/utils/edit/selectionRange.js +9 -49
- package/dist/{blur.d.ts → utils/focus/blur.d.ts} +0 -0
- package/dist/utils/focus/blur.js +19 -0
- package/dist/{focus.d.ts → utils/focus/focus.d.ts} +0 -0
- package/dist/utils/focus/focus.js +19 -0
- package/dist/utils/focus/getTabDestination.d.ts +1 -0
- package/dist/utils/focus/getTabDestination.js +72 -0
- package/dist/utils/focus/isFocusable.js +1 -3
- package/dist/utils/index.d.ts +10 -3
- package/dist/utils/index.js +120 -29
- package/dist/utils/keyDef/readNextDescriptor.d.ts +19 -0
- package/dist/utils/keyDef/readNextDescriptor.js +102 -0
- package/dist/utils/misc/findClosest.d.ts +1 -0
- package/dist/utils/misc/findClosest.js +20 -0
- package/dist/utils/misc/isDescendantOrSelf.d.ts +1 -0
- package/dist/utils/misc/isDescendantOrSelf.js +20 -0
- package/dist/utils/pointer/fakeEvent.d.ts +20 -0
- package/dist/utils/pointer/fakeEvent.js +91 -0
- package/dist/utils/pointer/firePointerEvents.d.ts +14 -0
- package/dist/utils/pointer/firePointerEvents.js +55 -0
- package/dist/utils/pointer/mouseButtons.d.ts +12 -0
- package/dist/utils/pointer/mouseButtons.js +45 -0
- package/package.json +4 -3
- package/dist/blur.js +0 -15
- package/dist/dom-helpers.d.ts +0 -3
- package/dist/focus.js +0 -15
- package/dist/keyboard/shared/carryValue.d.ts +0 -2
- package/dist/keyboard/shared/carryValue.js +0 -13
- package/dist/keyboard/shared/fireInputEvent.js +0 -110
- package/dist/select-options.d.ts +0 -4
- package/dist/type/index.d.ts +0 -7
- package/dist/type/index.js +0 -33
- package/dist/type/typeImplementation.d.ts +0 -10
- package/dist/type/typeImplementation.js +0 -64
- package/dist/utils/click/getMouseEventOptions.d.ts +0 -31
- package/dist/utils/click/getMouseEventOptions.js +0 -61
- package/dist/utils/edit/hasUnreliableEmptyValue.d.ts +0 -10
- package/dist/utils/edit/hasUnreliableEmptyValue.js +0 -21
- package/dist/utils/misc/isLabelWithInternallyDisabledControl.d.ts +0 -1
- package/dist/utils/misc/isLabelWithInternallyDisabledControl.js +0 -22
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.typeImplementation = typeImplementation;
|
|
7
|
-
|
|
8
|
-
var _utils = require("../utils");
|
|
9
|
-
|
|
10
|
-
var _click = require("../click");
|
|
11
|
-
|
|
12
|
-
var _keyboard = require("../keyboard");
|
|
13
|
-
|
|
14
|
-
async function typeImplementation(element, text, {
|
|
15
|
-
delay,
|
|
16
|
-
skipClick = false,
|
|
17
|
-
skipAutoClose = false,
|
|
18
|
-
initialSelectionStart = undefined,
|
|
19
|
-
initialSelectionEnd = undefined
|
|
20
|
-
}) {
|
|
21
|
-
// TODO: properly type guard
|
|
22
|
-
// we use this workaround for now to prevent changing behavior
|
|
23
|
-
if (element.disabled) return;
|
|
24
|
-
if (!skipClick) (0, _click.click)(element); // The focused element could change between each event, so get the currently active element each time
|
|
25
|
-
|
|
26
|
-
const currentElement = () => (0, _utils.getActiveElement)(element.ownerDocument); // by default, a new element has its selection start and end at 0
|
|
27
|
-
// but most of the time when people call "type", they expect it to type
|
|
28
|
-
// at the end of the current input value. So, if the selection start
|
|
29
|
-
// and end are both the default of 0, then we'll go ahead and change
|
|
30
|
-
// them to the length of the current value.
|
|
31
|
-
// the only time it would make sense to pass the initialSelectionStart or
|
|
32
|
-
// initialSelectionEnd is if you have an input with a value and want to
|
|
33
|
-
// explicitly start typing with the cursor at 0. Not super common.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const value = (0, _utils.getValue)(currentElement());
|
|
37
|
-
const {
|
|
38
|
-
selectionStart,
|
|
39
|
-
selectionEnd
|
|
40
|
-
} = (0, _utils.getSelectionRange)(element);
|
|
41
|
-
|
|
42
|
-
if (value != null && (selectionStart === null || selectionStart === 0) && (selectionEnd === null || selectionEnd === 0)) {
|
|
43
|
-
(0, _utils.setSelectionRange)(currentElement(), initialSelectionStart != null ? initialSelectionStart : value.length, initialSelectionEnd != null ? initialSelectionEnd : value.length);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const {
|
|
47
|
-
promise,
|
|
48
|
-
releaseAllKeys
|
|
49
|
-
} = (0, _keyboard.keyboardImplementationWrapper)(text, {
|
|
50
|
-
delay,
|
|
51
|
-
document: element.ownerDocument
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (delay > 0) {
|
|
55
|
-
await promise;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (!skipAutoClose) {
|
|
59
|
-
releaseAllKeys();
|
|
60
|
-
} // eslint-disable-next-line consistent-return -- we need to return the internal Promise so that it is catchable if we don't await
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return promise;
|
|
64
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export declare function getMouseEventOptions(event: string, init?: MouseEventInit, clickCount?: number): {
|
|
2
|
-
detail: number;
|
|
3
|
-
buttons: number;
|
|
4
|
-
button: number;
|
|
5
|
-
clientX?: number | undefined;
|
|
6
|
-
clientY?: number | undefined;
|
|
7
|
-
movementX?: number | undefined;
|
|
8
|
-
movementY?: number | undefined;
|
|
9
|
-
relatedTarget?: EventTarget | null | undefined;
|
|
10
|
-
screenX?: number | undefined;
|
|
11
|
-
screenY?: number | undefined;
|
|
12
|
-
altKey?: boolean | undefined;
|
|
13
|
-
ctrlKey?: boolean | undefined;
|
|
14
|
-
metaKey?: boolean | undefined;
|
|
15
|
-
modifierAltGraph?: boolean | undefined;
|
|
16
|
-
modifierCapsLock?: boolean | undefined;
|
|
17
|
-
modifierFn?: boolean | undefined;
|
|
18
|
-
modifierFnLock?: boolean | undefined;
|
|
19
|
-
modifierHyper?: boolean | undefined;
|
|
20
|
-
modifierNumLock?: boolean | undefined;
|
|
21
|
-
modifierScrollLock?: boolean | undefined;
|
|
22
|
-
modifierSuper?: boolean | undefined;
|
|
23
|
-
modifierSymbol?: boolean | undefined;
|
|
24
|
-
modifierSymbolLock?: boolean | undefined;
|
|
25
|
-
shiftKey?: boolean | undefined;
|
|
26
|
-
view?: Window | null | undefined;
|
|
27
|
-
which?: number | undefined;
|
|
28
|
-
bubbles?: boolean | undefined;
|
|
29
|
-
cancelable?: boolean | undefined;
|
|
30
|
-
composed?: boolean | undefined;
|
|
31
|
-
};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getMouseEventOptions = getMouseEventOptions;
|
|
7
|
-
|
|
8
|
-
function isMousePressEvent(event) {
|
|
9
|
-
return event === 'mousedown' || event === 'mouseup' || event === 'click' || event === 'dblclick';
|
|
10
|
-
} // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const BUTTONS_NAMES = {
|
|
14
|
-
none: 0,
|
|
15
|
-
primary: 1,
|
|
16
|
-
secondary: 2,
|
|
17
|
-
auxiliary: 4
|
|
18
|
-
}; // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button
|
|
19
|
-
|
|
20
|
-
const BUTTON_NAMES = {
|
|
21
|
-
primary: 0,
|
|
22
|
-
auxiliary: 1,
|
|
23
|
-
secondary: 2
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function translateButtonNumber(value, from) {
|
|
27
|
-
var _Object$entries$find;
|
|
28
|
-
|
|
29
|
-
const [mapIn, mapOut] = from === 'button' ? [BUTTON_NAMES, BUTTONS_NAMES] : [BUTTONS_NAMES, BUTTON_NAMES];
|
|
30
|
-
const name = (_Object$entries$find = Object.entries(mapIn).find(([, i]) => i === value)) == null ? void 0 : _Object$entries$find[0]; // istanbul ignore next
|
|
31
|
-
|
|
32
|
-
return name && Object.prototype.hasOwnProperty.call(mapOut, name) ? mapOut[name] : 0;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function convertMouseButtons(event, init, property) {
|
|
36
|
-
if (!isMousePressEvent(event)) {
|
|
37
|
-
return 0;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
if (typeof init[property] === 'number') {
|
|
41
|
-
return init[property];
|
|
42
|
-
} else if (property === 'button' && typeof init.buttons === 'number') {
|
|
43
|
-
return translateButtonNumber(init.buttons, 'buttons');
|
|
44
|
-
} else if (property === 'buttons' && typeof init.button === 'number') {
|
|
45
|
-
return translateButtonNumber(init.button, 'button');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return property != 'button' && isMousePressEvent(event) ? 1 : 0;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function getMouseEventOptions(event, init, clickCount = 0) {
|
|
52
|
-
var _init;
|
|
53
|
-
|
|
54
|
-
init = (_init = init) != null ? _init : {};
|
|
55
|
-
return { ...init,
|
|
56
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/detail
|
|
57
|
-
detail: event === 'mousedown' || event === 'mouseup' || event === 'click' ? 1 + clickCount : clickCount,
|
|
58
|
-
buttons: convertMouseButtons(event, init, 'buttons'),
|
|
59
|
-
button: convertMouseButtons(event, init, 'button')
|
|
60
|
-
};
|
|
61
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare enum unreliableValueInputTypes {
|
|
2
|
-
'number' = "number"
|
|
3
|
-
}
|
|
4
|
-
/**
|
|
5
|
-
* Check if an empty IDL value on the element could mean a derivation of displayed value and IDL value
|
|
6
|
-
*/
|
|
7
|
-
export declare function hasUnreliableEmptyValue(element: Element): element is HTMLInputElement & {
|
|
8
|
-
type: unreliableValueInputTypes;
|
|
9
|
-
};
|
|
10
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.hasUnreliableEmptyValue = hasUnreliableEmptyValue;
|
|
7
|
-
|
|
8
|
-
var _isElementType = require("../misc/isElementType");
|
|
9
|
-
|
|
10
|
-
var unreliableValueInputTypes;
|
|
11
|
-
/**
|
|
12
|
-
* Check if an empty IDL value on the element could mean a derivation of displayed value and IDL value
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
(function (unreliableValueInputTypes) {
|
|
16
|
-
unreliableValueInputTypes["number"] = "number";
|
|
17
|
-
})(unreliableValueInputTypes || (unreliableValueInputTypes = {}));
|
|
18
|
-
|
|
19
|
-
function hasUnreliableEmptyValue(element) {
|
|
20
|
-
return (0, _isElementType.isElementType)(element, 'input') && Boolean(unreliableValueInputTypes[element.type]);
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isLabelWithInternallyDisabledControl(element: Element): boolean;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isLabelWithInternallyDisabledControl = isLabelWithInternallyDisabledControl;
|
|
7
|
-
|
|
8
|
-
var _isDisabled = require("./isDisabled");
|
|
9
|
-
|
|
10
|
-
var _isElementType = require("./isElementType");
|
|
11
|
-
|
|
12
|
-
// Absolutely NO events fire on label elements that contain their control
|
|
13
|
-
// if that control is disabled. NUTS!
|
|
14
|
-
// no joke. There are NO events for: <label><input disabled /><label>
|
|
15
|
-
function isLabelWithInternallyDisabledControl(element) {
|
|
16
|
-
if (!(0, _isElementType.isElementType)(element, 'label')) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const control = element.control;
|
|
21
|
-
return Boolean(control && element.contains(control) && (0, _isDisabled.isDisabled)(control));
|
|
22
|
-
}
|