@testing-library/user-event 14.0.0-alpha.8 → 14.0.0-beta.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 +5 -192
- package/dist/index.cjs +2864 -0
- package/dist/index.mjs +2935 -0
- package/dist/types/clipboard/copy.d.ts +2 -0
- package/dist/types/clipboard/cut.d.ts +2 -0
- package/dist/types/clipboard/index.d.ts +3 -0
- package/dist/types/clipboard/paste.d.ts +2 -0
- package/dist/types/convenience/click.d.ts +4 -0
- package/dist/types/convenience/hover.d.ts +3 -0
- package/dist/types/convenience/index.d.ts +3 -0
- package/dist/types/convenience/tab.d.ts +4 -0
- package/dist/{document → types/document}/index.d.ts +0 -0
- package/dist/{document → types/document}/interceptor.d.ts +0 -0
- package/dist/{document → types/document}/selection.d.ts +0 -0
- package/dist/{document → types/document}/value.d.ts +0 -0
- package/dist/types/event/behavior/click.d.ts +1 -0
- package/dist/types/event/behavior/index.d.ts +6 -0
- package/dist/types/event/behavior/keydown.d.ts +1 -0
- package/dist/types/event/behavior/keypress.d.ts +1 -0
- package/dist/types/event/behavior/keyup.d.ts +1 -0
- package/dist/types/event/behavior/registry.d.ts +9 -0
- package/dist/types/event/createEvent.d.ts +8 -0
- package/dist/types/event/dispatchEvent.d.ts +2 -0
- package/dist/types/event/eventMap.d.ts +342 -0
- package/dist/types/event/eventTypes.d.ts +2 -0
- package/dist/types/event/index.d.ts +6 -0
- package/dist/types/event/types.d.ts +13 -0
- package/dist/types/event/wrapEvent.d.ts +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/keyboard/index.d.ts +7 -0
- package/dist/{keyboard → types/keyboard}/keyMap.d.ts +0 -0
- package/dist/types/keyboard/keyboardAction.d.ts +10 -0
- package/dist/types/keyboard/modifiers.d.ts +9 -0
- package/dist/{keyboard/getNextKeyDef.d.ts → types/keyboard/parseKeyDef.d.ts} +4 -6
- package/dist/{keyboard → types/keyboard}/types.d.ts +19 -26
- package/dist/types/options.d.ts +117 -0
- package/dist/types/pointer/firePointerEvents.d.ts +11 -0
- package/dist/types/pointer/index.d.ts +10 -0
- package/dist/{pointer → types/pointer}/keyMap.d.ts +0 -0
- package/dist/types/pointer/parseKeyDef.d.ts +6 -0
- package/dist/{pointer → types/pointer}/pointerAction.d.ts +3 -2
- package/dist/types/pointer/pointerMove.d.ts +6 -0
- package/dist/types/pointer/pointerPress.d.ts +8 -0
- package/dist/{pointer → types/pointer}/resolveSelectionTarget.d.ts +0 -0
- package/dist/{pointer → types/pointer}/types.d.ts +2 -12
- package/dist/types/setup/api.d.ts +5 -0
- package/dist/types/setup/config.d.ts +10 -0
- package/dist/types/setup/directApi.d.ts +19 -0
- package/dist/types/setup/index.d.ts +36 -0
- package/dist/types/setup/setup.d.ts +20 -0
- package/dist/types/setup/wrapAsync.d.ts +4 -0
- package/dist/types/utility/clear.d.ts +2 -0
- package/dist/types/utility/index.d.ts +4 -0
- package/dist/types/utility/selectOptions.d.ts +3 -0
- package/dist/types/utility/type.d.ts +9 -0
- package/dist/types/utility/upload.d.ts +5 -0
- package/dist/{utils → types/utils}/click/isClickableInput.d.ts +0 -0
- package/dist/types/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +9 -0
- package/dist/types/utils/dataTransfer/DataTransfer.d.ts +2 -0
- package/dist/types/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/{utils → types/utils}/edit/buildTimeValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/getValue.d.ts +0 -0
- package/dist/types/utils/edit/input.d.ts +2 -0
- package/dist/{utils → types/utils}/edit/isContentEditable.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isEditable.d.ts +0 -0
- package/dist/types/utils/edit/isValidDateOrTimeValue.d.ts +3 -0
- package/dist/{utils → types/utils}/edit/maxLength.d.ts +0 -0
- package/dist/types/utils/edit/setFiles.d.ts +12 -0
- package/dist/{utils → types/utils}/focus/blur.d.ts +0 -0
- package/dist/types/utils/focus/copySelection.d.ts +1 -0
- package/dist/types/utils/focus/cursor.d.ts +9 -0
- package/dist/{utils → types/utils}/focus/focus.d.ts +3 -0
- package/dist/{utils → types/utils}/focus/getActiveElement.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/getTabDestination.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/isFocusable.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selectAll.d.ts +1 -0
- package/dist/{utils → types/utils}/focus/selection.d.ts +4 -0
- package/dist/{utils → types/utils}/focus/selector.d.ts +0 -0
- package/dist/{utils → types/utils}/index.d.ts +14 -11
- package/dist/{utils → types/utils}/keyDef/readNextDescriptor.d.ts +0 -0
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +5 -0
- package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
- package/dist/types/utils/misc/cloneEvent.d.ts +1 -0
- package/dist/{utils → types/utils}/misc/eventWrapper.d.ts +0 -0
- package/dist/types/utils/misc/findClosest.d.ts +1 -0
- package/dist/types/utils/misc/getDocumentFromNode.d.ts +1 -0
- package/dist/{utils → types/utils}/misc/isDescendantOrSelf.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isDisabled.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isElementType.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isVisible.d.ts +0 -0
- package/dist/types/utils/misc/level.d.ts +17 -0
- package/dist/{utils → types/utils}/misc/wait.d.ts +0 -0
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +15 -0
- package/dist/{utils → types/utils}/pointer/mouseButtons.d.ts +0 -0
- package/package.json +13 -30
- package/CHANGELOG.md +0 -5
- package/dist/clear.d.ts +0 -2
- package/dist/clear.js +0 -46
- package/dist/click.d.ts +0 -9
- package/dist/click.js +0 -62
- package/dist/document/index.js +0 -100
- package/dist/document/interceptor.js +0 -37
- package/dist/document/selection.js +0 -90
- package/dist/document/value.js +0 -77
- package/dist/hover.d.ts +0 -4
- package/dist/hover.js +0 -43
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -22
- package/dist/keyboard/getEventProps.d.ts +0 -17
- package/dist/keyboard/getEventProps.js +0 -33
- package/dist/keyboard/getNextKeyDef.js +0 -85
- package/dist/keyboard/index.d.ts +0 -19
- package/dist/keyboard/index.js +0 -78
- package/dist/keyboard/keyMap.js +0 -143
- package/dist/keyboard/keyboardImplementation.d.ts +0 -3
- package/dist/keyboard/keyboardImplementation.js +0 -169
- package/dist/keyboard/plugins/arrow.d.ts +0 -6
- package/dist/keyboard/plugins/arrow.js +0 -28
- package/dist/keyboard/plugins/character.d.ts +0 -5
- package/dist/keyboard/plugins/character.js +0 -166
- package/dist/keyboard/plugins/combination.d.ts +0 -5
- package/dist/keyboard/plugins/combination.js +0 -17
- package/dist/keyboard/plugins/control.d.ts +0 -6
- package/dist/keyboard/plugins/control.js +0 -52
- package/dist/keyboard/plugins/functional.d.ts +0 -11
- package/dist/keyboard/plugins/functional.js +0 -140
- package/dist/keyboard/plugins/index.d.ts +0 -8
- package/dist/keyboard/plugins/index.js +0 -42
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -3
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
- package/dist/keyboard/shared/index.d.ts +0 -1
- package/dist/keyboard/shared/index.js +0 -18
- package/dist/keyboard/specialCharMap.d.ts +0 -22
- package/dist/keyboard/specialCharMap.js +0 -30
- package/dist/keyboard/types.js +0 -19
- package/dist/paste.d.ts +0 -7
- package/dist/paste.js +0 -60
- package/dist/pointer/index.d.ts +0 -18
- package/dist/pointer/index.js +0 -90
- package/dist/pointer/keyMap.js +0 -29
- package/dist/pointer/parseKeyDef.d.ts +0 -6
- package/dist/pointer/parseKeyDef.js +0 -36
- package/dist/pointer/pointerAction.js +0 -52
- package/dist/pointer/pointerMove.d.ts +0 -5
- package/dist/pointer/pointerMove.js +0 -136
- package/dist/pointer/pointerPress.d.ts +0 -7
- package/dist/pointer/pointerPress.js +0 -330
- package/dist/pointer/resolveSelectionTarget.js +0 -75
- package/dist/pointer/types.js +0 -1
- package/dist/selectOptions.d.ts +0 -4
- package/dist/selectOptions.js +0 -142
- 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/upload.js +0 -92
- package/dist/utils/click/isClickableInput.js +0 -14
- package/dist/utils/edit/buildTimeValue.js +0 -44
- package/dist/utils/edit/calculateNewValue.d.ts +0 -16
- package/dist/utils/edit/calculateNewValue.js +0 -50
- package/dist/utils/edit/fireInputEvent.d.ts +0 -11
- package/dist/utils/edit/fireInputEvent.js +0 -65
- package/dist/utils/edit/getValue.js +0 -23
- package/dist/utils/edit/isContentEditable.js +0 -25
- package/dist/utils/edit/isEditable.js +0 -42
- package/dist/utils/edit/isValidDateValue.d.ts +0 -3
- package/dist/utils/edit/isValidDateValue.js +0 -12
- package/dist/utils/edit/isValidInputTimeValue.d.ts +0 -3
- package/dist/utils/edit/isValidInputTimeValue.js +0 -12
- package/dist/utils/edit/maxLength.js +0 -50
- package/dist/utils/edit/prepareInput.d.ts +0 -4
- package/dist/utils/edit/prepareInput.js +0 -60
- package/dist/utils/focus/blur.js +0 -19
- package/dist/utils/focus/focus.js +0 -22
- package/dist/utils/focus/getActiveElement.js +0 -26
- package/dist/utils/focus/getTabDestination.js +0 -71
- package/dist/utils/focus/isFocusable.js +0 -12
- package/dist/utils/focus/selectAll.js +0 -38
- package/dist/utils/focus/selection.js +0 -190
- package/dist/utils/focus/selector.js +0 -8
- package/dist/utils/index.js +0 -421
- package/dist/utils/keyDef/readNextDescriptor.js +0 -102
- package/dist/utils/misc/eventWrapper.js +0 -16
- package/dist/utils/misc/findClosest.d.ts +0 -1
- package/dist/utils/misc/findClosest.js +0 -20
- package/dist/utils/misc/hasFormSubmit.d.ts +0 -1
- package/dist/utils/misc/hasFormSubmit.js +0 -10
- package/dist/utils/misc/hasPointerEvents.d.ts +0 -15
- package/dist/utils/misc/hasPointerEvents.js +0 -24
- package/dist/utils/misc/isDescendantOrSelf.js +0 -20
- package/dist/utils/misc/isDisabled.js +0 -12
- package/dist/utils/misc/isElementType.js +0 -24
- package/dist/utils/misc/isVisible.js +0 -24
- package/dist/utils/misc/wait.js +0 -10
- package/dist/utils/pointer/fakeEvent.d.ts +0 -20
- package/dist/utils/pointer/fakeEvent.js +0 -91
- package/dist/utils/pointer/firePointerEvents.d.ts +0 -14
- package/dist/utils/pointer/firePointerEvents.js +0 -55
- package/dist/utils/pointer/mouseButtons.js +0 -45
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { keyboardKey } from './keyboard/types';
|
|
2
|
+
import type { pointerKey } from './pointer/types';
|
|
3
|
+
export declare enum PointerEventsCheckLevel {
|
|
4
|
+
/**
|
|
5
|
+
* Check pointer events on every user interaction that triggers a bunch of events.
|
|
6
|
+
* E.g. once for releasing a mouse button even though this triggers `pointerup`, `mouseup`, `click`, etc...
|
|
7
|
+
*/
|
|
8
|
+
EachTrigger = 4,
|
|
9
|
+
/** Check each target once per call to pointer (related) API */
|
|
10
|
+
EachApiCall = 2,
|
|
11
|
+
/** Check each event target once */
|
|
12
|
+
EachTarget = 1,
|
|
13
|
+
/** No pointer events check */
|
|
14
|
+
Never = 0
|
|
15
|
+
}
|
|
16
|
+
export interface Options {
|
|
17
|
+
/**
|
|
18
|
+
* When using `userEvent.upload`, automatically discard files
|
|
19
|
+
* that don't match an `accept` property if it exists.
|
|
20
|
+
*
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
applyAccept?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* We intend to automatically apply modifier keys for printable characters in the future.
|
|
26
|
+
* I.e. `A` implying `{Shift>}a{/Shift}` if caps lock is not active.
|
|
27
|
+
*
|
|
28
|
+
* This options allows you to opt out of this change in foresight.
|
|
29
|
+
* The feature therefore will not constitute a breaking change.
|
|
30
|
+
*
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
autoModify?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Between some subsequent inputs like typing a series of characters
|
|
36
|
+
* the code execution is delayed per `setTimeout` for (at least) `delay` seconds.
|
|
37
|
+
* This moves the next changes at least to next macro task
|
|
38
|
+
* and allows other (asynchronous) code to run between events.
|
|
39
|
+
*
|
|
40
|
+
* `null` prevents `setTimeout` from being called.
|
|
41
|
+
*
|
|
42
|
+
* @default 0
|
|
43
|
+
*/
|
|
44
|
+
delay?: number | null;
|
|
45
|
+
/**
|
|
46
|
+
* The document.
|
|
47
|
+
*
|
|
48
|
+
* This defaults to the owner document of an element if an API is called directly with an element and without setup.
|
|
49
|
+
* Otherwise it falls back to the global document.
|
|
50
|
+
*
|
|
51
|
+
* @default element.ownerDocument??global.document
|
|
52
|
+
*/
|
|
53
|
+
document?: Document;
|
|
54
|
+
/**
|
|
55
|
+
* An array of keyboard keys the keyboard device consists of.
|
|
56
|
+
*
|
|
57
|
+
* This allows to plug in different layouts / localizations.
|
|
58
|
+
*
|
|
59
|
+
* Defaults to a "standard" US-104-QWERTY keyboard.
|
|
60
|
+
*/
|
|
61
|
+
keyboardMap?: keyboardKey[];
|
|
62
|
+
/**
|
|
63
|
+
* An array of available pointer keys.
|
|
64
|
+
*
|
|
65
|
+
* This allows to plug in different pointer devices.
|
|
66
|
+
*/
|
|
67
|
+
pointerMap?: pointerKey[];
|
|
68
|
+
/**
|
|
69
|
+
* The pointer API includes a check if an element has or inherits `pointer-events: none`.
|
|
70
|
+
* This check is known to be expensive and very expensive when checking deeply nested nodes.
|
|
71
|
+
* This option determines how often the pointer related APIs perform the check.
|
|
72
|
+
*
|
|
73
|
+
* This is a binary flag option. You can combine multiple Levels.
|
|
74
|
+
*
|
|
75
|
+
* @default PointerEventsCheckLevel.EachCall
|
|
76
|
+
*/
|
|
77
|
+
pointerEventsCheck?: PointerEventsCheckLevel | number;
|
|
78
|
+
/**
|
|
79
|
+
* `userEvent.type` automatically releases any keys still pressed at the end of the call.
|
|
80
|
+
* This option allows to opt out of this feature.
|
|
81
|
+
*
|
|
82
|
+
* @default false
|
|
83
|
+
*/
|
|
84
|
+
skipAutoClose?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* `userEvent.type` implys a click at the end of the element content/value.
|
|
87
|
+
* This option allows to opt out of this feature.
|
|
88
|
+
*
|
|
89
|
+
* @default false
|
|
90
|
+
*/
|
|
91
|
+
skipClick?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* `userEvent.click` implys moving the cursor to the target element first.
|
|
94
|
+
* This options allows to opt out of this feature.
|
|
95
|
+
*
|
|
96
|
+
* @default false
|
|
97
|
+
*/
|
|
98
|
+
skipHover?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Write selected data to Clipboard API when a `cut` or `copy` is triggered.
|
|
101
|
+
*
|
|
102
|
+
* The Clipboard API is usually not available to test code.
|
|
103
|
+
* Our `setup` replaces the `navigator.clipboard` property with a stub.
|
|
104
|
+
*
|
|
105
|
+
* Defaults to `false` when calling the APIs directly.
|
|
106
|
+
* Defaults to `true` when calling the APIs per `setup`.
|
|
107
|
+
*/
|
|
108
|
+
writeToClipboard?: boolean;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Default options applied when API is called per `userEvent.anyApi()`
|
|
112
|
+
*/
|
|
113
|
+
export declare const defaultOptionsDirect: Required<Options>;
|
|
114
|
+
/**
|
|
115
|
+
* Default options applied when API is called per `userEvent().anyApi()`
|
|
116
|
+
*/
|
|
117
|
+
export declare const defaultOptionsSetup: Required<Options>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EventType, PointerCoords } from '../event';
|
|
2
|
+
import { Config } from '../setup';
|
|
3
|
+
import { MouseButton } from '../utils';
|
|
4
|
+
export declare function firePointerEvent(config: Config, target: Element, type: EventType, { pointerType, button, coords, pointerId, isPrimary, clickCount, }: {
|
|
5
|
+
pointerType?: 'mouse' | 'pen' | 'touch';
|
|
6
|
+
button?: MouseButton;
|
|
7
|
+
coords?: PointerCoords;
|
|
8
|
+
pointerId?: number;
|
|
9
|
+
isPrimary?: boolean;
|
|
10
|
+
clickCount?: number;
|
|
11
|
+
}): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Instance } from '../setup';
|
|
2
|
+
import { PointerAction, PointerActionTarget } from './pointerAction';
|
|
3
|
+
import type { pointerState, pointerKey } from './types';
|
|
4
|
+
export type { pointerState, pointerKey };
|
|
5
|
+
declare type PointerActionInput = string | ({
|
|
6
|
+
keys: string;
|
|
7
|
+
} & PointerActionTarget) | PointerAction;
|
|
8
|
+
export declare type PointerInput = PointerActionInput | Array<PointerActionInput>;
|
|
9
|
+
export declare function pointer(this: Instance, input: PointerInput): Promise<void>;
|
|
10
|
+
export declare function createPointerState(document: Document): pointerState;
|
|
File without changes
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { Config } from '../setup';
|
|
1
2
|
import { PointerMoveAction } from './pointerMove';
|
|
2
3
|
import { PointerPressAction } from './pointerPress';
|
|
3
|
-
import {
|
|
4
|
+
import { PointerTarget, SelectionTarget } from './types';
|
|
4
5
|
export declare type PointerActionTarget = Partial<PointerTarget> & Partial<SelectionTarget>;
|
|
5
6
|
export declare type PointerAction = PointerActionTarget & (Omit<PointerPressAction, 'target' | 'coords'> | Omit<PointerMoveAction, 'target' | 'coords'>);
|
|
6
|
-
export declare function pointerAction(actions: PointerAction[]
|
|
7
|
+
export declare function pointerAction(config: Config, actions: PointerAction[]): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Config } from '../setup';
|
|
2
|
+
import { PointerTarget, SelectionTarget } from './types';
|
|
3
|
+
export interface PointerMoveAction extends PointerTarget, SelectionTarget {
|
|
4
|
+
pointerName?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function pointerMove(config: Config, { pointerName, target, coords, node, offset }: PointerMoveAction): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Config } from '../setup';
|
|
2
|
+
import type { pointerKey, PointerTarget, SelectionTarget } from './types';
|
|
3
|
+
export interface PointerPressAction extends PointerTarget, SelectionTarget {
|
|
4
|
+
keyDef: pointerKey;
|
|
5
|
+
releasePrevious: boolean;
|
|
6
|
+
releaseSelf: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function pointerPress(config: Config, action: PointerPressAction): Promise<void>;
|
|
File without changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { PointerCoords } from '../event';
|
|
2
|
+
import { MouseButton } from '../utils';
|
|
3
3
|
/**
|
|
4
4
|
* @internal Do not create/alter this by yourself as this type might be subject to changes.
|
|
5
5
|
*/
|
|
@@ -34,12 +34,6 @@ export declare type pointerState = {
|
|
|
34
34
|
*/
|
|
35
35
|
pointerId: number;
|
|
36
36
|
};
|
|
37
|
-
export declare type pointerOptions = {
|
|
38
|
-
/** Delay between keystrokes */
|
|
39
|
-
delay: number;
|
|
40
|
-
/** Available pointer keys */
|
|
41
|
-
pointerMap: pointerKey[];
|
|
42
|
-
};
|
|
43
37
|
export interface pointerKey {
|
|
44
38
|
/** Name of the pointer key */
|
|
45
39
|
name: string;
|
|
@@ -66,7 +60,3 @@ export interface SelectionInputRange {
|
|
|
66
60
|
start: number;
|
|
67
61
|
end: number;
|
|
68
62
|
}
|
|
69
|
-
export interface inputDeviceState {
|
|
70
|
-
pointerState: pointerState;
|
|
71
|
-
keyboardState: keyboardState;
|
|
72
|
-
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { click, dblClick, tripleClick, hover, unhover, tab } from '../convenience';
|
|
2
|
+
export { keyboard } from '../keyboard';
|
|
3
|
+
export { copy, cut, paste } from '../clipboard';
|
|
4
|
+
export { pointer } from '../pointer';
|
|
5
|
+
export { clear, deselectOptions, selectOptions, type, upload } from '../utility';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { keyboardState } from '../keyboard/types';
|
|
2
|
+
import type { pointerState } from '../pointer/types';
|
|
3
|
+
import type { Options } from '../options';
|
|
4
|
+
export interface inputDeviceState {
|
|
5
|
+
pointerState: pointerState;
|
|
6
|
+
keyboardState: keyboardState;
|
|
7
|
+
}
|
|
8
|
+
export interface Config extends Required<Options>, inputDeviceState {
|
|
9
|
+
}
|
|
10
|
+
export declare const Config: unique symbol;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PointerInput } from '../pointer';
|
|
2
|
+
import type { UserEventApi } from '.';
|
|
3
|
+
import { Config } from './config';
|
|
4
|
+
export declare function clear(element: Element): Promise<void>;
|
|
5
|
+
export declare function click(element: Element, options?: Partial<Config>): Promise<void>;
|
|
6
|
+
export declare function copy(options?: Partial<Config>): Promise<DataTransfer | undefined>;
|
|
7
|
+
export declare function cut(options?: Partial<Config>): Promise<DataTransfer | undefined>;
|
|
8
|
+
export declare function dblClick(element: Element, options?: Partial<Config>): Promise<void>;
|
|
9
|
+
export declare function deselectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
|
|
10
|
+
export declare function hover(element: Element, options?: Partial<Config>): Promise<void>;
|
|
11
|
+
export declare function keyboard(text: string, options?: Partial<Config>): Promise<import("../keyboard").keyboardState>;
|
|
12
|
+
export declare function pointer(input: PointerInput, options?: Partial<Config>): Promise<import("../pointer").pointerState>;
|
|
13
|
+
export declare function paste(clipboardData?: DataTransfer | string, options?: Partial<Config>): Promise<void>;
|
|
14
|
+
export declare function selectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
|
|
15
|
+
export declare function tripleClick(element: Element, options?: Partial<Config>): Promise<void>;
|
|
16
|
+
export declare function type(element: Element, text: string, options?: Partial<Config> & Parameters<UserEventApi['type']>[2]): Promise<void>;
|
|
17
|
+
export declare function unhover(element: Element, options?: Partial<Config>): Promise<void>;
|
|
18
|
+
export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?: Partial<Config>): Promise<void>;
|
|
19
|
+
export declare function tab(options?: Partial<Config> & Parameters<UserEventApi['tab']>[0]): Promise<void>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { bindDispatchUIEvent } from '../event';
|
|
2
|
+
import type * as userEventApi from './api';
|
|
3
|
+
import { setupMain, setupSub } from './setup';
|
|
4
|
+
import { Config, inputDeviceState } from './config';
|
|
5
|
+
import * as directApi from './directApi';
|
|
6
|
+
export type { inputDeviceState };
|
|
7
|
+
export { Config };
|
|
8
|
+
export declare type UserEventApi = typeof userEventApi;
|
|
9
|
+
export declare type Instance = UserEventApi & {
|
|
10
|
+
[Config]: Config;
|
|
11
|
+
dispatchUIEvent: ReturnType<typeof bindDispatchUIEvent>;
|
|
12
|
+
};
|
|
13
|
+
export declare type UserEvent = {
|
|
14
|
+
readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;
|
|
15
|
+
} & {
|
|
16
|
+
readonly [k in keyof UserEventApi]: (...args: Parameters<UserEventApi[k]>) => ReturnType<UserEventApi[k]>;
|
|
17
|
+
};
|
|
18
|
+
export declare const userEvent: {
|
|
19
|
+
readonly setup: typeof setupMain;
|
|
20
|
+
readonly clear: typeof directApi.clear;
|
|
21
|
+
readonly click: typeof directApi.click;
|
|
22
|
+
readonly copy: typeof directApi.copy;
|
|
23
|
+
readonly cut: typeof directApi.cut;
|
|
24
|
+
readonly dblClick: typeof directApi.dblClick;
|
|
25
|
+
readonly deselectOptions: typeof directApi.deselectOptions;
|
|
26
|
+
readonly hover: typeof directApi.hover;
|
|
27
|
+
readonly keyboard: typeof directApi.keyboard;
|
|
28
|
+
readonly pointer: typeof directApi.pointer;
|
|
29
|
+
readonly paste: typeof directApi.paste;
|
|
30
|
+
readonly selectOptions: typeof directApi.selectOptions;
|
|
31
|
+
readonly tripleClick: typeof directApi.tripleClick;
|
|
32
|
+
readonly type: typeof directApi.type;
|
|
33
|
+
readonly unhover: typeof directApi.unhover;
|
|
34
|
+
readonly upload: typeof directApi.upload;
|
|
35
|
+
readonly tab: typeof directApi.tab;
|
|
36
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Options } from '../options';
|
|
2
|
+
import type { Instance, UserEvent } from './index';
|
|
3
|
+
import { Config } from './config';
|
|
4
|
+
export declare function createConfig(options?: Partial<Config>, defaults?: Required<Options>, node?: Node): Config;
|
|
5
|
+
/**
|
|
6
|
+
* Start a "session" with userEvent.
|
|
7
|
+
* All APIs returned by this function share an input device state and a default configuration.
|
|
8
|
+
*/
|
|
9
|
+
export declare function setupMain(options?: Options): UserEvent;
|
|
10
|
+
/**
|
|
11
|
+
* Setup in direct call per `userEvent.anyApi()`
|
|
12
|
+
*/
|
|
13
|
+
export declare function setupDirect(options?: Partial<Config>, node?: Node): {
|
|
14
|
+
config: Config;
|
|
15
|
+
api: UserEvent;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Create a set of callbacks with different default settings but the same state.
|
|
19
|
+
*/
|
|
20
|
+
export declare function setupSub(this: Instance, options: Options): UserEvent;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Instance } from '../setup';
|
|
2
|
+
export declare function selectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
3
|
+
export declare function deselectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Instance } from '../setup';
|
|
2
|
+
import { Config } from '../setup/config';
|
|
3
|
+
export interface typeOptions {
|
|
4
|
+
skipClick?: Config['skipClick'];
|
|
5
|
+
skipAutoClose?: Config['skipClick'];
|
|
6
|
+
initialSelectionStart?: number;
|
|
7
|
+
initialSelectionEnd?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function type(this: Instance, element: Element, text: string, { skipClick, skipAutoClose, initialSelectionStart, initialSelectionEnd, }?: typeOptions): Promise<void>;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readBlobText(blob: Blob): Promise<string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare function createClipboardItem(...blobs: Array<Blob | string>): ClipboardItem;
|
|
2
|
+
export declare function attachClipboardStubToView(window: Window & typeof globalThis): {
|
|
3
|
+
resetClipboardStub: () => void;
|
|
4
|
+
detachClipboardStub: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare function resetClipboardStubOnView(window: Window & typeof globalThis): void;
|
|
7
|
+
export declare function detachClipboardStubFromView(window: Window & typeof globalThis): void;
|
|
8
|
+
export declare function readDataTransferFromClipboard(document: Document): Promise<DataTransfer>;
|
|
9
|
+
export declare function writeDataTransferToClipboard(document: Document, clipboardData: DataTransfer): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createFileList(files: File[]): FileList;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const fakeFiles: unique symbol;
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLInputElement {
|
|
4
|
+
[fakeFiles]?: {
|
|
5
|
+
restore: () => void;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export declare function setFiles(el: HTMLInputElement & {
|
|
10
|
+
type: 'file';
|
|
11
|
+
}, files: FileList): void;
|
|
12
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copySelection(target: Element): DataTransfer;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export * from './click/isClickableInput';
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './
|
|
2
|
+
export * from './dataTransfer/Blob';
|
|
3
|
+
export * from './dataTransfer/DataTransfer';
|
|
4
|
+
export * from './dataTransfer/FileList';
|
|
5
|
+
export * from './dataTransfer/Clipboard';
|
|
5
6
|
export * from './edit/getValue';
|
|
7
|
+
export * from './edit/input';
|
|
6
8
|
export * from './edit/isContentEditable';
|
|
7
9
|
export * from './edit/isEditable';
|
|
8
|
-
export * from './edit/
|
|
9
|
-
export * from './edit/isValidInputTimeValue';
|
|
10
|
-
export * from './edit/maxLength';
|
|
11
|
-
export * from './edit/prepareInput';
|
|
10
|
+
export * from './edit/setFiles';
|
|
12
11
|
export * from './focus/blur';
|
|
12
|
+
export * from './focus/copySelection';
|
|
13
|
+
export * from './focus/cursor';
|
|
13
14
|
export * from './focus/focus';
|
|
14
15
|
export * from './focus/getActiveElement';
|
|
15
16
|
export * from './focus/getTabDestination';
|
|
@@ -17,16 +18,18 @@ export * from './focus/isFocusable';
|
|
|
17
18
|
export * from './focus/selectAll';
|
|
18
19
|
export * from './focus/selection';
|
|
19
20
|
export * from './focus/selector';
|
|
21
|
+
export * from './keyboard/getKeyEventProps';
|
|
22
|
+
export * from './keyboard/getUIEventModifiers';
|
|
20
23
|
export * from './keyDef/readNextDescriptor';
|
|
24
|
+
export * from './misc/cloneEvent';
|
|
21
25
|
export * from './misc/eventWrapper';
|
|
22
26
|
export * from './misc/findClosest';
|
|
27
|
+
export * from './misc/getDocumentFromNode';
|
|
23
28
|
export * from './misc/isDescendantOrSelf';
|
|
24
29
|
export * from './misc/isElementType';
|
|
25
30
|
export * from './misc/isVisible';
|
|
26
31
|
export * from './misc/isDisabled';
|
|
32
|
+
export * from './misc/level';
|
|
27
33
|
export * from './misc/wait';
|
|
28
|
-
export * from './
|
|
29
|
-
export * from './misc/hasFormSubmit';
|
|
30
|
-
export * from './pointer/fakeEvent';
|
|
31
|
-
export * from './pointer/firePointerEvents';
|
|
34
|
+
export * from './pointer/cssPointerEvents';
|
|
32
35
|
export * from './pointer/mouseButtons';
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { keyboardState } from '../../keyboard';
|
|
2
|
+
export declare function getUIEventModifiers(keyboardState: keyboardState): {
|
|
3
|
+
altKey: boolean;
|
|
4
|
+
ctrlKey: boolean;
|
|
5
|
+
metaKey: boolean;
|
|
6
|
+
shiftKey: boolean;
|
|
7
|
+
modifierAltGraph: boolean;
|
|
8
|
+
modifierCapsLock: boolean;
|
|
9
|
+
modifierFn: boolean;
|
|
10
|
+
modifierFnLock: boolean;
|
|
11
|
+
modifierNumLock: boolean;
|
|
12
|
+
modifierScrollLock: boolean;
|
|
13
|
+
modifierSymbol: boolean;
|
|
14
|
+
modifierSymbolLock: boolean;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cloneEvent<E extends Event>(event: E): E;
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findClosest<T extends Element>(element: Element, callback: (e: Element) => e is T): T | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDocumentFromNode(el: Node): Document | null;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Config } from '../../setup';
|
|
2
|
+
export declare enum ApiLevel {
|
|
3
|
+
Trigger = 2,
|
|
4
|
+
Call = 1
|
|
5
|
+
}
|
|
6
|
+
declare const Level: unique symbol;
|
|
7
|
+
interface LevelRefs {
|
|
8
|
+
[k: number]: object | undefined;
|
|
9
|
+
}
|
|
10
|
+
declare module '../../setup' {
|
|
11
|
+
interface Config {
|
|
12
|
+
[Level]?: LevelRefs;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export declare function setLevelRef(config: Config, level: ApiLevel): void;
|
|
16
|
+
export declare function getLevelRef(config: Config, level: ApiLevel): object | undefined;
|
|
17
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Config } from '../../setup';
|
|
2
|
+
import { ApiLevel } from '..';
|
|
3
|
+
export declare function hasPointerEvents(element: Element): boolean;
|
|
4
|
+
declare const PointerEventsCheck: unique symbol;
|
|
5
|
+
declare global {
|
|
6
|
+
interface Element {
|
|
7
|
+
[PointerEventsCheck]?: {
|
|
8
|
+
[k in ApiLevel]?: object;
|
|
9
|
+
} & {
|
|
10
|
+
result: boolean;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export declare function assertPointerEvents(config: Config, element: Element): void;
|
|
15
|
+
export {};
|
|
File without changes
|