@testing-library/user-event 14.0.0-beta.4 → 14.0.0-beta.5
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/index.cjs +2760 -0
- package/dist/{index.js → index.mjs} +0 -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/types/document/index.d.ts +10 -0
- package/dist/types/document/interceptor.d.ts +15 -0
- package/dist/types/document/selection.d.ts +27 -0
- package/dist/types/document/value.d.ts +18 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/keyboard/index.d.ts +7 -0
- package/dist/types/keyboard/keyMap.d.ts +5 -0
- package/dist/types/keyboard/keyboardAction.d.ts +10 -0
- package/dist/types/keyboard/parseKeyDef.d.ts +17 -0
- package/dist/types/keyboard/plugins/arrow.d.ts +6 -0
- package/dist/types/keyboard/plugins/character.d.ts +5 -0
- package/dist/types/keyboard/plugins/combination.d.ts +5 -0
- package/dist/types/keyboard/plugins/control.d.ts +6 -0
- package/dist/types/keyboard/plugins/functional.d.ts +8 -0
- package/dist/types/keyboard/plugins/index.d.ts +7 -0
- package/dist/types/keyboard/plugins/modifiers.d.ts +8 -0
- package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +3 -0
- package/dist/types/keyboard/shared/index.d.ts +1 -0
- package/dist/types/keyboard/types.d.ts +78 -0
- package/dist/types/options.d.ts +102 -0
- package/dist/types/pointer/index.d.ts +10 -0
- package/dist/types/pointer/keyMap.d.ts +2 -0
- package/dist/types/pointer/parseKeyDef.d.ts +6 -0
- package/dist/types/pointer/pointerAction.d.ts +7 -0
- package/dist/types/pointer/pointerMove.d.ts +6 -0
- package/dist/types/pointer/pointerPress.d.ts +8 -0
- package/dist/types/pointer/resolveSelectionTarget.d.ts +5 -0
- package/dist/types/pointer/types.d.ts +61 -0
- 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 +20 -0
- package/dist/types/setup/index.d.ts +30 -0
- package/dist/types/setup/setup.d.ts +74 -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/types/utils/click/isClickableInput.d.ts +1 -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/types/utils/edit/buildTimeValue.d.ts +1 -0
- package/dist/types/utils/edit/calculateNewValue.d.ts +14 -0
- package/dist/types/utils/edit/editInputElement.d.ts +16 -0
- package/dist/types/utils/edit/getValue.d.ts +1 -0
- package/dist/types/utils/edit/isContentEditable.d.ts +7 -0
- package/dist/types/utils/edit/isEditable.d.ts +25 -0
- package/dist/types/utils/edit/isValidDateValue.d.ts +3 -0
- package/dist/types/utils/edit/isValidInputTimeValue.d.ts +3 -0
- package/dist/types/utils/edit/maxLength.d.ts +1 -0
- package/dist/types/utils/edit/prepareInput.d.ts +7 -0
- package/dist/types/utils/edit/setFiles.d.ts +12 -0
- package/dist/types/utils/focus/blur.d.ts +2 -0
- package/dist/types/utils/focus/copySelection.d.ts +1 -0
- package/dist/types/utils/focus/focus.d.ts +2 -0
- package/dist/types/utils/focus/getActiveElement.d.ts +1 -0
- package/dist/types/utils/focus/getTabDestination.d.ts +1 -0
- package/dist/types/utils/focus/isFocusable.d.ts +1 -0
- package/dist/types/utils/focus/selectAll.d.ts +5 -0
- package/dist/types/utils/focus/selection.d.ts +42 -0
- package/dist/types/utils/focus/selector.d.ts +1 -0
- package/dist/types/utils/index.d.ts +40 -0
- package/dist/types/utils/keyDef/readNextDescriptor.d.ts +19 -0
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +17 -0
- package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
- package/dist/types/utils/misc/eventWrapper.d.ts +1 -0
- package/dist/types/utils/misc/findClosest.d.ts +1 -0
- package/dist/types/utils/misc/getDocumentFromNode.d.ts +1 -0
- package/dist/types/utils/misc/hasFormSubmit.d.ts +1 -0
- package/dist/types/utils/misc/hasPointerEvents.d.ts +15 -0
- package/dist/types/utils/misc/isDescendantOrSelf.d.ts +1 -0
- package/dist/types/utils/misc/isDisabled.d.ts +1 -0
- package/dist/types/utils/misc/isElementType.d.ts +5 -0
- package/dist/types/utils/misc/isVisible.d.ts +1 -0
- package/dist/types/utils/misc/wait.d.ts +1 -0
- package/dist/types/utils/pointer/firePointerEvents.d.ts +25 -0
- package/dist/types/utils/pointer/mouseButtons.d.ts +12 -0
- package/package.json +10 -3
- package/dist/index.d.ts +0 -1110
- package/dist/package.json +0 -1
|
File without changes
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { UserEvent } from '../setup';
|
|
2
|
+
export declare function click(this: UserEvent, element: Element): Promise<void>;
|
|
3
|
+
export declare function dblClick(this: UserEvent, element: Element): Promise<void>;
|
|
4
|
+
export declare function tripleClick(this: UserEvent, element: Element): Promise<void>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const isPrepared: unique symbol;
|
|
2
|
+
declare global {
|
|
3
|
+
interface Node {
|
|
4
|
+
[isPrepared]?: typeof isPrepared;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare function prepareDocument(document: Document): void;
|
|
8
|
+
export { getUIValue, setUIValue, startTrackValue, endTrackValue } from './value';
|
|
9
|
+
export { getUISelection, setUISelection } from './selection';
|
|
10
|
+
export type { UISelectionRange } from './selection';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare type anyFunc = (...a: any[]) => any;
|
|
2
|
+
declare type Params<Prop> = Prop extends anyFunc ? Parameters<Prop> : [Prop];
|
|
3
|
+
declare type ImplReturn<Prop> = Prop extends anyFunc ? Parameters<Prop> : Prop;
|
|
4
|
+
export declare function prepareInterceptor<ElementType extends Node, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => {
|
|
5
|
+
/**
|
|
6
|
+
* React tracks the changes on element properties.
|
|
7
|
+
* This workaround tries to alter the DOM element without React noticing,
|
|
8
|
+
* so that it later picks up the change.
|
|
9
|
+
*
|
|
10
|
+
* @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104
|
|
11
|
+
*/
|
|
12
|
+
applyNative?: boolean;
|
|
13
|
+
realArgs?: ImplReturn<ElementType[PropName]>;
|
|
14
|
+
}): void;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
declare const UISelection: unique symbol;
|
|
2
|
+
export interface UISelectionRange {
|
|
3
|
+
startOffset: number;
|
|
4
|
+
endOffset: number;
|
|
5
|
+
}
|
|
6
|
+
export interface UISelection {
|
|
7
|
+
anchorOffset: number;
|
|
8
|
+
focusOffset: number;
|
|
9
|
+
}
|
|
10
|
+
declare global {
|
|
11
|
+
interface Element {
|
|
12
|
+
[UISelection]?: UISelection;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export declare function prepareSelectionInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
16
|
+
export declare function setUISelection(element: HTMLInputElement | HTMLTextAreaElement, { focusOffset: focusOffsetParam, anchorOffset: anchorOffsetParam, }: {
|
|
17
|
+
anchorOffset?: number;
|
|
18
|
+
focusOffset: number;
|
|
19
|
+
}, mode?: 'replace' | 'modify'): void;
|
|
20
|
+
export declare function getUISelection(element: HTMLInputElement | HTMLTextAreaElement): {
|
|
21
|
+
startOffset: number;
|
|
22
|
+
endOffset: number;
|
|
23
|
+
anchorOffset: number;
|
|
24
|
+
focusOffset: number;
|
|
25
|
+
};
|
|
26
|
+
export declare function clearUISelection(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare const UIValue: unique symbol;
|
|
2
|
+
declare const InitialValue: unique symbol;
|
|
3
|
+
declare const TrackChanges: unique symbol;
|
|
4
|
+
declare global {
|
|
5
|
+
interface Element {
|
|
6
|
+
[UIValue]?: string;
|
|
7
|
+
[InitialValue]?: string;
|
|
8
|
+
[TrackChanges]?: string[];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare function prepareValueInterceptor(element: HTMLInputElement): void;
|
|
12
|
+
export declare function setUIValue(element: HTMLInputElement | HTMLTextAreaElement, value: string): void;
|
|
13
|
+
export declare function getUIValue(element: HTMLInputElement | HTMLTextAreaElement): string;
|
|
14
|
+
export declare function setInitialValue(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
15
|
+
export declare function getInitialValue(element: HTMLInputElement | HTMLTextAreaElement): string | undefined;
|
|
16
|
+
export declare function startTrackValue(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
17
|
+
export declare function endTrackValue(element: HTMLInputElement | HTMLTextAreaElement): string[] | undefined;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UserEvent } from '../setup';
|
|
2
|
+
import { releaseAllKeys } from './keyboardAction';
|
|
3
|
+
import type { keyboardState, keyboardKey } from './types';
|
|
4
|
+
export { releaseAllKeys };
|
|
5
|
+
export type { keyboardKey, keyboardState };
|
|
6
|
+
export declare function keyboard(this: UserEvent, text: string): Promise<void>;
|
|
7
|
+
export declare function createKeyboardState(): keyboardState;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Config } from '../setup';
|
|
2
|
+
import { keyboardKey } from './types';
|
|
3
|
+
export interface KeyboardAction {
|
|
4
|
+
keyDef: keyboardKey;
|
|
5
|
+
releasePrevious: boolean;
|
|
6
|
+
releaseSelf: boolean;
|
|
7
|
+
repeat: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function keyboardAction(config: Config, actions: KeyboardAction[]): Promise<void>;
|
|
10
|
+
export declare function releaseAllKeys(config: Config): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { keyboardKey } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Parse key defintions per `keyboardMap`
|
|
4
|
+
*
|
|
5
|
+
* Keys can be referenced by `{key}` or `{special}` as well as physical locations per `[code]`.
|
|
6
|
+
* Everything else will be interpreted as a typed character - e.g. `a`.
|
|
7
|
+
* Brackets `{` and `[` can be escaped by doubling - e.g. `foo[[bar` translates to `foo[bar`.
|
|
8
|
+
* Keeping the key pressed can be written as `{key>}`.
|
|
9
|
+
* When keeping the key pressed you can choose how long (how many keydown and keypress) the key is pressed `{key>3}`.
|
|
10
|
+
* You can then release the key per `{key>3/}` or keep it pressed and continue with the next key.
|
|
11
|
+
*/
|
|
12
|
+
export declare function parseKeyDef(keyboardMap: keyboardKey[], text: string): {
|
|
13
|
+
keyDef: keyboardKey;
|
|
14
|
+
releasePrevious: boolean;
|
|
15
|
+
releaseSelf: boolean;
|
|
16
|
+
repeat: number;
|
|
17
|
+
}[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file should contain behavior for functional keys as described here:
|
|
3
|
+
* https://w3c.github.io/uievents-code/#key-alphanumeric-functional
|
|
4
|
+
*/
|
|
5
|
+
import { behaviorPlugin } from '../types';
|
|
6
|
+
export declare const keydownBehavior: behaviorPlugin[];
|
|
7
|
+
export declare const keypressBehavior: behaviorPlugin[];
|
|
8
|
+
export declare const keyupBehavior: behaviorPlugin[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { behaviorPlugin } from '../types';
|
|
2
|
+
export declare const preKeydownBehavior: behaviorPlugin[];
|
|
3
|
+
export declare const keydownBehavior: behaviorPlugin[];
|
|
4
|
+
export declare const keypressBehavior: behaviorPlugin[];
|
|
5
|
+
export declare const preKeyupBehavior: behaviorPlugin[];
|
|
6
|
+
export declare const keyupBehavior: behaviorPlugin[];
|
|
7
|
+
export declare const postKeyupBehavior: behaviorPlugin[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file should contain behavior for modifier keys:
|
|
3
|
+
* https://www.w3.org/TR/uievents-key/#keys-modifier
|
|
4
|
+
*/
|
|
5
|
+
import { behaviorPlugin } from '../types';
|
|
6
|
+
export declare const preKeydownBehavior: behaviorPlugin[];
|
|
7
|
+
export declare const preKeyupBehavior: behaviorPlugin[];
|
|
8
|
+
export declare const postKeyupBehavior: behaviorPlugin[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './fireChangeForInputTimeIfValid';
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Config } from '../setup';
|
|
2
|
+
/**
|
|
3
|
+
* @internal Do not create/alter this by yourself as this type might be subject to changes.
|
|
4
|
+
*/
|
|
5
|
+
export declare type keyboardState = {
|
|
6
|
+
/**
|
|
7
|
+
All keys that have been pressed and not been lifted up yet.
|
|
8
|
+
*/
|
|
9
|
+
pressed: {
|
|
10
|
+
keyDef: keyboardKey;
|
|
11
|
+
unpreventedDefault: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
/**
|
|
14
|
+
Active modifiers
|
|
15
|
+
*/
|
|
16
|
+
modifiers: {
|
|
17
|
+
Alt: boolean;
|
|
18
|
+
AltGraph: boolean;
|
|
19
|
+
CapsLock: boolean;
|
|
20
|
+
Control: boolean;
|
|
21
|
+
Fn: boolean;
|
|
22
|
+
FnLock: boolean;
|
|
23
|
+
Meta: boolean;
|
|
24
|
+
NumLock: boolean;
|
|
25
|
+
ScrollLock: boolean;
|
|
26
|
+
Shift: boolean;
|
|
27
|
+
Symbol: boolean;
|
|
28
|
+
SymbolLock: boolean;
|
|
29
|
+
};
|
|
30
|
+
modifierPhase: {
|
|
31
|
+
CapsLock?: boolean;
|
|
32
|
+
FnLock?: boolean;
|
|
33
|
+
NumLock?: boolean;
|
|
34
|
+
ScrollLock?: boolean;
|
|
35
|
+
SymbolLock?: boolean;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
The element the keyboard input is performed on.
|
|
39
|
+
Some behavior might differ if the activeElement changes between corresponding keyboard events.
|
|
40
|
+
*/
|
|
41
|
+
activeElement: Element | null;
|
|
42
|
+
/**
|
|
43
|
+
For HTMLInputElements type='number':
|
|
44
|
+
If the last input char is '.', '-' or 'e',
|
|
45
|
+
the IDL value attribute does not reflect the input value.
|
|
46
|
+
|
|
47
|
+
@deprecated The document state workaround in `src/document/value.ts` keeps track
|
|
48
|
+
of UI value diverging from value property.
|
|
49
|
+
*/
|
|
50
|
+
carryValue?: string;
|
|
51
|
+
/**
|
|
52
|
+
Carry over characters to following key handlers.
|
|
53
|
+
E.g. ^1
|
|
54
|
+
*/
|
|
55
|
+
carryChar: string;
|
|
56
|
+
};
|
|
57
|
+
export declare enum DOM_KEY_LOCATION {
|
|
58
|
+
STANDARD = 0,
|
|
59
|
+
LEFT = 1,
|
|
60
|
+
RIGHT = 2,
|
|
61
|
+
NUMPAD = 3
|
|
62
|
+
}
|
|
63
|
+
export interface keyboardKey {
|
|
64
|
+
/** Physical location on a keyboard */
|
|
65
|
+
code?: string;
|
|
66
|
+
/** Character or functional key descriptor */
|
|
67
|
+
key?: string;
|
|
68
|
+
/** Location on the keyboard for keys with multiple representation */
|
|
69
|
+
location?: DOM_KEY_LOCATION;
|
|
70
|
+
/** Does the character in `key` require/imply AltRight to be pressed? */
|
|
71
|
+
altGr?: boolean;
|
|
72
|
+
/** Does the character in `key` require/imply a shiftKey to be pressed? */
|
|
73
|
+
shift?: boolean;
|
|
74
|
+
}
|
|
75
|
+
export interface behaviorPlugin {
|
|
76
|
+
matches: (keyDef: keyboardKey, element: Element, config: Config) => boolean;
|
|
77
|
+
handle: (keyDef: keyboardKey, element: Element, config: Config) => void;
|
|
78
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { keyboardKey } from './keyboard/types';
|
|
2
|
+
import type { pointerKey } from './pointer/types';
|
|
3
|
+
export interface Options {
|
|
4
|
+
/**
|
|
5
|
+
* When using `userEvent.upload`, automatically discard files
|
|
6
|
+
* that don't match an `accept` property if it exists.
|
|
7
|
+
*
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
applyAccept?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* We intend to automatically apply modifier keys for printable characters in the future.
|
|
13
|
+
* I.e. `A` implying `{Shift>}a{/Shift}` if caps lock is not active.
|
|
14
|
+
*
|
|
15
|
+
* This options allows you to opt out of this change in foresight.
|
|
16
|
+
* The feature therefore will not constitute a breaking change.
|
|
17
|
+
*
|
|
18
|
+
* @default true
|
|
19
|
+
*/
|
|
20
|
+
autoModify?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Between some subsequent inputs like typing a series of characters
|
|
23
|
+
* the code execution is delayed per `setTimeout` for (at least) `delay` seconds.
|
|
24
|
+
* This moves the next changes at least to next macro task
|
|
25
|
+
* and allows other (asynchronous) code to run between events.
|
|
26
|
+
*
|
|
27
|
+
* `null` prevents `setTimeout` from being called.
|
|
28
|
+
*
|
|
29
|
+
* @default 0
|
|
30
|
+
*/
|
|
31
|
+
delay?: number | null;
|
|
32
|
+
/**
|
|
33
|
+
* The document.
|
|
34
|
+
*
|
|
35
|
+
* This defaults to the owner document of an element if an API is called directly with an element and without setup.
|
|
36
|
+
* Otherwise it falls back to the global document.
|
|
37
|
+
*
|
|
38
|
+
* @default element.ownerDocument??global.document
|
|
39
|
+
*/
|
|
40
|
+
document?: Document;
|
|
41
|
+
/**
|
|
42
|
+
* An array of keyboard keys the keyboard device consists of.
|
|
43
|
+
*
|
|
44
|
+
* This allows to plug in different layouts / localizations.
|
|
45
|
+
*
|
|
46
|
+
* Defaults to a "standard" US-104-QWERTY keyboard.
|
|
47
|
+
*/
|
|
48
|
+
keyboardMap?: keyboardKey[];
|
|
49
|
+
/**
|
|
50
|
+
* An array of available pointer keys.
|
|
51
|
+
*
|
|
52
|
+
* This allows to plug in different pointer devices.
|
|
53
|
+
*/
|
|
54
|
+
pointerMap?: pointerKey[];
|
|
55
|
+
/**
|
|
56
|
+
* `userEvent.type` automatically releases any keys still pressed at the end of the call.
|
|
57
|
+
* This option allows to opt out of this feature.
|
|
58
|
+
*
|
|
59
|
+
* @default false
|
|
60
|
+
*/
|
|
61
|
+
skipAutoClose?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* `userEvent.type` implys a click at the end of the element content/value.
|
|
64
|
+
* This option allows to opt out of this feature.
|
|
65
|
+
*
|
|
66
|
+
* @default false
|
|
67
|
+
*/
|
|
68
|
+
skipClick?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* `userEvent.click` implys moving the cursor to the target element first.
|
|
71
|
+
* This options allows to opt out of this feature.
|
|
72
|
+
*
|
|
73
|
+
* @default false
|
|
74
|
+
*/
|
|
75
|
+
skipHover?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Calling pointer related APIs on an element triggers a check if that element can receive pointer events.
|
|
78
|
+
* This check is known to be expensive.
|
|
79
|
+
* This option allows to skip the check.
|
|
80
|
+
*
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
skipPointerEventsCheck?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Write selected data to Clipboard API when a `cut` or `copy` is triggered.
|
|
86
|
+
*
|
|
87
|
+
* The Clipboard API is usually not available to test code.
|
|
88
|
+
* Our `setup` replaces the `navigator.clipboard` property with a stub.
|
|
89
|
+
*
|
|
90
|
+
* Defaults to `false` when calling the APIs directly.
|
|
91
|
+
* Defaults to `true` when calling the APIs per `setup`.
|
|
92
|
+
*/
|
|
93
|
+
writeToClipboard?: boolean;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Default options applied when API is called per `userEvent.anyApi()`
|
|
97
|
+
*/
|
|
98
|
+
export declare const defaultOptionsDirect: Required<Options>;
|
|
99
|
+
/**
|
|
100
|
+
* Default options applied when API is called per `userEvent().anyApi()`
|
|
101
|
+
*/
|
|
102
|
+
export declare const defaultOptionsSetup: Required<Options>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { UserEvent } 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: UserEvent, input: PointerInput): Promise<void>;
|
|
10
|
+
export declare function createPointerState(document: Document): pointerState;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Config } from '../setup';
|
|
2
|
+
import { PointerMoveAction } from './pointerMove';
|
|
3
|
+
import { PointerPressAction } from './pointerPress';
|
|
4
|
+
import { PointerTarget, SelectionTarget } from './types';
|
|
5
|
+
export declare type PointerActionTarget = Partial<PointerTarget> & Partial<SelectionTarget>;
|
|
6
|
+
export declare type PointerAction = PointerActionTarget & (Omit<PointerPressAction, 'target' | 'coords'> | Omit<PointerMoveAction, 'target' | 'coords'>);
|
|
7
|
+
export declare function pointerAction(config: Config, actions: PointerAction[]): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { inputDeviceState } from '../setup';
|
|
2
|
+
import { PointerTarget, SelectionTarget } from './types';
|
|
3
|
+
export interface PointerMoveAction extends PointerTarget, SelectionTarget {
|
|
4
|
+
pointerName?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function pointerMove({ pointerName, target, coords, node, offset }: PointerMoveAction, { pointerState, keyboardState }: inputDeviceState): Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { inputDeviceState } 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(action: PointerPressAction, state: inputDeviceState): Promise<void>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { PointerCoords, MouseButton } from '../utils';
|
|
2
|
+
/**
|
|
3
|
+
* @internal Do not create/alter this by yourself as this type might be subject to changes.
|
|
4
|
+
*/
|
|
5
|
+
export declare type pointerState = {
|
|
6
|
+
/**
|
|
7
|
+
All keys that have been pressed and not been lifted up yet.
|
|
8
|
+
*/
|
|
9
|
+
pressed: {
|
|
10
|
+
keyDef: pointerKey;
|
|
11
|
+
pointerId: number;
|
|
12
|
+
isMultiTouch: boolean;
|
|
13
|
+
isPrimary: boolean;
|
|
14
|
+
clickCount: number;
|
|
15
|
+
unpreventedDefault: boolean;
|
|
16
|
+
/** Target the key was pressed on */
|
|
17
|
+
downTarget: Element;
|
|
18
|
+
}[];
|
|
19
|
+
activeClickCount?: [string, number];
|
|
20
|
+
/**
|
|
21
|
+
* Position of each pointer.
|
|
22
|
+
* The mouse is always pointer 1 and keeps its position.
|
|
23
|
+
* Pen and touch devices receive a new pointerId for every interaction.
|
|
24
|
+
*/
|
|
25
|
+
position: Record<string, {
|
|
26
|
+
pointerId: number;
|
|
27
|
+
pointerType: 'mouse' | 'pen' | 'touch';
|
|
28
|
+
} & Partial<PointerTarget> & {
|
|
29
|
+
selectionRange?: Range | SelectionInputRange;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* Last applied pointer id
|
|
33
|
+
*/
|
|
34
|
+
pointerId: number;
|
|
35
|
+
};
|
|
36
|
+
export interface pointerKey {
|
|
37
|
+
/** Name of the pointer key */
|
|
38
|
+
name: string;
|
|
39
|
+
/** Type of the pointer device */
|
|
40
|
+
pointerType: 'mouse' | 'pen' | 'touch';
|
|
41
|
+
/** Type of button */
|
|
42
|
+
button?: MouseButton;
|
|
43
|
+
}
|
|
44
|
+
export interface PointerTarget {
|
|
45
|
+
target: Element;
|
|
46
|
+
coords?: PointerCoords;
|
|
47
|
+
}
|
|
48
|
+
export interface SelectionTarget {
|
|
49
|
+
node?: Node;
|
|
50
|
+
/**
|
|
51
|
+
* If `node` is set, this is the DOM offset.
|
|
52
|
+
* Otherwise this is the `textContent`/`value` offset on the `target`.
|
|
53
|
+
*/
|
|
54
|
+
offset?: number;
|
|
55
|
+
}
|
|
56
|
+
/** Describes a selection inside `HTMLInputElement`/`HTMLTextareaElement` */
|
|
57
|
+
export interface SelectionInputRange {
|
|
58
|
+
node: HTMLInputElement | HTMLTextAreaElement;
|
|
59
|
+
start: number;
|
|
60
|
+
end: number;
|
|
61
|
+
}
|
|
@@ -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,20 @@
|
|
|
1
|
+
import type { PointerOptions } from '../utils';
|
|
2
|
+
import type { PointerInput } from '../pointer';
|
|
3
|
+
import type { UserEventApi } from '.';
|
|
4
|
+
import { Config } from './config';
|
|
5
|
+
export declare function clear(element: Element): Promise<void>;
|
|
6
|
+
export declare function click(element: Element, options?: Partial<Config>): Promise<void>;
|
|
7
|
+
export declare function copy(options?: Partial<Config>): Promise<DataTransfer | undefined>;
|
|
8
|
+
export declare function cut(options?: Partial<Config>): Promise<DataTransfer | undefined>;
|
|
9
|
+
export declare function dblClick(element: Element, options?: Partial<Config>): Promise<void>;
|
|
10
|
+
export declare function deselectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
|
|
11
|
+
export declare function hover(element: Element, options?: Partial<Config>): Promise<void>;
|
|
12
|
+
export declare function keyboard(text: string, options?: Partial<Config>): Promise<import("../keyboard").keyboardState>;
|
|
13
|
+
export declare function pointer(input: PointerInput, options?: Partial<Config>): Promise<import("../pointer").pointerState>;
|
|
14
|
+
export declare function paste(clipboardData?: DataTransfer | string, options?: Partial<Config>): Promise<void>;
|
|
15
|
+
export declare function selectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
|
|
16
|
+
export declare function tripleClick(element: Element, options?: Partial<Config>): Promise<void>;
|
|
17
|
+
export declare function type(element: Element, text: string, options?: Partial<Config> & Parameters<UserEventApi['type']>[2]): Promise<void>;
|
|
18
|
+
export declare function unhover(element: Element, options?: PointerOptions): Promise<void>;
|
|
19
|
+
export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?: Partial<Config>): Promise<void>;
|
|
20
|
+
export declare function tab(options?: Partial<Config> & Parameters<UserEventApi['tab']>[0]): Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type * as userEventApi from './api';
|
|
2
|
+
import { setupMain, setupSub } from './setup';
|
|
3
|
+
import { Config, inputDeviceState } from './config';
|
|
4
|
+
import * as directApi from './directApi';
|
|
5
|
+
export type { inputDeviceState };
|
|
6
|
+
export { Config };
|
|
7
|
+
export declare type UserEventApi = typeof userEventApi;
|
|
8
|
+
export declare type UserEvent = UserEventApi & {
|
|
9
|
+
readonly setup: typeof setupSub;
|
|
10
|
+
[Config]: Config;
|
|
11
|
+
};
|
|
12
|
+
export declare const userEvent: {
|
|
13
|
+
readonly setup: typeof setupMain;
|
|
14
|
+
readonly clear: typeof directApi.clear;
|
|
15
|
+
readonly click: typeof directApi.click;
|
|
16
|
+
readonly copy: typeof directApi.copy;
|
|
17
|
+
readonly cut: typeof directApi.cut;
|
|
18
|
+
readonly dblClick: typeof directApi.dblClick;
|
|
19
|
+
readonly deselectOptions: typeof directApi.deselectOptions;
|
|
20
|
+
readonly hover: typeof directApi.hover;
|
|
21
|
+
readonly keyboard: typeof directApi.keyboard;
|
|
22
|
+
readonly pointer: typeof directApi.pointer;
|
|
23
|
+
readonly paste: typeof directApi.paste;
|
|
24
|
+
readonly selectOptions: typeof directApi.selectOptions;
|
|
25
|
+
readonly tripleClick: typeof directApi.tripleClick;
|
|
26
|
+
readonly type: typeof directApi.type;
|
|
27
|
+
readonly unhover: typeof directApi.unhover;
|
|
28
|
+
readonly upload: typeof directApi.upload;
|
|
29
|
+
readonly tab: typeof directApi.tab;
|
|
30
|
+
};
|