@testing-library/user-event 14.0.0-beta.5 → 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.
Files changed (48) hide show
  1. package/README.md +5 -192
  2. package/dist/index.cjs +860 -617
  3. package/dist/index.mjs +861 -618
  4. package/dist/types/clipboard/copy.d.ts +2 -2
  5. package/dist/types/clipboard/cut.d.ts +2 -2
  6. package/dist/types/clipboard/paste.d.ts +2 -2
  7. package/dist/types/convenience/click.d.ts +4 -4
  8. package/dist/types/convenience/hover.d.ts +3 -3
  9. package/dist/types/convenience/tab.d.ts +2 -2
  10. package/dist/types/event/behavior/click.d.ts +1 -0
  11. package/dist/types/event/behavior/index.d.ts +3 -0
  12. package/dist/types/event/behavior/registry.d.ts +9 -0
  13. package/dist/types/event/createEvent.d.ts +8 -0
  14. package/dist/types/event/dispatchEvent.d.ts +2 -0
  15. package/dist/types/event/eventTypes.d.ts +2 -0
  16. package/dist/types/event/index.d.ts +6 -0
  17. package/dist/types/event/types.d.ts +13 -0
  18. package/dist/types/event/wrapEvent.d.ts +1 -0
  19. package/dist/types/index.d.ts +1 -0
  20. package/dist/types/keyboard/index.d.ts +2 -2
  21. package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +2 -1
  22. package/dist/types/options.d.ts +23 -8
  23. package/dist/types/pointer/firePointerEvents.d.ts +11 -0
  24. package/dist/types/pointer/index.d.ts +2 -2
  25. package/dist/types/pointer/pointerMove.d.ts +2 -2
  26. package/dist/types/pointer/pointerPress.d.ts +2 -2
  27. package/dist/types/pointer/types.d.ts +2 -1
  28. package/dist/types/setup/directApi.d.ts +1 -2
  29. package/dist/types/setup/index.d.ts +8 -2
  30. package/dist/types/setup/setup.d.ts +6 -60
  31. package/dist/types/utility/clear.d.ts +2 -2
  32. package/dist/types/utility/selectOptions.d.ts +3 -3
  33. package/dist/types/utility/type.d.ts +2 -2
  34. package/dist/types/utility/upload.d.ts +2 -2
  35. package/dist/types/utils/edit/editInputElement.d.ts +3 -5
  36. package/dist/types/utils/edit/prepareInput.d.ts +2 -1
  37. package/dist/types/utils/focus/cursor.d.ts +9 -0
  38. package/dist/types/utils/focus/focus.d.ts +3 -0
  39. package/dist/types/utils/index.d.ts +4 -2
  40. package/dist/types/utils/keyboard/getKeyEventProps.d.ts +2 -14
  41. package/dist/types/utils/misc/cloneEvent.d.ts +1 -0
  42. package/dist/types/utils/misc/findClosest.d.ts +1 -1
  43. package/dist/types/utils/misc/level.d.ts +17 -0
  44. package/dist/types/utils/pointer/cssPointerEvents.d.ts +15 -0
  45. package/package.json +1 -1
  46. package/CHANGELOG.md +0 -5
  47. package/dist/types/utils/misc/hasPointerEvents.d.ts +0 -15
  48. package/dist/types/utils/pointer/firePointerEvents.d.ts +0 -25
@@ -1,2 +1,2 @@
1
- import { UserEvent } from '../setup';
2
- export declare function copy(this: UserEvent): Promise<DataTransfer | undefined>;
1
+ import { Instance } from '../setup';
2
+ export declare function copy(this: Instance): Promise<DataTransfer | undefined>;
@@ -1,2 +1,2 @@
1
- import { UserEvent } from '../setup';
2
- export declare function cut(this: UserEvent): Promise<DataTransfer | undefined>;
1
+ import { Instance } from '../setup';
2
+ export declare function cut(this: Instance): Promise<DataTransfer | undefined>;
@@ -1,2 +1,2 @@
1
- import { UserEvent } from '../setup';
2
- export declare function paste(this: UserEvent, clipboardData?: DataTransfer | string): Promise<void>;
1
+ import { Instance } from '../setup';
2
+ export declare function paste(this: Instance, clipboardData?: DataTransfer | string): Promise<void>;
@@ -1,4 +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>;
1
+ import { Instance } from '../setup';
2
+ export declare function click(this: Instance, element: Element): Promise<void>;
3
+ export declare function dblClick(this: Instance, element: Element): Promise<void>;
4
+ export declare function tripleClick(this: Instance, element: Element): Promise<void>;
@@ -1,3 +1,3 @@
1
- import { UserEvent } from '../setup';
2
- export declare function hover(this: UserEvent, element: Element): Promise<void>;
3
- export declare function unhover(this: UserEvent, element: Element): Promise<void>;
1
+ import { Instance } from '../setup';
2
+ export declare function hover(this: Instance, element: Element): Promise<void>;
3
+ export declare function unhover(this: Instance, element: Element): Promise<void>;
@@ -1,4 +1,4 @@
1
- import type { UserEvent } from '../setup';
2
- export declare function tab(this: UserEvent, { shift, }?: {
1
+ import type { Instance } from '../setup';
2
+ export declare function tab(this: Instance, { shift, }?: {
3
3
  shift?: boolean;
4
4
  }): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import './click';
2
+ export { behavior } from './registry';
3
+ export type { BehaviorPlugin } from './registry';
@@ -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,2 @@
1
+ import { Config } from '../setup';
2
+ export declare function dispatchEvent(config: Config, target: Element, event: Event): boolean;
@@ -0,0 +1,2 @@
1
+ export declare function isMouseEvent(type: keyof DocumentEventMap): boolean;
2
+ export declare function isKeyboardEvent(type: keyof DocumentEventMap): boolean;
@@ -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
  export { userEvent as default } from './setup';
2
2
  export type { keyboardKey } from './keyboard';
3
3
  export type { pointerKey } from './pointer';
4
+ export { PointerEventsCheckLevel } from './options';
@@ -1,7 +1,7 @@
1
- import { UserEvent } from '../setup';
1
+ import { Instance } from '../setup';
2
2
  import { releaseAllKeys } from './keyboardAction';
3
3
  import type { keyboardState, keyboardKey } from './types';
4
4
  export { releaseAllKeys };
5
5
  export type { keyboardKey, keyboardState };
6
- export declare function keyboard(this: UserEvent, text: string): Promise<void>;
6
+ export declare function keyboard(this: Instance, text: string): Promise<void>;
7
7
  export declare function createKeyboardState(): keyboardState;
@@ -1,3 +1,4 @@
1
- export declare function fireChangeForInputTimeIfValid(el: HTMLInputElement & {
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;
@@ -1,5 +1,18 @@
1
1
  import type { keyboardKey } from './keyboard/types';
2
2
  import type { pointerKey } from './pointer/types';
3
+ export declare enum PointerEventsCheckLevel {
4
+ /**
5
+ * Check pointer events on every user interaction that triggers a bunch of events.
6
+ * E.g. once for releasing a mouse button even though this triggers `pointerup`, `mouseup`, `click`, etc...
7
+ */
8
+ EachTrigger = 4,
9
+ /** Check each target once per call to pointer (related) API */
10
+ EachApiCall = 2,
11
+ /** Check each event target once */
12
+ EachTarget = 1,
13
+ /** No pointer events check */
14
+ Never = 0
15
+ }
3
16
  export interface Options {
4
17
  /**
5
18
  * When using `userEvent.upload`, automatically discard files
@@ -52,6 +65,16 @@ export interface Options {
52
65
  * This allows to plug in different pointer devices.
53
66
  */
54
67
  pointerMap?: pointerKey[];
68
+ /**
69
+ * The pointer API includes a check if an element has or inherits `pointer-events: none`.
70
+ * This check is known to be expensive and very expensive when checking deeply nested nodes.
71
+ * This option determines how often the pointer related APIs perform the check.
72
+ *
73
+ * This is a binary flag option. You can combine multiple Levels.
74
+ *
75
+ * @default PointerEventsCheckLevel.EachCall
76
+ */
77
+ pointerEventsCheck?: PointerEventsCheckLevel | number;
55
78
  /**
56
79
  * `userEvent.type` automatically releases any keys still pressed at the end of the call.
57
80
  * This option allows to opt out of this feature.
@@ -73,14 +96,6 @@ export interface Options {
73
96
  * @default false
74
97
  */
75
98
  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
99
  /**
85
100
  * Write selected data to Clipboard API when a `cut` or `copy` is triggered.
86
101
  *
@@ -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,4 +1,4 @@
1
- import { UserEvent } from '../setup';
1
+ import { Instance } from '../setup';
2
2
  import { PointerAction, PointerActionTarget } from './pointerAction';
3
3
  import type { pointerState, pointerKey } from './types';
4
4
  export type { pointerState, pointerKey };
@@ -6,5 +6,5 @@ declare type PointerActionInput = string | ({
6
6
  keys: string;
7
7
  } & PointerActionTarget) | PointerAction;
8
8
  export declare type PointerInput = PointerActionInput | Array<PointerActionInput>;
9
- export declare function pointer(this: UserEvent, input: PointerInput): Promise<void>;
9
+ export declare function pointer(this: Instance, input: PointerInput): Promise<void>;
10
10
  export declare function createPointerState(document: Document): pointerState;
@@ -1,6 +1,6 @@
1
- import { inputDeviceState } from '../setup';
1
+ import { Config } from '../setup';
2
2
  import { PointerTarget, SelectionTarget } from './types';
3
3
  export interface PointerMoveAction extends PointerTarget, SelectionTarget {
4
4
  pointerName?: string;
5
5
  }
6
- export declare function pointerMove({ pointerName, target, coords, node, offset }: PointerMoveAction, { pointerState, keyboardState }: inputDeviceState): Promise<void>;
6
+ export declare function pointerMove(config: Config, { pointerName, target, coords, node, offset }: PointerMoveAction): Promise<void>;
@@ -1,8 +1,8 @@
1
- import { inputDeviceState } from '../setup';
1
+ import { Config } from '../setup';
2
2
  import type { pointerKey, PointerTarget, SelectionTarget } from './types';
3
3
  export interface PointerPressAction extends PointerTarget, SelectionTarget {
4
4
  keyDef: pointerKey;
5
5
  releasePrevious: boolean;
6
6
  releaseSelf: boolean;
7
7
  }
8
- export declare function pointerPress(action: PointerPressAction, state: inputDeviceState): Promise<void>;
8
+ export declare function pointerPress(config: Config, action: PointerPressAction): Promise<void>;
@@ -1,4 +1,5 @@
1
- import { PointerCoords, MouseButton } from '../utils';
1
+ import { PointerCoords } from '../event';
2
+ import { MouseButton } from '../utils';
2
3
  /**
3
4
  * @internal Do not create/alter this by yourself as this type might be subject to changes.
4
5
  */
@@ -1,4 +1,3 @@
1
- import type { PointerOptions } from '../utils';
2
1
  import type { PointerInput } from '../pointer';
3
2
  import type { UserEventApi } from '.';
4
3
  import { Config } from './config';
@@ -15,6 +14,6 @@ export declare function paste(clipboardData?: DataTransfer | string, options?: P
15
14
  export declare function selectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
16
15
  export declare function tripleClick(element: Element, options?: Partial<Config>): Promise<void>;
17
16
  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>;
17
+ export declare function unhover(element: Element, options?: Partial<Config>): Promise<void>;
19
18
  export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?: Partial<Config>): Promise<void>;
20
19
  export declare function tab(options?: Partial<Config> & Parameters<UserEventApi['tab']>[0]): Promise<void>;
@@ -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';
@@ -5,9 +6,14 @@ import * as directApi from './directApi';
5
6
  export type { inputDeviceState };
6
7
  export { Config };
7
8
  export declare type UserEventApi = typeof userEventApi;
8
- export declare type UserEvent = UserEventApi & {
9
- readonly setup: typeof setupSub;
9
+ export declare type Instance = UserEventApi & {
10
10
  [Config]: Config;
11
+ dispatchUIEvent: ReturnType<typeof bindDispatchUIEvent>;
12
+ };
13
+ export declare type UserEvent = {
14
+ readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;
15
+ } & {
16
+ readonly [k in keyof UserEventApi]: (...args: Parameters<UserEventApi[k]>) => ReturnType<UserEventApi[k]>;
11
17
  };
12
18
  export declare const userEvent: {
13
19
  readonly setup: typeof setupMain;
@@ -1,74 +1,20 @@
1
1
  import { Options } from '../options';
2
- import type { UserEvent } from './index';
2
+ import type { Instance, UserEvent } from './index';
3
3
  import { Config } from './config';
4
- import * as userEventApi from './api';
4
+ export declare function createConfig(options?: Partial<Config>, defaults?: Required<Options>, node?: Node): Config;
5
5
  /**
6
6
  * Start a "session" with userEvent.
7
7
  * All APIs returned by this function share an input device state and a default configuration.
8
8
  */
9
- export declare function setupMain(options?: Options): {
10
- setup: typeof setupSub;
11
- [Config]: Config;
12
- click: typeof userEventApi.click;
13
- dblClick: typeof userEventApi.dblClick;
14
- tripleClick: typeof userEventApi.tripleClick;
15
- hover: typeof userEventApi.hover;
16
- unhover: typeof userEventApi.unhover;
17
- tab: typeof userEventApi.tab;
18
- keyboard: typeof userEventApi.keyboard;
19
- copy: typeof userEventApi.copy;
20
- cut: typeof userEventApi.cut;
21
- paste: typeof userEventApi.paste;
22
- pointer: typeof userEventApi.pointer;
23
- clear: typeof userEventApi.clear;
24
- deselectOptions: typeof userEventApi.deselectOptions;
25
- selectOptions: typeof userEventApi.selectOptions;
26
- type: typeof userEventApi.type;
27
- upload: typeof userEventApi.upload;
28
- };
9
+ export declare function setupMain(options?: Options): UserEvent;
29
10
  /**
30
11
  * Setup in direct call per `userEvent.anyApi()`
31
12
  */
32
13
  export declare function setupDirect(options?: Partial<Config>, node?: Node): {
33
- setup: typeof setupSub;
34
- [Config]: Config;
35
- click: typeof userEventApi.click;
36
- dblClick: typeof userEventApi.dblClick;
37
- tripleClick: typeof userEventApi.tripleClick;
38
- hover: typeof userEventApi.hover;
39
- unhover: typeof userEventApi.unhover;
40
- tab: typeof userEventApi.tab;
41
- keyboard: typeof userEventApi.keyboard;
42
- copy: typeof userEventApi.copy;
43
- cut: typeof userEventApi.cut;
44
- paste: typeof userEventApi.paste;
45
- pointer: typeof userEventApi.pointer;
46
- clear: typeof userEventApi.clear;
47
- deselectOptions: typeof userEventApi.deselectOptions;
48
- selectOptions: typeof userEventApi.selectOptions;
49
- type: typeof userEventApi.type;
50
- upload: typeof userEventApi.upload;
14
+ config: Config;
15
+ api: UserEvent;
51
16
  };
52
17
  /**
53
18
  * Create a set of callbacks with different default settings but the same state.
54
19
  */
55
- export declare function setupSub(this: UserEvent, options: Options): {
56
- setup: typeof setupSub;
57
- [Config]: Config;
58
- click: typeof userEventApi.click;
59
- dblClick: typeof userEventApi.dblClick;
60
- tripleClick: typeof userEventApi.tripleClick;
61
- hover: typeof userEventApi.hover;
62
- unhover: typeof userEventApi.unhover;
63
- tab: typeof userEventApi.tab;
64
- keyboard: typeof userEventApi.keyboard;
65
- copy: typeof userEventApi.copy;
66
- cut: typeof userEventApi.cut;
67
- paste: typeof userEventApi.paste;
68
- pointer: typeof userEventApi.pointer;
69
- clear: typeof userEventApi.clear;
70
- deselectOptions: typeof userEventApi.deselectOptions;
71
- selectOptions: typeof userEventApi.selectOptions;
72
- type: typeof userEventApi.type;
73
- upload: typeof userEventApi.upload;
74
- };
20
+ export declare function setupSub(this: Instance, options: Options): UserEvent;
@@ -1,2 +1,2 @@
1
- import type { UserEvent } from '../setup';
2
- export declare function clear(this: UserEvent, element: Element): Promise<void>;
1
+ import { Instance } from '../setup';
2
+ export declare function clear(this: Instance, element: Element): Promise<void>;
@@ -1,3 +1,3 @@
1
- import { UserEvent } from '../setup';
2
- export declare function selectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
3
- export declare function deselectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
1
+ import { Instance } from '../setup';
2
+ export declare function selectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
3
+ export declare function deselectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
@@ -1,4 +1,4 @@
1
- import type { UserEvent } from '../setup';
1
+ import type { Instance } from '../setup';
2
2
  import { Config } from '../setup/config';
3
3
  export interface typeOptions {
4
4
  skipClick?: Config['skipClick'];
@@ -6,4 +6,4 @@ export interface typeOptions {
6
6
  initialSelectionStart?: number;
7
7
  initialSelectionEnd?: number;
8
8
  }
9
- export declare function type(this: UserEvent, element: Element, text: string, { skipClick, skipAutoClose, initialSelectionStart, initialSelectionEnd, }?: typeOptions): Promise<void>;
9
+ export declare function type(this: Instance, element: Element, text: string, { skipClick, skipAutoClose, initialSelectionStart, initialSelectionEnd, }?: typeOptions): Promise<void>;
@@ -1,5 +1,5 @@
1
- import { UserEvent } from '../setup';
1
+ import { Instance } from '../setup';
2
2
  export interface uploadInit {
3
3
  changeInit?: EventInit;
4
4
  }
5
- export declare function upload(this: UserEvent, element: HTMLElement, fileOrFiles: File | File[]): Promise<void>;
5
+ export declare function upload(this: Instance, element: HTMLElement, fileOrFiles: File | File[]): Promise<void>;
@@ -1,16 +1,14 @@
1
- import { fireEvent } from '@testing-library/dom';
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: Partial<Parameters<typeof fireEvent>[1]> & {
14
- [k: string]: unknown;
15
- };
13
+ eventOverrides: InputEventInit;
16
14
  }): void;
@@ -1,4 +1,5 @@
1
- export declare function prepareInput(data: string, element: Element, inputType?: string): {
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
  } | {
@@ -0,0 +1,9 @@
1
+ declare global {
2
+ interface Text {
3
+ nodeValue: string;
4
+ }
5
+ }
6
+ export declare function getNextCursorPosition(node: Node, offset: number, direction: -1 | 1, inputType?: string): {
7
+ node: Node;
8
+ offset: number;
9
+ } | undefined;
@@ -1,2 +1,5 @@
1
+ /**
2
+ * Focus closest focusable element.
3
+ */
1
4
  declare function focus(element: Element): void;
2
5
  export { focus };
@@ -16,6 +16,7 @@ export * from './edit/prepareInput';
16
16
  export * from './edit/setFiles';
17
17
  export * from './focus/blur';
18
18
  export * from './focus/copySelection';
19
+ export * from './focus/cursor';
19
20
  export * from './focus/focus';
20
21
  export * from './focus/getActiveElement';
21
22
  export * from './focus/getTabDestination';
@@ -26,6 +27,7 @@ export * from './focus/selector';
26
27
  export * from './keyboard/getKeyEventProps';
27
28
  export * from './keyboard/getUIEventModifiers';
28
29
  export * from './keyDef/readNextDescriptor';
30
+ export * from './misc/cloneEvent';
29
31
  export * from './misc/eventWrapper';
30
32
  export * from './misc/findClosest';
31
33
  export * from './misc/getDocumentFromNode';
@@ -33,8 +35,8 @@ export * from './misc/isDescendantOrSelf';
33
35
  export * from './misc/isElementType';
34
36
  export * from './misc/isVisible';
35
37
  export * from './misc/isDisabled';
38
+ export * from './misc/level';
36
39
  export * from './misc/wait';
37
- export * from './misc/hasPointerEvents';
38
40
  export * from './misc/hasFormSubmit';
39
- export * from './pointer/firePointerEvents';
41
+ export * from './pointer/cssPointerEvents';
40
42
  export * from './pointer/mouseButtons';
@@ -1,17 +1,5 @@
1
- import { keyboardKey, keyboardState } from '../../keyboard/types';
2
- export declare function getKeyEventProps(keyDef: keyboardKey, state: keyboardState): {
3
- altKey: boolean;
4
- ctrlKey: boolean;
5
- metaKey: boolean;
6
- shiftKey: boolean;
7
- modifierAltGraph: boolean;
8
- modifierCapsLock: boolean;
9
- modifierFn: boolean;
10
- modifierFnLock: boolean;
11
- modifierNumLock: boolean;
12
- modifierScrollLock: boolean;
13
- modifierSymbol: boolean;
14
- modifierSymbolLock: boolean;
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;
@@ -1 +1 @@
1
- export declare function findClosest(element: Element, callback: (e: Element) => boolean): Element | undefined;
1
+ export declare function findClosest<T extends Element>(element: Element, callback: (e: Element) => e is T): T | undefined;
@@ -0,0 +1,17 @@
1
+ import { Config } from '../../setup';
2
+ export declare enum ApiLevel {
3
+ Trigger = 2,
4
+ Call = 1
5
+ }
6
+ declare const Level: unique symbol;
7
+ interface LevelRefs {
8
+ [k: number]: object | undefined;
9
+ }
10
+ declare module '../../setup' {
11
+ interface Config {
12
+ [Level]?: LevelRefs;
13
+ }
14
+ }
15
+ export declare function setLevelRef(config: Config, level: ApiLevel): void;
16
+ export declare function getLevelRef(config: Config, level: ApiLevel): object | undefined;
17
+ export {};
@@ -0,0 +1,15 @@
1
+ import { Config } from '../../setup';
2
+ import { ApiLevel } from '..';
3
+ export declare function hasPointerEvents(element: Element): boolean;
4
+ declare const PointerEventsCheck: unique symbol;
5
+ declare global {
6
+ interface Element {
7
+ [PointerEventsCheck]?: {
8
+ [k in ApiLevel]?: object;
9
+ } & {
10
+ result: boolean;
11
+ };
12
+ }
13
+ }
14
+ export declare function assertPointerEvents(config: Config, element: Element): void;
15
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "14.0.0-beta.5",
3
+ "version": "14.0.0-beta.9",
4
4
  "description": "Fire events the same way the user does",
5
5
  "keywords": [
6
6
  "react-testing-library",
package/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- # CHANGELOG
2
-
3
- The changelog is automatically updated using
4
- [semantic-release](https://github.com/semantic-release/semantic-release). You
5
- can see it on the [releases page](../../releases).
@@ -1,15 +0,0 @@
1
- /**
2
- * Options that can be passed to any event that relies
3
- * on pointer-events property
4
- */
5
- export declare interface PointerOptions {
6
- /**
7
- * When set to `true` the event skips checking if any element
8
- * in the DOM-tree has `'pointer-events: none'` set. This check is
9
- * costly in general and very costly when rendering large DOM-trees.
10
- * Can be used to speed up tests.
11
- * Default: `false`
12
- * */
13
- skipPointerEventsCheck?: boolean;
14
- }
15
- export declare function hasPointerEvents(element: Element): boolean;
@@ -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
- }