@testing-library/user-event 14.4.2 → 14.5.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/_interop/dtl.js +30 -0
- package/dist/cjs/_interop/dtlEventMap.js +30 -0
- package/dist/cjs/_interop/dtlHelpers.js +30 -0
- package/dist/cjs/clipboard/copy.js +6 -16
- package/dist/cjs/clipboard/cut.js +6 -16
- package/dist/cjs/clipboard/paste.js +6 -16
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/convenience/tab.js +1 -1
- package/dist/cjs/document/UI.js +94 -0
- package/dist/cjs/document/copySelection.js +37 -0
- package/dist/cjs/document/getValueOrTextContent.js +27 -0
- package/dist/cjs/document/index.js +13 -68
- package/dist/cjs/document/interceptor.js +89 -4
- package/dist/cjs/document/prepareDocument.js +67 -0
- package/dist/cjs/document/trackValue.js +65 -0
- package/dist/cjs/event/behavior/click.js +8 -12
- package/dist/cjs/event/behavior/cut.js +5 -11
- package/dist/cjs/event/behavior/keydown.js +43 -47
- package/dist/cjs/event/behavior/keypress.js +12 -12
- package/dist/cjs/event/behavior/keyup.js +6 -8
- package/dist/cjs/event/behavior/paste.js +7 -13
- package/dist/cjs/event/createEvent.js +43 -50
- package/dist/cjs/event/dispatchEvent.js +21 -3
- package/dist/cjs/event/eventMap.js +2 -2
- package/dist/cjs/event/focus.js +44 -0
- package/dist/cjs/event/index.js +24 -17
- package/dist/cjs/{utils/edit → event}/input.js +52 -50
- package/dist/cjs/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/cjs/event/selection/getInputRange.js +20 -0
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +41 -0
- package/dist/cjs/event/selection/index.js +26 -0
- package/dist/cjs/event/selection/modifySelection.js +30 -0
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +50 -0
- package/dist/cjs/event/selection/moveSelection.js +48 -0
- package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +10 -18
- package/dist/cjs/event/selection/selectAll.js +48 -0
- package/dist/cjs/event/selection/setSelection.js +30 -0
- package/dist/cjs/event/selection/setSelectionPerMouse.js +91 -0
- package/dist/cjs/event/selection/setSelectionRange.js +40 -0
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +46 -0
- package/dist/cjs/event/wrapEvent.js +3 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/keyboard/index.js +13 -23
- package/dist/cjs/keyboard/parseKeyDef.js +9 -17
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +28 -38
- package/dist/cjs/pointer/keyMap.js +1 -1
- package/dist/cjs/pointer/parseKeyDef.js +2 -10
- package/dist/cjs/setup/api.js +19 -17
- package/dist/cjs/setup/directApi.js +6 -6
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +70 -42
- package/dist/cjs/setup/wrapAsync.js +3 -2
- package/dist/cjs/system/index.js +15 -2
- package/dist/cjs/system/keyboard.js +34 -21
- package/dist/cjs/system/pointer/buttons.js +14 -1
- package/dist/cjs/system/pointer/device.js +14 -1
- package/dist/cjs/system/pointer/index.js +60 -45
- package/dist/cjs/system/pointer/mouse.js +77 -56
- package/dist/cjs/system/pointer/pointer.js +56 -42
- package/dist/cjs/system/pointer/shared.js +10 -0
- package/dist/cjs/utility/clear.js +10 -11
- package/dist/cjs/utility/selectOptions.js +28 -29
- package/dist/cjs/utility/type.js +6 -15
- package/dist/cjs/utility/upload.js +9 -18
- package/dist/cjs/utils/dataTransfer/Clipboard.js +26 -24
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +25 -9
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +6 -17
- package/dist/cjs/utils/edit/setFiles.js +4 -4
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +2 -18
- package/dist/cjs/utils/focus/getActiveElement.js +4 -3
- package/dist/cjs/utils/focus/selection.js +1 -271
- package/dist/cjs/utils/focus/selector.js +1 -1
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
- package/dist/cjs/utils/misc/getWindow.js +3 -2
- package/dist/cjs/utils/misc/isDisabled.js +3 -3
- package/dist/cjs/utils/misc/isVisible.js +3 -2
- package/dist/cjs/utils/misc/level.js +4 -9
- package/dist/cjs/utils/misc/wait.js +1 -1
- package/dist/cjs/utils/pointer/cssPointerEvents.js +31 -40
- package/dist/esm/_interop/dtl.js +6 -0
- package/dist/esm/_interop/dtlEventMap.js +6 -0
- package/dist/esm/_interop/dtlHelpers.js +6 -0
- package/dist/esm/clipboard/copy.js +6 -16
- package/dist/esm/clipboard/cut.js +6 -16
- package/dist/esm/clipboard/paste.js +6 -16
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/convenience/tab.js +1 -1
- package/dist/esm/document/UI.js +79 -0
- package/dist/esm/document/copySelection.js +33 -0
- package/dist/esm/document/getValueOrTextContent.js +23 -0
- package/dist/esm/document/index.js +4 -66
- package/dist/esm/document/interceptor.js +87 -5
- package/dist/esm/document/prepareDocument.js +63 -0
- package/dist/esm/document/trackValue.js +59 -0
- package/dist/esm/event/behavior/click.js +8 -12
- package/dist/esm/event/behavior/cut.js +5 -11
- package/dist/esm/event/behavior/keydown.js +36 -40
- package/dist/esm/event/behavior/keypress.js +12 -12
- package/dist/esm/event/behavior/keyup.js +6 -8
- package/dist/esm/event/behavior/paste.js +7 -13
- package/dist/esm/event/createEvent.js +43 -50
- package/dist/esm/event/dispatchEvent.js +20 -4
- package/dist/esm/event/eventMap.js +2 -2
- package/dist/esm/event/focus.js +39 -0
- package/dist/esm/event/index.js +14 -19
- package/dist/esm/{utils/edit → event}/input.js +39 -37
- package/dist/esm/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/esm/event/selection/getInputRange.js +16 -0
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +37 -0
- package/dist/esm/event/selection/index.js +9 -0
- package/dist/esm/event/selection/modifySelection.js +26 -0
- package/dist/esm/event/selection/modifySelectionPerMouse.js +46 -0
- package/dist/esm/event/selection/moveSelection.js +44 -0
- package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +9 -17
- package/dist/esm/event/selection/selectAll.js +43 -0
- package/dist/esm/event/selection/setSelection.js +26 -0
- package/dist/esm/event/selection/setSelectionPerMouse.js +87 -0
- package/dist/esm/event/selection/setSelectionRange.js +36 -0
- package/dist/esm/event/selection/updateSelectionOnFocus.js +42 -0
- package/dist/esm/event/wrapEvent.js +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/keyboard/index.js +13 -23
- package/dist/esm/keyboard/parseKeyDef.js +9 -17
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +28 -38
- package/dist/esm/pointer/keyMap.js +1 -1
- package/dist/esm/pointer/parseKeyDef.js +2 -10
- package/dist/esm/setup/api.js +33 -12
- package/dist/esm/setup/directApi.js +6 -6
- package/dist/esm/setup/index.js +0 -1
- package/dist/esm/setup/setup.js +66 -39
- package/dist/esm/setup/wrapAsync.js +2 -1
- package/dist/esm/system/index.js +15 -2
- package/dist/esm/system/keyboard.js +34 -21
- package/dist/esm/system/pointer/buttons.js +14 -1
- package/dist/esm/system/pointer/device.js +14 -1
- package/dist/esm/system/pointer/index.js +61 -45
- package/dist/esm/system/pointer/mouse.js +74 -53
- package/dist/esm/system/pointer/pointer.js +55 -41
- package/dist/esm/system/pointer/shared.js +6 -0
- package/dist/esm/utility/clear.js +10 -11
- package/dist/esm/utility/selectOptions.js +24 -25
- package/dist/esm/utility/type.js +5 -14
- package/dist/esm/utility/upload.js +9 -18
- package/dist/esm/utils/dataTransfer/Clipboard.js +26 -24
- package/dist/esm/utils/dataTransfer/DataTransfer.js +25 -9
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +5 -17
- package/dist/esm/utils/edit/setFiles.js +4 -4
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +2 -18
- package/dist/esm/utils/focus/getActiveElement.js +4 -3
- package/dist/esm/utils/focus/selection.js +3 -265
- package/dist/esm/utils/focus/selector.js +1 -1
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/esm/utils/misc/getTreeDiff.js +3 -3
- package/dist/esm/utils/misc/getWindow.js +2 -1
- package/dist/esm/utils/misc/isDisabled.js +3 -3
- package/dist/esm/utils/misc/isVisible.js +3 -2
- package/dist/esm/utils/misc/level.js +4 -9
- package/dist/esm/utils/misc/wait.js +1 -1
- package/dist/esm/utils/pointer/cssPointerEvents.js +31 -40
- package/dist/types/_interop/dtl.d.ts +3 -0
- package/dist/types/_interop/dtlEventMap.d.ts +3 -0
- package/dist/types/_interop/dtlHelpers.d.ts +3 -0
- package/dist/types/clipboard/copy.d.ts +1 -1
- package/dist/types/clipboard/cut.d.ts +1 -1
- package/dist/types/clipboard/paste.d.ts +1 -1
- package/dist/types/convenience/click.d.ts +1 -1
- package/dist/types/convenience/hover.d.ts +1 -1
- package/dist/types/convenience/tab.d.ts +1 -1
- package/dist/types/document/UI.d.ts +42 -0
- package/dist/types/document/getValueOrTextContent.d.ts +1 -0
- package/dist/types/document/index.d.ts +5 -10
- package/dist/types/document/interceptor.d.ts +6 -3
- package/dist/types/document/prepareDocument.d.ts +8 -0
- package/dist/types/document/trackValue.d.ts +17 -0
- package/dist/types/event/behavior/registry.d.ts +2 -2
- package/dist/types/event/createEvent.d.ts +1 -1
- package/dist/types/event/dispatchEvent.d.ts +5 -2
- package/dist/types/event/eventMap.d.ts +8 -0
- package/dist/types/event/focus.d.ts +5 -0
- package/dist/types/event/index.d.ts +6 -4
- package/dist/types/event/input.d.ts +2 -0
- package/dist/types/event/radio.d.ts +4 -0
- package/dist/types/event/selection/getInputRange.d.ts +5 -0
- package/dist/types/event/selection/getTargetTypeAndSelection.d.ts +10 -0
- package/dist/types/event/selection/index.d.ts +15 -0
- package/dist/types/event/selection/modifySelection.d.ts +8 -0
- package/dist/types/event/selection/modifySelectionPerMouse.d.ts +7 -0
- package/dist/types/event/selection/moveSelection.d.ts +4 -0
- package/dist/types/event/selection/setSelection.d.ts +10 -0
- package/dist/types/event/selection/setSelectionPerMouse.d.ts +8 -0
- package/dist/types/event/selection/setSelectionRange.d.ts +6 -0
- package/dist/types/event/selection/updateSelectionOnFocus.d.ts +5 -0
- package/dist/types/event/types.d.ts +3 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/types/keyboard/index.d.ts +2 -2
- package/dist/types/options.d.ts +2 -10
- package/dist/types/pointer/index.d.ts +7 -7
- package/dist/types/setup/api.d.ts +23 -5
- package/dist/types/setup/directApi.d.ts +5 -5
- package/dist/types/setup/index.d.ts +2 -15
- package/dist/types/setup/setup.d.ts +25 -7
- package/dist/types/system/keyboard.d.ts +4 -4
- package/dist/types/system/pointer/buttons.d.ts +2 -2
- package/dist/types/system/pointer/device.d.ts +1 -1
- package/dist/types/system/pointer/index.d.ts +7 -25
- package/dist/types/system/pointer/mouse.d.ts +6 -6
- package/dist/types/system/pointer/pointer.d.ts +8 -8
- package/dist/types/system/pointer/shared.d.ts +20 -0
- package/dist/types/utility/clear.d.ts +1 -1
- package/dist/types/utility/selectOptions.d.ts +1 -1
- package/dist/types/utility/type.d.ts +4 -4
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +2 -2
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
- package/dist/types/utils/edit/isEditable.d.ts +6 -7
- package/dist/types/utils/edit/maxLength.d.ts +14 -1
- package/dist/types/utils/edit/{isValidDateOrTimeValue.d.ts → timeValue.d.ts} +1 -0
- package/dist/types/utils/focus/selection.d.ts +4 -69
- package/dist/types/utils/index.d.ts +2 -9
- package/dist/types/utils/keyDef/readNextDescriptor.d.ts +1 -1
- package/dist/types/utils/misc/isElementType.d.ts +1 -1
- package/dist/types/utils/misc/level.d.ts +4 -13
- package/dist/types/utils/misc/wait.d.ts +2 -2
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +4 -4
- package/package.json +24 -12
- package/dist/cjs/document/selection.js +0 -108
- package/dist/cjs/document/setRangeText.js +0 -21
- package/dist/cjs/document/value.js +0 -127
- package/dist/cjs/setup/config.js +0 -7
- package/dist/cjs/utils/edit/getValue.js +0 -35
- package/dist/cjs/utils/edit/isValidDateOrTimeValue.js +0 -11
- package/dist/cjs/utils/focus/blur.js +0 -16
- package/dist/cjs/utils/focus/copySelection.js +0 -46
- package/dist/cjs/utils/focus/focus.js +0 -29
- package/dist/cjs/utils/focus/selectAll.js +0 -56
- package/dist/cjs/utils/misc/eventWrapper.js +0 -15
- package/dist/esm/document/selection.js +0 -100
- package/dist/esm/document/setRangeText.js +0 -17
- package/dist/esm/document/value.js +0 -117
- package/dist/esm/setup/config.js +0 -3
- package/dist/esm/utils/edit/getValue.js +0 -31
- package/dist/esm/utils/edit/isValidDateOrTimeValue.js +0 -7
- package/dist/esm/utils/focus/blur.js +0 -12
- package/dist/esm/utils/focus/copySelection.js +0 -42
- package/dist/esm/utils/focus/focus.js +0 -25
- package/dist/esm/utils/focus/selectAll.js +0 -51
- package/dist/esm/utils/misc/eventWrapper.js +0 -11
- package/dist/types/document/selection.d.ts +0 -29
- package/dist/types/document/setRangeText.d.ts +0 -1
- package/dist/types/document/value.d.ts +0 -26
- package/dist/types/setup/config.d.ts +0 -6
- package/dist/types/utils/edit/buildTimeValue.d.ts +0 -1
- package/dist/types/utils/edit/getValue.d.ts +0 -1
- package/dist/types/utils/edit/input.d.ts +0 -2
- package/dist/types/utils/edit/walkRadio.d.ts +0 -4
- package/dist/types/utils/focus/blur.d.ts +0 -2
- package/dist/types/utils/focus/focus.d.ts +0 -5
- package/dist/types/utils/misc/eventWrapper.d.ts +0 -1
- /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
- /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
- /package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -0
- /package/dist/types/{utils/focus → event/selection}/resolveCaretPosition.d.ts +0 -0
- /package/dist/types/{utils/focus → event/selection}/selectAll.d.ts +0 -0
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
import { dispatchEvent, dispatchUIEvent } from '../event';
|
|
1
2
|
import { Options } from '../options';
|
|
2
3
|
import { System } from '../system';
|
|
3
|
-
import
|
|
4
|
-
import { Config } from './config';
|
|
4
|
+
import { userEventApi } from './api';
|
|
5
5
|
import { DirectOptions } from './directApi';
|
|
6
|
-
export
|
|
6
|
+
export type UserEventApi = typeof userEventApi;
|
|
7
|
+
export type UserEvent = {
|
|
8
|
+
readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;
|
|
9
|
+
} & {
|
|
10
|
+
readonly [k in keyof UserEventApi]: (...args: Parameters<UserEventApi[k]>) => ReturnType<UserEventApi[k]>;
|
|
11
|
+
};
|
|
12
|
+
export type Instance = UserEventApi & {
|
|
13
|
+
config: Config;
|
|
14
|
+
dispatchEvent: OmitThisParameter<typeof dispatchEvent>;
|
|
15
|
+
dispatchUIEvent: OmitThisParameter<typeof dispatchUIEvent>;
|
|
16
|
+
system: System;
|
|
17
|
+
levelRefs: Record<number, object | undefined>;
|
|
18
|
+
};
|
|
19
|
+
export type Config = Required<Options>;
|
|
20
|
+
export declare function createConfig(options?: Options, defaults?: Required<Options>, node?: Node): Config;
|
|
7
21
|
/**
|
|
8
22
|
* Start a "session" with userEvent.
|
|
9
23
|
* All APIs returned by this function share an input device state and a default configuration.
|
|
@@ -12,15 +26,19 @@ export declare function setupMain(options?: Options): UserEvent;
|
|
|
12
26
|
/**
|
|
13
27
|
* Setup in direct call per `userEvent.anyApi()`
|
|
14
28
|
*/
|
|
15
|
-
export declare function setupDirect({ keyboardState, pointerState, ...options }?: DirectOptions &
|
|
16
|
-
{
|
|
29
|
+
export declare function setupDirect({ keyboardState, pointerState, ...options }?: DirectOptions & {
|
|
17
30
|
keyboardState?: System;
|
|
18
31
|
pointerState?: System;
|
|
19
|
-
},
|
|
20
|
-
|
|
32
|
+
}, // backward-compatibility
|
|
33
|
+
node?: Node): {
|
|
21
34
|
api: UserEvent;
|
|
35
|
+
system: System;
|
|
22
36
|
};
|
|
23
37
|
/**
|
|
24
38
|
* Create a set of callbacks with different default settings but the same state.
|
|
25
39
|
*/
|
|
26
40
|
export declare function setupSub(this: Instance, options: Options): UserEvent;
|
|
41
|
+
export declare function createInstance(config: Config, system?: System): {
|
|
42
|
+
instance: Instance;
|
|
43
|
+
api: UserEvent;
|
|
44
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
|
+
import { type System } from '.';
|
|
3
3
|
export declare enum DOM_KEY_LOCATION {
|
|
4
4
|
STANDARD = 0,
|
|
5
5
|
LEFT = 1,
|
|
@@ -45,9 +45,9 @@ export declare class KeyboardHost {
|
|
|
45
45
|
isKeyPressed(keyDef: keyboardKey): boolean;
|
|
46
46
|
getPressedKeys(): keyboardKey[];
|
|
47
47
|
/** Press a key */
|
|
48
|
-
keydown(
|
|
48
|
+
keydown(instance: Instance, keyDef: keyboardKey): Promise<void>;
|
|
49
49
|
/** Release a key */
|
|
50
|
-
keyup(
|
|
50
|
+
keyup(instance: Instance, keyDef: keyboardKey): Promise<void>;
|
|
51
51
|
private setKeydownTarget;
|
|
52
52
|
private hasKeyPress;
|
|
53
53
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type pointerKey } from './shared';
|
|
2
2
|
export declare class Buttons {
|
|
3
3
|
private readonly pressed;
|
|
4
4
|
getButtons(): number;
|
|
@@ -14,7 +14,7 @@ export declare const MouseButton: {
|
|
|
14
14
|
readonly forward: 4;
|
|
15
15
|
readonly X2: 4;
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type MouseButton = keyof typeof MouseButton | number;
|
|
18
18
|
export declare function getMouseButtonId(button?: MouseButton): number;
|
|
19
19
|
export declare const MouseButtonFlip: {
|
|
20
20
|
readonly 1: 2;
|
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
import { System } from '..';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
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
|
-
}
|
|
2
|
+
import { Instance } from '../../setup';
|
|
3
|
+
import { pointerKey, PointerPosition } from './shared';
|
|
4
|
+
export type { pointerKey, PointerPosition } from './shared';
|
|
22
5
|
export declare class PointerHost {
|
|
23
6
|
readonly system: System;
|
|
24
7
|
constructor(system: System);
|
|
@@ -27,13 +10,12 @@ export declare class PointerHost {
|
|
|
27
10
|
private readonly devices;
|
|
28
11
|
private readonly pointers;
|
|
29
12
|
isKeyPressed(keyDef: pointerKey): boolean;
|
|
30
|
-
press(
|
|
31
|
-
move(
|
|
32
|
-
release(
|
|
13
|
+
press(instance: Instance, keyDef: pointerKey, position: PointerPosition): Promise<void>;
|
|
14
|
+
move(instance: Instance, pointerName: string, position: PointerPosition): Promise<void>;
|
|
15
|
+
release(instance: Instance, keyDef: pointerKey, position: PointerPosition): Promise<void>;
|
|
33
16
|
getPointerName(keyDef: pointerKey): string;
|
|
34
17
|
getPreviousPosition(pointerName: string): PointerPosition | undefined;
|
|
35
18
|
resetClickCount(): void;
|
|
36
|
-
getMouseTarget(
|
|
19
|
+
getMouseTarget(instance: Instance): Element;
|
|
37
20
|
setMousePosition(position: PointerPosition): void;
|
|
38
21
|
}
|
|
39
|
-
export declare function isDifferentPointerPosition(positionA: PointerPosition, positionB: PointerPosition): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
|
+
import { type Pointer } from './pointer';
|
|
3
|
+
import { pointerKey, PointerPosition } from './shared';
|
|
4
4
|
/**
|
|
5
5
|
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
|
|
6
6
|
*/
|
|
@@ -10,13 +10,13 @@ export declare class Mouse {
|
|
|
10
10
|
private selecting?;
|
|
11
11
|
private buttonDownTarget;
|
|
12
12
|
private readonly clickCount;
|
|
13
|
-
move(
|
|
13
|
+
move(instance: Instance, position: PointerPosition): {
|
|
14
14
|
leave: () => void;
|
|
15
15
|
enter: () => void;
|
|
16
16
|
move: () => void;
|
|
17
17
|
} | undefined;
|
|
18
|
-
down(
|
|
19
|
-
up(
|
|
18
|
+
down(instance: Instance, keyDef: pointerKey, pointer: Pointer): void;
|
|
19
|
+
up(instance: Instance, keyDef: pointerKey, pointer: Pointer): void;
|
|
20
20
|
resetClickCount(): void;
|
|
21
21
|
private getEventInit;
|
|
22
22
|
private getTarget;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { pointerKey, PointerPosition } from '
|
|
3
|
-
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
|
+
import { pointerKey, PointerPosition } from './shared';
|
|
3
|
+
type PointerInit = {
|
|
4
4
|
pointerId: number;
|
|
5
5
|
pointerType: string;
|
|
6
6
|
isPrimary: boolean;
|
|
@@ -15,15 +15,15 @@ export declare class Pointer {
|
|
|
15
15
|
isDown: boolean;
|
|
16
16
|
isPrevented: boolean;
|
|
17
17
|
position: PointerPosition;
|
|
18
|
-
init(
|
|
19
|
-
move(
|
|
18
|
+
init(instance: Instance, position: PointerPosition): this;
|
|
19
|
+
move(instance: Instance, position: PointerPosition): {
|
|
20
20
|
leave: () => void;
|
|
21
21
|
enter: () => void;
|
|
22
22
|
move: () => void;
|
|
23
23
|
} | undefined;
|
|
24
|
-
down(
|
|
25
|
-
up(
|
|
26
|
-
release(
|
|
24
|
+
down(instance: Instance, _keyDef: pointerKey): void;
|
|
25
|
+
up(instance: Instance, _keyDef: pointerKey): void;
|
|
26
|
+
release(instance: Instance): void;
|
|
27
27
|
private getTarget;
|
|
28
28
|
private getEventInit;
|
|
29
29
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PointerCoords } from '../../event';
|
|
2
|
+
import { MouseButton } from './buttons';
|
|
3
|
+
export interface pointerKey {
|
|
4
|
+
/** Name of the pointer key */
|
|
5
|
+
name: string;
|
|
6
|
+
/** Type of the pointer device */
|
|
7
|
+
pointerType: 'mouse' | 'pen' | 'touch';
|
|
8
|
+
/** Type of button */
|
|
9
|
+
button?: MouseButton;
|
|
10
|
+
}
|
|
11
|
+
export interface PointerPosition {
|
|
12
|
+
target?: Element;
|
|
13
|
+
coords?: PointerCoords;
|
|
14
|
+
caret?: CaretPosition;
|
|
15
|
+
}
|
|
16
|
+
export interface CaretPosition {
|
|
17
|
+
node?: Node;
|
|
18
|
+
offset?: number;
|
|
19
|
+
}
|
|
20
|
+
export declare function isDifferentPointerPosition(positionA: PointerPosition, positionB: PointerPosition): boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Instance } from '../setup';
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
2
|
export declare function clear(this: Instance, element: Element): Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Instance } from '../setup';
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
2
|
export declare function selectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
3
3
|
export declare function deselectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
1
|
+
import { type Instance } from '../setup';
|
|
2
|
+
import { type Options } from '../options';
|
|
3
3
|
export interface typeOptions {
|
|
4
|
-
skipClick?:
|
|
5
|
-
skipAutoClose?:
|
|
4
|
+
skipClick?: Options['skipClick'];
|
|
5
|
+
skipAutoClose?: Options['skipAutoClose'];
|
|
6
6
|
initialSelectionStart?: number;
|
|
7
7
|
initialSelectionEnd?: number;
|
|
8
8
|
}
|
|
@@ -8,8 +8,8 @@ declare enum clickableInputTypes {
|
|
|
8
8
|
'checkbox' = "checkbox",
|
|
9
9
|
'radio' = "radio"
|
|
10
10
|
}
|
|
11
|
-
export
|
|
12
|
-
export declare function isClickableInput(element: Element): element is HTMLButtonElement | (HTMLInputElement & {
|
|
11
|
+
export type ClickableInputOrButton = HTMLButtonElement | (HTMLInputElement & {
|
|
13
12
|
type: clickableInputTypes;
|
|
14
13
|
});
|
|
14
|
+
export declare function isClickableInput(element: Element): element is ClickableInputOrButton;
|
|
15
15
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function createClipboardItem(window: Window & typeof globalThis, ...blobs: Array<Blob | string>): ClipboardItem;
|
|
2
|
-
|
|
2
|
+
type ClipboardStubControlInstance = {
|
|
3
3
|
resetClipboardStub: () => void;
|
|
4
4
|
detachClipboardStub: () => void;
|
|
5
5
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isContentEditable } from './isContentEditable';
|
|
2
|
-
|
|
3
|
-
export declare function isEditable(element: Element): element is GuardedType<typeof isContentEditable> |
|
|
2
|
+
type GuardedType<T> = T extends (x: any) => x is infer R ? R : never;
|
|
3
|
+
export declare function isEditable(element: Element): element is GuardedType<typeof isContentEditable> | (EditableInputOrTextarea & {
|
|
4
4
|
readOnly: false;
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
declare enum editableInputTypes {
|
|
7
7
|
'text' = "text",
|
|
8
8
|
'date' = "date",
|
|
9
9
|
'datetime-local' = "datetime-local",
|
|
@@ -17,9 +17,8 @@ export declare enum editableInputTypes {
|
|
|
17
17
|
'url' = "url",
|
|
18
18
|
'week' = "week"
|
|
19
19
|
}
|
|
20
|
-
export
|
|
21
|
-
export declare function isEditableInput(element: Element): element is HTMLInputElement & {
|
|
22
|
-
readOnly: false;
|
|
20
|
+
export type EditableInputOrTextarea = HTMLTextAreaElement | (HTMLInputElement & {
|
|
23
21
|
type: editableInputTypes;
|
|
24
|
-
};
|
|
22
|
+
});
|
|
23
|
+
export declare function isEditableInputOrTextArea(element: Element): element is EditableInputOrTextarea;
|
|
25
24
|
export {};
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
declare enum maxLengthSupportedTypes {
|
|
2
|
+
'email' = "email",
|
|
3
|
+
'password' = "password",
|
|
4
|
+
'search' = "search",
|
|
5
|
+
'telephone' = "telephone",
|
|
6
|
+
'text' = "text",
|
|
7
|
+
'url' = "url"
|
|
8
|
+
}
|
|
9
|
+
type ElementWithMaxLengthSupport = HTMLTextAreaElement | (HTMLInputElement & {
|
|
10
|
+
type: maxLengthSupportedTypes;
|
|
11
|
+
});
|
|
12
|
+
export declare function getMaxLength(element: ElementWithMaxLengthSupport): number | undefined;
|
|
13
|
+
export declare function supportsMaxLength(element: Element): element is ElementWithMaxLengthSupport;
|
|
14
|
+
export {};
|
|
@@ -1,73 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
/**
|
|
4
|
-
* Backward-compatible selection.
|
|
5
|
-
*
|
|
6
|
-
* Handles input elements and contenteditable if it only contains a single text node.
|
|
7
|
-
*/
|
|
8
|
-
export declare function setSelectionRange(element: Element, anchorOffset: number, focusOffset: number): void;
|
|
1
|
+
import { ClickableInputOrButton } from '../click/isClickableInput';
|
|
2
|
+
import { EditableInputOrTextarea } from '../edit/isEditable';
|
|
9
3
|
/**
|
|
10
4
|
* Determine if the element has its own selection implementation
|
|
11
5
|
* and does not interact with the Document Selection API.
|
|
12
6
|
*/
|
|
13
|
-
export declare function hasOwnSelection(node: Node): node is
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
export declare function hasNoSelection(node: Node): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Reset the Document Selection when moving focus into an element
|
|
19
|
-
* with own selection implementation.
|
|
20
|
-
*/
|
|
21
|
-
export declare function updateSelectionOnFocus(element: Element): void;
|
|
22
|
-
/**
|
|
23
|
-
* Get the range that would be overwritten by input.
|
|
24
|
-
*/
|
|
25
|
-
export declare function getInputRange(focusNode: Node): UISelectionRange | Range | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
|
|
28
|
-
*/
|
|
29
|
-
export declare function modifySelection({ focusNode, focusOffset, }: {
|
|
30
|
-
focusNode: Node;
|
|
31
|
-
/** DOM Offset */
|
|
32
|
-
focusOffset: number;
|
|
33
|
-
}): void;
|
|
34
|
-
/**
|
|
35
|
-
* Set the selection
|
|
36
|
-
*/
|
|
37
|
-
export declare function setSelection({ focusNode, focusOffset, anchorNode, anchorOffset, }: {
|
|
38
|
-
anchorNode?: Node;
|
|
39
|
-
/** DOM offset */
|
|
40
|
-
anchorOffset?: number;
|
|
41
|
-
focusNode: Node;
|
|
42
|
-
focusOffset: number;
|
|
43
|
-
}): void;
|
|
44
|
-
/**
|
|
45
|
-
* Move the selection
|
|
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;
|
|
7
|
+
export declare function hasOwnSelection(node: Node): node is EditableInputOrTextarea;
|
|
8
|
+
export declare function hasNoSelection(node: Node): node is ClickableInputOrButton;
|
|
@@ -3,26 +3,19 @@ export * from './dataTransfer/Blob';
|
|
|
3
3
|
export * from './dataTransfer/DataTransfer';
|
|
4
4
|
export * from './dataTransfer/FileList';
|
|
5
5
|
export * from './dataTransfer/Clipboard';
|
|
6
|
-
export * from './edit/
|
|
7
|
-
export * from './edit/input';
|
|
6
|
+
export * from './edit/timeValue';
|
|
8
7
|
export * from './edit/isContentEditable';
|
|
9
8
|
export * from './edit/isEditable';
|
|
9
|
+
export * from './edit/maxLength';
|
|
10
10
|
export * from './edit/setFiles';
|
|
11
|
-
export * from './edit/walkRadio';
|
|
12
|
-
export * from './focus/blur';
|
|
13
|
-
export * from './focus/copySelection';
|
|
14
11
|
export * from './focus/cursor';
|
|
15
|
-
export * from './focus/focus';
|
|
16
12
|
export * from './focus/getActiveElement';
|
|
17
13
|
export * from './focus/getTabDestination';
|
|
18
14
|
export * from './focus/isFocusable';
|
|
19
|
-
export * from './focus/selectAll';
|
|
20
|
-
export * from './focus/resolveCaretPosition';
|
|
21
15
|
export * from './focus/selection';
|
|
22
16
|
export * from './focus/selector';
|
|
23
17
|
export * from './keyDef/readNextDescriptor';
|
|
24
18
|
export * from './misc/cloneEvent';
|
|
25
|
-
export * from './misc/eventWrapper';
|
|
26
19
|
export * from './misc/findClosest';
|
|
27
20
|
export * from './misc/getDocumentFromNode';
|
|
28
21
|
export * from './misc/getTreeDiff';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type tag = keyof HTMLElementTagNameMap;
|
|
2
2
|
export declare function isElementType<T extends tag, P extends {
|
|
3
3
|
[k: string]: unknown;
|
|
4
4
|
} | undefined = undefined>(element: Element, tag: T | T[], props?: P): element is P extends undefined ? HTMLElementTagNameMap[T] : HTMLElementTagNameMap[T] & P;
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
2
|
export declare enum ApiLevel {
|
|
3
3
|
Trigger = 2,
|
|
4
4
|
Call = 1
|
|
5
5
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 {};
|
|
6
|
+
export type LevelRefs = Record<ApiLevel, object | undefined>;
|
|
7
|
+
export declare function setLevelRef(instance: Instance, level: ApiLevel): void;
|
|
8
|
+
export declare function getLevelRef(instance: Instance, level: ApiLevel): object | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function wait(config:
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
|
+
export declare function wait(config: Instance['config']): Promise<[void, void]> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ApiLevel } from '
|
|
3
|
-
export declare function hasPointerEvents(
|
|
1
|
+
import { type Instance } from '../../setup';
|
|
2
|
+
import { ApiLevel } from '../misc/level';
|
|
3
|
+
export declare function hasPointerEvents(instance: Instance, element: Element): boolean;
|
|
4
4
|
declare function closestPointerEventsDeclaration(element: Element): {
|
|
5
5
|
pointerEvents: string;
|
|
6
6
|
tree: Element[];
|
|
@@ -15,5 +15,5 @@ declare global {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
export declare function assertPointerEvents(
|
|
18
|
+
export declare function assertPointerEvents(instance: Instance, element: Element): void;
|
|
19
19
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/user-event",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.5.0",
|
|
4
4
|
"description": "Fire events the same way the user does",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-testing-library",
|
|
@@ -29,41 +29,53 @@
|
|
|
29
29
|
"build": "scripts ts-build2 --cjs --target es2019",
|
|
30
30
|
"lint": "kcd-scripts lint",
|
|
31
31
|
"setup": "npm install && npm run validate -s",
|
|
32
|
+
"setup:env": "node --experimental-import-meta-resolve scripts/setup.js",
|
|
32
33
|
"test": "kcd-scripts test",
|
|
34
|
+
"test:jest": "kcd-scripts test",
|
|
35
|
+
"test:toolbox": "NODE_OPTIONS='--experimental-vm-modules --experimental-modules --experimental-import-meta-resolve' node scripts/test.js",
|
|
33
36
|
"test:debug": "kcd-scripts --inspect-brk test --runInBand",
|
|
34
37
|
"test:update": "npm test -- --updateSnapshot --coverage",
|
|
35
38
|
"validate": "kcd-scripts typecheck"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
38
|
-
"@ph.fritsche/scripts-config": "^2.
|
|
39
|
-
"@
|
|
41
|
+
"@ph.fritsche/scripts-config": "^2.4.0",
|
|
42
|
+
"@ph.fritsche/toolbox": "^1.0.0-alpha.1",
|
|
43
|
+
"@testing-library/dom": "^8.19.0",
|
|
40
44
|
"@testing-library/jest-dom": "^5.16.3",
|
|
41
|
-
"@testing-library/react": "^13.
|
|
45
|
+
"@testing-library/react": "^13.4.0",
|
|
42
46
|
"@types/jest-in-case": "^1.0.3",
|
|
43
|
-
"@types/react": "^
|
|
44
|
-
"
|
|
45
|
-
"
|
|
47
|
+
"@types/react": "^18.0.25",
|
|
48
|
+
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
49
|
+
"css.escape": "^1.5.1",
|
|
50
|
+
"eslint-import-resolver-typescript": "^3.5.2",
|
|
51
|
+
"eslint-plugin-local-rules": "^1.3.2",
|
|
52
|
+
"expect": "^28.1.3",
|
|
46
53
|
"is-ci": "^3.0.1",
|
|
54
|
+
"istanbul-lib-coverage": "^3.2.0",
|
|
55
|
+
"istanbul-lib-report": "^3.0.0",
|
|
56
|
+
"istanbul-lib-source-maps": "^4.0.1",
|
|
57
|
+
"istanbul-reports": "^3.1.5",
|
|
47
58
|
"jest-in-case": "^1.0.2",
|
|
59
|
+
"jest-mock": "^28.1.3",
|
|
48
60
|
"jest-serializer-ansi": "^1.0.3",
|
|
61
|
+
"jsdom": "^20.0.3",
|
|
49
62
|
"kcd-scripts": "^12.1.0",
|
|
50
63
|
"react": "^18.0.0",
|
|
51
64
|
"react-dom": "^18.0.0",
|
|
52
|
-
"react17": "npm:react@^17.0.2",
|
|
53
|
-
"reactDom17": "npm:react-dom@^17.0.2",
|
|
54
|
-
"reactIs17": "npm:react-is@^17.0.2",
|
|
55
|
-
"reactTesting17": "npm:@testing-library/react@^12.1.3",
|
|
56
65
|
"shared-scripts": "^1.5.1",
|
|
57
|
-
"
|
|
66
|
+
"ts-node": "^10.9.1",
|
|
67
|
+
"typescript": "^4.9.3"
|
|
58
68
|
},
|
|
59
69
|
"peerDependencies": {
|
|
60
70
|
"@testing-library/dom": ">=7.21.4"
|
|
61
71
|
},
|
|
72
|
+
"dependencies": {},
|
|
62
73
|
"main": "./dist/cjs/index.js",
|
|
63
74
|
"module": "./dist/esm/index.js",
|
|
64
75
|
"types": "./dist/types/index.d.ts",
|
|
65
76
|
"exports": {
|
|
66
77
|
".": {
|
|
78
|
+
"types": "./dist/types/index.d.ts",
|
|
67
79
|
"require": "./dist/cjs/index.js",
|
|
68
80
|
"default": "./dist/esm/index.js"
|
|
69
81
|
},
|