@testing-library/user-event 14.0.0-alpha.6 → 14.0.0-beta.1
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/clipboard/copy.d.ts +2 -0
- package/dist/clipboard/copy.js +36 -0
- package/dist/clipboard/cut.d.ts +2 -0
- package/dist/clipboard/cut.js +42 -0
- package/dist/clipboard/index.d.ts +3 -0
- package/dist/clipboard/index.js +44 -0
- package/dist/clipboard/paste.d.ts +2 -0
- package/dist/clipboard/paste.js +47 -0
- package/dist/convenience/click.d.ts +4 -0
- package/dist/convenience/click.js +52 -0
- package/dist/convenience/hover.d.ts +3 -0
- package/dist/convenience/hover.js +31 -0
- package/dist/convenience/index.d.ts +3 -0
- package/dist/convenience/index.js +44 -0
- package/dist/convenience/tab.d.ts +4 -0
- package/dist/convenience/tab.js +12 -0
- package/dist/document/index.d.ts +1 -0
- package/dist/document/selection.d.ts +17 -7
- package/dist/document/selection.js +33 -17
- package/dist/document/value.d.ts +1 -1
- package/dist/document/value.js +1 -1
- package/dist/index.d.ts +2 -7
- package/dist/index.js +3 -12
- package/dist/keyboard/getEventProps.d.ts +0 -2
- package/dist/keyboard/getEventProps.js +1 -7
- package/dist/keyboard/index.d.ts +6 -18
- package/dist/keyboard/index.js +9 -45
- package/dist/keyboard/keyMap.js +24 -48
- package/dist/keyboard/keyboardAction.d.ts +10 -0
- package/dist/keyboard/keyboardAction.js +156 -0
- package/dist/keyboard/{getNextKeyDef.d.ts → parseKeyDef.d.ts} +4 -6
- package/dist/keyboard/parseKeyDef.js +61 -0
- package/dist/keyboard/plugins/arrow.js +7 -12
- package/dist/keyboard/plugins/character.js +42 -54
- package/dist/keyboard/plugins/combination.d.ts +5 -0
- package/dist/keyboard/plugins/combination.js +19 -0
- package/dist/keyboard/plugins/control.js +4 -12
- package/dist/keyboard/plugins/functional.js +46 -33
- package/dist/keyboard/plugins/index.d.ts +0 -1
- package/dist/keyboard/plugins/index.js +4 -11
- package/dist/keyboard/types.d.ts +3 -19
- package/dist/options.d.ts +102 -0
- package/dist/options.js +36 -0
- package/dist/pointer/index.d.ts +6 -14
- package/dist/pointer/index.js +8 -42
- package/dist/pointer/parseKeyDef.d.ts +2 -2
- package/dist/pointer/parseKeyDef.js +1 -3
- package/dist/pointer/pointerAction.d.ts +3 -2
- package/dist/pointer/pointerAction.js +9 -15
- package/dist/pointer/pointerMove.d.ts +2 -1
- package/dist/pointer/pointerMove.js +28 -17
- package/dist/pointer/pointerPress.d.ts +2 -1
- package/dist/pointer/pointerPress.js +6 -4
- package/dist/pointer/resolveSelectionTarget.js +7 -6
- package/dist/pointer/types.d.ts +0 -11
- package/dist/setup/api.d.ts +5 -0
- package/dist/setup/api.js +111 -0
- package/dist/setup/config.d.ts +10 -0
- package/dist/setup/config.js +8 -0
- package/dist/setup/directApi.d.ts +20 -0
- package/dist/setup/directApi.js +95 -0
- package/dist/setup/index.d.ts +30 -0
- package/dist/setup/index.js +27 -0
- package/dist/setup/setup.d.ts +74 -0
- package/dist/setup/setup.js +98 -0
- package/dist/setup/wrapAsync.d.ts +4 -0
- package/dist/setup/wrapAsync.js +15 -0
- package/dist/{clear.d.ts → utility/clear.d.ts} +2 -2
- package/dist/utility/clear.js +30 -0
- package/dist/utility/index.d.ts +4 -0
- package/dist/utility/index.js +57 -0
- package/dist/utility/selectOptions.d.ts +3 -0
- package/dist/{selectOptions.js → utility/selectOptions.js} +31 -41
- package/dist/utility/type.d.ts +9 -0
- package/dist/utility/type.js +37 -0
- package/dist/utility/upload.d.ts +5 -0
- package/dist/{upload.js → utility/upload.js} +12 -40
- package/dist/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/utils/dataTransfer/Blob.js +21 -0
- package/dist/utils/dataTransfer/Clipboard.d.ts +9 -0
- package/dist/utils/dataTransfer/Clipboard.js +188 -0
- package/dist/utils/dataTransfer/DataTransfer.d.ts +2 -0
- package/dist/utils/dataTransfer/DataTransfer.js +158 -0
- package/dist/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/utils/dataTransfer/FileList.js +23 -0
- package/dist/utils/edit/calculateNewValue.d.ts +12 -5
- package/dist/utils/edit/calculateNewValue.js +19 -21
- package/dist/utils/edit/editInputElement.d.ts +16 -0
- package/dist/utils/edit/{fireInputEvent.js → editInputElement.js} +20 -26
- package/dist/utils/edit/isContentEditable.d.ts +4 -0
- package/dist/utils/edit/isContentEditable.js +14 -0
- package/dist/utils/edit/isEditable.d.ts +1 -0
- package/dist/utils/edit/prepareInput.d.ts +7 -0
- package/dist/utils/edit/prepareInput.js +77 -0
- package/dist/utils/edit/setFiles.d.ts +12 -0
- package/dist/utils/edit/setFiles.js +72 -0
- package/dist/utils/focus/copySelection.d.ts +1 -0
- package/dist/utils/focus/copySelection.js +36 -0
- package/dist/utils/focus/focus.js +3 -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/utils/index.d.ts +11 -4
- package/dist/utils/index.js +124 -33
- package/dist/utils/misc/getDocumentFromNode.d.ts +1 -0
- package/dist/utils/misc/getDocumentFromNode.js +14 -0
- package/dist/utils/pointer/firePointerEvents.d.ts +12 -1
- package/dist/utils/pointer/firePointerEvents.js +62 -5
- package/package.json +1 -1
- package/dist/clear.js +0 -46
- package/dist/click.d.ts +0 -9
- package/dist/click.js +0 -62
- package/dist/hover.d.ts +0 -4
- package/dist/hover.js +0 -43
- package/dist/keyboard/getNextKeyDef.js +0 -85
- package/dist/keyboard/keyboardImplementation.d.ts +0 -3
- package/dist/keyboard/keyboardImplementation.js +0 -169
- package/dist/keyboard/specialCharMap.d.ts +0 -22
- package/dist/keyboard/specialCharMap.js +0 -30
- package/dist/paste.d.ts +0 -7
- package/dist/paste.js +0 -67
- package/dist/selectOptions.d.ts +0 -4
- 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/utils/edit/cursorPosition.d.ts +0 -2
- package/dist/utils/edit/cursorPosition.js +0 -35
- package/dist/utils/edit/fireInputEvent.d.ts +0 -8
- package/dist/utils/edit/selectionRange.d.ts +0 -5
- package/dist/utils/edit/selectionRange.js +0 -64
- package/dist/utils/pointer/fakeEvent.d.ts +0 -20
- package/dist/utils/pointer/fakeEvent.js +0 -91
|
@@ -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
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
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';
|
|
16
|
+
export * from './edit/setFiles';
|
|
13
17
|
export * from './focus/blur';
|
|
18
|
+
export * from './focus/copySelection';
|
|
14
19
|
export * from './focus/focus';
|
|
15
20
|
export * from './focus/getActiveElement';
|
|
16
21
|
export * from './focus/getTabDestination';
|
|
17
22
|
export * from './focus/isFocusable';
|
|
23
|
+
export * from './focus/selectAll';
|
|
24
|
+
export * from './focus/selection';
|
|
18
25
|
export * from './focus/selector';
|
|
19
26
|
export * from './keyDef/readNextDescriptor';
|
|
20
27
|
export * from './misc/eventWrapper';
|
|
21
28
|
export * from './misc/findClosest';
|
|
29
|
+
export * from './misc/getDocumentFromNode';
|
|
22
30
|
export * from './misc/isDescendantOrSelf';
|
|
23
31
|
export * from './misc/isElementType';
|
|
24
32
|
export * from './misc/isVisible';
|
|
@@ -26,6 +34,5 @@ export * from './misc/isDisabled';
|
|
|
26
34
|
export * from './misc/wait';
|
|
27
35
|
export * from './misc/hasPointerEvents';
|
|
28
36
|
export * from './misc/hasFormSubmit';
|
|
29
|
-
export * from './pointer/fakeEvent';
|
|
30
37
|
export * from './pointer/firePointerEvents';
|
|
31
38
|
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
42
|
}
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
var
|
|
46
|
+
var _FileList = require("./dataTransfer/FileList");
|
|
47
47
|
|
|
48
|
-
Object.keys(
|
|
48
|
+
Object.keys(_FileList).forEach(function (key) {
|
|
49
49
|
if (key === "default" || key === "__esModule") return;
|
|
50
|
-
if (key in exports && exports[key] ===
|
|
50
|
+
if (key in exports && exports[key] === _FileList[key]) return;
|
|
51
51
|
Object.defineProperty(exports, key, {
|
|
52
52
|
enumerable: true,
|
|
53
53
|
get: function () {
|
|
54
|
-
return
|
|
54
|
+
return _FileList[key];
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
var
|
|
59
|
+
var _Clipboard = require("./dataTransfer/Clipboard");
|
|
60
60
|
|
|
61
|
-
Object.keys(
|
|
61
|
+
Object.keys(_Clipboard).forEach(function (key) {
|
|
62
62
|
if (key === "default" || key === "__esModule") return;
|
|
63
|
-
if (key in exports && exports[key] ===
|
|
63
|
+
if (key in exports && exports[key] === _Clipboard[key]) return;
|
|
64
64
|
Object.defineProperty(exports, key, {
|
|
65
65
|
enumerable: true,
|
|
66
66
|
get: function () {
|
|
67
|
-
return
|
|
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];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
var _calculateNewValue = require("./edit/calculateNewValue");
|
|
86
|
+
|
|
87
|
+
Object.keys(_calculateNewValue).forEach(function (key) {
|
|
88
|
+
if (key === "default" || key === "__esModule") return;
|
|
89
|
+
if (key in exports && exports[key] === _calculateNewValue[key]) return;
|
|
90
|
+
Object.defineProperty(exports, key, {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function () {
|
|
93
|
+
return _calculateNewValue[key];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
var _editInputElement = require("./edit/editInputElement");
|
|
99
|
+
|
|
100
|
+
Object.keys(_editInputElement).forEach(function (key) {
|
|
101
|
+
if (key === "default" || key === "__esModule") return;
|
|
102
|
+
if (key in exports && exports[key] === _editInputElement[key]) return;
|
|
103
|
+
Object.defineProperty(exports, key, {
|
|
104
|
+
enumerable: true,
|
|
105
|
+
get: function () {
|
|
106
|
+
return _editInputElement[key];
|
|
68
107
|
}
|
|
69
108
|
});
|
|
70
109
|
});
|
|
@@ -147,15 +186,28 @@ 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];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
var _setFiles = require("./edit/setFiles");
|
|
203
|
+
|
|
204
|
+
Object.keys(_setFiles).forEach(function (key) {
|
|
205
|
+
if (key === "default" || key === "__esModule") return;
|
|
206
|
+
if (key in exports && exports[key] === _setFiles[key]) return;
|
|
207
|
+
Object.defineProperty(exports, key, {
|
|
208
|
+
enumerable: true,
|
|
209
|
+
get: function () {
|
|
210
|
+
return _setFiles[key];
|
|
159
211
|
}
|
|
160
212
|
});
|
|
161
213
|
});
|
|
@@ -173,6 +225,19 @@ Object.keys(_blur).forEach(function (key) {
|
|
|
173
225
|
});
|
|
174
226
|
});
|
|
175
227
|
|
|
228
|
+
var _copySelection = require("./focus/copySelection");
|
|
229
|
+
|
|
230
|
+
Object.keys(_copySelection).forEach(function (key) {
|
|
231
|
+
if (key === "default" || key === "__esModule") return;
|
|
232
|
+
if (key in exports && exports[key] === _copySelection[key]) return;
|
|
233
|
+
Object.defineProperty(exports, key, {
|
|
234
|
+
enumerable: true,
|
|
235
|
+
get: function () {
|
|
236
|
+
return _copySelection[key];
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
176
241
|
var _focus = require("./focus/focus");
|
|
177
242
|
|
|
178
243
|
Object.keys(_focus).forEach(function (key) {
|
|
@@ -225,6 +290,32 @@ Object.keys(_isFocusable).forEach(function (key) {
|
|
|
225
290
|
});
|
|
226
291
|
});
|
|
227
292
|
|
|
293
|
+
var _selectAll = require("./focus/selectAll");
|
|
294
|
+
|
|
295
|
+
Object.keys(_selectAll).forEach(function (key) {
|
|
296
|
+
if (key === "default" || key === "__esModule") return;
|
|
297
|
+
if (key in exports && exports[key] === _selectAll[key]) return;
|
|
298
|
+
Object.defineProperty(exports, key, {
|
|
299
|
+
enumerable: true,
|
|
300
|
+
get: function () {
|
|
301
|
+
return _selectAll[key];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
var _selection = require("./focus/selection");
|
|
307
|
+
|
|
308
|
+
Object.keys(_selection).forEach(function (key) {
|
|
309
|
+
if (key === "default" || key === "__esModule") return;
|
|
310
|
+
if (key in exports && exports[key] === _selection[key]) return;
|
|
311
|
+
Object.defineProperty(exports, key, {
|
|
312
|
+
enumerable: true,
|
|
313
|
+
get: function () {
|
|
314
|
+
return _selection[key];
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
228
319
|
var _selector = require("./focus/selector");
|
|
229
320
|
|
|
230
321
|
Object.keys(_selector).forEach(function (key) {
|
|
@@ -277,6 +368,19 @@ Object.keys(_findClosest).forEach(function (key) {
|
|
|
277
368
|
});
|
|
278
369
|
});
|
|
279
370
|
|
|
371
|
+
var _getDocumentFromNode = require("./misc/getDocumentFromNode");
|
|
372
|
+
|
|
373
|
+
Object.keys(_getDocumentFromNode).forEach(function (key) {
|
|
374
|
+
if (key === "default" || key === "__esModule") return;
|
|
375
|
+
if (key in exports && exports[key] === _getDocumentFromNode[key]) return;
|
|
376
|
+
Object.defineProperty(exports, key, {
|
|
377
|
+
enumerable: true,
|
|
378
|
+
get: function () {
|
|
379
|
+
return _getDocumentFromNode[key];
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
280
384
|
var _isDescendantOrSelf = require("./misc/isDescendantOrSelf");
|
|
281
385
|
|
|
282
386
|
Object.keys(_isDescendantOrSelf).forEach(function (key) {
|
|
@@ -368,19 +472,6 @@ Object.keys(_hasFormSubmit).forEach(function (key) {
|
|
|
368
472
|
});
|
|
369
473
|
});
|
|
370
474
|
|
|
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
475
|
var _firePointerEvents = require("./pointer/firePointerEvents");
|
|
385
476
|
|
|
386
477
|
Object.keys(_firePointerEvents).forEach(function (key) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDocumentFromNode(el: Node): Document | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDocumentFromNode = getDocumentFromNode;
|
|
7
|
+
|
|
8
|
+
function getDocumentFromNode(el) {
|
|
9
|
+
return isDocument(el) ? el : el.ownerDocument;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function isDocument(node) {
|
|
13
|
+
return node.nodeType === 9;
|
|
14
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { pointerState } from '../../pointer/types';
|
|
2
2
|
import type { keyboardState } from '../../keyboard/types';
|
|
3
|
-
import { PointerCoords } from './fakeEvent';
|
|
4
3
|
import { MouseButton } from './mouseButtons';
|
|
5
4
|
export declare function firePointerEvent(target: Element, type: string, { pointerState, keyboardState, pointerType, button, coords, pointerId, isPrimary, clickCount, }: {
|
|
6
5
|
pointerState: pointerState;
|
|
@@ -12,3 +11,15 @@ export declare function firePointerEvent(target: Element, type: string, { pointe
|
|
|
12
11
|
isPrimary?: boolean;
|
|
13
12
|
clickCount?: number;
|
|
14
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
|
}
|
package/package.json
CHANGED
package/dist/clear.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.clear = clear;
|
|
7
|
-
|
|
8
|
-
var _utils = require("./utils");
|
|
9
|
-
|
|
10
|
-
function clear(element) {
|
|
11
|
-
var _element$selectionSta, _element$selectionEnd;
|
|
12
|
-
|
|
13
|
-
if (!(0, _utils.isElementType)(element, ['input', 'textarea'])) {
|
|
14
|
-
// TODO: support contenteditable
|
|
15
|
-
throw new Error('clear currently only supports input and textarea elements.');
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if ((0, _utils.isDisabled)(element)) {
|
|
19
|
-
return;
|
|
20
|
-
} // TODO: track the selection range ourselves so we don't have to do this input "type" trickery
|
|
21
|
-
// just like cypress does: https://github.com/cypress-io/cypress/blob/8d7f1a0bedc3c45a2ebf1ff50324b34129fdc683/packages/driver/src/dom/selection.ts#L16-L37
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const elementType = element.type;
|
|
25
|
-
|
|
26
|
-
if (elementType !== 'textarea') {
|
|
27
|
-
// setSelectionRange is not supported on certain types of inputs, e.g. "number" or "email"
|
|
28
|
-
;
|
|
29
|
-
element.type = 'text';
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
this.type(element, '{selectall}{del}', {
|
|
33
|
-
delay: 0,
|
|
34
|
-
initialSelectionStart: (_element$selectionSta = element.selectionStart) != null ? _element$selectionSta :
|
|
35
|
-
/* istanbul ignore next */
|
|
36
|
-
undefined,
|
|
37
|
-
initialSelectionEnd: (_element$selectionEnd = element.selectionEnd) != null ? _element$selectionEnd :
|
|
38
|
-
/* istanbul ignore next */
|
|
39
|
-
undefined
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
if (elementType !== 'textarea') {
|
|
43
|
-
;
|
|
44
|
-
element.type = elementType;
|
|
45
|
-
}
|
|
46
|
-
}
|
package/dist/click.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { PointerOptions } from './utils';
|
|
2
|
-
import type { UserEvent } from './setup';
|
|
3
|
-
export declare interface clickOptions {
|
|
4
|
-
skipHover?: boolean;
|
|
5
|
-
clickCount?: number;
|
|
6
|
-
}
|
|
7
|
-
export declare function click(this: UserEvent, element: Element, init?: MouseEventInit, { skipHover, skipPointerEventsCheck, }?: clickOptions & PointerOptions): void;
|
|
8
|
-
export declare function dblClick(this: UserEvent, element: Element, init?: MouseEventInit, { skipPointerEventsCheck }?: clickOptions & PointerOptions): void;
|
|
9
|
-
export declare function tripleClick(this: UserEvent, element: Element, init?: MouseEventInit, { skipPointerEventsCheck }?: clickOptions & PointerOptions): void;
|