@testing-library/user-event 14.0.0-beta.1 → 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 (210) 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/{clipboard → types/clipboard}/index.d.ts +0 -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/{convenience → types/convenience}/index.d.ts +0 -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/{index.d.ts → types/index.d.ts} +1 -0
  26. package/dist/{keyboard → types/keyboard}/index.d.ts +2 -2
  27. package/dist/{keyboard → types/keyboard}/keyMap.d.ts +0 -0
  28. package/dist/{keyboard → types/keyboard}/keyboardAction.d.ts +0 -0
  29. package/dist/{keyboard → types/keyboard}/parseKeyDef.d.ts +0 -0
  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/{keyboard → types/keyboard}/plugins/combination.d.ts +0 -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 -0
  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 +19 -5
  40. package/dist/{options.d.ts → types/options.d.ts} +23 -8
  41. package/dist/types/pointer/firePointerEvents.d.ts +11 -0
  42. package/dist/{pointer → types/pointer}/index.d.ts +2 -2
  43. package/dist/{pointer → types/pointer}/keyMap.d.ts +0 -0
  44. package/dist/{pointer → types/pointer}/parseKeyDef.d.ts +0 -0
  45. package/dist/{pointer → types/pointer}/pointerAction.d.ts +0 -0
  46. package/dist/types/pointer/pointerMove.d.ts +6 -0
  47. package/dist/{pointer → types/pointer}/pointerPress.d.ts +2 -2
  48. package/dist/{pointer → types/pointer}/resolveSelectionTarget.d.ts +0 -0
  49. package/dist/{pointer → types/pointer}/types.d.ts +2 -1
  50. package/dist/{setup → types/setup}/api.d.ts +0 -0
  51. package/dist/{setup → types/setup}/config.d.ts +0 -0
  52. package/dist/{setup → types/setup}/directApi.d.ts +1 -2
  53. package/dist/{setup → types/setup}/index.d.ts +8 -2
  54. package/dist/types/setup/setup.d.ts +20 -0
  55. package/dist/{setup → types/setup}/wrapAsync.d.ts +0 -0
  56. package/dist/types/utility/clear.d.ts +2 -0
  57. package/dist/{utility → types/utility}/index.d.ts +0 -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/{utils → types/utils}/dataTransfer/Blob.d.ts +0 -0
  63. package/dist/{utils → types/utils}/dataTransfer/Clipboard.d.ts +0 -0
  64. package/dist/{utils → types/utils}/dataTransfer/DataTransfer.d.ts +0 -0
  65. package/dist/{utils → types/utils}/dataTransfer/FileList.d.ts +0 -0
  66. package/dist/{utils → types/utils}/edit/buildTimeValue.d.ts +0 -0
  67. package/dist/{utils → types/utils}/edit/calculateNewValue.d.ts +0 -0
  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/{utils → types/utils}/edit/setFiles.d.ts +0 -0
  77. package/dist/{utils → types/utils}/focus/blur.d.ts +0 -0
  78. package/dist/{utils → types/utils}/focus/copySelection.d.ts +0 -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/{utils → types/utils}/focus/selectAll.d.ts +0 -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 +6 -2
  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/{utils → types/utils}/misc/getDocumentFromNode.d.ts +0 -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/clipboard/copy.d.ts +0 -2
  107. package/dist/clipboard/copy.js +0 -36
  108. package/dist/clipboard/cut.d.ts +0 -2
  109. package/dist/clipboard/cut.js +0 -42
  110. package/dist/clipboard/index.js +0 -44
  111. package/dist/clipboard/paste.d.ts +0 -2
  112. package/dist/clipboard/paste.js +0 -47
  113. package/dist/convenience/click.d.ts +0 -4
  114. package/dist/convenience/click.js +0 -52
  115. package/dist/convenience/hover.d.ts +0 -3
  116. package/dist/convenience/hover.js +0 -31
  117. package/dist/convenience/index.js +0 -44
  118. package/dist/convenience/tab.d.ts +0 -4
  119. package/dist/convenience/tab.js +0 -12
  120. package/dist/document/index.js +0 -100
  121. package/dist/document/interceptor.js +0 -37
  122. package/dist/document/selection.js +0 -90
  123. package/dist/document/value.js +0 -77
  124. package/dist/index.js +0 -13
  125. package/dist/keyboard/getEventProps.d.ts +0 -15
  126. package/dist/keyboard/getEventProps.js +0 -27
  127. package/dist/keyboard/index.js +0 -42
  128. package/dist/keyboard/keyMap.js +0 -119
  129. package/dist/keyboard/keyboardAction.js +0 -156
  130. package/dist/keyboard/parseKeyDef.js +0 -61
  131. package/dist/keyboard/plugins/arrow.js +0 -28
  132. package/dist/keyboard/plugins/character.js +0 -173
  133. package/dist/keyboard/plugins/combination.js +0 -19
  134. package/dist/keyboard/plugins/control.js +0 -52
  135. package/dist/keyboard/plugins/functional.js +0 -158
  136. package/dist/keyboard/plugins/index.js +0 -33
  137. package/dist/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -3
  138. package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
  139. package/dist/keyboard/shared/index.js +0 -18
  140. package/dist/keyboard/types.js +0 -19
  141. package/dist/options.js +0 -36
  142. package/dist/pointer/index.js +0 -56
  143. package/dist/pointer/keyMap.js +0 -29
  144. package/dist/pointer/parseKeyDef.js +0 -34
  145. package/dist/pointer/pointerAction.js +0 -46
  146. package/dist/pointer/pointerMove.d.ts +0 -6
  147. package/dist/pointer/pointerMove.js +0 -136
  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/setup/api.js +0 -111
  152. package/dist/setup/config.js +0 -8
  153. package/dist/setup/directApi.js +0 -95
  154. package/dist/setup/index.js +0 -27
  155. package/dist/setup/setup.d.ts +0 -74
  156. package/dist/setup/setup.js +0 -98
  157. package/dist/setup/wrapAsync.js +0 -15
  158. package/dist/utility/clear.d.ts +0 -2
  159. package/dist/utility/clear.js +0 -30
  160. package/dist/utility/index.js +0 -57
  161. package/dist/utility/selectOptions.d.ts +0 -3
  162. package/dist/utility/selectOptions.js +0 -132
  163. package/dist/utility/type.d.ts +0 -9
  164. package/dist/utility/type.js +0 -37
  165. package/dist/utility/upload.d.ts +0 -5
  166. package/dist/utility/upload.js +0 -64
  167. package/dist/utils/click/isClickableInput.js +0 -14
  168. package/dist/utils/dataTransfer/Blob.js +0 -21
  169. package/dist/utils/dataTransfer/Clipboard.js +0 -188
  170. package/dist/utils/dataTransfer/DataTransfer.js +0 -158
  171. package/dist/utils/dataTransfer/FileList.js +0 -23
  172. package/dist/utils/edit/buildTimeValue.js +0 -44
  173. package/dist/utils/edit/calculateNewValue.js +0 -46
  174. package/dist/utils/edit/editInputElement.d.ts +0 -16
  175. package/dist/utils/edit/editInputElement.js +0 -53
  176. package/dist/utils/edit/getValue.js +0 -23
  177. package/dist/utils/edit/isContentEditable.js +0 -25
  178. package/dist/utils/edit/isEditable.js +0 -42
  179. package/dist/utils/edit/isValidDateValue.js +0 -12
  180. package/dist/utils/edit/isValidInputTimeValue.js +0 -12
  181. package/dist/utils/edit/maxLength.js +0 -50
  182. package/dist/utils/edit/prepareInput.d.ts +0 -7
  183. package/dist/utils/edit/prepareInput.js +0 -77
  184. package/dist/utils/edit/setFiles.js +0 -72
  185. package/dist/utils/focus/blur.js +0 -19
  186. package/dist/utils/focus/copySelection.js +0 -36
  187. package/dist/utils/focus/focus.js +0 -22
  188. package/dist/utils/focus/getActiveElement.js +0 -26
  189. package/dist/utils/focus/getTabDestination.js +0 -71
  190. package/dist/utils/focus/isFocusable.js +0 -12
  191. package/dist/utils/focus/selectAll.js +0 -51
  192. package/dist/utils/focus/selection.js +0 -190
  193. package/dist/utils/focus/selector.js +0 -8
  194. package/dist/utils/index.js +0 -499
  195. package/dist/utils/keyDef/readNextDescriptor.js +0 -102
  196. package/dist/utils/misc/eventWrapper.js +0 -16
  197. package/dist/utils/misc/findClosest.d.ts +0 -1
  198. package/dist/utils/misc/findClosest.js +0 -20
  199. package/dist/utils/misc/getDocumentFromNode.js +0 -14
  200. package/dist/utils/misc/hasFormSubmit.js +0 -10
  201. package/dist/utils/misc/hasPointerEvents.d.ts +0 -15
  202. package/dist/utils/misc/hasPointerEvents.js +0 -24
  203. package/dist/utils/misc/isDescendantOrSelf.js +0 -20
  204. package/dist/utils/misc/isDisabled.js +0 -12
  205. package/dist/utils/misc/isElementType.js +0 -24
  206. package/dist/utils/misc/isVisible.js +0 -24
  207. package/dist/utils/misc/wait.js +0 -10
  208. package/dist/utils/pointer/firePointerEvents.d.ts +0 -25
  209. package/dist/utils/pointer/firePointerEvents.js +0 -112
  210. 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>;
File without changes
@@ -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,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;
@@ -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;
File without changes
@@ -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[];
@@ -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;
@@ -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.
@@ -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;
File without changes
File without changes
@@ -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>;
@@ -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
  */
File without changes
File without changes
@@ -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;
@@ -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;
File without changes
@@ -0,0 +1,2 @@
1
+ import { Instance } from '../setup';
2
+ export declare function clear(this: Instance, element: Element): Promise<void>;
File without changes
@@ -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>;
@@ -0,0 +1,5 @@
1
+ import { Instance } from '../setup';
2
+ export interface uploadInit {
3
+ changeInit?: EventInit;
4
+ }
5
+ export declare function upload(this: Instance, element: HTMLElement, fileOrFiles: File | File[]): Promise<void>;
@@ -0,0 +1,14 @@
1
+ import { Config } from '../../setup';
2
+ /**
3
+ * Change the value of an element as if it was changed as a result of a user input.
4
+ *
5
+ * Fires the input event.
6
+ */
7
+ export declare function editInputElement(config: Config, element: HTMLInputElement | HTMLTextAreaElement, { newValue, newSelection, eventOverrides, }: {
8
+ newValue: string;
9
+ newSelection: {
10
+ node: Node;
11
+ offset: number;
12
+ };
13
+ eventOverrides: InputEventInit;
14
+ }): void;
File without changes
File without changes
File without changes
@@ -0,0 +1,8 @@
1
+ import { Config } from '../../setup';
2
+ export declare function prepareInput(config: Config, data: string, element: Element, inputType?: string): {
3
+ commit: () => void;
4
+ getNewValue?: undefined;
5
+ } | {
6
+ getNewValue: () => string;
7
+ commit: () => void;
8
+ } | undefined;
File without changes
File without changes
@@ -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 };
File without changes
File without changes
File without changes
@@ -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';
@@ -23,7 +24,10 @@ export * from './focus/isFocusable';
23
24
  export * from './focus/selectAll';
24
25
  export * from './focus/selection';
25
26
  export * from './focus/selector';
27
+ export * from './keyboard/getKeyEventProps';
28
+ export * from './keyboard/getUIEventModifiers';
26
29
  export * from './keyDef/readNextDescriptor';
30
+ export * from './misc/cloneEvent';
27
31
  export * from './misc/eventWrapper';
28
32
  export * from './misc/findClosest';
29
33
  export * from './misc/getDocumentFromNode';
@@ -31,8 +35,8 @@ export * from './misc/isDescendantOrSelf';
31
35
  export * from './misc/isElementType';
32
36
  export * from './misc/isVisible';
33
37
  export * from './misc/isDisabled';
38
+ export * from './misc/level';
34
39
  export * from './misc/wait';
35
- export * from './misc/hasPointerEvents';
36
40
  export * from './misc/hasFormSubmit';
37
- export * from './pointer/firePointerEvents';
41
+ export * from './pointer/cssPointerEvents';
38
42
  export * from './pointer/mouseButtons';
@@ -0,0 +1,5 @@
1
+ import { keyboardKey } from '../../keyboard/types';
2
+ export declare function getKeyEventProps(keyDef: keyboardKey): {
3
+ key: string | undefined;
4
+ code: string | undefined;
5
+ };
@@ -0,0 +1,15 @@
1
+ import type { keyboardState } from '../../keyboard';
2
+ export declare function getUIEventModifiers(keyboardState: 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;
15
+ };
@@ -0,0 +1 @@
1
+ export declare function cloneEvent<E extends Event>(event: E): E;
@@ -0,0 +1 @@
1
+ export declare function findClosest<T extends Element>(element: Element, callback: (e: Element) => e is T): T | undefined;
File without changes
File without changes
@@ -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 {};