@testing-library/user-event 14.0.0-alpha.1 → 14.0.0-alpha.13
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/{src/clear.d.ts → clear.d.ts} +0 -0
- package/dist/clear.js +14 -27
- package/dist/{src/click.d.ts → click.d.ts} +3 -2
- package/dist/click.js +23 -7
- package/dist/document/index.d.ts +10 -0
- package/dist/document/index.js +8 -10
- package/dist/document/interceptor.d.ts +15 -0
- package/dist/document/interceptor.js +7 -4
- package/dist/document/selection.d.ts +27 -0
- package/dist/document/selection.js +51 -28
- package/dist/{src/document → document}/value.d.ts +5 -1
- package/dist/document/value.js +27 -6
- package/dist/{src/hover.d.ts → hover.d.ts} +2 -2
- package/dist/hover.js +2 -2
- package/dist/{src/index.d.ts → index.d.ts} +0 -2
- package/dist/index.js +0 -8
- package/dist/{src/keyboard → keyboard}/getEventProps.d.ts +0 -2
- package/dist/keyboard/getEventProps.js +1 -7
- package/dist/{src/keyboard → keyboard}/getNextKeyDef.d.ts +0 -1
- package/dist/keyboard/getNextKeyDef.js +2 -32
- package/dist/{src/keyboard → keyboard}/index.d.ts +0 -1
- package/dist/keyboard/index.js +0 -8
- package/dist/{src/keyboard → keyboard}/keyMap.d.ts +0 -0
- package/dist/keyboard/keyMap.js +26 -46
- package/dist/{src/keyboard → keyboard}/keyboardImplementation.d.ts +0 -0
- package/dist/keyboard/keyboardImplementation.js +15 -17
- package/dist/{src/keyboard → keyboard}/plugins/arrow.d.ts +0 -0
- package/dist/keyboard/plugins/arrow.js +7 -12
- package/dist/{src/keyboard → keyboard}/plugins/character.d.ts +0 -0
- package/dist/keyboard/plugins/character.js +27 -45
- package/dist/keyboard/plugins/combination.d.ts +5 -0
- package/dist/keyboard/plugins/combination.js +17 -0
- package/dist/{src/keyboard → keyboard}/plugins/control.d.ts +0 -0
- package/dist/keyboard/plugins/control.js +4 -12
- package/dist/{src/keyboard → keyboard}/plugins/functional.d.ts +0 -0
- package/dist/keyboard/plugins/functional.js +23 -11
- package/dist/{src/keyboard → keyboard}/plugins/index.d.ts +0 -1
- package/dist/keyboard/plugins/index.js +4 -11
- package/dist/{src/keyboard → keyboard}/shared/fireChangeForInputTimeIfValid.d.ts +0 -0
- package/dist/{src/keyboard → keyboard}/shared/index.d.ts +0 -0
- package/dist/{src/keyboard → keyboard}/types.d.ts +0 -2
- package/dist/paste.d.ts +6 -0
- package/dist/paste.js +40 -43
- package/dist/{src/pointer → pointer}/index.d.ts +0 -0
- package/dist/{src/pointer → pointer}/keyMap.d.ts +0 -0
- package/dist/{src/pointer → pointer}/parseKeyDef.d.ts +0 -0
- package/dist/{src/pointer → pointer}/pointerAction.d.ts +2 -6
- package/dist/pointer/pointerAction.js +2 -26
- package/dist/pointer/pointerMove.d.ts +5 -0
- package/dist/pointer/pointerMove.js +49 -5
- package/dist/pointer/pointerPress.d.ts +7 -0
- package/dist/pointer/pointerPress.js +135 -29
- package/dist/pointer/resolveSelectionTarget.d.ts +5 -0
- package/dist/pointer/resolveSelectionTarget.js +75 -0
- package/dist/{src/pointer → pointer}/types.d.ts +18 -4
- package/dist/{src/selectOptions.d.ts → selectOptions.d.ts} +2 -2
- package/dist/selectOptions.js +25 -26
- package/dist/{src/setup.d.ts → setup.d.ts} +5 -2
- package/dist/setup.js +32 -21
- package/dist/tab.d.ts +5 -0
- package/dist/tab.js +3 -132
- package/dist/{src/type.d.ts → type.d.ts} +0 -0
- package/dist/type.js +3 -19
- package/dist/{src/upload.d.ts → upload.d.ts} +0 -1
- package/dist/upload.js +1 -1
- package/dist/{src/utils → utils}/click/isClickableInput.d.ts +0 -0
- package/dist/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/utils/dataTransfer/Blob.js +21 -0
- package/dist/utils/dataTransfer/Clipboard.d.ts +7 -0
- package/dist/utils/dataTransfer/Clipboard.js +143 -0
- package/dist/utils/dataTransfer/DataTransfer.d.ts +1 -0
- package/dist/utils/dataTransfer/DataTransfer.js +143 -0
- package/dist/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/utils/dataTransfer/FileList.js +13 -0
- package/dist/{src/utils → utils}/edit/buildTimeValue.d.ts +0 -0
- package/dist/utils/edit/calculateNewValue.d.ts +14 -0
- package/dist/utils/edit/calculateNewValue.js +19 -21
- package/dist/utils/edit/editInputElement.d.ts +16 -0
- package/dist/utils/edit/editInputElement.js +53 -0
- package/dist/{src/utils → utils}/edit/getValue.d.ts +0 -0
- package/dist/utils/edit/getValue.js +1 -3
- package/dist/utils/edit/isContentEditable.d.ts +7 -0
- package/dist/utils/edit/isContentEditable.js +14 -0
- package/dist/{src/utils → utils}/edit/isEditable.d.ts +1 -0
- package/dist/{src/utils → utils}/edit/isValidDateValue.d.ts +0 -0
- package/dist/{src/utils → utils}/edit/isValidInputTimeValue.d.ts +0 -0
- package/dist/{src/utils → utils}/edit/maxLength.d.ts +0 -0
- package/dist/utils/edit/prepareInput.d.ts +7 -0
- package/dist/utils/edit/prepareInput.js +77 -0
- package/dist/{src/utils → utils}/focus/blur.d.ts +0 -0
- package/dist/{src/utils → utils}/focus/focus.d.ts +0 -0
- package/dist/utils/focus/focus.js +3 -0
- package/dist/{src/utils → utils}/focus/getActiveElement.d.ts +0 -0
- package/dist/utils/focus/getTabDestination.d.ts +1 -0
- package/dist/utils/focus/getTabDestination.js +71 -0
- package/dist/{src/utils → utils}/focus/isFocusable.d.ts +0 -0
- package/dist/utils/focus/selectAll.d.ts +5 -0
- package/dist/utils/focus/selectAll.js +51 -0
- package/dist/utils/focus/selection.d.ts +42 -0
- package/dist/utils/focus/selection.js +190 -0
- package/dist/{src/utils → utils}/focus/selector.d.ts +0 -0
- package/dist/{src/utils → utils}/index.d.ts +9 -5
- package/dist/utils/index.js +98 -46
- package/dist/{src/utils → utils}/keyDef/readNextDescriptor.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/eventWrapper.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/findClosest.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/hasFormSubmit.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/hasPointerEvents.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isDescendantOrSelf.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isDisabled.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isElementType.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isVisible.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/wait.d.ts +0 -0
- package/dist/{src/utils → utils}/pointer/firePointerEvents.d.ts +13 -11
- package/dist/utils/pointer/firePointerEvents.js +62 -5
- package/dist/{src/utils → utils}/pointer/mouseButtons.d.ts +0 -0
- package/package.json +2 -2
- package/dist/document/applyNative.js +0 -28
- package/dist/keyboard/specialCharMap.js +0 -30
- package/dist/src/document/applyNative.d.ts +0 -8
- package/dist/src/document/index.d.ts +0 -10
- package/dist/src/document/interceptor.d.ts +0 -5
- package/dist/src/document/selection.d.ts +0 -18
- package/dist/src/keyboard/specialCharMap.d.ts +0 -22
- package/dist/src/paste.d.ts +0 -7
- package/dist/src/pointer/pointerMove.d.ts +0 -5
- package/dist/src/pointer/pointerPress.d.ts +0 -7
- package/dist/src/tab.d.ts +0 -6
- package/dist/src/utils/edit/calculateNewValue.d.ts +0 -7
- package/dist/src/utils/edit/cursorPosition.d.ts +0 -2
- package/dist/src/utils/edit/fireInputEvent.d.ts +0 -8
- package/dist/src/utils/edit/isContentEditable.d.ts +0 -3
- package/dist/src/utils/edit/selectionRange.d.ts +0 -5
- package/dist/src/utils/misc/isDocument.d.ts +0 -1
- package/dist/src/utils/pointer/fakeEvent.d.ts +0 -16
- package/dist/tests/_helpers/custom-element.d.ts +0 -8
- package/dist/tests/_helpers/utils.d.ts +0 -73
- package/dist/tests/_setup-env.d.ts +0 -1
- package/dist/tests/clear.d.ts +0 -1
- package/dist/tests/click/click.d.ts +0 -1
- package/dist/tests/click/dblclick.d.ts +0 -1
- package/dist/tests/document/index.d.ts +0 -1
- package/dist/tests/document/selectionRange.d.ts +0 -1
- package/dist/tests/hover/hover.d.ts +0 -1
- package/dist/tests/hover/unhover.d.ts +0 -1
- package/dist/tests/keyboard/getNextKeyDef.d.ts +0 -1
- package/dist/tests/keyboard/index.d.ts +0 -1
- package/dist/tests/keyboard/keyboardImplementation.d.ts +0 -1
- package/dist/tests/keyboard/plugin/arrow.d.ts +0 -1
- package/dist/tests/keyboard/plugin/character.d.ts +0 -1
- package/dist/tests/keyboard/plugin/control.d.ts +0 -1
- package/dist/tests/keyboard/plugin/functional.d.ts +0 -1
- package/dist/tests/keyboard/shared/fireInputEvent.d.ts +0 -1
- package/dist/tests/paste.d.ts +0 -1
- package/dist/tests/pointer/index.d.ts +0 -1
- package/dist/tests/react/keyboard.d.ts +0 -1
- package/dist/tests/react/type.d.ts +0 -1
- package/dist/tests/selectOptions/deselect.d.ts +0 -1
- package/dist/tests/selectOptions/select.d.ts +0 -1
- package/dist/tests/setup.d.ts +0 -10
- package/dist/tests/tab.d.ts +0 -1
- package/dist/tests/type/index.d.ts +0 -1
- package/dist/tests/type/modifiers.d.ts +0 -1
- package/dist/tests/upload.d.ts +0 -1
- package/dist/tests/utils/edit/calculateNewValue.d.ts +0 -1
- package/dist/tests/utils/edit/isContentEditable.d.ts +0 -1
- package/dist/tests/utils/focus/blur.d.ts +0 -1
- package/dist/tests/utils/focus/focus.d.ts +0 -1
- package/dist/tests/utils/misc/hasPointerEvents.d.ts +0 -1
- package/dist/tests/utils/misc/isDescendantOrSelf.d.ts +0 -1
- package/dist/tests/utils/misc/isElementType.d.ts +0 -1
- package/dist/tests/utils/misc/isVisible.d.ts +0 -1
- package/dist/utils/edit/cursorPosition.js +0 -35
- package/dist/utils/edit/fireInputEvent.js +0 -55
- package/dist/utils/edit/selectionRange.js +0 -64
- package/dist/utils/misc/dom-helpers.d.ts +0 -3
- package/dist/utils/misc/isDocument.js +0 -10
- package/dist/utils/pointer/fakeEvent.js +0 -82
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getInputRange = getInputRange;
|
|
7
|
+
exports.hasOwnSelection = hasOwnSelection;
|
|
8
|
+
exports.modifySelection = modifySelection;
|
|
9
|
+
exports.setSelection = setSelection;
|
|
10
|
+
exports.setSelectionRange = setSelectionRange;
|
|
11
|
+
exports.updateSelectionOnFocus = updateSelectionOnFocus;
|
|
12
|
+
|
|
13
|
+
var _isElementType = require("../misc/isElementType");
|
|
14
|
+
|
|
15
|
+
var _document = require("../../document");
|
|
16
|
+
|
|
17
|
+
var _isEditable = require("../edit/isEditable");
|
|
18
|
+
|
|
19
|
+
var _isContentEditable = require("../edit/isContentEditable");
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Backward-compatible selection.
|
|
23
|
+
*
|
|
24
|
+
* Handles input elements and contenteditable if it only contains a single text node.
|
|
25
|
+
*/
|
|
26
|
+
function setSelectionRange(element, anchorOffset, focusOffset) {
|
|
27
|
+
var _element$firstChild;
|
|
28
|
+
|
|
29
|
+
if (hasOwnSelection(element)) {
|
|
30
|
+
return setSelection({
|
|
31
|
+
focusNode: element,
|
|
32
|
+
anchorOffset,
|
|
33
|
+
focusOffset
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/* istanbul ignore else */
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
if ((0, _isContentEditable.isContentEditable)(element) && ((_element$firstChild = element.firstChild) == null ? void 0 : _element$firstChild.nodeType) === 3) {
|
|
40
|
+
return setSelection({
|
|
41
|
+
focusNode: element.firstChild,
|
|
42
|
+
anchorOffset,
|
|
43
|
+
focusOffset
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/* istanbul ignore next */
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
throw new Error('Not implemented. The result of this interaction is unreliable.');
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Determine if the element has its own selection implementation
|
|
53
|
+
* and does not interact with the Document Selection API.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
function hasOwnSelection(node) {
|
|
58
|
+
return isElement(node) && ((0, _isElementType.isElementType)(node, 'textarea') || (0, _isElementType.isElementType)(node, 'input') && node.type in _isEditable.editableInputTypes);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isElement(node) {
|
|
62
|
+
return node.nodeType === 1;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Determine which selection logic and selection ranges to consider.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
function getTargetTypeAndSelection(node) {
|
|
70
|
+
const element = getElement(node);
|
|
71
|
+
|
|
72
|
+
if (element && hasOwnSelection(element)) {
|
|
73
|
+
return {
|
|
74
|
+
type: 'input',
|
|
75
|
+
selection: (0, _document.getUISelection)(element)
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const selection = element == null ? void 0 : element.ownerDocument.getSelection(); // It is possible to extend a single-range selection into a contenteditable.
|
|
80
|
+
// This results in the range acting like a range outside of contenteditable.
|
|
81
|
+
|
|
82
|
+
const isCE = (0, _isContentEditable.getContentEditable)(node) && (selection == null ? void 0 : selection.anchorNode) && (0, _isContentEditable.getContentEditable)(selection.anchorNode);
|
|
83
|
+
return {
|
|
84
|
+
type: isCE ? 'contenteditable' : 'default',
|
|
85
|
+
selection
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function getElement(node) {
|
|
90
|
+
return node.nodeType === 1 ? node : node.parentElement;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Reset the Document Selection when moving focus into an element
|
|
94
|
+
* with own selection implementation.
|
|
95
|
+
*/
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
function updateSelectionOnFocus(element) {
|
|
99
|
+
const selection = element.ownerDocument.getSelection();
|
|
100
|
+
/* istanbul ignore if */
|
|
101
|
+
|
|
102
|
+
if (!(selection != null && selection.focusNode)) {
|
|
103
|
+
return;
|
|
104
|
+
} // If the focus moves inside an element with own selection implementation,
|
|
105
|
+
// the document selection will be this element.
|
|
106
|
+
// But if the focused element is inside a contenteditable,
|
|
107
|
+
// 1) a collapsed selection will be retained.
|
|
108
|
+
// 2) other selections will be replaced by a cursor
|
|
109
|
+
// 2.a) at the start of the first child if it is a text node
|
|
110
|
+
// 2.b) at the start of the contenteditable.
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
if (hasOwnSelection(element)) {
|
|
114
|
+
const contenteditable = (0, _isContentEditable.getContentEditable)(selection.focusNode);
|
|
115
|
+
|
|
116
|
+
if (contenteditable) {
|
|
117
|
+
if (!selection.isCollapsed) {
|
|
118
|
+
var _contenteditable$firs;
|
|
119
|
+
|
|
120
|
+
const focusNode = ((_contenteditable$firs = contenteditable.firstChild) == null ? void 0 : _contenteditable$firs.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
|
|
121
|
+
selection.setBaseAndExtent(focusNode, 0, focusNode, 0);
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
selection.setBaseAndExtent(element, 0, element, 0);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get the range that would be overwritten by input.
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
function getInputRange(focusNode) {
|
|
134
|
+
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
135
|
+
|
|
136
|
+
if (typeAndSelection.type === 'input') {
|
|
137
|
+
return typeAndSelection.selection;
|
|
138
|
+
} else if (typeAndSelection.type === 'contenteditable') {
|
|
139
|
+
var _typeAndSelection$sel;
|
|
140
|
+
|
|
141
|
+
// Multi-range on contenteditable edits the first selection instead of the last
|
|
142
|
+
return (_typeAndSelection$sel = typeAndSelection.selection) == null ? void 0 : _typeAndSelection$sel.getRangeAt(0);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
|
|
147
|
+
*/
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
function modifySelection({
|
|
151
|
+
focusNode,
|
|
152
|
+
focusOffset
|
|
153
|
+
}) {
|
|
154
|
+
var _focusNode$ownerDocum, _focusNode$ownerDocum2;
|
|
155
|
+
|
|
156
|
+
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
157
|
+
|
|
158
|
+
if (typeAndSelection.type === 'input') {
|
|
159
|
+
return (0, _document.setUISelection)(focusNode, {
|
|
160
|
+
anchorOffset: typeAndSelection.selection.anchorOffset,
|
|
161
|
+
focusOffset
|
|
162
|
+
}, 'modify');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
(_focusNode$ownerDocum = focusNode.ownerDocument) == null ? void 0 : (_focusNode$ownerDocum2 = _focusNode$ownerDocum.getSelection()) == null ? void 0 : _focusNode$ownerDocum2.extend(focusNode, focusOffset);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Set the selection
|
|
169
|
+
*/
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
function setSelection({
|
|
173
|
+
focusNode,
|
|
174
|
+
focusOffset,
|
|
175
|
+
anchorNode = focusNode,
|
|
176
|
+
anchorOffset = focusOffset
|
|
177
|
+
}) {
|
|
178
|
+
var _anchorNode$ownerDocu, _anchorNode$ownerDocu2;
|
|
179
|
+
|
|
180
|
+
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
181
|
+
|
|
182
|
+
if (typeAndSelection.type === 'input') {
|
|
183
|
+
return (0, _document.setUISelection)(focusNode, {
|
|
184
|
+
anchorOffset,
|
|
185
|
+
focusOffset
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
(_anchorNode$ownerDocu = anchorNode.ownerDocument) == null ? void 0 : (_anchorNode$ownerDocu2 = _anchorNode$ownerDocu.getSelection()) == null ? void 0 : _anchorNode$ownerDocu2.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
190
|
+
}
|
|
File without changes
|
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
export * from './click/isClickableInput';
|
|
2
|
+
export * from './dataTransfer/Blob';
|
|
3
|
+
export * from './dataTransfer/DataTransfer';
|
|
4
|
+
export * from './dataTransfer/FileList';
|
|
5
|
+
export * from './dataTransfer/Clipboard';
|
|
2
6
|
export * from './edit/buildTimeValue';
|
|
3
7
|
export * from './edit/calculateNewValue';
|
|
4
|
-
export * from './edit/
|
|
5
|
-
export * from './edit/fireInputEvent';
|
|
8
|
+
export * from './edit/editInputElement';
|
|
6
9
|
export * from './edit/getValue';
|
|
7
10
|
export * from './edit/isContentEditable';
|
|
8
11
|
export * from './edit/isEditable';
|
|
9
12
|
export * from './edit/isValidDateValue';
|
|
10
13
|
export * from './edit/isValidInputTimeValue';
|
|
11
14
|
export * from './edit/maxLength';
|
|
12
|
-
export * from './edit/
|
|
15
|
+
export * from './edit/prepareInput';
|
|
13
16
|
export * from './focus/blur';
|
|
14
17
|
export * from './focus/focus';
|
|
15
18
|
export * from './focus/getActiveElement';
|
|
19
|
+
export * from './focus/getTabDestination';
|
|
16
20
|
export * from './focus/isFocusable';
|
|
21
|
+
export * from './focus/selectAll';
|
|
22
|
+
export * from './focus/selection';
|
|
17
23
|
export * from './focus/selector';
|
|
18
24
|
export * from './keyDef/readNextDescriptor';
|
|
19
25
|
export * from './misc/eventWrapper';
|
|
@@ -22,10 +28,8 @@ export * from './misc/isDescendantOrSelf';
|
|
|
22
28
|
export * from './misc/isElementType';
|
|
23
29
|
export * from './misc/isVisible';
|
|
24
30
|
export * from './misc/isDisabled';
|
|
25
|
-
export * from './misc/isDocument';
|
|
26
31
|
export * from './misc/wait';
|
|
27
32
|
export * from './misc/hasPointerEvents';
|
|
28
33
|
export * from './misc/hasFormSubmit';
|
|
29
|
-
export * from './pointer/fakeEvent';
|
|
30
34
|
export * from './pointer/firePointerEvents';
|
|
31
35
|
export * from './pointer/mouseButtons';
|
package/dist/utils/index.js
CHANGED
|
@@ -17,54 +17,93 @@ Object.keys(_isClickableInput).forEach(function (key) {
|
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
var
|
|
20
|
+
var _Blob = require("./dataTransfer/Blob");
|
|
21
21
|
|
|
22
|
-
Object.keys(
|
|
22
|
+
Object.keys(_Blob).forEach(function (key) {
|
|
23
23
|
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] ===
|
|
24
|
+
if (key in exports && exports[key] === _Blob[key]) return;
|
|
25
25
|
Object.defineProperty(exports, key, {
|
|
26
26
|
enumerable: true,
|
|
27
27
|
get: function () {
|
|
28
|
-
return
|
|
28
|
+
return _Blob[key];
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var _DataTransfer = require("./dataTransfer/DataTransfer");
|
|
34
34
|
|
|
35
|
-
Object.keys(
|
|
35
|
+
Object.keys(_DataTransfer).forEach(function (key) {
|
|
36
36
|
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (key in exports && exports[key] ===
|
|
37
|
+
if (key in exports && exports[key] === _DataTransfer[key]) return;
|
|
38
38
|
Object.defineProperty(exports, key, {
|
|
39
39
|
enumerable: true,
|
|
40
40
|
get: function () {
|
|
41
|
-
return
|
|
41
|
+
return _DataTransfer[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _FileList = require("./dataTransfer/FileList");
|
|
47
|
+
|
|
48
|
+
Object.keys(_FileList).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _FileList[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _FileList[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var _Clipboard = require("./dataTransfer/Clipboard");
|
|
60
|
+
|
|
61
|
+
Object.keys(_Clipboard).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (key in exports && exports[key] === _Clipboard[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () {
|
|
67
|
+
return _Clipboard[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var _buildTimeValue = require("./edit/buildTimeValue");
|
|
73
|
+
|
|
74
|
+
Object.keys(_buildTimeValue).forEach(function (key) {
|
|
75
|
+
if (key === "default" || key === "__esModule") return;
|
|
76
|
+
if (key in exports && exports[key] === _buildTimeValue[key]) return;
|
|
77
|
+
Object.defineProperty(exports, key, {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
get: function () {
|
|
80
|
+
return _buildTimeValue[key];
|
|
42
81
|
}
|
|
43
82
|
});
|
|
44
83
|
});
|
|
45
84
|
|
|
46
|
-
var
|
|
85
|
+
var _calculateNewValue = require("./edit/calculateNewValue");
|
|
47
86
|
|
|
48
|
-
Object.keys(
|
|
87
|
+
Object.keys(_calculateNewValue).forEach(function (key) {
|
|
49
88
|
if (key === "default" || key === "__esModule") return;
|
|
50
|
-
if (key in exports && exports[key] ===
|
|
89
|
+
if (key in exports && exports[key] === _calculateNewValue[key]) return;
|
|
51
90
|
Object.defineProperty(exports, key, {
|
|
52
91
|
enumerable: true,
|
|
53
92
|
get: function () {
|
|
54
|
-
return
|
|
93
|
+
return _calculateNewValue[key];
|
|
55
94
|
}
|
|
56
95
|
});
|
|
57
96
|
});
|
|
58
97
|
|
|
59
|
-
var
|
|
98
|
+
var _editInputElement = require("./edit/editInputElement");
|
|
60
99
|
|
|
61
|
-
Object.keys(
|
|
100
|
+
Object.keys(_editInputElement).forEach(function (key) {
|
|
62
101
|
if (key === "default" || key === "__esModule") return;
|
|
63
|
-
if (key in exports && exports[key] ===
|
|
102
|
+
if (key in exports && exports[key] === _editInputElement[key]) return;
|
|
64
103
|
Object.defineProperty(exports, key, {
|
|
65
104
|
enumerable: true,
|
|
66
105
|
get: function () {
|
|
67
|
-
return
|
|
106
|
+
return _editInputElement[key];
|
|
68
107
|
}
|
|
69
108
|
});
|
|
70
109
|
});
|
|
@@ -147,15 +186,15 @@ Object.keys(_maxLength).forEach(function (key) {
|
|
|
147
186
|
});
|
|
148
187
|
});
|
|
149
188
|
|
|
150
|
-
var
|
|
189
|
+
var _prepareInput = require("./edit/prepareInput");
|
|
151
190
|
|
|
152
|
-
Object.keys(
|
|
191
|
+
Object.keys(_prepareInput).forEach(function (key) {
|
|
153
192
|
if (key === "default" || key === "__esModule") return;
|
|
154
|
-
if (key in exports && exports[key] ===
|
|
193
|
+
if (key in exports && exports[key] === _prepareInput[key]) return;
|
|
155
194
|
Object.defineProperty(exports, key, {
|
|
156
195
|
enumerable: true,
|
|
157
196
|
get: function () {
|
|
158
|
-
return
|
|
197
|
+
return _prepareInput[key];
|
|
159
198
|
}
|
|
160
199
|
});
|
|
161
200
|
});
|
|
@@ -199,6 +238,19 @@ Object.keys(_getActiveElement).forEach(function (key) {
|
|
|
199
238
|
});
|
|
200
239
|
});
|
|
201
240
|
|
|
241
|
+
var _getTabDestination = require("./focus/getTabDestination");
|
|
242
|
+
|
|
243
|
+
Object.keys(_getTabDestination).forEach(function (key) {
|
|
244
|
+
if (key === "default" || key === "__esModule") return;
|
|
245
|
+
if (key in exports && exports[key] === _getTabDestination[key]) return;
|
|
246
|
+
Object.defineProperty(exports, key, {
|
|
247
|
+
enumerable: true,
|
|
248
|
+
get: function () {
|
|
249
|
+
return _getTabDestination[key];
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
});
|
|
253
|
+
|
|
202
254
|
var _isFocusable = require("./focus/isFocusable");
|
|
203
255
|
|
|
204
256
|
Object.keys(_isFocusable).forEach(function (key) {
|
|
@@ -212,6 +264,32 @@ Object.keys(_isFocusable).forEach(function (key) {
|
|
|
212
264
|
});
|
|
213
265
|
});
|
|
214
266
|
|
|
267
|
+
var _selectAll = require("./focus/selectAll");
|
|
268
|
+
|
|
269
|
+
Object.keys(_selectAll).forEach(function (key) {
|
|
270
|
+
if (key === "default" || key === "__esModule") return;
|
|
271
|
+
if (key in exports && exports[key] === _selectAll[key]) return;
|
|
272
|
+
Object.defineProperty(exports, key, {
|
|
273
|
+
enumerable: true,
|
|
274
|
+
get: function () {
|
|
275
|
+
return _selectAll[key];
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
var _selection = require("./focus/selection");
|
|
281
|
+
|
|
282
|
+
Object.keys(_selection).forEach(function (key) {
|
|
283
|
+
if (key === "default" || key === "__esModule") return;
|
|
284
|
+
if (key in exports && exports[key] === _selection[key]) return;
|
|
285
|
+
Object.defineProperty(exports, key, {
|
|
286
|
+
enumerable: true,
|
|
287
|
+
get: function () {
|
|
288
|
+
return _selection[key];
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
});
|
|
292
|
+
|
|
215
293
|
var _selector = require("./focus/selector");
|
|
216
294
|
|
|
217
295
|
Object.keys(_selector).forEach(function (key) {
|
|
@@ -316,19 +394,6 @@ Object.keys(_isDisabled).forEach(function (key) {
|
|
|
316
394
|
});
|
|
317
395
|
});
|
|
318
396
|
|
|
319
|
-
var _isDocument = require("./misc/isDocument");
|
|
320
|
-
|
|
321
|
-
Object.keys(_isDocument).forEach(function (key) {
|
|
322
|
-
if (key === "default" || key === "__esModule") return;
|
|
323
|
-
if (key in exports && exports[key] === _isDocument[key]) return;
|
|
324
|
-
Object.defineProperty(exports, key, {
|
|
325
|
-
enumerable: true,
|
|
326
|
-
get: function () {
|
|
327
|
-
return _isDocument[key];
|
|
328
|
-
}
|
|
329
|
-
});
|
|
330
|
-
});
|
|
331
|
-
|
|
332
397
|
var _wait = require("./misc/wait");
|
|
333
398
|
|
|
334
399
|
Object.keys(_wait).forEach(function (key) {
|
|
@@ -368,19 +433,6 @@ Object.keys(_hasFormSubmit).forEach(function (key) {
|
|
|
368
433
|
});
|
|
369
434
|
});
|
|
370
435
|
|
|
371
|
-
var _fakeEvent = require("./pointer/fakeEvent");
|
|
372
|
-
|
|
373
|
-
Object.keys(_fakeEvent).forEach(function (key) {
|
|
374
|
-
if (key === "default" || key === "__esModule") return;
|
|
375
|
-
if (key in exports && exports[key] === _fakeEvent[key]) return;
|
|
376
|
-
Object.defineProperty(exports, key, {
|
|
377
|
-
enumerable: true,
|
|
378
|
-
get: function () {
|
|
379
|
-
return _fakeEvent[key];
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
});
|
|
383
|
-
|
|
384
436
|
var _firePointerEvents = require("./pointer/firePointerEvents");
|
|
385
437
|
|
|
386
438
|
Object.keys(_firePointerEvents).forEach(function (key) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import type { pointerState } from '../../pointer/types';
|
|
2
2
|
import type { keyboardState } from '../../keyboard/types';
|
|
3
3
|
import { MouseButton } from './mouseButtons';
|
|
4
|
-
export interface Coords {
|
|
5
|
-
x: number;
|
|
6
|
-
y: number;
|
|
7
|
-
clientX: number;
|
|
8
|
-
clientY: number;
|
|
9
|
-
offsetX: number;
|
|
10
|
-
offsetY: number;
|
|
11
|
-
pageX: number;
|
|
12
|
-
pageY: number;
|
|
13
|
-
}
|
|
14
4
|
export declare function firePointerEvent(target: Element, type: string, { pointerState, keyboardState, pointerType, button, coords, pointerId, isPrimary, clickCount, }: {
|
|
15
5
|
pointerState: pointerState;
|
|
16
6
|
keyboardState: keyboardState;
|
|
17
7
|
pointerType?: 'mouse' | 'pen' | 'touch';
|
|
18
8
|
button?: MouseButton;
|
|
19
|
-
coords
|
|
9
|
+
coords?: PointerCoords;
|
|
20
10
|
pointerId?: number;
|
|
21
11
|
isPrimary?: boolean;
|
|
22
12
|
clickCount?: number;
|
|
23
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
|
+
}
|
|
@@ -7,7 +7,7 @@ exports.firePointerEvent = firePointerEvent;
|
|
|
7
7
|
|
|
8
8
|
var _dom = require("@testing-library/dom");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _eventMap = require("@testing-library/dom/dist/event-map");
|
|
11
11
|
|
|
12
12
|
var _mouseButtons = require("./mouseButtons");
|
|
13
13
|
|
|
@@ -21,7 +21,6 @@ function firePointerEvent(target, type, {
|
|
|
21
21
|
isPrimary,
|
|
22
22
|
clickCount
|
|
23
23
|
}) {
|
|
24
|
-
const Event = type === 'click' || type.startsWith('mouse') ? _fakeEvent.FakeMouseEvent : _fakeEvent.FakePointerEvent;
|
|
25
24
|
const init = { ...coords,
|
|
26
25
|
altKey: keyboardState.modifiers.alt,
|
|
27
26
|
ctrlKey: keyboardState.modifiers.ctrl,
|
|
@@ -29,7 +28,7 @@ function firePointerEvent(target, type, {
|
|
|
29
28
|
shiftKey: keyboardState.modifiers.shift
|
|
30
29
|
};
|
|
31
30
|
|
|
32
|
-
if (
|
|
31
|
+
if (type === 'click' || type.startsWith('pointer')) {
|
|
33
32
|
init.pointerId = pointerId;
|
|
34
33
|
init.pointerType = pointerType;
|
|
35
34
|
}
|
|
@@ -47,9 +46,67 @@ function firePointerEvent(target, type, {
|
|
|
47
46
|
}));
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
if (['mousedown', 'mouseup', 'click'].includes(type)) {
|
|
49
|
+
if (['mousedown', 'mouseup', 'click', 'dblclick'].includes(type)) {
|
|
51
50
|
init.detail = clickCount;
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
const eventKey = Object.keys(_eventMap.eventMap).find(k => k.toLowerCase() === type);
|
|
54
|
+
|
|
55
|
+
const event = _dom.createEvent[eventKey](target, init); // see https://github.com/testing-library/react-testing-library/issues/268
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
assignPositionInit(event, init);
|
|
59
|
+
assignPointerInit(event, init);
|
|
60
|
+
return (0, _dom.fireEvent)(target, event);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function assignProps(obj, props) {
|
|
64
|
+
for (const [key, value] of Object.entries(props)) {
|
|
65
|
+
Object.defineProperty(obj, key, {
|
|
66
|
+
get: () => value
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function assignPositionInit(obj, {
|
|
72
|
+
x,
|
|
73
|
+
y,
|
|
74
|
+
clientX,
|
|
75
|
+
clientY,
|
|
76
|
+
offsetX,
|
|
77
|
+
offsetY,
|
|
78
|
+
pageX,
|
|
79
|
+
pageY,
|
|
80
|
+
screenX,
|
|
81
|
+
screenY
|
|
82
|
+
}) {
|
|
83
|
+
var _ref, _ref2, _ref3, _ref4;
|
|
84
|
+
|
|
85
|
+
assignProps(obj, {
|
|
86
|
+
/* istanbul ignore start */
|
|
87
|
+
x: (_ref = x != null ? x : clientX) != null ? _ref : 0,
|
|
88
|
+
y: (_ref2 = y != null ? y : clientY) != null ? _ref2 : 0,
|
|
89
|
+
clientX: (_ref3 = x != null ? x : clientX) != null ? _ref3 : 0,
|
|
90
|
+
clientY: (_ref4 = y != null ? y : clientY) != null ? _ref4 : 0,
|
|
91
|
+
offsetX: offsetX != null ? offsetX : 0,
|
|
92
|
+
offsetY: offsetY != null ? offsetY : 0,
|
|
93
|
+
pageX: pageX != null ? pageX : 0,
|
|
94
|
+
pageY: pageY != null ? pageY : 0,
|
|
95
|
+
screenX: screenX != null ? screenX : 0,
|
|
96
|
+
screenY: screenY != null ? screenY : 0
|
|
97
|
+
/* istanbul ignore end */
|
|
98
|
+
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function assignPointerInit(obj, {
|
|
103
|
+
isPrimary,
|
|
104
|
+
pointerId,
|
|
105
|
+
pointerType
|
|
106
|
+
}) {
|
|
107
|
+
assignProps(obj, {
|
|
108
|
+
isPrimary,
|
|
109
|
+
pointerId,
|
|
110
|
+
pointerType
|
|
111
|
+
});
|
|
55
112
|
}
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/user-event",
|
|
3
|
-
"version": "14.0.0-alpha.
|
|
3
|
+
"version": "14.0.0-alpha.13",
|
|
4
4
|
"description": "Fire events the same way the user does",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "kcd-scripts build",
|
|
30
|
+
"build": "kcd-scripts build --no-ts-defs && tsc -p tsconfig.build.json",
|
|
31
31
|
"lint": "kcd-scripts lint",
|
|
32
32
|
"setup": "npm install && npm run validate -s",
|
|
33
33
|
"test": "kcd-scripts test",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.applyNative = applyNative;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* React tracks the changes on element properties.
|
|
10
|
-
* This workaround tries to alter the DOM element without React noticing,
|
|
11
|
-
* so that it later picks up the change.
|
|
12
|
-
*
|
|
13
|
-
* @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104
|
|
14
|
-
*/
|
|
15
|
-
function applyNative(element, propName, propValue) {
|
|
16
|
-
const descriptor = Object.getOwnPropertyDescriptor(element, propName);
|
|
17
|
-
const nativeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
|
|
18
|
-
|
|
19
|
-
if (descriptor && nativeDescriptor) {
|
|
20
|
-
Object.defineProperty(element, propName, nativeDescriptor);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
element[propName] = propValue;
|
|
24
|
-
|
|
25
|
-
if (descriptor) {
|
|
26
|
-
Object.defineProperty(element, propName, descriptor);
|
|
27
|
-
}
|
|
28
|
-
}
|