@testing-library/user-event 14.0.0-alpha.7 → 14.0.0-beta.10

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 (198) hide show
  1. package/README.md +5 -192
  2. package/dist/index.cjs +3003 -0
  3. package/dist/index.mjs +3074 -0
  4. package/dist/types/clipboard/copy.d.ts +2 -0
  5. package/dist/types/clipboard/cut.d.ts +2 -0
  6. package/dist/types/clipboard/index.d.ts +3 -0
  7. package/dist/types/clipboard/paste.d.ts +2 -0
  8. package/dist/types/convenience/click.d.ts +4 -0
  9. package/dist/types/convenience/hover.d.ts +3 -0
  10. package/dist/types/convenience/index.d.ts +3 -0
  11. package/dist/types/convenience/tab.d.ts +4 -0
  12. package/dist/{document → types/document}/index.d.ts +0 -0
  13. package/dist/{document → types/document}/interceptor.d.ts +0 -0
  14. package/dist/{document → types/document}/selection.d.ts +0 -0
  15. package/dist/{document → types/document}/value.d.ts +0 -0
  16. package/dist/types/event/behavior/click.d.ts +1 -0
  17. package/dist/types/event/behavior/index.d.ts +3 -0
  18. package/dist/types/event/behavior/registry.d.ts +9 -0
  19. package/dist/types/event/createEvent.d.ts +8 -0
  20. package/dist/types/event/dispatchEvent.d.ts +2 -0
  21. package/dist/types/event/eventTypes.d.ts +2 -0
  22. package/dist/types/event/index.d.ts +6 -0
  23. package/dist/types/event/types.d.ts +13 -0
  24. package/dist/types/event/wrapEvent.d.ts +1 -0
  25. package/dist/types/index.d.ts +4 -0
  26. package/dist/types/keyboard/index.d.ts +7 -0
  27. package/dist/{keyboard → types/keyboard}/keyMap.d.ts +0 -0
  28. package/dist/types/keyboard/keyboardAction.d.ts +10 -0
  29. package/dist/{keyboard/getNextKeyDef.d.ts → types/keyboard/parseKeyDef.d.ts} +4 -6
  30. package/dist/{keyboard → types/keyboard}/plugins/arrow.d.ts +0 -0
  31. package/dist/{keyboard → types/keyboard}/plugins/character.d.ts +0 -0
  32. package/dist/types/keyboard/plugins/combination.d.ts +5 -0
  33. package/dist/{keyboard → types/keyboard}/plugins/control.d.ts +0 -0
  34. package/dist/{keyboard → types/keyboard}/plugins/functional.d.ts +0 -3
  35. package/dist/{keyboard → types/keyboard}/plugins/index.d.ts +0 -1
  36. package/dist/types/keyboard/plugins/modifiers.d.ts +8 -0
  37. package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +4 -0
  38. package/dist/{keyboard → types/keyboard}/shared/index.d.ts +0 -0
  39. package/dist/{keyboard → types/keyboard}/types.d.ts +22 -24
  40. package/dist/types/options.d.ts +117 -0
  41. package/dist/types/pointer/firePointerEvents.d.ts +11 -0
  42. package/dist/types/pointer/index.d.ts +10 -0
  43. package/dist/{pointer → types/pointer}/keyMap.d.ts +0 -0
  44. package/dist/types/pointer/parseKeyDef.d.ts +6 -0
  45. package/dist/{pointer → types/pointer}/pointerAction.d.ts +3 -2
  46. package/dist/types/pointer/pointerMove.d.ts +6 -0
  47. package/dist/types/pointer/pointerPress.d.ts +8 -0
  48. package/dist/{pointer → types/pointer}/resolveSelectionTarget.d.ts +0 -0
  49. package/dist/{pointer → types/pointer}/types.d.ts +2 -12
  50. package/dist/types/setup/api.d.ts +5 -0
  51. package/dist/types/setup/config.d.ts +10 -0
  52. package/dist/types/setup/directApi.d.ts +19 -0
  53. package/dist/types/setup/index.d.ts +36 -0
  54. package/dist/types/setup/setup.d.ts +20 -0
  55. package/dist/types/setup/wrapAsync.d.ts +4 -0
  56. package/dist/types/utility/clear.d.ts +2 -0
  57. package/dist/types/utility/index.d.ts +4 -0
  58. package/dist/types/utility/selectOptions.d.ts +3 -0
  59. package/dist/types/utility/type.d.ts +9 -0
  60. package/dist/types/utility/upload.d.ts +5 -0
  61. package/dist/{utils → types/utils}/click/isClickableInput.d.ts +0 -0
  62. package/dist/types/utils/dataTransfer/Blob.d.ts +1 -0
  63. package/dist/types/utils/dataTransfer/Clipboard.d.ts +9 -0
  64. package/dist/types/utils/dataTransfer/DataTransfer.d.ts +2 -0
  65. package/dist/types/utils/dataTransfer/FileList.d.ts +1 -0
  66. package/dist/{utils → types/utils}/edit/buildTimeValue.d.ts +0 -0
  67. package/dist/{utils → types/utils}/edit/calculateNewValue.d.ts +1 -3
  68. package/dist/types/utils/edit/editInputElement.d.ts +14 -0
  69. package/dist/{utils → types/utils}/edit/getValue.d.ts +0 -0
  70. package/dist/{utils → types/utils}/edit/isContentEditable.d.ts +0 -0
  71. package/dist/{utils → types/utils}/edit/isEditable.d.ts +0 -0
  72. package/dist/{utils → types/utils}/edit/isValidDateValue.d.ts +0 -0
  73. package/dist/{utils → types/utils}/edit/isValidInputTimeValue.d.ts +0 -0
  74. package/dist/{utils → types/utils}/edit/maxLength.d.ts +0 -0
  75. package/dist/types/utils/edit/prepareInput.d.ts +8 -0
  76. package/dist/types/utils/edit/setFiles.d.ts +12 -0
  77. package/dist/{utils → types/utils}/focus/blur.d.ts +0 -0
  78. package/dist/types/utils/focus/copySelection.d.ts +1 -0
  79. package/dist/types/utils/focus/cursor.d.ts +9 -0
  80. package/dist/{utils → types/utils}/focus/focus.d.ts +3 -0
  81. package/dist/{utils → types/utils}/focus/getActiveElement.d.ts +0 -0
  82. package/dist/{utils → types/utils}/focus/getTabDestination.d.ts +0 -0
  83. package/dist/{utils → types/utils}/focus/isFocusable.d.ts +0 -0
  84. package/dist/types/utils/focus/selectAll.d.ts +5 -0
  85. package/dist/{utils → types/utils}/focus/selection.d.ts +0 -0
  86. package/dist/{utils → types/utils}/focus/selector.d.ts +0 -0
  87. package/dist/{utils → types/utils}/index.d.ts +15 -4
  88. package/dist/{utils → types/utils}/keyDef/readNextDescriptor.d.ts +0 -0
  89. package/dist/types/utils/keyboard/getKeyEventProps.d.ts +5 -0
  90. package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
  91. package/dist/types/utils/misc/cloneEvent.d.ts +1 -0
  92. package/dist/{utils → types/utils}/misc/eventWrapper.d.ts +0 -0
  93. package/dist/types/utils/misc/findClosest.d.ts +1 -0
  94. package/dist/types/utils/misc/getDocumentFromNode.d.ts +1 -0
  95. package/dist/{utils → types/utils}/misc/hasFormSubmit.d.ts +0 -0
  96. package/dist/{utils → types/utils}/misc/isDescendantOrSelf.d.ts +0 -0
  97. package/dist/{utils → types/utils}/misc/isDisabled.d.ts +0 -0
  98. package/dist/{utils → types/utils}/misc/isElementType.d.ts +0 -0
  99. package/dist/{utils → types/utils}/misc/isVisible.d.ts +0 -0
  100. package/dist/types/utils/misc/level.d.ts +17 -0
  101. package/dist/{utils → types/utils}/misc/wait.d.ts +0 -0
  102. package/dist/types/utils/pointer/cssPointerEvents.d.ts +15 -0
  103. package/dist/{utils → types/utils}/pointer/mouseButtons.d.ts +0 -0
  104. package/package.json +13 -30
  105. package/CHANGELOG.md +0 -5
  106. package/dist/clear.d.ts +0 -2
  107. package/dist/clear.js +0 -46
  108. package/dist/click.d.ts +0 -9
  109. package/dist/click.js +0 -62
  110. package/dist/document/index.js +0 -100
  111. package/dist/document/interceptor.js +0 -37
  112. package/dist/document/selection.js +0 -90
  113. package/dist/document/value.js +0 -77
  114. package/dist/hover.d.ts +0 -4
  115. package/dist/hover.js +0 -43
  116. package/dist/index.d.ts +0 -8
  117. package/dist/index.js +0 -22
  118. package/dist/keyboard/getEventProps.d.ts +0 -17
  119. package/dist/keyboard/getEventProps.js +0 -33
  120. package/dist/keyboard/getNextKeyDef.js +0 -85
  121. package/dist/keyboard/index.d.ts +0 -19
  122. package/dist/keyboard/index.js +0 -78
  123. package/dist/keyboard/keyMap.js +0 -143
  124. package/dist/keyboard/keyboardImplementation.d.ts +0 -3
  125. package/dist/keyboard/keyboardImplementation.js +0 -169
  126. package/dist/keyboard/plugins/arrow.js +0 -28
  127. package/dist/keyboard/plugins/character.js +0 -166
  128. package/dist/keyboard/plugins/control.js +0 -52
  129. package/dist/keyboard/plugins/functional.js +0 -140
  130. package/dist/keyboard/plugins/index.js +0 -40
  131. package/dist/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -3
  132. package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
  133. package/dist/keyboard/shared/index.js +0 -18
  134. package/dist/keyboard/specialCharMap.d.ts +0 -22
  135. package/dist/keyboard/specialCharMap.js +0 -30
  136. package/dist/keyboard/types.js +0 -19
  137. package/dist/paste.d.ts +0 -7
  138. package/dist/paste.js +0 -60
  139. package/dist/pointer/index.d.ts +0 -18
  140. package/dist/pointer/index.js +0 -90
  141. package/dist/pointer/keyMap.js +0 -29
  142. package/dist/pointer/parseKeyDef.d.ts +0 -6
  143. package/dist/pointer/parseKeyDef.js +0 -36
  144. package/dist/pointer/pointerAction.js +0 -52
  145. package/dist/pointer/pointerMove.d.ts +0 -5
  146. package/dist/pointer/pointerMove.js +0 -136
  147. package/dist/pointer/pointerPress.d.ts +0 -7
  148. package/dist/pointer/pointerPress.js +0 -330
  149. package/dist/pointer/resolveSelectionTarget.js +0 -75
  150. package/dist/pointer/types.js +0 -1
  151. package/dist/selectOptions.d.ts +0 -4
  152. package/dist/selectOptions.js +0 -142
  153. package/dist/setup.d.ts +0 -92
  154. package/dist/setup.js +0 -203
  155. package/dist/tab.d.ts +0 -5
  156. package/dist/tab.js +0 -12
  157. package/dist/type.d.ts +0 -14
  158. package/dist/type.js +0 -74
  159. package/dist/upload.d.ts +0 -10
  160. package/dist/upload.js +0 -92
  161. package/dist/utils/click/isClickableInput.js +0 -14
  162. package/dist/utils/edit/buildTimeValue.js +0 -44
  163. package/dist/utils/edit/calculateNewValue.js +0 -50
  164. package/dist/utils/edit/fireInputEvent.d.ts +0 -11
  165. package/dist/utils/edit/fireInputEvent.js +0 -65
  166. package/dist/utils/edit/getValue.js +0 -23
  167. package/dist/utils/edit/isContentEditable.js +0 -25
  168. package/dist/utils/edit/isEditable.js +0 -42
  169. package/dist/utils/edit/isValidDateValue.js +0 -12
  170. package/dist/utils/edit/isValidInputTimeValue.js +0 -12
  171. package/dist/utils/edit/maxLength.js +0 -50
  172. package/dist/utils/edit/prepareInput.d.ts +0 -4
  173. package/dist/utils/edit/prepareInput.js +0 -60
  174. package/dist/utils/focus/blur.js +0 -19
  175. package/dist/utils/focus/focus.js +0 -22
  176. package/dist/utils/focus/getActiveElement.js +0 -26
  177. package/dist/utils/focus/getTabDestination.js +0 -71
  178. package/dist/utils/focus/isFocusable.js +0 -12
  179. package/dist/utils/focus/selection.js +0 -190
  180. package/dist/utils/focus/selector.js +0 -8
  181. package/dist/utils/index.js +0 -408
  182. package/dist/utils/keyDef/readNextDescriptor.js +0 -102
  183. package/dist/utils/misc/eventWrapper.js +0 -16
  184. package/dist/utils/misc/findClosest.d.ts +0 -1
  185. package/dist/utils/misc/findClosest.js +0 -20
  186. package/dist/utils/misc/hasFormSubmit.js +0 -10
  187. package/dist/utils/misc/hasPointerEvents.d.ts +0 -15
  188. package/dist/utils/misc/hasPointerEvents.js +0 -24
  189. package/dist/utils/misc/isDescendantOrSelf.js +0 -20
  190. package/dist/utils/misc/isDisabled.js +0 -12
  191. package/dist/utils/misc/isElementType.js +0 -24
  192. package/dist/utils/misc/isVisible.js +0 -24
  193. package/dist/utils/misc/wait.js +0 -10
  194. package/dist/utils/pointer/fakeEvent.d.ts +0 -20
  195. package/dist/utils/pointer/fakeEvent.js +0 -91
  196. package/dist/utils/pointer/firePointerEvents.d.ts +0 -14
  197. package/dist/utils/pointer/firePointerEvents.js +0 -55
  198. package/dist/utils/pointer/mouseButtons.js +0 -45
@@ -0,0 +1,2 @@
1
+ import { Instance } from '../setup';
2
+ export declare function copy(this: Instance): Promise<DataTransfer | undefined>;
@@ -0,0 +1,2 @@
1
+ import { Instance } from '../setup';
2
+ export declare function cut(this: Instance): Promise<DataTransfer | undefined>;
@@ -0,0 +1,3 @@
1
+ export * from './copy';
2
+ export * from './cut';
3
+ export * from './paste';
@@ -0,0 +1,2 @@
1
+ import { Instance } from '../setup';
2
+ export declare function paste(this: Instance, clipboardData?: DataTransfer | string): Promise<void>;
@@ -0,0 +1,4 @@
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>;
@@ -0,0 +1,3 @@
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>;
@@ -0,0 +1,3 @@
1
+ export * from './click';
2
+ export * from './hover';
3
+ export * from './tab';
@@ -0,0 +1,4 @@
1
+ import type { Instance } from '../setup';
2
+ export declare function tab(this: Instance, { shift, }?: {
3
+ shift?: boolean;
4
+ }): Promise<void>;
File without changes
File without changes
File without changes
@@ -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;
@@ -0,0 +1,4 @@
1
+ export { userEvent as default } from './setup';
2
+ export type { keyboardKey } from './keyboard';
3
+ export type { pointerKey } from './pointer';
4
+ export { PointerEventsCheckLevel } from './options';
@@ -0,0 +1,7 @@
1
+ import { Instance } from '../setup';
2
+ import { releaseAllKeys } from './keyboardAction';
3
+ import type { keyboardState, keyboardKey } from './types';
4
+ export { releaseAllKeys };
5
+ export type { keyboardKey, keyboardState };
6
+ export declare function keyboard(this: Instance, text: string): Promise<void>;
7
+ export declare function createKeyboardState(): keyboardState;
File without changes
@@ -0,0 +1,10 @@
1
+ import { Config } from '../setup';
2
+ import { keyboardKey } from './types';
3
+ export interface KeyboardAction {
4
+ keyDef: keyboardKey;
5
+ releasePrevious: boolean;
6
+ releaseSelf: boolean;
7
+ repeat: number;
8
+ }
9
+ export declare function keyboardAction(config: Config, actions: KeyboardAction[]): Promise<void>;
10
+ export declare function releaseAllKeys(config: Config): Promise<void>;
@@ -1,6 +1,6 @@
1
- import { keyboardKey, keyboardOptions } from './types';
1
+ import { keyboardKey } from './types';
2
2
  /**
3
- * Get the next key from keyMap
3
+ * Parse key defintions per `keyboardMap`
4
4
  *
5
5
  * Keys can be referenced by `{key}` or `{special}` as well as physical locations per `[code]`.
6
6
  * Everything else will be interpreted as a typed character - e.g. `a`.
@@ -8,12 +8,10 @@ import { keyboardKey, keyboardOptions } from './types';
8
8
  * Keeping the key pressed can be written as `{key>}`.
9
9
  * When keeping the key pressed you can choose how long (how many keydown and keypress) the key is pressed `{key>3}`.
10
10
  * You can then release the key per `{key>3/}` or keep it pressed and continue with the next key.
11
- * Modifiers like `{shift}` imply being kept pressed. This can be turned of per `{shift/}`.
12
11
  */
13
- export declare function getNextKeyDef(text: string, options: keyboardOptions): {
12
+ export declare function parseKeyDef(keyboardMap: keyboardKey[], text: string): {
14
13
  keyDef: keyboardKey;
15
- consumedLength: number;
16
14
  releasePrevious: boolean;
17
15
  releaseSelf: boolean;
18
16
  repeat: number;
19
- };
17
+ }[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Default behavior for key combinations
3
+ */
4
+ import { behaviorPlugin } from '../types';
5
+ export declare const keydownBehavior: behaviorPlugin[];
@@ -3,9 +3,6 @@
3
3
  * https://w3c.github.io/uievents-code/#key-alphanumeric-functional
4
4
  */
5
5
  import { behaviorPlugin } from '../types';
6
- export declare const preKeydownBehavior: behaviorPlugin[];
7
6
  export declare const keydownBehavior: behaviorPlugin[];
8
7
  export declare const keypressBehavior: behaviorPlugin[];
9
- export declare const preKeyupBehavior: behaviorPlugin[];
10
8
  export declare const keyupBehavior: behaviorPlugin[];
11
- export declare const postKeyupBehavior: behaviorPlugin[];
@@ -1,5 +1,4 @@
1
1
  import { behaviorPlugin } from '../types';
2
- export declare const replaceBehavior: behaviorPlugin[];
3
2
  export declare const preKeydownBehavior: behaviorPlugin[];
4
3
  export declare const keydownBehavior: behaviorPlugin[];
5
4
  export declare const keypressBehavior: behaviorPlugin[];
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This file should contain behavior for modifier keys:
3
+ * https://www.w3.org/TR/uievents-key/#keys-modifier
4
+ */
5
+ import { behaviorPlugin } from '../types';
6
+ export declare const preKeydownBehavior: behaviorPlugin[];
7
+ export declare const preKeyupBehavior: behaviorPlugin[];
8
+ export declare const postKeyupBehavior: behaviorPlugin[];
@@ -0,0 +1,4 @@
1
+ import { Config } from '../../setup';
2
+ export declare function fireChangeForInputTimeIfValid(config: Config, el: HTMLInputElement & {
3
+ type: 'time';
4
+ }, prevValue: unknown, timeNewEntry: string): void;
@@ -1,4 +1,4 @@
1
- import { getNextKeyDef } from './getNextKeyDef';
1
+ import { Config } from '../setup';
2
2
  /**
3
3
  * @internal Do not create/alter this by yourself as this type might be subject to changes.
4
4
  */
@@ -14,11 +14,25 @@ export declare type keyboardState = {
14
14
  Active modifiers
15
15
  */
16
16
  modifiers: {
17
- alt: boolean;
18
- caps: boolean;
19
- ctrl: boolean;
20
- meta: boolean;
21
- shift: boolean;
17
+ Alt: boolean;
18
+ AltGraph: boolean;
19
+ CapsLock: boolean;
20
+ Control: boolean;
21
+ Fn: boolean;
22
+ FnLock: boolean;
23
+ Meta: boolean;
24
+ NumLock: boolean;
25
+ ScrollLock: boolean;
26
+ Shift: boolean;
27
+ Symbol: boolean;
28
+ SymbolLock: boolean;
29
+ };
30
+ modifierPhase: {
31
+ CapsLock?: boolean;
32
+ FnLock?: boolean;
33
+ NumLock?: boolean;
34
+ ScrollLock?: boolean;
35
+ SymbolLock?: boolean;
22
36
  };
23
37
  /**
24
38
  The element the keyboard input is performed on.
@@ -39,20 +53,6 @@ export declare type keyboardState = {
39
53
  E.g. ^1
40
54
  */
41
55
  carryChar: string;
42
- /**
43
- Repeat keydown and keypress event
44
- */
45
- repeatKey?: ReturnType<typeof getNextKeyDef>;
46
- };
47
- export declare type keyboardOptions = {
48
- /** Document in which to perform the events */
49
- document: Document;
50
- /** Delay between keystrokes */
51
- delay: number;
52
- /** Add modifiers for given keys - not implemented yet */
53
- autoModify: boolean;
54
- /** Keyboard layout to use */
55
- keyboardMap: keyboardKey[];
56
56
  };
57
57
  export declare enum DOM_KEY_LOCATION {
58
58
  STANDARD = 0,
@@ -67,14 +67,12 @@ export interface keyboardKey {
67
67
  key?: string;
68
68
  /** Location on the keyboard for keys with multiple representation */
69
69
  location?: DOM_KEY_LOCATION;
70
- /** keyCode for legacy support */
71
- keyCode?: number;
72
70
  /** Does the character in `key` require/imply AltRight to be pressed? */
73
71
  altGr?: boolean;
74
72
  /** Does the character in `key` require/imply a shiftKey to be pressed? */
75
73
  shift?: boolean;
76
74
  }
77
75
  export interface behaviorPlugin {
78
- matches: (keyDef: keyboardKey, element: Element, options: keyboardOptions, state: keyboardState) => boolean;
79
- handle: (keyDef: keyboardKey, element: Element, options: keyboardOptions, state: keyboardState) => void;
76
+ matches: (keyDef: keyboardKey, element: Element, config: Config) => boolean;
77
+ handle: (keyDef: keyboardKey, element: Element, config: Config) => void;
80
78
  }
@@ -0,0 +1,117 @@
1
+ import type { keyboardKey } from './keyboard/types';
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
+ }
16
+ export interface Options {
17
+ /**
18
+ * When using `userEvent.upload`, automatically discard files
19
+ * that don't match an `accept` property if it exists.
20
+ *
21
+ * @default true
22
+ */
23
+ applyAccept?: boolean;
24
+ /**
25
+ * We intend to automatically apply modifier keys for printable characters in the future.
26
+ * I.e. `A` implying `{Shift>}a{/Shift}` if caps lock is not active.
27
+ *
28
+ * This options allows you to opt out of this change in foresight.
29
+ * The feature therefore will not constitute a breaking change.
30
+ *
31
+ * @default true
32
+ */
33
+ autoModify?: boolean;
34
+ /**
35
+ * Between some subsequent inputs like typing a series of characters
36
+ * the code execution is delayed per `setTimeout` for (at least) `delay` seconds.
37
+ * This moves the next changes at least to next macro task
38
+ * and allows other (asynchronous) code to run between events.
39
+ *
40
+ * `null` prevents `setTimeout` from being called.
41
+ *
42
+ * @default 0
43
+ */
44
+ delay?: number | null;
45
+ /**
46
+ * The document.
47
+ *
48
+ * This defaults to the owner document of an element if an API is called directly with an element and without setup.
49
+ * Otherwise it falls back to the global document.
50
+ *
51
+ * @default element.ownerDocument??global.document
52
+ */
53
+ document?: Document;
54
+ /**
55
+ * An array of keyboard keys the keyboard device consists of.
56
+ *
57
+ * This allows to plug in different layouts / localizations.
58
+ *
59
+ * Defaults to a "standard" US-104-QWERTY keyboard.
60
+ */
61
+ keyboardMap?: keyboardKey[];
62
+ /**
63
+ * An array of available pointer keys.
64
+ *
65
+ * This allows to plug in different pointer devices.
66
+ */
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;
78
+ /**
79
+ * `userEvent.type` automatically releases any keys still pressed at the end of the call.
80
+ * This option allows to opt out of this feature.
81
+ *
82
+ * @default false
83
+ */
84
+ skipAutoClose?: boolean;
85
+ /**
86
+ * `userEvent.type` implys a click at the end of the element content/value.
87
+ * This option allows to opt out of this feature.
88
+ *
89
+ * @default false
90
+ */
91
+ skipClick?: boolean;
92
+ /**
93
+ * `userEvent.click` implys moving the cursor to the target element first.
94
+ * This options allows to opt out of this feature.
95
+ *
96
+ * @default false
97
+ */
98
+ skipHover?: boolean;
99
+ /**
100
+ * Write selected data to Clipboard API when a `cut` or `copy` is triggered.
101
+ *
102
+ * The Clipboard API is usually not available to test code.
103
+ * Our `setup` replaces the `navigator.clipboard` property with a stub.
104
+ *
105
+ * Defaults to `false` when calling the APIs directly.
106
+ * Defaults to `true` when calling the APIs per `setup`.
107
+ */
108
+ writeToClipboard?: boolean;
109
+ }
110
+ /**
111
+ * Default options applied when API is called per `userEvent.anyApi()`
112
+ */
113
+ export declare const defaultOptionsDirect: Required<Options>;
114
+ /**
115
+ * Default options applied when API is called per `userEvent().anyApi()`
116
+ */
117
+ export declare const defaultOptionsSetup: Required<Options>;
@@ -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;
@@ -0,0 +1,10 @@
1
+ import { Instance } from '../setup';
2
+ import { PointerAction, PointerActionTarget } from './pointerAction';
3
+ import type { pointerState, pointerKey } from './types';
4
+ export type { pointerState, pointerKey };
5
+ declare type PointerActionInput = string | ({
6
+ keys: string;
7
+ } & PointerActionTarget) | PointerAction;
8
+ export declare type PointerInput = PointerActionInput | Array<PointerActionInput>;
9
+ export declare function pointer(this: Instance, input: PointerInput): Promise<void>;
10
+ export declare function createPointerState(document: Document): pointerState;
File without changes
@@ -0,0 +1,6 @@
1
+ import { pointerKey } from './types';
2
+ export declare function parseKeyDef(pointerMap: pointerKey[], keys: string): {
3
+ keyDef: pointerKey;
4
+ releasePrevious: boolean;
5
+ releaseSelf: boolean;
6
+ }[];
@@ -1,6 +1,7 @@
1
+ import { Config } from '../setup';
1
2
  import { PointerMoveAction } from './pointerMove';
2
3
  import { PointerPressAction } from './pointerPress';
3
- import { inputDeviceState, pointerOptions, PointerTarget, SelectionTarget } from './types';
4
+ import { PointerTarget, SelectionTarget } from './types';
4
5
  export declare type PointerActionTarget = Partial<PointerTarget> & Partial<SelectionTarget>;
5
6
  export declare type PointerAction = PointerActionTarget & (Omit<PointerPressAction, 'target' | 'coords'> | Omit<PointerMoveAction, 'target' | 'coords'>);
6
- export declare function pointerAction(actions: PointerAction[], options: pointerOptions, state: inputDeviceState): Promise<unknown[]>;
7
+ export declare function pointerAction(config: Config, actions: PointerAction[]): Promise<void>;
@@ -0,0 +1,6 @@
1
+ import { Config } from '../setup';
2
+ import { PointerTarget, SelectionTarget } from './types';
3
+ export interface PointerMoveAction extends PointerTarget, SelectionTarget {
4
+ pointerName?: string;
5
+ }
6
+ export declare function pointerMove(config: Config, { pointerName, target, coords, node, offset }: PointerMoveAction): Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { Config } from '../setup';
2
+ import type { pointerKey, PointerTarget, SelectionTarget } from './types';
3
+ export interface PointerPressAction extends PointerTarget, SelectionTarget {
4
+ keyDef: pointerKey;
5
+ releasePrevious: boolean;
6
+ releaseSelf: boolean;
7
+ }
8
+ export declare function pointerPress(config: Config, action: PointerPressAction): Promise<void>;
@@ -1,5 +1,5 @@
1
- import { keyboardState } from '../keyboard/types';
2
- import { PointerCoords, MouseButton } from '../utils';
1
+ import { PointerCoords } from '../event';
2
+ import { MouseButton } from '../utils';
3
3
  /**
4
4
  * @internal Do not create/alter this by yourself as this type might be subject to changes.
5
5
  */
@@ -34,12 +34,6 @@ export declare type pointerState = {
34
34
  */
35
35
  pointerId: number;
36
36
  };
37
- export declare type pointerOptions = {
38
- /** Delay between keystrokes */
39
- delay: number;
40
- /** Available pointer keys */
41
- pointerMap: pointerKey[];
42
- };
43
37
  export interface pointerKey {
44
38
  /** Name of the pointer key */
45
39
  name: string;
@@ -66,7 +60,3 @@ export interface SelectionInputRange {
66
60
  start: number;
67
61
  end: number;
68
62
  }
69
- export interface inputDeviceState {
70
- pointerState: pointerState;
71
- keyboardState: keyboardState;
72
- }
@@ -0,0 +1,5 @@
1
+ export { click, dblClick, tripleClick, hover, unhover, tab } from '../convenience';
2
+ export { keyboard } from '../keyboard';
3
+ export { copy, cut, paste } from '../clipboard';
4
+ export { pointer } from '../pointer';
5
+ export { clear, deselectOptions, selectOptions, type, upload } from '../utility';
@@ -0,0 +1,10 @@
1
+ import type { keyboardState } from '../keyboard/types';
2
+ import type { pointerState } from '../pointer/types';
3
+ import type { Options } from '../options';
4
+ export interface inputDeviceState {
5
+ pointerState: pointerState;
6
+ keyboardState: keyboardState;
7
+ }
8
+ export interface Config extends Required<Options>, inputDeviceState {
9
+ }
10
+ export declare const Config: unique symbol;
@@ -0,0 +1,19 @@
1
+ import type { PointerInput } from '../pointer';
2
+ import type { UserEventApi } from '.';
3
+ import { Config } from './config';
4
+ export declare function clear(element: Element): Promise<void>;
5
+ export declare function click(element: Element, options?: Partial<Config>): Promise<void>;
6
+ export declare function copy(options?: Partial<Config>): Promise<DataTransfer | undefined>;
7
+ export declare function cut(options?: Partial<Config>): Promise<DataTransfer | undefined>;
8
+ export declare function dblClick(element: Element, options?: Partial<Config>): Promise<void>;
9
+ export declare function deselectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
10
+ export declare function hover(element: Element, options?: Partial<Config>): Promise<void>;
11
+ export declare function keyboard(text: string, options?: Partial<Config>): Promise<import("../keyboard").keyboardState>;
12
+ export declare function pointer(input: PointerInput, options?: Partial<Config>): Promise<import("../pointer").pointerState>;
13
+ export declare function paste(clipboardData?: DataTransfer | string, options?: Partial<Config>): Promise<void>;
14
+ export declare function selectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
15
+ export declare function tripleClick(element: Element, options?: Partial<Config>): Promise<void>;
16
+ export declare function type(element: Element, text: string, options?: Partial<Config> & Parameters<UserEventApi['type']>[2]): Promise<void>;
17
+ export declare function unhover(element: Element, options?: Partial<Config>): Promise<void>;
18
+ export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?: Partial<Config>): Promise<void>;
19
+ export declare function tab(options?: Partial<Config> & Parameters<UserEventApi['tab']>[0]): Promise<void>;
@@ -0,0 +1,36 @@
1
+ import type { bindDispatchUIEvent } from '../event';
2
+ import type * as userEventApi from './api';
3
+ import { setupMain, setupSub } from './setup';
4
+ import { Config, inputDeviceState } from './config';
5
+ import * as directApi from './directApi';
6
+ export type { inputDeviceState };
7
+ export { Config };
8
+ export declare type UserEventApi = typeof userEventApi;
9
+ export declare type Instance = UserEventApi & {
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]>;
17
+ };
18
+ export declare const userEvent: {
19
+ readonly setup: typeof setupMain;
20
+ readonly clear: typeof directApi.clear;
21
+ readonly click: typeof directApi.click;
22
+ readonly copy: typeof directApi.copy;
23
+ readonly cut: typeof directApi.cut;
24
+ readonly dblClick: typeof directApi.dblClick;
25
+ readonly deselectOptions: typeof directApi.deselectOptions;
26
+ readonly hover: typeof directApi.hover;
27
+ readonly keyboard: typeof directApi.keyboard;
28
+ readonly pointer: typeof directApi.pointer;
29
+ readonly paste: typeof directApi.paste;
30
+ readonly selectOptions: typeof directApi.selectOptions;
31
+ readonly tripleClick: typeof directApi.tripleClick;
32
+ readonly type: typeof directApi.type;
33
+ readonly unhover: typeof directApi.unhover;
34
+ readonly upload: typeof directApi.upload;
35
+ readonly tab: typeof directApi.tab;
36
+ };
@@ -0,0 +1,20 @@
1
+ import { Options } from '../options';
2
+ import type { Instance, UserEvent } from './index';
3
+ import { Config } from './config';
4
+ export declare function createConfig(options?: Partial<Config>, defaults?: Required<Options>, node?: Node): Config;
5
+ /**
6
+ * Start a "session" with userEvent.
7
+ * All APIs returned by this function share an input device state and a default configuration.
8
+ */
9
+ export declare function setupMain(options?: Options): UserEvent;
10
+ /**
11
+ * Setup in direct call per `userEvent.anyApi()`
12
+ */
13
+ export declare function setupDirect(options?: Partial<Config>, node?: Node): {
14
+ config: Config;
15
+ api: UserEvent;
16
+ };
17
+ /**
18
+ * Create a set of callbacks with different default settings but the same state.
19
+ */
20
+ export declare function setupSub(this: Instance, options: Options): UserEvent;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Wrap an internal Promise
3
+ */
4
+ export declare function wrapAsync<R, P extends (() => Promise<R>) | (() => R)>(implementation: P): Promise<R>;
@@ -0,0 +1,2 @@
1
+ import { Instance } from '../setup';
2
+ export declare function clear(this: Instance, element: Element): Promise<void>;
@@ -0,0 +1,4 @@
1
+ export * from './clear';
2
+ export * from './selectOptions';
3
+ export * from './type';
4
+ export * from './upload';
@@ -0,0 +1,3 @@
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>;
@@ -0,0 +1,9 @@
1
+ import type { Instance } from '../setup';
2
+ import { Config } from '../setup/config';
3
+ export interface typeOptions {
4
+ skipClick?: Config['skipClick'];
5
+ skipAutoClose?: Config['skipClick'];
6
+ initialSelectionStart?: number;
7
+ initialSelectionEnd?: number;
8
+ }
9
+ export declare function type(this: Instance, element: Element, text: string, { skipClick, skipAutoClose, initialSelectionStart, initialSelectionEnd, }?: typeOptions): Promise<void>;