@testing-library/user-event 13.4.2 → 14.0.0-alpha.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/clear.d.ts +2 -2
- package/dist/clear.js +14 -29
- package/dist/click.d.ts +4 -3
- package/dist/click.js +29 -143
- package/dist/document/index.d.ts +10 -0
- package/dist/document/index.js +100 -0
- package/dist/document/interceptor.d.ts +15 -0
- package/dist/document/interceptor.js +37 -0
- package/dist/document/selection.d.ts +27 -0
- package/dist/document/selection.js +90 -0
- package/dist/document/value.d.ts +18 -0
- package/dist/document/value.js +77 -0
- package/dist/hover.d.ts +3 -3
- package/dist/hover.js +15 -57
- package/dist/index.d.ts +3 -22
- package/dist/index.js +3 -36
- package/dist/keyboard/getEventProps.d.ts +0 -2
- package/dist/keyboard/getEventProps.js +1 -7
- package/dist/keyboard/getNextKeyDef.d.ts +3 -0
- package/dist/keyboard/getNextKeyDef.js +59 -87
- package/dist/keyboard/index.d.ts +1 -1
- package/dist/keyboard/index.js +4 -8
- package/dist/keyboard/keyMap.js +26 -46
- package/dist/keyboard/keyboardImplementation.js +35 -19
- package/dist/keyboard/plugins/arrow.js +7 -12
- package/dist/keyboard/plugins/character.js +29 -57
- package/dist/keyboard/plugins/combination.d.ts +5 -0
- package/dist/keyboard/plugins/combination.js +17 -0
- package/dist/keyboard/plugins/control.js +5 -16
- package/dist/keyboard/plugins/functional.js +23 -14
- package/dist/keyboard/plugins/index.d.ts +0 -1
- package/dist/keyboard/plugins/index.js +4 -13
- package/dist/keyboard/shared/index.d.ts +0 -2
- package/dist/keyboard/shared/index.js +0 -26
- package/dist/keyboard/types.d.ts +8 -2
- package/dist/paste.d.ts +3 -2
- package/dist/paste.js +8 -15
- package/dist/pointer/index.d.ts +18 -0
- package/dist/pointer/index.js +90 -0
- package/dist/pointer/keyMap.d.ts +2 -0
- package/dist/pointer/keyMap.js +29 -0
- package/dist/pointer/parseKeyDef.d.ts +6 -0
- package/dist/pointer/parseKeyDef.js +36 -0
- package/dist/pointer/pointerAction.d.ts +6 -0
- package/dist/pointer/pointerAction.js +52 -0
- package/dist/pointer/pointerMove.d.ts +5 -0
- package/dist/pointer/pointerMove.js +136 -0
- package/dist/pointer/pointerPress.d.ts +7 -0
- package/dist/pointer/pointerPress.js +330 -0
- package/dist/pointer/resolveSelectionTarget.d.ts +5 -0
- package/dist/pointer/resolveSelectionTarget.js +75 -0
- package/dist/pointer/types.d.ts +72 -0
- package/dist/pointer/types.js +1 -0
- package/dist/selectOptions.d.ts +4 -0
- package/dist/{select-options.js → selectOptions.js} +18 -20
- package/dist/setup.d.ts +92 -0
- package/dist/setup.js +203 -0
- package/dist/tab.d.ts +3 -4
- package/dist/tab.js +3 -136
- package/dist/type.d.ts +14 -0
- package/dist/type.js +74 -0
- package/dist/upload.d.ts +4 -3
- package/dist/upload.js +3 -9
- package/dist/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/editInputElement.js +53 -0
- package/dist/utils/edit/getValue.d.ts +1 -1
- package/dist/utils/edit/getValue.js +3 -1
- 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/{blur.d.ts → utils/focus/blur.d.ts} +0 -0
- package/dist/utils/focus/blur.js +19 -0
- package/dist/{focus.d.ts → utils/focus/focus.d.ts} +0 -0
- package/dist/utils/focus/focus.js +22 -0
- package/dist/utils/focus/getTabDestination.d.ts +1 -0
- package/dist/utils/focus/getTabDestination.js +71 -0
- package/dist/utils/focus/isFocusable.js +1 -3
- 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 +12 -6
- package/dist/utils/index.js +132 -54
- package/dist/utils/keyDef/readNextDescriptor.d.ts +19 -0
- package/dist/utils/keyDef/readNextDescriptor.js +102 -0
- package/dist/utils/misc/findClosest.d.ts +1 -0
- package/dist/utils/misc/findClosest.js +20 -0
- package/dist/utils/misc/isDescendantOrSelf.d.ts +1 -0
- package/dist/utils/misc/isDescendantOrSelf.js +20 -0
- package/dist/utils/pointer/firePointerEvents.d.ts +25 -0
- package/dist/utils/pointer/firePointerEvents.js +112 -0
- package/dist/utils/pointer/mouseButtons.d.ts +12 -0
- package/dist/utils/pointer/mouseButtons.js +45 -0
- package/package.json +4 -3
- package/dist/blur.js +0 -15
- package/dist/dom-helpers.d.ts +0 -3
- package/dist/focus.js +0 -15
- package/dist/keyboard/shared/carryValue.d.ts +0 -2
- package/dist/keyboard/shared/carryValue.js +0 -13
- package/dist/keyboard/shared/fireInputEvent.d.ts +0 -17
- package/dist/keyboard/shared/fireInputEvent.js +0 -110
- package/dist/keyboard/specialCharMap.d.ts +0 -22
- package/dist/keyboard/specialCharMap.js +0 -30
- package/dist/select-options.d.ts +0 -4
- package/dist/type/index.d.ts +0 -7
- package/dist/type/index.js +0 -33
- package/dist/type/typeImplementation.d.ts +0 -10
- package/dist/type/typeImplementation.js +0 -64
- package/dist/utils/click/getMouseEventOptions.d.ts +0 -31
- package/dist/utils/click/getMouseEventOptions.js +0 -61
- package/dist/utils/edit/cursorPosition.d.ts +0 -2
- package/dist/utils/edit/cursorPosition.js +0 -35
- package/dist/utils/edit/hasUnreliableEmptyValue.d.ts +0 -10
- package/dist/utils/edit/hasUnreliableEmptyValue.js +0 -21
- package/dist/utils/edit/selectionRange.d.ts +0 -16
- package/dist/utils/edit/selectionRange.js +0 -104
- package/dist/utils/misc/isDocument.d.ts +0 -1
- package/dist/utils/misc/isDocument.js +0 -10
- package/dist/utils/misc/isLabelWithInternallyDisabledControl.d.ts +0 -1
- package/dist/utils/misc/isLabelWithInternallyDisabledControl.js +0 -22
|
@@ -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,25 +1,31 @@
|
|
|
1
|
-
export * from './click/getMouseEventOptions';
|
|
2
1
|
export * from './click/isClickableInput';
|
|
3
2
|
export * from './edit/buildTimeValue';
|
|
4
3
|
export * from './edit/calculateNewValue';
|
|
5
|
-
export * from './edit/
|
|
4
|
+
export * from './edit/editInputElement';
|
|
6
5
|
export * from './edit/getValue';
|
|
7
|
-
export * from './edit/hasUnreliableEmptyValue';
|
|
8
6
|
export * from './edit/isContentEditable';
|
|
9
7
|
export * from './edit/isEditable';
|
|
10
8
|
export * from './edit/isValidDateValue';
|
|
11
9
|
export * from './edit/isValidInputTimeValue';
|
|
12
10
|
export * from './edit/maxLength';
|
|
13
|
-
export * from './edit/
|
|
11
|
+
export * from './edit/prepareInput';
|
|
12
|
+
export * from './focus/blur';
|
|
13
|
+
export * from './focus/focus';
|
|
14
14
|
export * from './focus/getActiveElement';
|
|
15
|
+
export * from './focus/getTabDestination';
|
|
15
16
|
export * from './focus/isFocusable';
|
|
17
|
+
export * from './focus/selectAll';
|
|
18
|
+
export * from './focus/selection';
|
|
16
19
|
export * from './focus/selector';
|
|
20
|
+
export * from './keyDef/readNextDescriptor';
|
|
17
21
|
export * from './misc/eventWrapper';
|
|
22
|
+
export * from './misc/findClosest';
|
|
23
|
+
export * from './misc/isDescendantOrSelf';
|
|
18
24
|
export * from './misc/isElementType';
|
|
19
|
-
export * from './misc/isLabelWithInternallyDisabledControl';
|
|
20
25
|
export * from './misc/isVisible';
|
|
21
26
|
export * from './misc/isDisabled';
|
|
22
|
-
export * from './misc/isDocument';
|
|
23
27
|
export * from './misc/wait';
|
|
24
28
|
export * from './misc/hasPointerEvents';
|
|
25
29
|
export * from './misc/hasFormSubmit';
|
|
30
|
+
export * from './pointer/firePointerEvents';
|
|
31
|
+
export * from './pointer/mouseButtons';
|
package/dist/utils/index.js
CHANGED
|
@@ -4,19 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _getMouseEventOptions = require("./click/getMouseEventOptions");
|
|
8
|
-
|
|
9
|
-
Object.keys(_getMouseEventOptions).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _getMouseEventOptions[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _getMouseEventOptions[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
7
|
var _isClickableInput = require("./click/isClickableInput");
|
|
21
8
|
|
|
22
9
|
Object.keys(_isClickableInput).forEach(function (key) {
|
|
@@ -56,15 +43,15 @@ Object.keys(_calculateNewValue).forEach(function (key) {
|
|
|
56
43
|
});
|
|
57
44
|
});
|
|
58
45
|
|
|
59
|
-
var
|
|
46
|
+
var _editInputElement = require("./edit/editInputElement");
|
|
60
47
|
|
|
61
|
-
Object.keys(
|
|
48
|
+
Object.keys(_editInputElement).forEach(function (key) {
|
|
62
49
|
if (key === "default" || key === "__esModule") return;
|
|
63
|
-
if (key in exports && exports[key] ===
|
|
50
|
+
if (key in exports && exports[key] === _editInputElement[key]) return;
|
|
64
51
|
Object.defineProperty(exports, key, {
|
|
65
52
|
enumerable: true,
|
|
66
53
|
get: function () {
|
|
67
|
-
return
|
|
54
|
+
return _editInputElement[key];
|
|
68
55
|
}
|
|
69
56
|
});
|
|
70
57
|
});
|
|
@@ -82,19 +69,6 @@ Object.keys(_getValue).forEach(function (key) {
|
|
|
82
69
|
});
|
|
83
70
|
});
|
|
84
71
|
|
|
85
|
-
var _hasUnreliableEmptyValue = require("./edit/hasUnreliableEmptyValue");
|
|
86
|
-
|
|
87
|
-
Object.keys(_hasUnreliableEmptyValue).forEach(function (key) {
|
|
88
|
-
if (key === "default" || key === "__esModule") return;
|
|
89
|
-
if (key in exports && exports[key] === _hasUnreliableEmptyValue[key]) return;
|
|
90
|
-
Object.defineProperty(exports, key, {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
get: function () {
|
|
93
|
-
return _hasUnreliableEmptyValue[key];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
72
|
var _isContentEditable = require("./edit/isContentEditable");
|
|
99
73
|
|
|
100
74
|
Object.keys(_isContentEditable).forEach(function (key) {
|
|
@@ -160,15 +134,41 @@ Object.keys(_maxLength).forEach(function (key) {
|
|
|
160
134
|
});
|
|
161
135
|
});
|
|
162
136
|
|
|
163
|
-
var
|
|
137
|
+
var _prepareInput = require("./edit/prepareInput");
|
|
138
|
+
|
|
139
|
+
Object.keys(_prepareInput).forEach(function (key) {
|
|
140
|
+
if (key === "default" || key === "__esModule") return;
|
|
141
|
+
if (key in exports && exports[key] === _prepareInput[key]) return;
|
|
142
|
+
Object.defineProperty(exports, key, {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function () {
|
|
145
|
+
return _prepareInput[key];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
var _blur = require("./focus/blur");
|
|
164
151
|
|
|
165
|
-
Object.keys(
|
|
152
|
+
Object.keys(_blur).forEach(function (key) {
|
|
166
153
|
if (key === "default" || key === "__esModule") return;
|
|
167
|
-
if (key in exports && exports[key] ===
|
|
154
|
+
if (key in exports && exports[key] === _blur[key]) return;
|
|
168
155
|
Object.defineProperty(exports, key, {
|
|
169
156
|
enumerable: true,
|
|
170
157
|
get: function () {
|
|
171
|
-
return
|
|
158
|
+
return _blur[key];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
var _focus = require("./focus/focus");
|
|
164
|
+
|
|
165
|
+
Object.keys(_focus).forEach(function (key) {
|
|
166
|
+
if (key === "default" || key === "__esModule") return;
|
|
167
|
+
if (key in exports && exports[key] === _focus[key]) return;
|
|
168
|
+
Object.defineProperty(exports, key, {
|
|
169
|
+
enumerable: true,
|
|
170
|
+
get: function () {
|
|
171
|
+
return _focus[key];
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
});
|
|
@@ -186,6 +186,19 @@ Object.keys(_getActiveElement).forEach(function (key) {
|
|
|
186
186
|
});
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
+
var _getTabDestination = require("./focus/getTabDestination");
|
|
190
|
+
|
|
191
|
+
Object.keys(_getTabDestination).forEach(function (key) {
|
|
192
|
+
if (key === "default" || key === "__esModule") return;
|
|
193
|
+
if (key in exports && exports[key] === _getTabDestination[key]) return;
|
|
194
|
+
Object.defineProperty(exports, key, {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function () {
|
|
197
|
+
return _getTabDestination[key];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
189
202
|
var _isFocusable = require("./focus/isFocusable");
|
|
190
203
|
|
|
191
204
|
Object.keys(_isFocusable).forEach(function (key) {
|
|
@@ -199,6 +212,32 @@ Object.keys(_isFocusable).forEach(function (key) {
|
|
|
199
212
|
});
|
|
200
213
|
});
|
|
201
214
|
|
|
215
|
+
var _selectAll = require("./focus/selectAll");
|
|
216
|
+
|
|
217
|
+
Object.keys(_selectAll).forEach(function (key) {
|
|
218
|
+
if (key === "default" || key === "__esModule") return;
|
|
219
|
+
if (key in exports && exports[key] === _selectAll[key]) return;
|
|
220
|
+
Object.defineProperty(exports, key, {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function () {
|
|
223
|
+
return _selectAll[key];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
var _selection = require("./focus/selection");
|
|
229
|
+
|
|
230
|
+
Object.keys(_selection).forEach(function (key) {
|
|
231
|
+
if (key === "default" || key === "__esModule") return;
|
|
232
|
+
if (key in exports && exports[key] === _selection[key]) return;
|
|
233
|
+
Object.defineProperty(exports, key, {
|
|
234
|
+
enumerable: true,
|
|
235
|
+
get: function () {
|
|
236
|
+
return _selection[key];
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
202
241
|
var _selector = require("./focus/selector");
|
|
203
242
|
|
|
204
243
|
Object.keys(_selector).forEach(function (key) {
|
|
@@ -212,6 +251,19 @@ Object.keys(_selector).forEach(function (key) {
|
|
|
212
251
|
});
|
|
213
252
|
});
|
|
214
253
|
|
|
254
|
+
var _readNextDescriptor = require("./keyDef/readNextDescriptor");
|
|
255
|
+
|
|
256
|
+
Object.keys(_readNextDescriptor).forEach(function (key) {
|
|
257
|
+
if (key === "default" || key === "__esModule") return;
|
|
258
|
+
if (key in exports && exports[key] === _readNextDescriptor[key]) return;
|
|
259
|
+
Object.defineProperty(exports, key, {
|
|
260
|
+
enumerable: true,
|
|
261
|
+
get: function () {
|
|
262
|
+
return _readNextDescriptor[key];
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
215
267
|
var _eventWrapper = require("./misc/eventWrapper");
|
|
216
268
|
|
|
217
269
|
Object.keys(_eventWrapper).forEach(function (key) {
|
|
@@ -225,67 +277,67 @@ Object.keys(_eventWrapper).forEach(function (key) {
|
|
|
225
277
|
});
|
|
226
278
|
});
|
|
227
279
|
|
|
228
|
-
var
|
|
280
|
+
var _findClosest = require("./misc/findClosest");
|
|
229
281
|
|
|
230
|
-
Object.keys(
|
|
282
|
+
Object.keys(_findClosest).forEach(function (key) {
|
|
231
283
|
if (key === "default" || key === "__esModule") return;
|
|
232
|
-
if (key in exports && exports[key] ===
|
|
284
|
+
if (key in exports && exports[key] === _findClosest[key]) return;
|
|
233
285
|
Object.defineProperty(exports, key, {
|
|
234
286
|
enumerable: true,
|
|
235
287
|
get: function () {
|
|
236
|
-
return
|
|
288
|
+
return _findClosest[key];
|
|
237
289
|
}
|
|
238
290
|
});
|
|
239
291
|
});
|
|
240
292
|
|
|
241
|
-
var
|
|
293
|
+
var _isDescendantOrSelf = require("./misc/isDescendantOrSelf");
|
|
242
294
|
|
|
243
|
-
Object.keys(
|
|
295
|
+
Object.keys(_isDescendantOrSelf).forEach(function (key) {
|
|
244
296
|
if (key === "default" || key === "__esModule") return;
|
|
245
|
-
if (key in exports && exports[key] ===
|
|
297
|
+
if (key in exports && exports[key] === _isDescendantOrSelf[key]) return;
|
|
246
298
|
Object.defineProperty(exports, key, {
|
|
247
299
|
enumerable: true,
|
|
248
300
|
get: function () {
|
|
249
|
-
return
|
|
301
|
+
return _isDescendantOrSelf[key];
|
|
250
302
|
}
|
|
251
303
|
});
|
|
252
304
|
});
|
|
253
305
|
|
|
254
|
-
var
|
|
306
|
+
var _isElementType = require("./misc/isElementType");
|
|
255
307
|
|
|
256
|
-
Object.keys(
|
|
308
|
+
Object.keys(_isElementType).forEach(function (key) {
|
|
257
309
|
if (key === "default" || key === "__esModule") return;
|
|
258
|
-
if (key in exports && exports[key] ===
|
|
310
|
+
if (key in exports && exports[key] === _isElementType[key]) return;
|
|
259
311
|
Object.defineProperty(exports, key, {
|
|
260
312
|
enumerable: true,
|
|
261
313
|
get: function () {
|
|
262
|
-
return
|
|
314
|
+
return _isElementType[key];
|
|
263
315
|
}
|
|
264
316
|
});
|
|
265
317
|
});
|
|
266
318
|
|
|
267
|
-
var
|
|
319
|
+
var _isVisible = require("./misc/isVisible");
|
|
268
320
|
|
|
269
|
-
Object.keys(
|
|
321
|
+
Object.keys(_isVisible).forEach(function (key) {
|
|
270
322
|
if (key === "default" || key === "__esModule") return;
|
|
271
|
-
if (key in exports && exports[key] ===
|
|
323
|
+
if (key in exports && exports[key] === _isVisible[key]) return;
|
|
272
324
|
Object.defineProperty(exports, key, {
|
|
273
325
|
enumerable: true,
|
|
274
326
|
get: function () {
|
|
275
|
-
return
|
|
327
|
+
return _isVisible[key];
|
|
276
328
|
}
|
|
277
329
|
});
|
|
278
330
|
});
|
|
279
331
|
|
|
280
|
-
var
|
|
332
|
+
var _isDisabled = require("./misc/isDisabled");
|
|
281
333
|
|
|
282
|
-
Object.keys(
|
|
334
|
+
Object.keys(_isDisabled).forEach(function (key) {
|
|
283
335
|
if (key === "default" || key === "__esModule") return;
|
|
284
|
-
if (key in exports && exports[key] ===
|
|
336
|
+
if (key in exports && exports[key] === _isDisabled[key]) return;
|
|
285
337
|
Object.defineProperty(exports, key, {
|
|
286
338
|
enumerable: true,
|
|
287
339
|
get: function () {
|
|
288
|
-
return
|
|
340
|
+
return _isDisabled[key];
|
|
289
341
|
}
|
|
290
342
|
});
|
|
291
343
|
});
|
|
@@ -327,4 +379,30 @@ Object.keys(_hasFormSubmit).forEach(function (key) {
|
|
|
327
379
|
return _hasFormSubmit[key];
|
|
328
380
|
}
|
|
329
381
|
});
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
var _firePointerEvents = require("./pointer/firePointerEvents");
|
|
385
|
+
|
|
386
|
+
Object.keys(_firePointerEvents).forEach(function (key) {
|
|
387
|
+
if (key === "default" || key === "__esModule") return;
|
|
388
|
+
if (key in exports && exports[key] === _firePointerEvents[key]) return;
|
|
389
|
+
Object.defineProperty(exports, key, {
|
|
390
|
+
enumerable: true,
|
|
391
|
+
get: function () {
|
|
392
|
+
return _firePointerEvents[key];
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
var _mouseButtons = require("./pointer/mouseButtons");
|
|
398
|
+
|
|
399
|
+
Object.keys(_mouseButtons).forEach(function (key) {
|
|
400
|
+
if (key === "default" || key === "__esModule") return;
|
|
401
|
+
if (key in exports && exports[key] === _mouseButtons[key]) return;
|
|
402
|
+
Object.defineProperty(exports, key, {
|
|
403
|
+
enumerable: true,
|
|
404
|
+
get: function () {
|
|
405
|
+
return _mouseButtons[key];
|
|
406
|
+
}
|
|
407
|
+
});
|
|
330
408
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the next key definition from user input
|
|
3
|
+
*
|
|
4
|
+
* Describe key per `{descriptor}` or `[descriptor]`.
|
|
5
|
+
* Everything else will be interpreted as a single character as descriptor - e.g. `a`.
|
|
6
|
+
* Brackets `{` and `[` can be escaped by doubling - e.g. `foo[[bar` translates to `foo[bar`.
|
|
7
|
+
* A previously pressed key can be released per `{/descriptor}`.
|
|
8
|
+
* Keeping the key pressed can be written as `{descriptor>}`.
|
|
9
|
+
* When keeping the key pressed you can choose how long the key is pressed `{descriptor>3}`.
|
|
10
|
+
* You can then release the key per `{descriptor>3/}` or keep it pressed and continue with the next key.
|
|
11
|
+
*/
|
|
12
|
+
export declare function readNextDescriptor(text: string): {
|
|
13
|
+
consumedLength: number;
|
|
14
|
+
descriptor: string;
|
|
15
|
+
releasePrevious: boolean;
|
|
16
|
+
repeat: number;
|
|
17
|
+
releaseSelf: boolean | undefined;
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.readNextDescriptor = readNextDescriptor;
|
|
7
|
+
var bracketDict;
|
|
8
|
+
/**
|
|
9
|
+
* Read the next key definition from user input
|
|
10
|
+
*
|
|
11
|
+
* Describe key per `{descriptor}` or `[descriptor]`.
|
|
12
|
+
* Everything else will be interpreted as a single character as descriptor - e.g. `a`.
|
|
13
|
+
* Brackets `{` and `[` can be escaped by doubling - e.g. `foo[[bar` translates to `foo[bar`.
|
|
14
|
+
* A previously pressed key can be released per `{/descriptor}`.
|
|
15
|
+
* Keeping the key pressed can be written as `{descriptor>}`.
|
|
16
|
+
* When keeping the key pressed you can choose how long the key is pressed `{descriptor>3}`.
|
|
17
|
+
* You can then release the key per `{descriptor>3/}` or keep it pressed and continue with the next key.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
(function (bracketDict) {
|
|
21
|
+
bracketDict["{"] = "}";
|
|
22
|
+
bracketDict["["] = "]";
|
|
23
|
+
})(bracketDict || (bracketDict = {}));
|
|
24
|
+
|
|
25
|
+
function readNextDescriptor(text) {
|
|
26
|
+
let pos = 0;
|
|
27
|
+
const startBracket = text[pos] in bracketDict ? text[pos] : '';
|
|
28
|
+
pos += startBracket.length; // `foo{{bar` is an escaped char at position 3,
|
|
29
|
+
// but `foo{{{>5}bar` should be treated as `{` pressed down for 5 keydowns.
|
|
30
|
+
|
|
31
|
+
const startBracketRepeated = startBracket ? text.match(new RegExp(`^\\${startBracket}+`))[0].length : 0;
|
|
32
|
+
const isEscapedChar = startBracketRepeated === 2 || startBracket === '{' && startBracketRepeated > 3;
|
|
33
|
+
const type = isEscapedChar ? '' : startBracket;
|
|
34
|
+
return {
|
|
35
|
+
type,
|
|
36
|
+
...(type === '' ? readPrintableChar(text, pos) : readTag(text, pos, type))
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function readPrintableChar(text, pos) {
|
|
41
|
+
const descriptor = text[pos];
|
|
42
|
+
assertDescriptor(descriptor, text, pos);
|
|
43
|
+
pos += descriptor.length;
|
|
44
|
+
return {
|
|
45
|
+
consumedLength: pos,
|
|
46
|
+
descriptor,
|
|
47
|
+
releasePrevious: false,
|
|
48
|
+
releaseSelf: true,
|
|
49
|
+
repeat: 1
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function readTag(text, pos, startBracket) {
|
|
54
|
+
var _text$slice$match, _text$slice$match$, _text$slice$match2;
|
|
55
|
+
|
|
56
|
+
const releasePreviousModifier = text[pos] === '/' ? '/' : '';
|
|
57
|
+
pos += releasePreviousModifier.length;
|
|
58
|
+
const descriptor = (_text$slice$match = text.slice(pos).match(/^\w+/)) == null ? void 0 : _text$slice$match[0];
|
|
59
|
+
assertDescriptor(descriptor, text, pos);
|
|
60
|
+
pos += descriptor.length;
|
|
61
|
+
const repeatModifier = (_text$slice$match$ = (_text$slice$match2 = text.slice(pos).match(/^>\d+/)) == null ? void 0 : _text$slice$match2[0]) != null ? _text$slice$match$ : '';
|
|
62
|
+
pos += repeatModifier.length;
|
|
63
|
+
const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : '';
|
|
64
|
+
pos += releaseSelfModifier.length;
|
|
65
|
+
const expectedEndBracket = bracketDict[startBracket];
|
|
66
|
+
const endBracket = text[pos] === expectedEndBracket ? expectedEndBracket : '';
|
|
67
|
+
|
|
68
|
+
if (!endBracket) {
|
|
69
|
+
throw new Error(getErrorMessage([!repeatModifier && 'repeat modifier', !releaseSelfModifier && 'release modifier', `"${expectedEndBracket}"`].filter(Boolean).join(' or '), text[pos], text));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
pos += endBracket.length;
|
|
73
|
+
return {
|
|
74
|
+
consumedLength: pos,
|
|
75
|
+
descriptor,
|
|
76
|
+
releasePrevious: !!releasePreviousModifier,
|
|
77
|
+
repeat: repeatModifier ? Math.max(Number(repeatModifier.substr(1)), 1) : 1,
|
|
78
|
+
releaseSelf: hasReleaseSelf(releaseSelfModifier, repeatModifier)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function assertDescriptor(descriptor, text, pos) {
|
|
83
|
+
if (!descriptor) {
|
|
84
|
+
throw new Error(getErrorMessage('key descriptor', text[pos], text));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function hasReleaseSelf(releaseSelfModifier, repeatModifier) {
|
|
89
|
+
if (releaseSelfModifier) {
|
|
90
|
+
return releaseSelfModifier === '/';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (repeatModifier) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getErrorMessage(expected, found, text) {
|
|
99
|
+
return `Expected ${expected} but found "${found != null ? found : ''}" in "${text}"
|
|
100
|
+
See https://github.com/testing-library/user-event/blob/main/README.md#keyboardtext-options
|
|
101
|
+
for more information about how userEvent parses your input.`;
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findClosest(element: Element, callback: (e: Element) => boolean): Element | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findClosest = findClosest;
|
|
7
|
+
|
|
8
|
+
function findClosest(element, callback) {
|
|
9
|
+
let el = element;
|
|
10
|
+
|
|
11
|
+
do {
|
|
12
|
+
if (callback(el)) {
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
el = el.parentElement;
|
|
17
|
+
} while (el && el !== element.ownerDocument.body);
|
|
18
|
+
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDescendantOrSelf(potentialDescendant: Element, potentialAncestor: Element): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isDescendantOrSelf = isDescendantOrSelf;
|
|
7
|
+
|
|
8
|
+
function isDescendantOrSelf(potentialDescendant, potentialAncestor) {
|
|
9
|
+
let el = potentialDescendant;
|
|
10
|
+
|
|
11
|
+
do {
|
|
12
|
+
if (el === potentialAncestor) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
el = el.parentElement;
|
|
17
|
+
} while (el);
|
|
18
|
+
|
|
19
|
+
return false;
|
|
20
|
+
}
|