@testing-library/user-event 14.0.0-alpha.11 → 14.0.0-alpha.15
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/index.d.ts +2 -5
- package/dist/index.js +7 -8
- package/dist/keyboard/getNextKeyDef.d.ts +2 -3
- package/dist/keyboard/getNextKeyDef.js +6 -36
- package/dist/keyboard/index.d.ts +6 -17
- package/dist/keyboard/index.js +9 -43
- package/dist/keyboard/keyboardImplementation.d.ts +3 -3
- package/dist/keyboard/keyboardImplementation.js +47 -44
- package/dist/keyboard/plugins/character.js +16 -10
- package/dist/keyboard/plugins/combination.js +3 -1
- package/dist/keyboard/plugins/functional.js +38 -20
- package/dist/keyboard/types.d.ts +3 -12
- 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/pointerPress.d.ts +2 -1
- 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 +21 -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/{clear.js → utility/clear.js} +2 -5
- 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} +6 -6
- 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 +13 -0
- package/dist/utils/focus/copySelection.d.ts +1 -0
- package/dist/utils/focus/copySelection.js +36 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.js +78 -0
- package/dist/utils/misc/getDocumentFromNode.d.ts +1 -0
- package/dist/utils/misc/getDocumentFromNode.js +14 -0
- package/package.json +1 -1
- 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/paste.d.ts +0 -7
- package/dist/paste.js +0 -60
- 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
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFileList = createFileList;
|
|
7
|
+
|
|
8
|
+
// FileList can not be created per constructor.
|
|
9
|
+
function createFileList(files) {
|
|
10
|
+
const f = [...files];
|
|
11
|
+
Object.setPrototypeOf(f, FileList.prototype);
|
|
12
|
+
return f;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copySelection(target: Element): DataTransfer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.copySelection = copySelection;
|
|
7
|
+
|
|
8
|
+
var _document = require("../../document");
|
|
9
|
+
|
|
10
|
+
var _DataTransfer = require("../dataTransfer/DataTransfer");
|
|
11
|
+
|
|
12
|
+
var _selection = require("./selection");
|
|
13
|
+
|
|
14
|
+
function copySelection(target) {
|
|
15
|
+
const data = (0, _selection.hasOwnSelection)(target) ? {
|
|
16
|
+
'text/plain': readSelectedValueFromInput(target)
|
|
17
|
+
} : // TODO: We could implement text/html copying of DOM nodes here
|
|
18
|
+
{
|
|
19
|
+
'text/plain': String(target.ownerDocument.getSelection())
|
|
20
|
+
};
|
|
21
|
+
const dt = (0, _DataTransfer.createDataTransfer)();
|
|
22
|
+
|
|
23
|
+
for (const type in data) {
|
|
24
|
+
if (data[type]) {
|
|
25
|
+
dt.setData(type, data[type]);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return dt;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function readSelectedValueFromInput(target) {
|
|
33
|
+
const sel = (0, _document.getUISelection)(target);
|
|
34
|
+
const val = (0, _document.getUIValue)(target);
|
|
35
|
+
return val.substring(sel.startOffset, sel.endOffset);
|
|
36
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
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
8
|
export * from './edit/editInputElement';
|
|
@@ -10,6 +14,7 @@ export * from './edit/isValidInputTimeValue';
|
|
|
10
14
|
export * from './edit/maxLength';
|
|
11
15
|
export * from './edit/prepareInput';
|
|
12
16
|
export * from './focus/blur';
|
|
17
|
+
export * from './focus/copySelection';
|
|
13
18
|
export * from './focus/focus';
|
|
14
19
|
export * from './focus/getActiveElement';
|
|
15
20
|
export * from './focus/getTabDestination';
|
|
@@ -20,6 +25,7 @@ export * from './focus/selector';
|
|
|
20
25
|
export * from './keyDef/readNextDescriptor';
|
|
21
26
|
export * from './misc/eventWrapper';
|
|
22
27
|
export * from './misc/findClosest';
|
|
28
|
+
export * from './misc/getDocumentFromNode';
|
|
23
29
|
export * from './misc/isDescendantOrSelf';
|
|
24
30
|
export * from './misc/isElementType';
|
|
25
31
|
export * from './misc/isVisible';
|
package/dist/utils/index.js
CHANGED
|
@@ -17,6 +17,58 @@ Object.keys(_isClickableInput).forEach(function (key) {
|
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
var _Blob = require("./dataTransfer/Blob");
|
|
21
|
+
|
|
22
|
+
Object.keys(_Blob).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _Blob[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _Blob[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _DataTransfer = require("./dataTransfer/DataTransfer");
|
|
34
|
+
|
|
35
|
+
Object.keys(_DataTransfer).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _DataTransfer[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
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
|
+
|
|
20
72
|
var _buildTimeValue = require("./edit/buildTimeValue");
|
|
21
73
|
|
|
22
74
|
Object.keys(_buildTimeValue).forEach(function (key) {
|
|
@@ -160,6 +212,19 @@ Object.keys(_blur).forEach(function (key) {
|
|
|
160
212
|
});
|
|
161
213
|
});
|
|
162
214
|
|
|
215
|
+
var _copySelection = require("./focus/copySelection");
|
|
216
|
+
|
|
217
|
+
Object.keys(_copySelection).forEach(function (key) {
|
|
218
|
+
if (key === "default" || key === "__esModule") return;
|
|
219
|
+
if (key in exports && exports[key] === _copySelection[key]) return;
|
|
220
|
+
Object.defineProperty(exports, key, {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function () {
|
|
223
|
+
return _copySelection[key];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
163
228
|
var _focus = require("./focus/focus");
|
|
164
229
|
|
|
165
230
|
Object.keys(_focus).forEach(function (key) {
|
|
@@ -290,6 +355,19 @@ Object.keys(_findClosest).forEach(function (key) {
|
|
|
290
355
|
});
|
|
291
356
|
});
|
|
292
357
|
|
|
358
|
+
var _getDocumentFromNode = require("./misc/getDocumentFromNode");
|
|
359
|
+
|
|
360
|
+
Object.keys(_getDocumentFromNode).forEach(function (key) {
|
|
361
|
+
if (key === "default" || key === "__esModule") return;
|
|
362
|
+
if (key in exports && exports[key] === _getDocumentFromNode[key]) return;
|
|
363
|
+
Object.defineProperty(exports, key, {
|
|
364
|
+
enumerable: true,
|
|
365
|
+
get: function () {
|
|
366
|
+
return _getDocumentFromNode[key];
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
293
371
|
var _isDescendantOrSelf = require("./misc/isDescendantOrSelf");
|
|
294
372
|
|
|
295
373
|
Object.keys(_isDescendantOrSelf).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
|
+
}
|
package/package.json
CHANGED
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;
|
package/dist/click.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.click = click;
|
|
7
|
-
exports.dblClick = dblClick;
|
|
8
|
-
exports.tripleClick = tripleClick;
|
|
9
|
-
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
|
|
12
|
-
function click(element, init, {
|
|
13
|
-
skipHover = false,
|
|
14
|
-
skipPointerEventsCheck = false
|
|
15
|
-
} = {}) {
|
|
16
|
-
if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
|
|
17
|
-
throw new Error('unable to click element as it has or inherits pointer-events set to "none".');
|
|
18
|
-
} // istanbul ignore else
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (!skipHover) // We just checked for `pointerEvents`. We can always skip this one in `hover`.
|
|
22
|
-
this.hover(element, init, {
|
|
23
|
-
skipPointerEventsCheck: true
|
|
24
|
-
});
|
|
25
|
-
const keys = (init == null ? void 0 : init.button) === 2 || (init == null ? void 0 : init.buttons) === 2 ? '[MouseRight]' : '[MouseLeft]';
|
|
26
|
-
this.pointer({
|
|
27
|
-
keys,
|
|
28
|
-
target: element
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function dblClick(element, init, {
|
|
33
|
-
skipPointerEventsCheck = false
|
|
34
|
-
} = {}) {
|
|
35
|
-
if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
|
|
36
|
-
throw new Error('unable to double-click element as it has or inherits pointer-events set to "none".');
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
this.hover(element, init, {
|
|
40
|
-
skipPointerEventsCheck
|
|
41
|
-
});
|
|
42
|
-
this.pointer({
|
|
43
|
-
keys: '[MouseLeft][MouseLeft]',
|
|
44
|
-
target: element
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function tripleClick(element, init, {
|
|
49
|
-
skipPointerEventsCheck = false
|
|
50
|
-
} = {}) {
|
|
51
|
-
if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
|
|
52
|
-
throw new Error('unable to triple-click element as it has or inherits pointer-events set to "none".');
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
this.hover(element, init, {
|
|
56
|
-
skipPointerEventsCheck: true
|
|
57
|
-
});
|
|
58
|
-
this.pointer({
|
|
59
|
-
keys: '[MouseLeft][MouseLeft][MouseLeft]',
|
|
60
|
-
target: element
|
|
61
|
-
});
|
|
62
|
-
}
|
package/dist/hover.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { UserEvent } from './setup';
|
|
2
|
-
import { PointerOptions } from './utils';
|
|
3
|
-
export declare function hover(this: UserEvent, element: Element, init?: MouseEventInit, { skipPointerEventsCheck }?: PointerOptions): void;
|
|
4
|
-
export declare function unhover(this: UserEvent, element: Element, init?: MouseEventInit, { skipPointerEventsCheck }?: PointerOptions): void;
|
package/dist/hover.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.hover = hover;
|
|
7
|
-
exports.unhover = unhover;
|
|
8
|
-
|
|
9
|
-
var _pointer = require("./pointer");
|
|
10
|
-
|
|
11
|
-
var _utils = require("./utils");
|
|
12
|
-
|
|
13
|
-
function hover(element, init, {
|
|
14
|
-
skipPointerEventsCheck = false
|
|
15
|
-
} = {}) {
|
|
16
|
-
if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
|
|
17
|
-
throw new Error('unable to hover element as it has or inherits pointer-events set to "none".');
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const pointerState = (0, _pointer.createPointerState)();
|
|
21
|
-
pointerState.position.mouse.target = element.ownerDocument.body;
|
|
22
|
-
this.pointer({
|
|
23
|
-
target: element
|
|
24
|
-
}, {
|
|
25
|
-
pointerState
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function unhover(element, init, {
|
|
30
|
-
skipPointerEventsCheck = false
|
|
31
|
-
} = {}) {
|
|
32
|
-
if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
|
|
33
|
-
throw new Error('unable to unhover element as it has or inherits pointer-events set to "none".');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const pointerState = (0, _pointer.createPointerState)();
|
|
37
|
-
pointerState.position.mouse.target = element;
|
|
38
|
-
this.pointer({
|
|
39
|
-
target: element.ownerDocument.body
|
|
40
|
-
}, {
|
|
41
|
-
pointerState
|
|
42
|
-
});
|
|
43
|
-
}
|
package/dist/paste.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { UserEvent } from './setup';
|
|
2
|
-
interface pasteOptions {
|
|
3
|
-
initialSelectionStart?: number;
|
|
4
|
-
initialSelectionEnd?: number;
|
|
5
|
-
}
|
|
6
|
-
export declare function paste(this: UserEvent, element: HTMLElement, text: string, init?: ClipboardEventInit, { initialSelectionStart, initialSelectionEnd }?: pasteOptions): void;
|
|
7
|
-
export {};
|
package/dist/paste.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.paste = paste;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _utils = require("./utils");
|
|
11
|
-
|
|
12
|
-
function isSupportedElement(element) {
|
|
13
|
-
return (0, _utils.isElementType)(element, 'input') && Boolean(_utils.editableInputTypes[element.type]) || (0, _utils.isElementType)(element, 'textarea');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function paste(element, text, init, {
|
|
17
|
-
initialSelectionStart,
|
|
18
|
-
initialSelectionEnd
|
|
19
|
-
} = {}) {
|
|
20
|
-
var _prepareInput;
|
|
21
|
-
|
|
22
|
-
// TODO: implement for contenteditable
|
|
23
|
-
if (!isSupportedElement(element)) {
|
|
24
|
-
throw new TypeError(`The given ${element.tagName} element is currently unsupported.
|
|
25
|
-
A PR extending this implementation would be very much welcome at https://github.com/testing-library/user-event`);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if ((0, _utils.isDisabled)(element)) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
(0, _utils.eventWrapper)(() => element.focus()); // by default, a new element has it's selection start and end at 0
|
|
33
|
-
// but most of the time when people call "paste", they expect it to paste
|
|
34
|
-
// at the end of the current input value. So, if the selection start
|
|
35
|
-
// and end are both the default of 0, then we'll go ahead and change
|
|
36
|
-
// them to the length of the current value.
|
|
37
|
-
// the only time it would make sense to pass the initialSelectionStart or
|
|
38
|
-
// initialSelectionEnd is if you have an input with a value and want to
|
|
39
|
-
// explicitely start typing with the cursor at 0. Not super common.
|
|
40
|
-
|
|
41
|
-
if (element.selectionStart === 0 && element.selectionEnd === 0) {
|
|
42
|
-
(0, _utils.setSelectionRange)(element, initialSelectionStart != null ? initialSelectionStart : element.value.length, initialSelectionEnd != null ? initialSelectionEnd : element.value.length);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
_dom.fireEvent.paste(element, init);
|
|
46
|
-
|
|
47
|
-
if (element.readOnly) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
text = text.substr(0, (0, _utils.getSpaceUntilMaxLength)(element));
|
|
52
|
-
const inputRange = (0, _utils.getInputRange)(element);
|
|
53
|
-
/* istanbul ignore if */
|
|
54
|
-
|
|
55
|
-
if (!inputRange) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
(_prepareInput = (0, _utils.prepareInput)(text, element, 'insertFromPaste')) == null ? void 0 : _prepareInput.commit();
|
|
60
|
-
}
|
package/dist/selectOptions.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { PointerOptions } from './utils';
|
|
2
|
-
import type { UserEvent } from './setup';
|
|
3
|
-
export declare function selectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string, init?: MouseEventInit, options?: PointerOptions): void;
|
|
4
|
-
export declare function deselectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string, init?: MouseEventInit, options?: PointerOptions): void;
|
package/dist/setup.d.ts
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { clear } from './clear';
|
|
2
|
-
import { click, clickOptions, dblClick, tripleClick } from './click';
|
|
3
|
-
import { hover, unhover } from './hover';
|
|
4
|
-
import { keyboard, keyboardOptions } from './keyboard';
|
|
5
|
-
import type { keyboardState } from './keyboard/types';
|
|
6
|
-
import { paste } from './paste';
|
|
7
|
-
import { pointer } from './pointer';
|
|
8
|
-
import type { pointerOptions, pointerState } from './pointer/types';
|
|
9
|
-
import { deselectOptions, selectOptions } from './selectOptions';
|
|
10
|
-
import { tab, tabOptions } from './tab';
|
|
11
|
-
import { type, typeOptions } from './type';
|
|
12
|
-
import { upload, uploadOptions } from './upload';
|
|
13
|
-
import { PointerOptions } from './utils';
|
|
14
|
-
export declare const userEventApis: {
|
|
15
|
-
clear: typeof clear;
|
|
16
|
-
click: typeof click;
|
|
17
|
-
dblClick: typeof dblClick;
|
|
18
|
-
deselectOptions: typeof deselectOptions;
|
|
19
|
-
hover: typeof hover;
|
|
20
|
-
keyboard: typeof keyboard;
|
|
21
|
-
paste: typeof paste;
|
|
22
|
-
pointer: typeof pointer;
|
|
23
|
-
selectOptions: typeof selectOptions;
|
|
24
|
-
tab: typeof tab;
|
|
25
|
-
tripleClick: typeof tripleClick;
|
|
26
|
-
type: typeof type;
|
|
27
|
-
unhover: typeof unhover;
|
|
28
|
-
upload: typeof upload;
|
|
29
|
-
};
|
|
30
|
-
export declare type UserEventApis = typeof userEventApis;
|
|
31
|
-
declare type setup = ReturnType<typeof _setup>['setup'];
|
|
32
|
-
export declare type UserEvent = UserEventApis & {
|
|
33
|
-
setup: setup;
|
|
34
|
-
};
|
|
35
|
-
declare type ClickOptions = Omit<clickOptions, 'clickCount'>;
|
|
36
|
-
declare type KeyboardOptions = Partial<keyboardOptions>;
|
|
37
|
-
declare type PointerApiOptions = Partial<pointerOptions>;
|
|
38
|
-
declare type TabOptions = Omit<tabOptions, 'shift'>;
|
|
39
|
-
declare type TypeOptions = Omit<typeOptions, 'initialSelectionStart' | 'initialSelectionEnd'>;
|
|
40
|
-
declare type UploadOptions = uploadOptions;
|
|
41
|
-
interface SetupOptions extends ClickOptions, KeyboardOptions, PointerOptions, PointerApiOptions, TabOptions, TypeOptions, UploadOptions {
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Start a "session" with userEvent.
|
|
45
|
-
* All APIs returned by this function share an input device state and a default configuration.
|
|
46
|
-
*/
|
|
47
|
-
export declare function setup(options?: SetupOptions): {
|
|
48
|
-
clear: typeof clear;
|
|
49
|
-
click: typeof click;
|
|
50
|
-
dblClick: typeof dblClick;
|
|
51
|
-
deselectOptions: typeof deselectOptions;
|
|
52
|
-
hover: typeof hover;
|
|
53
|
-
keyboard: typeof keyboard;
|
|
54
|
-
paste: typeof paste;
|
|
55
|
-
pointer: typeof pointer;
|
|
56
|
-
selectOptions: typeof selectOptions;
|
|
57
|
-
tab: typeof tab;
|
|
58
|
-
tripleClick: typeof tripleClick;
|
|
59
|
-
type: typeof type;
|
|
60
|
-
unhover: typeof unhover;
|
|
61
|
-
upload: typeof upload;
|
|
62
|
-
} & {
|
|
63
|
-
/**
|
|
64
|
-
* Create a set of callbacks with different default settings but the same state.
|
|
65
|
-
*/
|
|
66
|
-
setup(options: SetupOptions): {
|
|
67
|
-
clear: typeof clear;
|
|
68
|
-
click: typeof click;
|
|
69
|
-
dblClick: typeof dblClick;
|
|
70
|
-
deselectOptions: typeof deselectOptions;
|
|
71
|
-
hover: typeof hover;
|
|
72
|
-
keyboard: typeof keyboard;
|
|
73
|
-
paste: typeof paste;
|
|
74
|
-
pointer: typeof pointer;
|
|
75
|
-
selectOptions: typeof selectOptions;
|
|
76
|
-
tab: typeof tab;
|
|
77
|
-
tripleClick: typeof tripleClick;
|
|
78
|
-
type: typeof type;
|
|
79
|
-
unhover: typeof unhover;
|
|
80
|
-
upload: typeof upload;
|
|
81
|
-
} & any;
|
|
82
|
-
};
|
|
83
|
-
declare function _setup({ applyAccept, autoModify, delay, document, keyboardMap, pointerMap, skipAutoClose, skipClick, skipHover, skipPointerEventsCheck, }: SetupOptions, { keyboardState, pointerState, }: {
|
|
84
|
-
keyboardState: keyboardState;
|
|
85
|
-
pointerState: pointerState;
|
|
86
|
-
}): UserEventApis & {
|
|
87
|
-
/**
|
|
88
|
-
* Create a set of callbacks with different default settings but the same state.
|
|
89
|
-
*/
|
|
90
|
-
setup(options: SetupOptions): ReturnType<typeof _setup>;
|
|
91
|
-
};
|
|
92
|
-
export {};
|