@testing-library/user-event 14.3.0 → 14.4.0
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/cjs/clipboard/copy.js +40 -0
- package/dist/cjs/clipboard/cut.js +40 -0
- package/dist/cjs/clipboard/index.js +13 -0
- package/dist/cjs/clipboard/paste.js +41 -0
- package/dist/cjs/convenience/click.js +40 -0
- package/dist/cjs/convenience/hover.js +37 -0
- package/dist/cjs/convenience/index.js +16 -0
- package/dist/cjs/convenience/tab.js +9 -0
- package/dist/cjs/document/index.js +74 -0
- package/dist/cjs/document/interceptor.js +30 -0
- package/dist/cjs/document/selection.js +107 -0
- package/dist/cjs/document/setRangeText.js +21 -0
- package/dist/cjs/document/value.js +125 -0
- package/dist/cjs/event/behavior/click.js +42 -0
- package/dist/cjs/event/behavior/cut.js +26 -0
- package/dist/cjs/event/behavior/index.js +15 -0
- package/dist/cjs/event/behavior/keydown.js +134 -0
- package/dist/cjs/event/behavior/keypress.js +58 -0
- package/dist/cjs/event/behavior/keyup.js +24 -0
- package/dist/cjs/event/behavior/paste.js +29 -0
- package/dist/cjs/event/behavior/registry.js +7 -0
- package/dist/cjs/event/createEvent.js +193 -0
- package/dist/cjs/event/dispatchEvent.js +37 -0
- package/dist/cjs/event/dom-events.d.js +2 -0
- package/dist/cjs/event/eventMap.js +64 -0
- package/dist/cjs/event/index.js +24 -0
- package/dist/cjs/event/types.js +2 -0
- package/dist/cjs/event/wrapEvent.js +11 -0
- package/dist/cjs/index.js +14 -0
- package/dist/cjs/keyboard/index.js +59 -0
- package/dist/cjs/keyboard/keyMap.js +158 -0
- package/dist/cjs/keyboard/parseKeyDef.js +58 -0
- package/dist/cjs/options.js +42 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/pointer/index.js +88 -0
- package/dist/cjs/pointer/keyMap.js +35 -0
- package/dist/cjs/pointer/parseKeyDef.js +39 -0
- package/dist/cjs/setup/api.js +35 -0
- package/dist/cjs/setup/config.js +7 -0
- package/dist/cjs/setup/directApi.js +77 -0
- package/dist/cjs/setup/index.js +15 -0
- package/dist/cjs/setup/setup.js +97 -0
- package/dist/cjs/setup/wrapAsync.js +13 -0
- package/dist/cjs/system/index.js +31 -0
- package/dist/cjs/system/keyboard.js +135 -0
- package/dist/cjs/system/pointer/buttons.js +71 -0
- package/dist/cjs/system/pointer/device.js +21 -0
- package/dist/cjs/system/pointer/index.js +146 -0
- package/dist/cjs/system/pointer/mouse.js +186 -0
- package/dist/cjs/system/pointer/pointer.js +114 -0
- package/dist/cjs/utility/clear.js +42 -0
- package/dist/cjs/utility/index.js +16 -0
- package/dist/cjs/utility/selectOptions.js +125 -0
- package/dist/cjs/utility/type.js +41 -0
- package/dist/cjs/utility/upload.js +72 -0
- package/dist/cjs/utils/click/isClickableInput.js +22 -0
- package/dist/cjs/utils/dataTransfer/Blob.js +18 -0
- package/dist/cjs/utils/dataTransfer/Clipboard.js +168 -0
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +124 -0
- package/dist/cjs/utils/dataTransfer/FileList.js +26 -0
- package/dist/cjs/utils/edit/buildTimeValue.js +36 -0
- package/dist/cjs/utils/edit/getValue.js +35 -0
- package/dist/cjs/utils/edit/input.js +162 -0
- package/dist/cjs/utils/edit/isContentEditable.js +20 -0
- package/dist/cjs/utils/edit/isEditable.js +35 -0
- package/dist/cjs/utils/edit/isValidDateOrTimeValue.js +11 -0
- package/dist/cjs/utils/edit/maxLength.js +38 -0
- package/dist/cjs/utils/edit/setFiles.js +59 -0
- package/dist/cjs/utils/edit/walkRadio.js +28 -0
- package/dist/cjs/utils/focus/blur.js +16 -0
- package/dist/cjs/utils/focus/copySelection.js +46 -0
- package/dist/cjs/utils/focus/cursor.js +143 -0
- package/dist/cjs/utils/focus/focus.js +26 -0
- package/dist/cjs/utils/focus/getActiveElement.js +24 -0
- package/dist/cjs/utils/focus/getTabDestination.js +82 -0
- package/dist/cjs/utils/focus/isFocusable.js +11 -0
- package/dist/cjs/utils/focus/resolveCaretPosition.js +78 -0
- package/dist/cjs/utils/focus/selectAll.js +54 -0
- package/dist/cjs/utils/focus/selection.js +287 -0
- package/dist/cjs/utils/focus/selector.js +16 -0
- package/dist/cjs/utils/index.js +108 -0
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +92 -0
- package/dist/cjs/utils/misc/cloneEvent.js +9 -0
- package/dist/cjs/utils/misc/dom-helpers.d.js +2 -0
- package/dist/cjs/utils/misc/eventWrapper.js +15 -0
- package/dist/cjs/utils/misc/findClosest.js +16 -0
- package/dist/cjs/utils/misc/getDocumentFromNode.js +12 -0
- package/dist/cjs/utils/misc/getTreeDiff.js +27 -0
- package/dist/cjs/utils/misc/getWindow.js +11 -0
- package/dist/cjs/utils/misc/isDescendantOrSelf.js +16 -0
- package/dist/cjs/utils/misc/isDisabled.js +34 -0
- package/dist/cjs/utils/misc/isElementType.js +22 -0
- package/dist/cjs/utils/misc/isVisible.js +21 -0
- package/dist/cjs/utils/misc/level.js +20 -0
- package/dist/cjs/utils/misc/wait.js +16 -0
- package/dist/cjs/utils/pointer/cssPointerEvents.js +111 -0
- package/dist/esm/clipboard/copy.js +36 -0
- package/dist/esm/clipboard/cut.js +36 -0
- package/dist/esm/clipboard/index.js +3 -0
- package/dist/esm/clipboard/paste.js +37 -0
- package/dist/esm/convenience/click.js +34 -0
- package/dist/esm/convenience/hover.js +32 -0
- package/dist/esm/convenience/index.js +3 -0
- package/dist/esm/convenience/tab.js +5 -0
- package/dist/esm/document/index.js +66 -0
- package/dist/esm/document/interceptor.js +26 -0
- package/dist/esm/document/selection.js +99 -0
- package/dist/esm/document/setRangeText.js +17 -0
- package/dist/esm/document/value.js +115 -0
- package/dist/esm/event/behavior/click.js +40 -0
- package/dist/esm/event/behavior/cut.js +24 -0
- package/dist/esm/event/behavior/index.js +7 -0
- package/dist/esm/event/behavior/keydown.js +132 -0
- package/dist/esm/event/behavior/keypress.js +56 -0
- package/dist/esm/event/behavior/keyup.js +22 -0
- package/dist/esm/event/behavior/paste.js +27 -0
- package/dist/esm/event/behavior/registry.js +3 -0
- package/dist/esm/event/createEvent.js +189 -0
- package/dist/esm/event/dispatchEvent.js +33 -0
- package/dist/esm/event/dom-events.d.js +1 -0
- package/dist/esm/event/eventMap.js +57 -0
- package/dist/esm/event/index.js +19 -0
- package/dist/esm/event/types.js +1 -0
- package/dist/esm/event/wrapEvent.js +7 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/keyboard/index.js +54 -0
- package/dist/esm/keyboard/keyMap.js +154 -0
- package/dist/esm/keyboard/parseKeyDef.js +54 -0
- package/dist/esm/options.js +37 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/pointer/index.js +84 -0
- package/dist/esm/pointer/keyMap.js +31 -0
- package/dist/esm/pointer/parseKeyDef.js +35 -0
- package/dist/esm/setup/api.js +12 -0
- package/dist/esm/setup/config.js +3 -0
- package/dist/esm/setup/directApi.js +58 -0
- package/dist/esm/setup/index.js +10 -0
- package/dist/esm/setup/setup.js +90 -0
- package/dist/esm/setup/wrapAsync.js +9 -0
- package/dist/esm/system/index.js +27 -0
- package/dist/esm/system/keyboard.js +131 -0
- package/dist/esm/system/pointer/buttons.js +63 -0
- package/dist/esm/system/pointer/device.js +17 -0
- package/dist/esm/system/pointer/index.js +141 -0
- package/dist/esm/system/pointer/mouse.js +182 -0
- package/dist/esm/system/pointer/pointer.js +110 -0
- package/dist/esm/utility/clear.js +38 -0
- package/dist/esm/utility/index.js +4 -0
- package/dist/esm/utility/selectOptions.js +120 -0
- package/dist/esm/utility/type.js +37 -0
- package/dist/esm/utility/upload.js +68 -0
- package/dist/esm/utils/click/isClickableInput.js +18 -0
- package/dist/esm/utils/dataTransfer/Blob.js +14 -0
- package/dist/esm/utils/dataTransfer/Clipboard.js +159 -0
- package/dist/esm/utils/dataTransfer/DataTransfer.js +119 -0
- package/dist/esm/utils/dataTransfer/FileList.js +22 -0
- package/dist/esm/utils/edit/buildTimeValue.js +32 -0
- package/dist/esm/utils/edit/getValue.js +31 -0
- package/dist/esm/utils/edit/input.js +158 -0
- package/dist/esm/utils/edit/isContentEditable.js +15 -0
- package/dist/esm/utils/edit/isEditable.js +30 -0
- package/dist/esm/utils/edit/isValidDateOrTimeValue.js +7 -0
- package/dist/esm/utils/edit/maxLength.js +34 -0
- package/dist/esm/utils/edit/setFiles.js +55 -0
- package/dist/esm/utils/edit/walkRadio.js +24 -0
- package/dist/esm/utils/focus/blur.js +12 -0
- package/dist/esm/utils/focus/copySelection.js +42 -0
- package/dist/esm/utils/focus/cursor.js +139 -0
- package/dist/esm/utils/focus/focus.js +22 -0
- package/dist/esm/utils/focus/getActiveElement.js +19 -0
- package/dist/esm/utils/focus/getTabDestination.js +78 -0
- package/dist/esm/utils/focus/isFocusable.js +7 -0
- package/dist/esm/utils/focus/resolveCaretPosition.js +74 -0
- package/dist/esm/utils/focus/selectAll.js +49 -0
- package/dist/esm/utils/focus/selection.js +274 -0
- package/dist/esm/utils/focus/selector.js +12 -0
- package/dist/esm/utils/index.js +36 -0
- package/dist/esm/utils/keyDef/readNextDescriptor.js +88 -0
- package/dist/esm/utils/misc/cloneEvent.js +5 -0
- package/dist/esm/utils/misc/dom-helpers.d.js +1 -0
- package/dist/esm/utils/misc/eventWrapper.js +11 -0
- package/dist/esm/utils/misc/findClosest.js +12 -0
- package/dist/esm/utils/misc/getDocumentFromNode.js +8 -0
- package/dist/esm/utils/misc/getTreeDiff.js +23 -0
- package/dist/esm/utils/misc/getWindow.js +7 -0
- package/dist/esm/utils/misc/isDescendantOrSelf.js +12 -0
- package/dist/esm/utils/misc/isDisabled.js +30 -0
- package/dist/esm/utils/misc/isElementType.js +18 -0
- package/dist/esm/utils/misc/isVisible.js +17 -0
- package/dist/esm/utils/misc/level.js +15 -0
- package/dist/esm/utils/misc/wait.js +12 -0
- package/dist/esm/utils/pointer/cssPointerEvents.js +106 -0
- package/dist/types/event/createEvent.d.ts +2 -8
- package/dist/types/event/eventMap.d.ts +204 -181
- package/dist/types/event/index.d.ts +1 -2
- package/dist/types/event/types.d.ts +6 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/keyboard/index.d.ts +2 -6
- package/dist/types/keyboard/keyMap.d.ts +1 -1
- package/dist/types/keyboard/parseKeyDef.d.ts +1 -1
- package/dist/types/options.d.ts +4 -4
- package/dist/types/pointer/index.d.ts +23 -5
- package/dist/types/pointer/keyMap.d.ts +1 -1
- package/dist/types/pointer/parseKeyDef.d.ts +1 -1
- package/dist/types/setup/config.d.ts +3 -7
- package/dist/types/setup/directApi.d.ts +21 -16
- package/dist/types/setup/index.d.ts +1 -2
- package/dist/types/setup/setup.d.ts +7 -1
- package/dist/types/system/index.d.ts +10 -0
- package/dist/types/system/keyboard.d.ts +53 -0
- package/dist/types/system/pointer/buttons.d.ts +23 -0
- package/dist/types/system/pointer/device.d.ts +8 -0
- package/dist/types/system/pointer/index.d.ts +39 -0
- package/dist/types/system/pointer/mouse.d.ts +26 -0
- package/dist/types/system/pointer/pointer.d.ts +30 -0
- package/dist/types/utils/click/isClickableInput.d.ts +15 -1
- package/dist/types/utils/focus/getActiveElement.d.ts +1 -0
- package/dist/types/utils/focus/resolveCaretPosition.d.ts +8 -0
- package/dist/types/utils/focus/selection.d.ts +28 -1
- package/dist/types/utils/index.d.ts +2 -3
- package/dist/types/utils/misc/getTreeDiff.d.ts +1 -0
- package/package.json +9 -15
- package/dist/index.cjs +0 -3104
- package/dist/index.mjs +0 -3155
- package/dist/types/event/eventTypes.d.ts +0 -2
- package/dist/types/keyboard/keyboardAction.d.ts +0 -10
- package/dist/types/keyboard/modifiers.d.ts +0 -9
- package/dist/types/keyboard/types.d.ts +0 -73
- package/dist/types/pointer/firePointerEvents.d.ts +0 -11
- package/dist/types/pointer/pointerAction.d.ts +0 -7
- package/dist/types/pointer/pointerMove.d.ts +0 -6
- package/dist/types/pointer/pointerPress.d.ts +0 -8
- package/dist/types/pointer/resolveSelectionTarget.d.ts +0 -5
- package/dist/types/pointer/types.d.ts +0 -62
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +0 -5
- package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +0 -15
- package/dist/types/utils/pointer/mouseButtons.d.ts +0 -12
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { pointerKey } from '
|
|
1
|
+
import { pointerKey } from '../system/pointer';
|
|
2
2
|
export declare const defaultKeyMap: pointerKey[];
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type { keyboardState } from '../keyboard/types';
|
|
2
|
-
import type { pointerState } from '../pointer/types';
|
|
3
1
|
import type { Options } from '../options';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
export interface Config extends Required<Options>, inputDeviceState {
|
|
2
|
+
import { System } from '../system';
|
|
3
|
+
export interface Config extends Required<Options> {
|
|
4
|
+
system: System;
|
|
9
5
|
}
|
|
10
6
|
export declare const Config: unique symbol;
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
+
import type { Options } from '../options';
|
|
1
2
|
import type { PointerInput } from '../pointer';
|
|
3
|
+
import type { System } from '../system';
|
|
2
4
|
import type { UserEventApi } from '.';
|
|
3
|
-
|
|
5
|
+
export declare type DirectOptions = Options & {
|
|
6
|
+
keyboardState?: System;
|
|
7
|
+
pointerState?: System;
|
|
8
|
+
};
|
|
4
9
|
export declare function clear(element: Element): Promise<void>;
|
|
5
|
-
export declare function click(element: Element, options?:
|
|
6
|
-
export declare function copy(options?:
|
|
7
|
-
export declare function cut(options?:
|
|
8
|
-
export declare function dblClick(element: Element, options?:
|
|
9
|
-
export declare function deselectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?:
|
|
10
|
-
export declare function hover(element: Element, options?:
|
|
11
|
-
export declare function keyboard(text: string, options?:
|
|
12
|
-
export declare function pointer(input: PointerInput, options?:
|
|
13
|
-
export declare function paste(clipboardData?: DataTransfer | string, options?:
|
|
14
|
-
export declare function selectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?:
|
|
15
|
-
export declare function tripleClick(element: Element, options?:
|
|
16
|
-
export declare function type(element: Element, text: string, options?:
|
|
17
|
-
export declare function unhover(element: Element, options?:
|
|
18
|
-
export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?:
|
|
19
|
-
export declare function tab(options?:
|
|
10
|
+
export declare function click(element: Element, options?: DirectOptions): Promise<void>;
|
|
11
|
+
export declare function copy(options?: DirectOptions): Promise<DataTransfer | undefined>;
|
|
12
|
+
export declare function cut(options?: DirectOptions): Promise<DataTransfer | undefined>;
|
|
13
|
+
export declare function dblClick(element: Element, options?: DirectOptions): Promise<void>;
|
|
14
|
+
export declare function deselectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: DirectOptions): Promise<void>;
|
|
15
|
+
export declare function hover(element: Element, options?: DirectOptions): Promise<void>;
|
|
16
|
+
export declare function keyboard(text: string, options?: DirectOptions): Promise<System>;
|
|
17
|
+
export declare function pointer(input: PointerInput, options?: DirectOptions): Promise<System>;
|
|
18
|
+
export declare function paste(clipboardData?: DataTransfer | string, options?: DirectOptions): Promise<void>;
|
|
19
|
+
export declare function selectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: DirectOptions): Promise<void>;
|
|
20
|
+
export declare function tripleClick(element: Element, options?: DirectOptions): Promise<void>;
|
|
21
|
+
export declare function type(element: Element, text: string, options?: DirectOptions & Parameters<UserEventApi['type']>[2]): Promise<void>;
|
|
22
|
+
export declare function unhover(element: Element, options?: DirectOptions): Promise<void>;
|
|
23
|
+
export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?: DirectOptions): Promise<void>;
|
|
24
|
+
export declare function tab(options?: DirectOptions & Parameters<UserEventApi['tab']>[0]): Promise<void>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { bindDispatchUIEvent } from '../event';
|
|
2
2
|
import type * as userEventApi from './api';
|
|
3
3
|
import { setupMain, setupSub } from './setup';
|
|
4
|
-
import { Config
|
|
4
|
+
import { Config } from './config';
|
|
5
5
|
import * as directApi from './directApi';
|
|
6
|
-
export type { inputDeviceState };
|
|
7
6
|
export { Config };
|
|
8
7
|
export declare type UserEventApi = typeof userEventApi;
|
|
9
8
|
export declare type Instance = UserEventApi & {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Options } from '../options';
|
|
2
|
+
import { System } from '../system';
|
|
2
3
|
import type { Instance, UserEvent } from './index';
|
|
3
4
|
import { Config } from './config';
|
|
5
|
+
import { DirectOptions } from './directApi';
|
|
4
6
|
export declare function createConfig(options?: Partial<Config>, defaults?: Required<Options>, node?: Node): Config;
|
|
5
7
|
/**
|
|
6
8
|
* Start a "session" with userEvent.
|
|
@@ -10,7 +12,11 @@ export declare function setupMain(options?: Options): UserEvent;
|
|
|
10
12
|
/**
|
|
11
13
|
* Setup in direct call per `userEvent.anyApi()`
|
|
12
14
|
*/
|
|
13
|
-
export declare function setupDirect(options?:
|
|
15
|
+
export declare function setupDirect({ keyboardState, pointerState, ...options }?: DirectOptions & // backward-compatibility
|
|
16
|
+
{
|
|
17
|
+
keyboardState?: System;
|
|
18
|
+
pointerState?: System;
|
|
19
|
+
}, node?: Node): {
|
|
14
20
|
config: Config;
|
|
15
21
|
api: UserEvent;
|
|
16
22
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KeyboardHost } from './keyboard';
|
|
2
|
+
import { PointerHost } from './pointer';
|
|
3
|
+
/**
|
|
4
|
+
* @internal Do not create/alter this by yourself as this type might be subject to changes.
|
|
5
|
+
*/
|
|
6
|
+
export declare class System {
|
|
7
|
+
readonly keyboard: KeyboardHost;
|
|
8
|
+
readonly pointer: PointerHost;
|
|
9
|
+
getUIEventModifiers(): EventModifierInit;
|
|
10
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Config } from '../setup';
|
|
2
|
+
import type { System } from '.';
|
|
3
|
+
export declare enum DOM_KEY_LOCATION {
|
|
4
|
+
STANDARD = 0,
|
|
5
|
+
LEFT = 1,
|
|
6
|
+
RIGHT = 2,
|
|
7
|
+
NUMPAD = 3
|
|
8
|
+
}
|
|
9
|
+
export interface keyboardKey {
|
|
10
|
+
/** Physical location on a keyboard */
|
|
11
|
+
code?: string;
|
|
12
|
+
/** Character or functional key descriptor */
|
|
13
|
+
key?: string;
|
|
14
|
+
/** Location on the keyboard for keys with multiple representation */
|
|
15
|
+
location?: DOM_KEY_LOCATION;
|
|
16
|
+
/** Does the character in `key` require/imply AltRight to be pressed? */
|
|
17
|
+
altGr?: boolean;
|
|
18
|
+
/** Does the character in `key` require/imply a shiftKey to be pressed? */
|
|
19
|
+
shift?: boolean;
|
|
20
|
+
}
|
|
21
|
+
export declare class KeyboardHost {
|
|
22
|
+
readonly system: System;
|
|
23
|
+
constructor(system: System);
|
|
24
|
+
readonly modifiers: {
|
|
25
|
+
Alt: boolean;
|
|
26
|
+
AltGraph: boolean;
|
|
27
|
+
CapsLock: boolean;
|
|
28
|
+
Control: boolean;
|
|
29
|
+
Fn: boolean;
|
|
30
|
+
FnLock: boolean;
|
|
31
|
+
Meta: boolean;
|
|
32
|
+
NumLock: boolean;
|
|
33
|
+
ScrollLock: boolean;
|
|
34
|
+
Shift: boolean;
|
|
35
|
+
Symbol: boolean;
|
|
36
|
+
SymbolLock: boolean;
|
|
37
|
+
};
|
|
38
|
+
readonly pressed: Record<string, {
|
|
39
|
+
keyDef: keyboardKey;
|
|
40
|
+
unpreventedDefault: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
carryChar: string;
|
|
43
|
+
private lastKeydownTarget;
|
|
44
|
+
private readonly modifierLockStart;
|
|
45
|
+
isKeyPressed(keyDef: keyboardKey): boolean;
|
|
46
|
+
getPressedKeys(): keyboardKey[];
|
|
47
|
+
/** Press a key */
|
|
48
|
+
keydown(config: Config, keyDef: keyboardKey): Promise<void>;
|
|
49
|
+
/** Release a key */
|
|
50
|
+
keyup(config: Config, keyDef: keyboardKey): Promise<void>;
|
|
51
|
+
private setKeydownTarget;
|
|
52
|
+
private hasKeyPress;
|
|
53
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { pointerKey } from '.';
|
|
2
|
+
export declare class Buttons {
|
|
3
|
+
private readonly pressed;
|
|
4
|
+
getButtons(): number;
|
|
5
|
+
down(keyDef: pointerKey): number | undefined;
|
|
6
|
+
up(keyDef: pointerKey): number | undefined;
|
|
7
|
+
}
|
|
8
|
+
export declare const MouseButton: {
|
|
9
|
+
readonly primary: 0;
|
|
10
|
+
readonly secondary: 1;
|
|
11
|
+
readonly auxiliary: 2;
|
|
12
|
+
readonly back: 3;
|
|
13
|
+
readonly X1: 3;
|
|
14
|
+
readonly forward: 4;
|
|
15
|
+
readonly X2: 4;
|
|
16
|
+
};
|
|
17
|
+
export declare type MouseButton = keyof typeof MouseButton | number;
|
|
18
|
+
export declare function getMouseButtonId(button?: MouseButton): number;
|
|
19
|
+
export declare const MouseButtonFlip: {
|
|
20
|
+
readonly 1: 2;
|
|
21
|
+
readonly 2: 1;
|
|
22
|
+
};
|
|
23
|
+
export declare function getMouseEventButton(button?: MouseButton): number;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { System } from '..';
|
|
2
|
+
import { PointerCoords } from '../../event';
|
|
3
|
+
import { Config } from '../../setup';
|
|
4
|
+
import { MouseButton } from './buttons';
|
|
5
|
+
export interface pointerKey {
|
|
6
|
+
/** Name of the pointer key */
|
|
7
|
+
name: string;
|
|
8
|
+
/** Type of the pointer device */
|
|
9
|
+
pointerType: 'mouse' | 'pen' | 'touch';
|
|
10
|
+
/** Type of button */
|
|
11
|
+
button?: MouseButton;
|
|
12
|
+
}
|
|
13
|
+
export interface PointerPosition {
|
|
14
|
+
target?: Element;
|
|
15
|
+
coords?: PointerCoords;
|
|
16
|
+
caret?: CaretPosition;
|
|
17
|
+
}
|
|
18
|
+
export interface CaretPosition {
|
|
19
|
+
node?: Node;
|
|
20
|
+
offset?: number;
|
|
21
|
+
}
|
|
22
|
+
export declare class PointerHost {
|
|
23
|
+
readonly system: System;
|
|
24
|
+
constructor(system: System);
|
|
25
|
+
private readonly mouse;
|
|
26
|
+
private readonly buttons;
|
|
27
|
+
private readonly devices;
|
|
28
|
+
private readonly pointers;
|
|
29
|
+
isKeyPressed(keyDef: pointerKey): boolean;
|
|
30
|
+
press(config: Config, keyDef: pointerKey, position: PointerPosition): Promise<void>;
|
|
31
|
+
move(config: Config, pointerName: string, position: PointerPosition): Promise<void>;
|
|
32
|
+
release(config: Config, keyDef: pointerKey, position: PointerPosition): Promise<void>;
|
|
33
|
+
getPointerName(keyDef: pointerKey): string;
|
|
34
|
+
getPreviousPosition(pointerName: string): PointerPosition | undefined;
|
|
35
|
+
resetClickCount(): void;
|
|
36
|
+
getMouseTarget(config: Config): Element;
|
|
37
|
+
setMousePosition(position: PointerPosition): void;
|
|
38
|
+
}
|
|
39
|
+
export declare function isDifferentPointerPosition(positionA: PointerPosition, positionB: PointerPosition): boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Config } from '../../setup';
|
|
2
|
+
import { pointerKey, PointerPosition } from '.';
|
|
3
|
+
import type { Pointer } from './pointer';
|
|
4
|
+
/**
|
|
5
|
+
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Mouse {
|
|
8
|
+
position: PointerPosition;
|
|
9
|
+
private readonly buttons;
|
|
10
|
+
private selecting?;
|
|
11
|
+
private buttonDownTarget;
|
|
12
|
+
private readonly clickCount;
|
|
13
|
+
move(config: Config, position: PointerPosition): {
|
|
14
|
+
leave: () => void;
|
|
15
|
+
enter: () => void;
|
|
16
|
+
move: () => void;
|
|
17
|
+
} | undefined;
|
|
18
|
+
down(config: Config, keyDef: pointerKey, pointer: Pointer): void;
|
|
19
|
+
up(config: Config, keyDef: pointerKey, pointer: Pointer): void;
|
|
20
|
+
resetClickCount(): void;
|
|
21
|
+
private getEventInit;
|
|
22
|
+
private getTarget;
|
|
23
|
+
private startSelecting;
|
|
24
|
+
private modifySelecting;
|
|
25
|
+
private endSelecting;
|
|
26
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Config } from '../../setup';
|
|
2
|
+
import { pointerKey, PointerPosition } from '.';
|
|
3
|
+
declare type PointerInit = {
|
|
4
|
+
pointerId: number;
|
|
5
|
+
pointerType: string;
|
|
6
|
+
isPrimary: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare class Pointer {
|
|
9
|
+
constructor({ pointerId, pointerType, isPrimary }: PointerInit);
|
|
10
|
+
readonly pointerId: number;
|
|
11
|
+
readonly pointerType: string;
|
|
12
|
+
readonly isPrimary: boolean;
|
|
13
|
+
isMultitouch: boolean;
|
|
14
|
+
isCancelled: boolean;
|
|
15
|
+
isDown: boolean;
|
|
16
|
+
isPrevented: boolean;
|
|
17
|
+
position: PointerPosition;
|
|
18
|
+
init(config: Config, position: PointerPosition): this;
|
|
19
|
+
move(config: Config, position: PointerPosition): {
|
|
20
|
+
leave: () => void;
|
|
21
|
+
enter: () => void;
|
|
22
|
+
move: () => void;
|
|
23
|
+
} | undefined;
|
|
24
|
+
down(config: Config, _keyDef: pointerKey): void;
|
|
25
|
+
up(config: Config, _keyDef: pointerKey): void;
|
|
26
|
+
release(config: Config): void;
|
|
27
|
+
private getTarget;
|
|
28
|
+
private getEventInit;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
declare enum clickableInputTypes {
|
|
2
|
+
'button' = "button",
|
|
3
|
+
'color' = "color",
|
|
4
|
+
'file' = "file",
|
|
5
|
+
'image' = "image",
|
|
6
|
+
'reset' = "reset",
|
|
7
|
+
'submit' = "submit",
|
|
8
|
+
'checkbox' = "checkbox",
|
|
9
|
+
'radio' = "radio"
|
|
10
|
+
}
|
|
11
|
+
export declare type ClickableInputType = keyof typeof clickableInputTypes;
|
|
12
|
+
export declare function isClickableInput(element: Element): element is HTMLButtonElement | (HTMLInputElement & {
|
|
13
|
+
type: clickableInputTypes;
|
|
14
|
+
});
|
|
15
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UISelectionRange } from '../../document';
|
|
2
|
-
import { editableInputTypes } from '../edit/isEditable';
|
|
2
|
+
import { EditableInputType, editableInputTypes } from '../edit/isEditable';
|
|
3
3
|
/**
|
|
4
4
|
* Backward-compatible selection.
|
|
5
5
|
*
|
|
@@ -13,6 +13,7 @@ export declare function setSelectionRange(element: Element, anchorOffset: number
|
|
|
13
13
|
export declare function hasOwnSelection(node: Node): node is HTMLTextAreaElement | (HTMLInputElement & {
|
|
14
14
|
type: editableInputTypes;
|
|
15
15
|
});
|
|
16
|
+
export declare function hasNoSelection(node: Node): boolean;
|
|
16
17
|
/**
|
|
17
18
|
* Reset the Document Selection when moving focus into an element
|
|
18
19
|
* with own selection implementation.
|
|
@@ -44,3 +45,29 @@ export declare function setSelection({ focusNode, focusOffset, anchorNode, ancho
|
|
|
44
45
|
* Move the selection
|
|
45
46
|
*/
|
|
46
47
|
export declare function moveSelection(node: Element, direction: -1 | 1): void;
|
|
48
|
+
export declare type SelectionRange = {
|
|
49
|
+
node: (HTMLInputElement & {
|
|
50
|
+
type: EditableInputType;
|
|
51
|
+
}) | HTMLTextAreaElement;
|
|
52
|
+
start: number;
|
|
53
|
+
end: number;
|
|
54
|
+
};
|
|
55
|
+
export declare function setSelectionPerMouseDown({ document, target, clickCount, node, offset, }: {
|
|
56
|
+
document: Document;
|
|
57
|
+
target: Element;
|
|
58
|
+
clickCount: number;
|
|
59
|
+
node?: Node;
|
|
60
|
+
offset?: number;
|
|
61
|
+
}): Range | {
|
|
62
|
+
node: HTMLTextAreaElement | (HTMLInputElement & {
|
|
63
|
+
type: editableInputTypes;
|
|
64
|
+
});
|
|
65
|
+
start: number;
|
|
66
|
+
end: number;
|
|
67
|
+
} | undefined;
|
|
68
|
+
export declare function modifySelectionPerMouseMove(selectionRange: Range | SelectionRange, { document, target, node, offset, }: {
|
|
69
|
+
document: Document;
|
|
70
|
+
target: Element;
|
|
71
|
+
node?: Node;
|
|
72
|
+
offset?: number;
|
|
73
|
+
}): void;
|
|
@@ -17,15 +17,15 @@ export * from './focus/getActiveElement';
|
|
|
17
17
|
export * from './focus/getTabDestination';
|
|
18
18
|
export * from './focus/isFocusable';
|
|
19
19
|
export * from './focus/selectAll';
|
|
20
|
+
export * from './focus/resolveCaretPosition';
|
|
20
21
|
export * from './focus/selection';
|
|
21
22
|
export * from './focus/selector';
|
|
22
|
-
export * from './keyboard/getKeyEventProps';
|
|
23
|
-
export * from './keyboard/getUIEventModifiers';
|
|
24
23
|
export * from './keyDef/readNextDescriptor';
|
|
25
24
|
export * from './misc/cloneEvent';
|
|
26
25
|
export * from './misc/eventWrapper';
|
|
27
26
|
export * from './misc/findClosest';
|
|
28
27
|
export * from './misc/getDocumentFromNode';
|
|
28
|
+
export * from './misc/getTreeDiff';
|
|
29
29
|
export * from './misc/getWindow';
|
|
30
30
|
export * from './misc/isDescendantOrSelf';
|
|
31
31
|
export * from './misc/isElementType';
|
|
@@ -34,4 +34,3 @@ export * from './misc/isDisabled';
|
|
|
34
34
|
export * from './misc/level';
|
|
35
35
|
export * from './misc/wait';
|
|
36
36
|
export * from './pointer/cssPointerEvents';
|
|
37
|
-
export * from './pointer/mouseButtons';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTreeDiff(a: Element | null, b: Element | null): readonly [Element[], Element[], Element[]];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/user-event",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.4.0",
|
|
4
4
|
"description": "Fire events the same way the user does",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-testing-library",
|
|
@@ -25,32 +25,22 @@
|
|
|
25
25
|
"files": [
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
|
-
"main": "./dist/index.cjs",
|
|
29
|
-
"module": "./dist/index.mjs",
|
|
30
|
-
"exports": {
|
|
31
|
-
".": {
|
|
32
|
-
"require": "./dist/index.cjs",
|
|
33
|
-
"default": "./dist/index.mjs"
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"types": "./dist/types/index.d.ts",
|
|
37
28
|
"scripts": {
|
|
38
|
-
"build": "
|
|
29
|
+
"build": "scripts ts-build2 --cjs",
|
|
39
30
|
"lint": "kcd-scripts lint",
|
|
40
31
|
"setup": "npm install && npm run validate -s",
|
|
41
32
|
"test": "kcd-scripts test",
|
|
42
33
|
"test:debug": "kcd-scripts --inspect-brk test --runInBand",
|
|
43
34
|
"test:update": "npm test -- --updateSnapshot --coverage",
|
|
44
|
-
"validate": "kcd-scripts
|
|
45
|
-
"typecheck": "kcd-scripts typecheck"
|
|
35
|
+
"validate": "kcd-scripts typecheck"
|
|
46
36
|
},
|
|
47
37
|
"devDependencies": {
|
|
38
|
+
"@ph.fritsche/scripts-config": "^2.2.4",
|
|
48
39
|
"@testing-library/dom": "^8.11.4",
|
|
49
40
|
"@testing-library/jest-dom": "^5.16.3",
|
|
50
41
|
"@testing-library/react": "^13.0.0",
|
|
51
42
|
"@types/jest-in-case": "^1.0.3",
|
|
52
43
|
"@types/react": "^17.0.42",
|
|
53
|
-
"esbuild": "^0.14.27",
|
|
54
44
|
"eslint-import-resolver-typescript": "^2.7.0",
|
|
55
45
|
"eslint-plugin-local-rules": "^1.1.0",
|
|
56
46
|
"is-ci": "^3.0.1",
|
|
@@ -63,9 +53,13 @@
|
|
|
63
53
|
"reactDom17": "npm:react-dom@^17.0.2",
|
|
64
54
|
"reactIs17": "npm:react-is@^17.0.2",
|
|
65
55
|
"reactTesting17": "npm:@testing-library/react@^12.1.3",
|
|
56
|
+
"shared-scripts": "^1.5.1",
|
|
66
57
|
"typescript": "^4.1.2"
|
|
67
58
|
},
|
|
68
59
|
"peerDependencies": {
|
|
69
60
|
"@testing-library/dom": ">=7.21.4"
|
|
70
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"main": "./dist/cjs/index.js",
|
|
63
|
+
"module": "./dist/esm/index.js",
|
|
64
|
+
"types": "./dist/types/index.d.ts"
|
|
71
65
|
}
|