@testing-library/user-event 14.0.0-beta.8 → 14.0.0-beta.9
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 +445 -385
- package/dist/index.mjs +445 -385
- package/dist/types/event/behavior/click.d.ts +1 -0
- package/dist/types/event/behavior/index.d.ts +3 -0
- package/dist/types/event/behavior/registry.d.ts +9 -0
- package/dist/types/event/createEvent.d.ts +8 -0
- package/dist/types/event/dispatchEvent.d.ts +2 -0
- package/dist/types/event/eventTypes.d.ts +2 -0
- package/dist/types/event/index.d.ts +6 -0
- package/dist/types/event/types.d.ts +13 -0
- package/dist/types/event/wrapEvent.d.ts +1 -0
- package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +2 -1
- package/dist/types/pointer/firePointerEvents.d.ts +11 -0
- package/dist/types/pointer/types.d.ts +2 -1
- package/dist/types/setup/index.d.ts +2 -0
- package/dist/types/setup/setup.d.ts +1 -0
- package/dist/types/utility/clear.d.ts +1 -1
- package/dist/types/utils/edit/editInputElement.d.ts +3 -5
- package/dist/types/utils/edit/prepareInput.d.ts +2 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +2 -14
- package/dist/types/utils/misc/cloneEvent.d.ts +1 -0
- package/package.json +1 -1
- package/CHANGELOG.md +0 -5
- package/dist/types/utils/pointer/firePointerEvents.d.ts +0 -25
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Config } from '../../setup';
|
|
2
|
+
import { EventType } from '../types';
|
|
3
|
+
export interface BehaviorPlugin<Type extends EventType> {
|
|
4
|
+
(event: DocumentEventMap[Type], target: Element, config: Config): // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
5
|
+
void | (() => void);
|
|
6
|
+
}
|
|
7
|
+
export declare const behavior: {
|
|
8
|
+
[Type in EventType]?: BehaviorPlugin<Type>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EventType } from './types';
|
|
2
|
+
export declare type EventTypeInit<K extends EventType> = SpecificEventInit<FixedDocumentEventMap[K]>;
|
|
3
|
+
interface FixedDocumentEventMap extends DocumentEventMap {
|
|
4
|
+
input: InputEvent;
|
|
5
|
+
}
|
|
6
|
+
declare type SpecificEventInit<E extends Event> = E extends InputEvent ? InputEventInit : E extends ClipboardEvent ? ClipboardEventInit : E extends KeyboardEvent ? KeyboardEventInit : E extends PointerEvent ? PointerEventInit : E extends MouseEvent ? MouseEventInit : E extends UIEvent ? UIEventInit : EventInit;
|
|
7
|
+
export declare function createEvent<K extends EventType>(type: K, target: Element, init?: EventTypeInit<K>): DocumentEventMap[K];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Config } from '../setup';
|
|
2
|
+
import { EventTypeInit } from './createEvent';
|
|
3
|
+
import { EventType, PointerCoords } from './types';
|
|
4
|
+
export type { EventType, PointerCoords };
|
|
5
|
+
export declare function dispatchUIEvent<K extends EventType>(config: Config, target: Element, type: K, init?: EventTypeInit<K>): boolean;
|
|
6
|
+
export declare function bindDispatchUIEvent(config: Config): (target: Element, type: keyof DocumentEventMap, init?: InputEventInit | UIEventInit | EventInit | ClipboardEventInit | MouseEventInit | PointerEventInit | KeyboardEventInit | undefined) => boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare type EventType = keyof DocumentEventMap;
|
|
2
|
+
export interface PointerCoords {
|
|
3
|
+
x?: number;
|
|
4
|
+
y?: number;
|
|
5
|
+
clientX?: number;
|
|
6
|
+
clientY?: number;
|
|
7
|
+
offsetX?: number;
|
|
8
|
+
offsetY?: number;
|
|
9
|
+
pageX?: number;
|
|
10
|
+
pageY?: number;
|
|
11
|
+
screenX?: number;
|
|
12
|
+
screenY?: number;
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function wrapEvent<R>(cb: () => R, _element: Element): R;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import { Config } from '../../setup';
|
|
2
|
+
export declare function fireChangeForInputTimeIfValid(config: Config, el: HTMLInputElement & {
|
|
2
3
|
type: 'time';
|
|
3
4
|
}, prevValue: unknown, timeNewEntry: string): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EventType, PointerCoords } from '../event';
|
|
2
|
+
import { Config } from '../setup';
|
|
3
|
+
import { MouseButton } from '../utils';
|
|
4
|
+
export declare function firePointerEvent(config: Config, target: Element, type: EventType, { pointerType, button, coords, pointerId, isPrimary, clickCount, }: {
|
|
5
|
+
pointerType?: 'mouse' | 'pen' | 'touch';
|
|
6
|
+
button?: MouseButton;
|
|
7
|
+
coords?: PointerCoords;
|
|
8
|
+
pointerId?: number;
|
|
9
|
+
isPrimary?: boolean;
|
|
10
|
+
clickCount?: number;
|
|
11
|
+
}): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { bindDispatchUIEvent } from '../event';
|
|
1
2
|
import type * as userEventApi from './api';
|
|
2
3
|
import { setupMain, setupSub } from './setup';
|
|
3
4
|
import { Config, inputDeviceState } from './config';
|
|
@@ -7,6 +8,7 @@ export { Config };
|
|
|
7
8
|
export declare type UserEventApi = typeof userEventApi;
|
|
8
9
|
export declare type Instance = UserEventApi & {
|
|
9
10
|
[Config]: Config;
|
|
11
|
+
dispatchUIEvent: ReturnType<typeof bindDispatchUIEvent>;
|
|
10
12
|
};
|
|
11
13
|
export declare type UserEvent = {
|
|
12
14
|
readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Options } from '../options';
|
|
2
2
|
import type { Instance, UserEvent } from './index';
|
|
3
3
|
import { Config } from './config';
|
|
4
|
+
export declare function createConfig(options?: Partial<Config>, defaults?: Required<Options>, node?: Node): Config;
|
|
4
5
|
/**
|
|
5
6
|
* Start a "session" with userEvent.
|
|
6
7
|
* All APIs returned by this function share an input device state and a default configuration.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Instance } from '../setup';
|
|
2
2
|
export declare function clear(this: Instance, element: Element): Promise<void>;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Config } from '../../setup';
|
|
2
2
|
/**
|
|
3
3
|
* Change the value of an element as if it was changed as a result of a user input.
|
|
4
4
|
*
|
|
5
5
|
* Fires the input event.
|
|
6
6
|
*/
|
|
7
|
-
export declare function editInputElement(element: HTMLInputElement | HTMLTextAreaElement, { newValue, newSelection, eventOverrides, }: {
|
|
7
|
+
export declare function editInputElement(config: Config, element: HTMLInputElement | HTMLTextAreaElement, { newValue, newSelection, eventOverrides, }: {
|
|
8
8
|
newValue: string;
|
|
9
9
|
newSelection: {
|
|
10
10
|
node: Node;
|
|
11
11
|
offset: number;
|
|
12
12
|
};
|
|
13
|
-
eventOverrides:
|
|
14
|
-
[k: string]: unknown;
|
|
15
|
-
};
|
|
13
|
+
eventOverrides: InputEventInit;
|
|
16
14
|
}): void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { Config } from '../../setup';
|
|
2
|
+
export declare function prepareInput(config: Config, data: string, element: Element, inputType?: string): {
|
|
2
3
|
commit: () => void;
|
|
3
4
|
getNewValue?: undefined;
|
|
4
5
|
} | {
|
|
@@ -27,6 +27,7 @@ export * from './focus/selector';
|
|
|
27
27
|
export * from './keyboard/getKeyEventProps';
|
|
28
28
|
export * from './keyboard/getUIEventModifiers';
|
|
29
29
|
export * from './keyDef/readNextDescriptor';
|
|
30
|
+
export * from './misc/cloneEvent';
|
|
30
31
|
export * from './misc/eventWrapper';
|
|
31
32
|
export * from './misc/findClosest';
|
|
32
33
|
export * from './misc/getDocumentFromNode';
|
|
@@ -38,5 +39,4 @@ export * from './misc/level';
|
|
|
38
39
|
export * from './misc/wait';
|
|
39
40
|
export * from './misc/hasFormSubmit';
|
|
40
41
|
export * from './pointer/cssPointerEvents';
|
|
41
|
-
export * from './pointer/firePointerEvents';
|
|
42
42
|
export * from './pointer/mouseButtons';
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
import { keyboardKey
|
|
2
|
-
export declare function getKeyEventProps(keyDef: keyboardKey
|
|
3
|
-
altKey: boolean;
|
|
4
|
-
ctrlKey: boolean;
|
|
5
|
-
metaKey: boolean;
|
|
6
|
-
shiftKey: boolean;
|
|
7
|
-
modifierAltGraph: boolean;
|
|
8
|
-
modifierCapsLock: boolean;
|
|
9
|
-
modifierFn: boolean;
|
|
10
|
-
modifierFnLock: boolean;
|
|
11
|
-
modifierNumLock: boolean;
|
|
12
|
-
modifierScrollLock: boolean;
|
|
13
|
-
modifierSymbol: boolean;
|
|
14
|
-
modifierSymbolLock: boolean;
|
|
1
|
+
import { keyboardKey } from '../../keyboard/types';
|
|
2
|
+
export declare function getKeyEventProps(keyDef: keyboardKey): {
|
|
15
3
|
key: string | undefined;
|
|
16
4
|
code: string | undefined;
|
|
17
5
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cloneEvent<E extends Event>(event: E): E;
|
package/package.json
CHANGED
package/CHANGELOG.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { pointerState } from '../../pointer/types';
|
|
2
|
-
import type { keyboardState } from '../../keyboard/types';
|
|
3
|
-
import { MouseButton } from './mouseButtons';
|
|
4
|
-
export declare function firePointerEvent(target: Element, type: string, { pointerState, keyboardState, pointerType, button, coords, pointerId, isPrimary, clickCount, }: {
|
|
5
|
-
pointerState: pointerState;
|
|
6
|
-
keyboardState: keyboardState;
|
|
7
|
-
pointerType?: 'mouse' | 'pen' | 'touch';
|
|
8
|
-
button?: MouseButton;
|
|
9
|
-
coords?: PointerCoords;
|
|
10
|
-
pointerId?: number;
|
|
11
|
-
isPrimary?: boolean;
|
|
12
|
-
clickCount?: number;
|
|
13
|
-
}): boolean;
|
|
14
|
-
export interface PointerCoords {
|
|
15
|
-
x?: number;
|
|
16
|
-
y?: number;
|
|
17
|
-
clientX?: number;
|
|
18
|
-
clientY?: number;
|
|
19
|
-
offsetX?: number;
|
|
20
|
-
offsetY?: number;
|
|
21
|
-
pageX?: number;
|
|
22
|
-
pageY?: number;
|
|
23
|
-
screenX?: number;
|
|
24
|
-
screenY?: number;
|
|
25
|
-
}
|