@testing-library/user-event 14.4.0 → 14.4.3
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/cjs/clipboard/copy.js +6 -15
- package/dist/cjs/clipboard/cut.js +6 -15
- package/dist/cjs/clipboard/paste.js +6 -14
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/document/UI.js +94 -0
- package/dist/cjs/document/copySelection.js +37 -0
- package/dist/cjs/document/getValueOrTextContent.js +27 -0
- package/dist/cjs/document/index.js +13 -68
- package/dist/cjs/document/interceptor.js +87 -4
- package/dist/cjs/document/prepareDocument.js +67 -0
- package/dist/cjs/document/trackValue.js +65 -0
- package/dist/cjs/event/behavior/click.js +8 -12
- package/dist/cjs/event/behavior/cut.js +5 -11
- package/dist/cjs/event/behavior/keydown.js +43 -43
- package/dist/cjs/event/behavior/keypress.js +9 -10
- package/dist/cjs/event/behavior/keyup.js +6 -7
- package/dist/cjs/event/behavior/paste.js +7 -12
- package/dist/cjs/event/createEvent.js +37 -28
- package/dist/cjs/event/dispatchEvent.js +21 -2
- package/dist/cjs/event/focus.js +44 -0
- package/dist/cjs/event/index.js +24 -17
- package/dist/cjs/{utils/edit → event}/input.js +50 -47
- package/dist/cjs/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/cjs/event/selection/getInputRange.js +20 -0
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +40 -0
- package/dist/cjs/event/selection/index.js +26 -0
- package/dist/cjs/event/selection/modifySelection.js +30 -0
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +49 -0
- package/dist/cjs/event/selection/moveSelection.js +47 -0
- package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +11 -19
- package/dist/cjs/event/selection/selectAll.js +47 -0
- package/dist/cjs/event/selection/setSelection.js +30 -0
- package/dist/cjs/event/selection/setSelectionPerMouse.js +90 -0
- package/dist/cjs/event/selection/setSelectionRange.js +40 -0
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +45 -0
- package/dist/cjs/keyboard/index.js +13 -23
- package/dist/cjs/keyboard/parseKeyDef.js +8 -13
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +28 -34
- package/dist/cjs/pointer/parseKeyDef.js +1 -9
- package/dist/cjs/setup/directApi.js +6 -6
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +69 -38
- package/dist/cjs/system/index.js +4 -2
- package/dist/cjs/system/keyboard.js +32 -32
- package/dist/cjs/system/pointer/buttons.js +3 -1
- package/dist/cjs/system/pointer/device.js +3 -1
- package/dist/cjs/system/pointer/index.js +82 -79
- package/dist/cjs/system/pointer/mouse.js +97 -81
- package/dist/cjs/system/pointer/pointer.js +45 -46
- package/dist/cjs/system/pointer/shared.js +10 -0
- package/dist/cjs/utility/clear.js +10 -11
- package/dist/cjs/utility/selectOptions.js +17 -19
- package/dist/cjs/utility/type.js +6 -15
- package/dist/cjs/utility/upload.js +9 -15
- package/dist/cjs/utils/dataTransfer/Clipboard.js +11 -21
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +22 -19
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +6 -16
- package/dist/cjs/utils/edit/setFiles.js +4 -2
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +2 -17
- package/dist/cjs/utils/focus/getActiveElement.js +3 -2
- package/dist/cjs/utils/focus/selection.js +1 -266
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -3
- package/dist/cjs/utils/misc/isDisabled.js +2 -1
- package/dist/cjs/utils/misc/isVisible.js +1 -1
- package/dist/cjs/utils/misc/level.js +4 -6
- package/dist/cjs/utils/pointer/cssPointerEvents.js +26 -32
- package/dist/esm/clipboard/copy.js +6 -15
- package/dist/esm/clipboard/cut.js +6 -15
- package/dist/esm/clipboard/paste.js +6 -14
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/document/UI.js +79 -0
- package/dist/esm/document/copySelection.js +33 -0
- package/dist/esm/document/getValueOrTextContent.js +23 -0
- package/dist/esm/document/index.js +4 -66
- package/dist/esm/document/interceptor.js +85 -5
- package/dist/esm/document/prepareDocument.js +63 -0
- package/dist/esm/document/trackValue.js +59 -0
- package/dist/esm/event/behavior/click.js +8 -12
- package/dist/esm/event/behavior/cut.js +5 -11
- package/dist/esm/event/behavior/keydown.js +36 -36
- package/dist/esm/event/behavior/keypress.js +9 -10
- package/dist/esm/event/behavior/keyup.js +6 -7
- package/dist/esm/event/behavior/paste.js +7 -12
- package/dist/esm/event/createEvent.js +37 -28
- package/dist/esm/event/dispatchEvent.js +20 -3
- package/dist/esm/event/focus.js +39 -0
- package/dist/esm/event/index.js +14 -19
- package/dist/esm/{utils/edit → event}/input.js +37 -34
- package/dist/esm/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/esm/event/selection/getInputRange.js +16 -0
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +36 -0
- package/dist/esm/event/selection/index.js +9 -0
- package/dist/esm/event/selection/modifySelection.js +26 -0
- package/dist/esm/event/selection/modifySelectionPerMouse.js +45 -0
- package/dist/esm/event/selection/moveSelection.js +43 -0
- package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +11 -19
- package/dist/esm/event/selection/selectAll.js +42 -0
- package/dist/esm/event/selection/setSelection.js +26 -0
- package/dist/esm/event/selection/setSelectionPerMouse.js +86 -0
- package/dist/esm/event/selection/setSelectionRange.js +36 -0
- package/dist/esm/event/selection/updateSelectionOnFocus.js +41 -0
- package/dist/esm/keyboard/index.js +13 -23
- package/dist/esm/keyboard/parseKeyDef.js +8 -13
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +28 -34
- package/dist/esm/pointer/parseKeyDef.js +1 -9
- package/dist/esm/setup/directApi.js +6 -6
- package/dist/esm/setup/index.js +0 -1
- package/dist/esm/setup/setup.js +63 -33
- package/dist/esm/system/index.js +4 -2
- package/dist/esm/system/keyboard.js +32 -32
- package/dist/esm/system/pointer/buttons.js +3 -1
- package/dist/esm/system/pointer/device.js +3 -1
- package/dist/esm/system/pointer/index.js +83 -79
- package/dist/esm/system/pointer/mouse.js +95 -79
- package/dist/esm/system/pointer/pointer.js +44 -45
- package/dist/esm/system/pointer/shared.js +6 -0
- package/dist/esm/utility/clear.js +10 -11
- package/dist/esm/utility/selectOptions.js +17 -19
- package/dist/esm/utility/type.js +6 -15
- package/dist/esm/utility/upload.js +9 -15
- package/dist/esm/utils/dataTransfer/Clipboard.js +11 -21
- package/dist/esm/utils/dataTransfer/DataTransfer.js +22 -19
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +5 -16
- package/dist/esm/utils/edit/setFiles.js +4 -2
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +2 -17
- package/dist/esm/utils/focus/getActiveElement.js +3 -2
- package/dist/esm/utils/focus/selection.js +3 -260
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -3
- package/dist/esm/utils/misc/isDisabled.js +2 -1
- package/dist/esm/utils/misc/isVisible.js +1 -1
- package/dist/esm/utils/misc/level.js +4 -6
- package/dist/esm/utils/pointer/cssPointerEvents.js +26 -32
- package/dist/types/clipboard/copy.d.ts +1 -1
- package/dist/types/clipboard/cut.d.ts +1 -1
- package/dist/types/clipboard/paste.d.ts +1 -1
- package/dist/types/convenience/click.d.ts +1 -1
- package/dist/types/convenience/hover.d.ts +1 -1
- package/dist/types/document/UI.d.ts +42 -0
- package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -0
- package/dist/types/document/getValueOrTextContent.d.ts +1 -0
- package/dist/types/document/index.d.ts +5 -10
- package/dist/types/document/interceptor.d.ts +3 -0
- package/dist/types/document/prepareDocument.d.ts +8 -0
- package/dist/types/document/trackValue.d.ts +17 -0
- package/dist/types/event/behavior/registry.d.ts +2 -2
- package/dist/types/event/dispatchEvent.d.ts +5 -2
- package/dist/types/event/focus.d.ts +5 -0
- package/dist/types/event/index.d.ts +6 -4
- package/dist/types/event/input.d.ts +2 -0
- package/dist/types/event/radio.d.ts +4 -0
- package/dist/types/event/selection/getInputRange.d.ts +5 -0
- package/dist/types/event/selection/getTargetTypeAndSelection.d.ts +10 -0
- package/dist/types/event/selection/index.d.ts +15 -0
- package/dist/types/event/selection/modifySelection.d.ts +8 -0
- package/dist/types/event/selection/modifySelectionPerMouse.d.ts +7 -0
- package/dist/types/event/selection/moveSelection.d.ts +4 -0
- package/dist/types/{utils/focus → event/selection}/resolveCaretPosition.d.ts +0 -0
- package/dist/types/{utils/focus → event/selection}/selectAll.d.ts +0 -0
- package/dist/types/event/selection/setSelection.d.ts +10 -0
- package/dist/types/event/selection/setSelectionPerMouse.d.ts +8 -0
- package/dist/types/event/selection/setSelectionRange.d.ts +6 -0
- package/dist/types/event/selection/updateSelectionOnFocus.d.ts +5 -0
- package/dist/types/keyboard/index.d.ts +2 -2
- package/dist/types/options.d.ts +0 -8
- package/dist/types/pointer/index.d.ts +3 -3
- package/dist/types/setup/directApi.d.ts +1 -1
- package/dist/types/setup/index.d.ts +2 -15
- package/dist/types/setup/setup.d.ts +25 -7
- package/dist/types/system/keyboard.d.ts +3 -3
- package/dist/types/system/pointer/buttons.d.ts +1 -1
- package/dist/types/system/pointer/index.d.ts +7 -25
- package/dist/types/system/pointer/mouse.d.ts +5 -5
- package/dist/types/system/pointer/pointer.d.ts +7 -7
- package/dist/types/system/pointer/shared.d.ts +20 -0
- package/dist/types/utility/clear.d.ts +1 -1
- package/dist/types/utility/selectOptions.d.ts +1 -1
- package/dist/types/utility/type.d.ts +3 -3
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +2 -2
- package/dist/types/utils/edit/isEditable.d.ts +5 -6
- package/dist/types/utils/edit/maxLength.d.ts +14 -1
- package/dist/types/utils/edit/{isValidDateOrTimeValue.d.ts → timeValue.d.ts} +1 -0
- package/dist/types/utils/focus/selection.d.ts +4 -69
- package/dist/types/utils/index.d.ts +2 -9
- package/dist/types/utils/misc/level.d.ts +4 -13
- package/dist/types/utils/misc/wait.d.ts +2 -2
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +4 -4
- package/package.json +29 -4
- package/dist/cjs/document/selection.js +0 -107
- package/dist/cjs/document/setRangeText.js +0 -21
- package/dist/cjs/document/value.js +0 -125
- package/dist/cjs/setup/config.js +0 -7
- package/dist/cjs/utils/edit/getValue.js +0 -35
- package/dist/cjs/utils/edit/isValidDateOrTimeValue.js +0 -11
- package/dist/cjs/utils/focus/blur.js +0 -16
- package/dist/cjs/utils/focus/copySelection.js +0 -46
- package/dist/cjs/utils/focus/focus.js +0 -26
- package/dist/cjs/utils/focus/selectAll.js +0 -54
- package/dist/cjs/utils/misc/eventWrapper.js +0 -15
- package/dist/esm/document/selection.js +0 -99
- package/dist/esm/document/setRangeText.js +0 -17
- package/dist/esm/document/value.js +0 -115
- package/dist/esm/setup/config.js +0 -3
- package/dist/esm/utils/edit/getValue.js +0 -31
- package/dist/esm/utils/edit/isValidDateOrTimeValue.js +0 -7
- package/dist/esm/utils/focus/blur.js +0 -12
- package/dist/esm/utils/focus/copySelection.js +0 -42
- package/dist/esm/utils/focus/focus.js +0 -22
- package/dist/esm/utils/focus/selectAll.js +0 -49
- package/dist/esm/utils/misc/eventWrapper.js +0 -11
- package/dist/types/document/selection.d.ts +0 -29
- package/dist/types/document/setRangeText.d.ts +0 -1
- package/dist/types/document/value.d.ts +0 -26
- package/dist/types/setup/config.d.ts +0 -6
- package/dist/types/utils/edit/buildTimeValue.d.ts +0 -1
- package/dist/types/utils/edit/getValue.d.ts +0 -1
- package/dist/types/utils/edit/input.d.ts +0 -2
- package/dist/types/utils/edit/walkRadio.d.ts +0 -4
- package/dist/types/utils/focus/blur.d.ts +0 -2
- package/dist/types/utils/focus/focus.d.ts +0 -5
- package/dist/types/utils/misc/eventWrapper.d.ts +0 -1
|
@@ -3,13 +3,11 @@ var ApiLevel;
|
|
|
3
3
|
ApiLevel[ApiLevel["Trigger"] = 2] = "Trigger";
|
|
4
4
|
ApiLevel[ApiLevel["Call"] = 1] = "Call";
|
|
5
5
|
})(ApiLevel || (ApiLevel = {}));
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
config[Level] ??= {};
|
|
9
|
-
config[Level][level] = {};
|
|
6
|
+
function setLevelRef(instance, level) {
|
|
7
|
+
instance.levelRefs[level] = {};
|
|
10
8
|
}
|
|
11
|
-
function getLevelRef(
|
|
12
|
-
return
|
|
9
|
+
function getLevelRef(instance, level) {
|
|
10
|
+
return instance.levelRefs[level];
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
export { ApiLevel, getLevelRef, setLevelRef };
|
|
@@ -1,27 +1,15 @@
|
|
|
1
1
|
import { PointerEventsCheckLevel } from '../../options.js';
|
|
2
|
-
import '../click/isClickableInput.js';
|
|
3
|
-
import '../dataTransfer/Clipboard.js';
|
|
4
|
-
import '../../event/eventMap.js';
|
|
5
|
-
import '../../event/behavior/click.js';
|
|
6
|
-
import '../../event/behavior/cut.js';
|
|
7
|
-
import '../../event/behavior/keydown.js';
|
|
8
|
-
import '../../event/behavior/keypress.js';
|
|
9
|
-
import '../../event/behavior/keyup.js';
|
|
10
|
-
import '../../event/behavior/paste.js';
|
|
11
|
-
import '@testing-library/dom';
|
|
12
|
-
import '../edit/maxLength.js';
|
|
13
|
-
import '../edit/isEditable.js';
|
|
14
|
-
import { isElementType } from '../misc/isElementType.js';
|
|
15
2
|
import { getWindow } from '../misc/getWindow.js';
|
|
16
|
-
import '../
|
|
3
|
+
import { isElementType } from '../misc/isElementType.js';
|
|
17
4
|
import { ApiLevel, getLevelRef } from '../misc/level.js';
|
|
18
5
|
|
|
19
|
-
function hasPointerEvents(
|
|
20
|
-
|
|
6
|
+
function hasPointerEvents(instance, element) {
|
|
7
|
+
var ref;
|
|
8
|
+
return ((ref = checkPointerEvents(instance, element)) === null || ref === void 0 ? void 0 : ref.pointerEvents) !== 'none';
|
|
21
9
|
}
|
|
22
10
|
function closestPointerEventsDeclaration(element) {
|
|
23
11
|
const window = getWindow(element);
|
|
24
|
-
for(let el = element, tree = []; el
|
|
12
|
+
for(let el = element, tree = []; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
|
|
25
13
|
tree.push(el);
|
|
26
14
|
const pointerEvents = window.getComputedStyle(el).pointerEvents;
|
|
27
15
|
if (pointerEvents && ![
|
|
@@ -37,23 +25,23 @@ function closestPointerEventsDeclaration(element) {
|
|
|
37
25
|
return undefined;
|
|
38
26
|
}
|
|
39
27
|
const PointerEventsCheck = Symbol('Last check for pointer-events');
|
|
40
|
-
function checkPointerEvents(
|
|
28
|
+
function checkPointerEvents(instance, element) {
|
|
41
29
|
const lastCheck = element[PointerEventsCheck];
|
|
42
|
-
const needsCheck = config.pointerEventsCheck !== PointerEventsCheckLevel.Never && (!lastCheck || hasBitFlag(config.pointerEventsCheck, PointerEventsCheckLevel.EachApiCall) && lastCheck[ApiLevel.Call] !== getLevelRef(
|
|
30
|
+
const needsCheck = instance.config.pointerEventsCheck !== PointerEventsCheckLevel.Never && (!lastCheck || hasBitFlag(instance.config.pointerEventsCheck, PointerEventsCheckLevel.EachApiCall) && lastCheck[ApiLevel.Call] !== getLevelRef(instance, ApiLevel.Call) || hasBitFlag(instance.config.pointerEventsCheck, PointerEventsCheckLevel.EachTrigger) && lastCheck[ApiLevel.Trigger] !== getLevelRef(instance, ApiLevel.Trigger));
|
|
43
31
|
if (!needsCheck) {
|
|
44
|
-
return lastCheck
|
|
32
|
+
return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result;
|
|
45
33
|
}
|
|
46
34
|
const declaration = closestPointerEventsDeclaration(element);
|
|
47
35
|
element[PointerEventsCheck] = {
|
|
48
|
-
[ApiLevel.Call]: getLevelRef(
|
|
49
|
-
[ApiLevel.Trigger]: getLevelRef(
|
|
36
|
+
[ApiLevel.Call]: getLevelRef(instance, ApiLevel.Call),
|
|
37
|
+
[ApiLevel.Trigger]: getLevelRef(instance, ApiLevel.Trigger),
|
|
50
38
|
result: declaration
|
|
51
39
|
};
|
|
52
40
|
return declaration;
|
|
53
41
|
}
|
|
54
|
-
function assertPointerEvents(
|
|
55
|
-
const declaration = checkPointerEvents(
|
|
56
|
-
if (declaration
|
|
42
|
+
function assertPointerEvents(instance, element) {
|
|
43
|
+
const declaration = checkPointerEvents(instance, element);
|
|
44
|
+
if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') {
|
|
57
45
|
throw new Error([
|
|
58
46
|
`Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`,
|
|
59
47
|
'',
|
|
@@ -73,11 +61,13 @@ function printTree(tree) {
|
|
|
73
61
|
].filter(Boolean).join('')).join('\n');
|
|
74
62
|
}
|
|
75
63
|
function getLabelDescr(element) {
|
|
64
|
+
var ref;
|
|
76
65
|
let label;
|
|
77
66
|
if (element.hasAttribute('aria-label')) {
|
|
78
67
|
label = element.getAttribute('aria-label');
|
|
79
68
|
} else if (element.hasAttribute('aria-labelledby')) {
|
|
80
|
-
|
|
69
|
+
var ref1, ref2;
|
|
70
|
+
label = (ref1 = element.ownerDocument.getElementById(element.getAttribute('aria-labelledby'))) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.textContent) === null || ref2 === void 0 ? void 0 : ref2.trim();
|
|
81
71
|
} else if (isElementType(element, [
|
|
82
72
|
'button',
|
|
83
73
|
'input',
|
|
@@ -86,14 +76,18 @@ function getLabelDescr(element) {
|
|
|
86
76
|
'progress',
|
|
87
77
|
'select',
|
|
88
78
|
'textarea',
|
|
89
|
-
]) && element.labels
|
|
90
|
-
label = Array.from(element.labels).map((el)=>
|
|
79
|
+
]) && ((ref = element.labels) === null || ref === void 0 ? void 0 : ref.length)) {
|
|
80
|
+
label = Array.from(element.labels).map((el)=>{
|
|
81
|
+
var ref;
|
|
82
|
+
return (ref = el.textContent) === null || ref === void 0 ? void 0 : ref.trim();
|
|
83
|
+
}).join('|');
|
|
91
84
|
} else if (isElementType(element, 'button')) {
|
|
92
|
-
|
|
85
|
+
var ref3;
|
|
86
|
+
label = (ref3 = element.textContent) === null || ref3 === void 0 ? void 0 : ref3.trim();
|
|
93
87
|
}
|
|
94
|
-
label = label
|
|
95
|
-
if (Number(label
|
|
96
|
-
label = `${label
|
|
88
|
+
label = label === null || label === void 0 ? void 0 : label.replace(/\n/g, ' ');
|
|
89
|
+
if (Number(label === null || label === void 0 ? void 0 : label.length) > 30) {
|
|
90
|
+
label = `${label === null || label === void 0 ? void 0 : label.substring(0, 29)}…`;
|
|
97
91
|
}
|
|
98
92
|
return label ? `(label=${label})` : '';
|
|
99
93
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Instance } from '../setup';
|
|
1
|
+
import type { Instance } from '../setup';
|
|
2
2
|
export declare function copy(this: Instance): Promise<DataTransfer | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Instance } from '../setup';
|
|
1
|
+
import type { Instance } from '../setup';
|
|
2
2
|
export declare function cut(this: Instance): Promise<DataTransfer | undefined>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Instance } from '../setup';
|
|
1
|
+
import type { Instance } from '../setup';
|
|
2
2
|
export declare function paste(this: Instance, clipboardData?: DataTransfer | string): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Instance } from '../setup';
|
|
1
|
+
import type { Instance } from '../setup';
|
|
2
2
|
export declare function click(this: Instance, element: Element): Promise<void>;
|
|
3
3
|
export declare function dblClick(this: Instance, element: Element): Promise<void>;
|
|
4
4
|
export declare function tripleClick(this: Instance, element: Element): Promise<void>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
declare const UIValue: unique symbol;
|
|
2
|
+
declare const UISelection: unique symbol;
|
|
3
|
+
declare const InitialValue: unique symbol;
|
|
4
|
+
declare global {
|
|
5
|
+
interface Element {
|
|
6
|
+
[UIValue]?: string;
|
|
7
|
+
[InitialValue]?: string;
|
|
8
|
+
[UISelection]?: UISelection;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
interface UISelection {
|
|
12
|
+
anchorOffset: number;
|
|
13
|
+
focusOffset: number;
|
|
14
|
+
}
|
|
15
|
+
export declare type UIValueString = String & {
|
|
16
|
+
[UIValue]: true;
|
|
17
|
+
};
|
|
18
|
+
export declare type UISelectionStart = Number & {
|
|
19
|
+
[UISelection]: true;
|
|
20
|
+
};
|
|
21
|
+
export declare function isUIValue(value: string | UIValueString): value is UIValueString;
|
|
22
|
+
export declare function isUISelectionStart(start: number | UISelectionStart | null): start is UISelectionStart;
|
|
23
|
+
export declare function setUIValue(element: HTMLInputElement | HTMLTextAreaElement, value: string): void;
|
|
24
|
+
export declare function getUIValue(element: HTMLInputElement | HTMLTextAreaElement): string;
|
|
25
|
+
/** Flag the IDL value as clean. This does not change the value.*/
|
|
26
|
+
export declare function setUIValueClean(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
27
|
+
export declare function clearInitialValue(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
28
|
+
export declare function getInitialValue(element: HTMLInputElement | HTMLTextAreaElement): string | undefined;
|
|
29
|
+
export declare function setUISelectionRaw(element: HTMLInputElement | HTMLTextAreaElement, selection: UISelection): void;
|
|
30
|
+
export declare function setUISelection(element: HTMLInputElement | HTMLTextAreaElement, { focusOffset: focusOffsetParam, anchorOffset: anchorOffsetParam, }: {
|
|
31
|
+
anchorOffset?: number;
|
|
32
|
+
focusOffset: number;
|
|
33
|
+
}, mode?: 'replace' | 'modify'): void;
|
|
34
|
+
export declare type UISelectionRange = UISelection & {
|
|
35
|
+
startOffset: number;
|
|
36
|
+
endOffset: number;
|
|
37
|
+
};
|
|
38
|
+
export declare function getUISelection(element: HTMLInputElement | HTMLTextAreaElement): UISelectionRange;
|
|
39
|
+
export declare function hasUISelection(element: HTMLInputElement | HTMLTextAreaElement): boolean;
|
|
40
|
+
/** Flag the IDL selection as clean. This does not change the selection. */
|
|
41
|
+
export declare function setUISelectionClean(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
42
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getValueOrTextContent<T extends Element | null>(element: T): T extends HTMLInputElement | HTMLTextAreaElement ? string : string | null;
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export declare function prepareDocument(document: Document): void;
|
|
8
|
-
export { getUIValue, setUIValue, commitValueAfterInput, clearInitialValue, } from './value';
|
|
9
|
-
export { getUISelection, setUISelection } from './selection';
|
|
10
|
-
export type { UISelectionRange } from './selection';
|
|
1
|
+
export { getUISelection, getUIValue, setUISelection, setUIValue, clearInitialValue, } from './UI';
|
|
2
|
+
export type { UISelectionRange } from './UI';
|
|
3
|
+
export { getValueOrTextContent } from './getValueOrTextContent';
|
|
4
|
+
export { copySelection } from './copySelection';
|
|
5
|
+
export { commitValueAfterInput } from './trackValue';
|
|
@@ -13,4 +13,7 @@ export declare function prepareInterceptor<ElementType extends Element, PropName
|
|
|
13
13
|
realArgs?: ImplReturn<ElementType[PropName]>;
|
|
14
14
|
then?: () => void;
|
|
15
15
|
}): void;
|
|
16
|
+
export declare function prepareValueInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
17
|
+
export declare function prepareSelectionInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
18
|
+
export declare function prepareRangeTextInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
16
19
|
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
declare const TrackChanges: unique symbol;
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
REACT_VERSION?: number;
|
|
5
|
+
}
|
|
6
|
+
interface Element {
|
|
7
|
+
[TrackChanges]?: {
|
|
8
|
+
previousValue?: string;
|
|
9
|
+
tracked?: string[];
|
|
10
|
+
nextValue?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare function startTrackValue(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
15
|
+
export declare function trackOrSetValue(element: HTMLInputElement | HTMLTextAreaElement, v: string): void;
|
|
16
|
+
export declare function commitValueAfterInput(element: HTMLInputElement | HTMLTextAreaElement, cursorOffset: number): void;
|
|
17
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Instance } from '../../setup';
|
|
2
2
|
import { EventType } from '../types';
|
|
3
3
|
export interface BehaviorPlugin<Type extends EventType> {
|
|
4
|
-
(event: DocumentEventMap[Type], target: Element,
|
|
4
|
+
(event: DocumentEventMap[Type], target: Element, instance: Instance): // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
5
5
|
void | (() => void);
|
|
6
6
|
}
|
|
7
7
|
export declare const behavior: {
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { Instance } from '../setup';
|
|
2
|
+
import { EventType, EventTypeInit } from './types';
|
|
3
|
+
export declare function dispatchUIEvent<K extends EventType>(this: Instance, target: Element, type: K, init?: EventTypeInit<K>, preventDefault?: boolean): boolean;
|
|
4
|
+
export declare function dispatchEvent(this: Instance, target: Element, event: Event, preventDefault?: boolean): boolean;
|
|
5
|
+
export declare function dispatchDOMEvent<K extends EventType>(target: Element, type: K, init?: EventTypeInit<K>): void;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EventType, EventTypeInit, PointerCoords } from './types';
|
|
1
|
+
import { EventType, PointerCoords } from './types';
|
|
3
2
|
export type { EventType, PointerCoords };
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
export { dispatchEvent, dispatchUIEvent, dispatchDOMEvent } from './dispatchEvent';
|
|
4
|
+
export { blurElement, focusElement } from './focus';
|
|
5
|
+
export { input } from './input';
|
|
6
|
+
export type { SelectionRange } from './selection';
|
|
7
|
+
export { isAllSelected, modifySelectionPerMouseMove, setSelectionPerMouseDown, selectAll, } from './selection';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determine which selection logic and selection ranges to consider.
|
|
3
|
+
*/
|
|
4
|
+
export declare function getTargetTypeAndSelection(node: Node): {
|
|
5
|
+
readonly type: "input";
|
|
6
|
+
readonly selection: import("../../document").UISelectionRange;
|
|
7
|
+
} | {
|
|
8
|
+
readonly type: "contenteditable" | "default";
|
|
9
|
+
readonly selection: Selection | null | undefined;
|
|
10
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EditableInputOrTextarea } from '../../utils';
|
|
2
|
+
export { getInputRange } from './getInputRange';
|
|
3
|
+
export { modifySelection } from './modifySelection';
|
|
4
|
+
export { moveSelection } from './moveSelection';
|
|
5
|
+
export { setSelectionPerMouseDown } from './setSelectionPerMouse';
|
|
6
|
+
export { modifySelectionPerMouseMove } from './modifySelectionPerMouse';
|
|
7
|
+
export { isAllSelected, selectAll } from './selectAll';
|
|
8
|
+
export { setSelectionRange } from './setSelectionRange';
|
|
9
|
+
export { setSelection } from './setSelection';
|
|
10
|
+
export { updateSelectionOnFocus } from './updateSelectionOnFocus';
|
|
11
|
+
export declare type SelectionRange = {
|
|
12
|
+
node: EditableInputOrTextarea;
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SelectionRange } from '.';
|
|
2
|
+
export declare function setSelectionPerMouseDown({ document, target, clickCount, node, offset, }: {
|
|
3
|
+
document: Document;
|
|
4
|
+
target: Element;
|
|
5
|
+
clickCount: number;
|
|
6
|
+
node?: Node;
|
|
7
|
+
offset?: number;
|
|
8
|
+
}): Range | SelectionRange | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Instance } from '../setup';
|
|
2
2
|
export declare function keyboard(this: Instance, text: string): Promise<void>;
|
|
3
|
-
export declare function releaseAllKeys(
|
|
3
|
+
export declare function releaseAllKeys(instance: Instance): Promise<void>;
|
package/dist/types/options.d.ts
CHANGED
|
@@ -113,11 +113,3 @@ export interface Options {
|
|
|
113
113
|
*/
|
|
114
114
|
advanceTimers?: ((delay: number) => Promise<void>) | ((delay: number) => void);
|
|
115
115
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Default options applied when API is called per `userEvent.anyApi()`
|
|
118
|
-
*/
|
|
119
|
-
export declare const defaultOptionsDirect: Required<Options>;
|
|
120
|
-
/**
|
|
121
|
-
* Default options applied when API is called per `userEvent().anyApi()`
|
|
122
|
-
*/
|
|
123
|
-
export declare const defaultOptionsSetup: Required<Options>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PointerCoords } from '../event';
|
|
2
|
-
import { Instance } from '../setup';
|
|
3
|
-
import { pointerKey } from '../system/pointer';
|
|
1
|
+
import type { PointerCoords } from '../event';
|
|
2
|
+
import type { Instance } from '../setup';
|
|
3
|
+
import type { pointerKey } from '../system/pointer';
|
|
4
4
|
declare type PointerActionInput = string | ({
|
|
5
5
|
keys: string;
|
|
6
6
|
} & PointerActionPosition) | PointerAction;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Options } from '../options';
|
|
2
2
|
import type { PointerInput } from '../pointer';
|
|
3
3
|
import type { System } from '../system';
|
|
4
|
-
import type { UserEventApi } from '
|
|
4
|
+
import type { UserEventApi } from './setup';
|
|
5
5
|
export declare type DirectOptions = Options & {
|
|
6
6
|
keyboardState?: System;
|
|
7
7
|
pointerState?: System;
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type * as userEventApi from './api';
|
|
3
|
-
import { setupMain, setupSub } from './setup';
|
|
4
|
-
import { Config } from './config';
|
|
1
|
+
import { setupMain } from './setup';
|
|
5
2
|
import * as directApi from './directApi';
|
|
6
|
-
export {
|
|
7
|
-
export declare type UserEventApi = typeof userEventApi;
|
|
8
|
-
export declare type Instance = UserEventApi & {
|
|
9
|
-
[Config]: Config;
|
|
10
|
-
dispatchUIEvent: ReturnType<typeof bindDispatchUIEvent>;
|
|
11
|
-
};
|
|
12
|
-
export declare type UserEvent = {
|
|
13
|
-
readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;
|
|
14
|
-
} & {
|
|
15
|
-
readonly [k in keyof UserEventApi]: (...args: Parameters<UserEventApi[k]>) => ReturnType<UserEventApi[k]>;
|
|
16
|
-
};
|
|
3
|
+
export type { Instance } from './setup';
|
|
17
4
|
export declare const userEvent: {
|
|
18
5
|
readonly setup: typeof setupMain;
|
|
19
6
|
readonly clear: typeof directApi.clear;
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
import { dispatchEvent, dispatchUIEvent } from '../event';
|
|
1
2
|
import { Options } from '../options';
|
|
2
3
|
import { System } from '../system';
|
|
3
|
-
import
|
|
4
|
-
import { Config } from './config';
|
|
4
|
+
import * as userEventApi from './api';
|
|
5
5
|
import { DirectOptions } from './directApi';
|
|
6
|
-
export declare
|
|
6
|
+
export declare type UserEventApi = typeof userEventApi;
|
|
7
|
+
export declare type UserEvent = {
|
|
8
|
+
readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;
|
|
9
|
+
} & {
|
|
10
|
+
readonly [k in keyof UserEventApi]: (...args: Parameters<UserEventApi[k]>) => ReturnType<UserEventApi[k]>;
|
|
11
|
+
};
|
|
12
|
+
export declare type Instance = UserEventApi & {
|
|
13
|
+
config: Config;
|
|
14
|
+
dispatchEvent: OmitThisParameter<typeof dispatchEvent>;
|
|
15
|
+
dispatchUIEvent: OmitThisParameter<typeof dispatchUIEvent>;
|
|
16
|
+
system: System;
|
|
17
|
+
levelRefs: Record<number, object | undefined>;
|
|
18
|
+
};
|
|
19
|
+
export declare type Config = Required<Options>;
|
|
20
|
+
export declare function createConfig(options?: Options, defaults?: Required<Options>, node?: Node): Config;
|
|
7
21
|
/**
|
|
8
22
|
* Start a "session" with userEvent.
|
|
9
23
|
* All APIs returned by this function share an input device state and a default configuration.
|
|
@@ -12,15 +26,19 @@ export declare function setupMain(options?: Options): UserEvent;
|
|
|
12
26
|
/**
|
|
13
27
|
* Setup in direct call per `userEvent.anyApi()`
|
|
14
28
|
*/
|
|
15
|
-
export declare function setupDirect({ keyboardState, pointerState, ...options }?: DirectOptions &
|
|
16
|
-
{
|
|
29
|
+
export declare function setupDirect({ keyboardState, pointerState, ...options }?: DirectOptions & {
|
|
17
30
|
keyboardState?: System;
|
|
18
31
|
pointerState?: System;
|
|
19
|
-
},
|
|
20
|
-
|
|
32
|
+
}, // backward-compatibility
|
|
33
|
+
node?: Node): {
|
|
21
34
|
api: UserEvent;
|
|
35
|
+
system: System;
|
|
22
36
|
};
|
|
23
37
|
/**
|
|
24
38
|
* Create a set of callbacks with different default settings but the same state.
|
|
25
39
|
*/
|
|
26
40
|
export declare function setupSub(this: Instance, options: Options): UserEvent;
|
|
41
|
+
export declare function createInstance(config: Config, system?: System): {
|
|
42
|
+
instance: Instance;
|
|
43
|
+
api: UserEvent;
|
|
44
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Instance } from '../setup';
|
|
2
2
|
import type { System } from '.';
|
|
3
3
|
export declare enum DOM_KEY_LOCATION {
|
|
4
4
|
STANDARD = 0,
|
|
@@ -45,9 +45,9 @@ export declare class KeyboardHost {
|
|
|
45
45
|
isKeyPressed(keyDef: keyboardKey): boolean;
|
|
46
46
|
getPressedKeys(): keyboardKey[];
|
|
47
47
|
/** Press a key */
|
|
48
|
-
keydown(
|
|
48
|
+
keydown(instance: Instance, keyDef: keyboardKey): Promise<void>;
|
|
49
49
|
/** Release a key */
|
|
50
|
-
keyup(
|
|
50
|
+
keyup(instance: Instance, keyDef: keyboardKey): Promise<void>;
|
|
51
51
|
private setKeydownTarget;
|
|
52
52
|
private hasKeyPress;
|
|
53
53
|
}
|
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
import { System } from '..';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export interface pointerKey {
|
|
6
|
-
/** Name of the pointer key */
|
|
7
|
-
name: string;
|
|
8
|
-
/** Type of the pointer device */
|
|
9
|
-
pointerType: 'mouse' | 'pen' | 'touch';
|
|
10
|
-
/** Type of button */
|
|
11
|
-
button?: MouseButton;
|
|
12
|
-
}
|
|
13
|
-
export interface PointerPosition {
|
|
14
|
-
target?: Element;
|
|
15
|
-
coords?: PointerCoords;
|
|
16
|
-
caret?: CaretPosition;
|
|
17
|
-
}
|
|
18
|
-
export interface CaretPosition {
|
|
19
|
-
node?: Node;
|
|
20
|
-
offset?: number;
|
|
21
|
-
}
|
|
2
|
+
import { Instance } from '../../setup';
|
|
3
|
+
import { pointerKey, PointerPosition } from './shared';
|
|
4
|
+
export type { pointerKey, PointerPosition } from './shared';
|
|
22
5
|
export declare class PointerHost {
|
|
23
6
|
readonly system: System;
|
|
24
7
|
constructor(system: System);
|
|
@@ -27,13 +10,12 @@ export declare class PointerHost {
|
|
|
27
10
|
private readonly devices;
|
|
28
11
|
private readonly pointers;
|
|
29
12
|
isKeyPressed(keyDef: pointerKey): boolean;
|
|
30
|
-
press(
|
|
31
|
-
move(
|
|
32
|
-
release(
|
|
13
|
+
press(instance: Instance, keyDef: pointerKey, position: PointerPosition): Promise<void>;
|
|
14
|
+
move(instance: Instance, pointerName: string, position: PointerPosition): Promise<void>;
|
|
15
|
+
release(instance: Instance, keyDef: pointerKey, position: PointerPosition): Promise<void>;
|
|
33
16
|
getPointerName(keyDef: pointerKey): string;
|
|
34
17
|
getPreviousPosition(pointerName: string): PointerPosition | undefined;
|
|
35
18
|
resetClickCount(): void;
|
|
36
|
-
getMouseTarget(
|
|
19
|
+
getMouseTarget(instance: Instance): Element;
|
|
37
20
|
setMousePosition(position: PointerPosition): void;
|
|
38
21
|
}
|
|
39
|
-
export declare function isDifferentPointerPosition(positionA: PointerPosition, positionB: PointerPosition): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { pointerKey, PointerPosition } from '.';
|
|
1
|
+
import type { Instance } from '../../setup';
|
|
3
2
|
import type { Pointer } from './pointer';
|
|
3
|
+
import { pointerKey, PointerPosition } from './shared';
|
|
4
4
|
/**
|
|
5
5
|
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
|
|
6
6
|
*/
|
|
@@ -10,13 +10,13 @@ export declare class Mouse {
|
|
|
10
10
|
private selecting?;
|
|
11
11
|
private buttonDownTarget;
|
|
12
12
|
private readonly clickCount;
|
|
13
|
-
move(
|
|
13
|
+
move(instance: Instance, position: PointerPosition): {
|
|
14
14
|
leave: () => void;
|
|
15
15
|
enter: () => void;
|
|
16
16
|
move: () => void;
|
|
17
17
|
} | undefined;
|
|
18
|
-
down(
|
|
19
|
-
up(
|
|
18
|
+
down(instance: Instance, keyDef: pointerKey, pointer: Pointer): void;
|
|
19
|
+
up(instance: Instance, keyDef: pointerKey, pointer: Pointer): void;
|
|
20
20
|
resetClickCount(): void;
|
|
21
21
|
private getEventInit;
|
|
22
22
|
private getTarget;
|