@depup/testing-library__user-event 14.6.3-depup.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +25 -0
  3. package/changes.json +5 -0
  4. package/dist/cjs/clipboard/copy.js +22 -0
  5. package/dist/cjs/clipboard/cut.js +22 -0
  6. package/dist/cjs/clipboard/index.js +11 -0
  7. package/dist/cjs/clipboard/paste.js +24 -0
  8. package/dist/cjs/convenience/click.js +35 -0
  9. package/dist/cjs/convenience/hover.js +19 -0
  10. package/dist/cjs/convenience/index.js +14 -0
  11. package/dist/cjs/convenience/tab.js +7 -0
  12. package/dist/cjs/document/UI.js +90 -0
  13. package/dist/cjs/document/copySelection.js +29 -0
  14. package/dist/cjs/document/getValueOrTextContent.js +18 -0
  15. package/dist/cjs/document/index.js +17 -0
  16. package/dist/cjs/document/interceptor.js +104 -0
  17. package/dist/cjs/document/patchFocus.js +106 -0
  18. package/dist/cjs/document/prepareDocument.js +58 -0
  19. package/dist/cjs/document/trackValue.js +57 -0
  20. package/dist/cjs/event/behavior/click.js +32 -0
  21. package/dist/cjs/event/behavior/cut.js +14 -0
  22. package/dist/cjs/event/behavior/index.js +13 -0
  23. package/dist/cjs/event/behavior/keydown.js +128 -0
  24. package/dist/cjs/event/behavior/keypress.js +51 -0
  25. package/dist/cjs/event/behavior/keyup.js +17 -0
  26. package/dist/cjs/event/behavior/paste.js +18 -0
  27. package/dist/cjs/event/behavior/registry.js +5 -0
  28. package/dist/cjs/event/createEvent.js +193 -0
  29. package/dist/cjs/event/dispatchEvent.js +54 -0
  30. package/dist/cjs/event/eventMap.js +281 -0
  31. package/dist/cjs/event/focus.js +34 -0
  32. package/dist/cjs/event/index.js +22 -0
  33. package/dist/cjs/event/input.js +158 -0
  34. package/dist/cjs/event/radio.js +27 -0
  35. package/dist/cjs/event/selection/getInputRange.js +18 -0
  36. package/dist/cjs/event/selection/getTargetTypeAndSelection.js +31 -0
  37. package/dist/cjs/event/selection/index.js +24 -0
  38. package/dist/cjs/event/selection/modifySelection.js +21 -0
  39. package/dist/cjs/event/selection/modifySelectionPerMouse.js +40 -0
  40. package/dist/cjs/event/selection/moveSelection.js +38 -0
  41. package/dist/cjs/event/selection/resolveCaretPosition.js +60 -0
  42. package/dist/cjs/event/selection/selectAll.js +38 -0
  43. package/dist/cjs/event/selection/setSelection.js +21 -0
  44. package/dist/cjs/event/selection/setSelectionPerMouse.js +79 -0
  45. package/dist/cjs/event/selection/setSelectionRange.js +31 -0
  46. package/dist/cjs/event/selection/updateSelectionOnFocus.js +40 -0
  47. package/dist/cjs/event/types.js +2 -0
  48. package/dist/cjs/event/wrapEvent.js +10 -0
  49. package/dist/cjs/index.js +12 -0
  50. package/dist/cjs/keyboard/index.js +40 -0
  51. package/dist/cjs/keyboard/keyMap.js +178 -0
  52. package/dist/cjs/keyboard/parseKeyDef.js +45 -0
  53. package/dist/cjs/options.js +14 -0
  54. package/dist/cjs/package.json +3 -0
  55. package/dist/cjs/pointer/index.js +74 -0
  56. package/dist/cjs/pointer/keyMap.js +33 -0
  57. package/dist/cjs/pointer/parseKeyDef.js +23 -0
  58. package/dist/cjs/setup/api.js +35 -0
  59. package/dist/cjs/setup/directApi.js +75 -0
  60. package/dist/cjs/setup/index.js +11 -0
  61. package/dist/cjs/setup/setup.js +125 -0
  62. package/dist/cjs/setup/wrapAsync.js +11 -0
  63. package/dist/cjs/system/index.js +42 -0
  64. package/dist/cjs/system/keyboard.js +165 -0
  65. package/dist/cjs/system/pointer/buttons.js +80 -0
  66. package/dist/cjs/system/pointer/device.js +32 -0
  67. package/dist/cjs/system/pointer/index.js +156 -0
  68. package/dist/cjs/system/pointer/mouse.js +204 -0
  69. package/dist/cjs/system/pointer/pointer.js +129 -0
  70. package/dist/cjs/system/pointer/shared.js +8 -0
  71. package/dist/cjs/utility/clear.js +32 -0
  72. package/dist/cjs/utility/index.js +14 -0
  73. package/dist/cjs/utility/selectOptions.js +114 -0
  74. package/dist/cjs/utility/type.js +23 -0
  75. package/dist/cjs/utility/upload.js +62 -0
  76. package/dist/cjs/utils/click/isClickableInput.js +20 -0
  77. package/dist/cjs/utils/dataTransfer/Blob.js +16 -0
  78. package/dist/cjs/utils/dataTransfer/Clipboard.js +174 -0
  79. package/dist/cjs/utils/dataTransfer/DataTransfer.js +134 -0
  80. package/dist/cjs/utils/dataTransfer/FileList.js +24 -0
  81. package/dist/cjs/utils/edit/isContentEditable.js +18 -0
  82. package/dist/cjs/utils/edit/isEditable.js +29 -0
  83. package/dist/cjs/utils/edit/maxLength.js +26 -0
  84. package/dist/cjs/utils/edit/setFiles.js +58 -0
  85. package/dist/cjs/utils/edit/timeValue.js +40 -0
  86. package/dist/cjs/utils/focus/cursor.js +126 -0
  87. package/dist/cjs/utils/focus/getActiveElement.js +25 -0
  88. package/dist/cjs/utils/focus/getTabDestination.js +80 -0
  89. package/dist/cjs/utils/focus/isFocusable.js +9 -0
  90. package/dist/cjs/utils/focus/selection.js +20 -0
  91. package/dist/cjs/utils/focus/selector.js +15 -0
  92. package/dist/cjs/utils/index.js +78 -0
  93. package/dist/cjs/utils/keyDef/readNextDescriptor.js +91 -0
  94. package/dist/cjs/utils/misc/cloneEvent.js +7 -0
  95. package/dist/cjs/utils/misc/findClosest.js +14 -0
  96. package/dist/cjs/utils/misc/getDocumentFromNode.js +10 -0
  97. package/dist/cjs/utils/misc/getTreeDiff.js +25 -0
  98. package/dist/cjs/utils/misc/getWindow.js +19 -0
  99. package/dist/cjs/utils/misc/isDescendantOrSelf.js +14 -0
  100. package/dist/cjs/utils/misc/isDisabled.js +33 -0
  101. package/dist/cjs/utils/misc/isElementType.js +20 -0
  102. package/dist/cjs/utils/misc/isVisible.js +19 -0
  103. package/dist/cjs/utils/misc/level.js +17 -0
  104. package/dist/cjs/utils/misc/wait.js +14 -0
  105. package/dist/cjs/utils/pointer/cssPointerEvents.js +102 -0
  106. package/dist/esm/clipboard/copy.js +20 -0
  107. package/dist/esm/clipboard/cut.js +20 -0
  108. package/dist/esm/clipboard/index.js +3 -0
  109. package/dist/esm/clipboard/paste.js +22 -0
  110. package/dist/esm/convenience/click.js +31 -0
  111. package/dist/esm/convenience/hover.js +16 -0
  112. package/dist/esm/convenience/index.js +3 -0
  113. package/dist/esm/convenience/tab.js +5 -0
  114. package/dist/esm/document/UI.js +77 -0
  115. package/dist/esm/document/copySelection.js +27 -0
  116. package/dist/esm/document/getValueOrTextContent.js +16 -0
  117. package/dist/esm/document/index.js +4 -0
  118. package/dist/esm/document/interceptor.js +99 -0
  119. package/dist/esm/document/patchFocus.js +103 -0
  120. package/dist/esm/document/prepareDocument.js +56 -0
  121. package/dist/esm/document/trackValue.js +53 -0
  122. package/dist/esm/event/behavior/click.js +30 -0
  123. package/dist/esm/event/behavior/cut.js +12 -0
  124. package/dist/esm/event/behavior/index.js +7 -0
  125. package/dist/esm/event/behavior/keydown.js +126 -0
  126. package/dist/esm/event/behavior/keypress.js +49 -0
  127. package/dist/esm/event/behavior/keyup.js +15 -0
  128. package/dist/esm/event/behavior/paste.js +16 -0
  129. package/dist/esm/event/behavior/registry.js +3 -0
  130. package/dist/esm/event/createEvent.js +191 -0
  131. package/dist/esm/event/dispatchEvent.js +50 -0
  132. package/dist/esm/event/eventMap.js +277 -0
  133. package/dist/esm/event/focus.js +31 -0
  134. package/dist/esm/event/index.js +7 -0
  135. package/dist/esm/event/input.js +156 -0
  136. package/dist/esm/event/radio.js +25 -0
  137. package/dist/esm/event/selection/getInputRange.js +16 -0
  138. package/dist/esm/event/selection/getTargetTypeAndSelection.js +29 -0
  139. package/dist/esm/event/selection/index.js +9 -0
  140. package/dist/esm/event/selection/modifySelection.js +19 -0
  141. package/dist/esm/event/selection/modifySelectionPerMouse.js +38 -0
  142. package/dist/esm/event/selection/moveSelection.js +36 -0
  143. package/dist/esm/event/selection/resolveCaretPosition.js +58 -0
  144. package/dist/esm/event/selection/selectAll.js +35 -0
  145. package/dist/esm/event/selection/setSelection.js +19 -0
  146. package/dist/esm/event/selection/setSelectionPerMouse.js +77 -0
  147. package/dist/esm/event/selection/setSelectionRange.js +29 -0
  148. package/dist/esm/event/selection/updateSelectionOnFocus.js +38 -0
  149. package/dist/esm/event/types.js +1 -0
  150. package/dist/esm/event/wrapEvent.js +8 -0
  151. package/dist/esm/index.js +2 -0
  152. package/dist/esm/keyboard/index.js +37 -0
  153. package/dist/esm/keyboard/keyMap.js +176 -0
  154. package/dist/esm/keyboard/parseKeyDef.js +43 -0
  155. package/dist/esm/options.js +12 -0
  156. package/dist/esm/package.json +3 -0
  157. package/dist/esm/pointer/index.js +72 -0
  158. package/dist/esm/pointer/keyMap.js +31 -0
  159. package/dist/esm/pointer/parseKeyDef.js +21 -0
  160. package/dist/esm/setup/api.js +33 -0
  161. package/dist/esm/setup/directApi.js +58 -0
  162. package/dist/esm/setup/index.js +9 -0
  163. package/dist/esm/setup/setup.js +119 -0
  164. package/dist/esm/setup/wrapAsync.js +9 -0
  165. package/dist/esm/system/index.js +40 -0
  166. package/dist/esm/system/keyboard.js +162 -0
  167. package/dist/esm/system/pointer/buttons.js +74 -0
  168. package/dist/esm/system/pointer/device.js +30 -0
  169. package/dist/esm/system/pointer/index.js +154 -0
  170. package/dist/esm/system/pointer/mouse.js +202 -0
  171. package/dist/esm/system/pointer/pointer.js +127 -0
  172. package/dist/esm/system/pointer/shared.js +6 -0
  173. package/dist/esm/utility/clear.js +30 -0
  174. package/dist/esm/utility/index.js +4 -0
  175. package/dist/esm/utility/selectOptions.js +111 -0
  176. package/dist/esm/utility/type.js +21 -0
  177. package/dist/esm/utility/upload.js +60 -0
  178. package/dist/esm/utils/click/isClickableInput.js +18 -0
  179. package/dist/esm/utils/dataTransfer/Blob.js +14 -0
  180. package/dist/esm/utils/dataTransfer/Clipboard.js +167 -0
  181. package/dist/esm/utils/dataTransfer/DataTransfer.js +131 -0
  182. package/dist/esm/utils/dataTransfer/FileList.js +22 -0
  183. package/dist/esm/utils/edit/isContentEditable.js +15 -0
  184. package/dist/esm/utils/edit/isEditable.js +26 -0
  185. package/dist/esm/utils/edit/maxLength.js +23 -0
  186. package/dist/esm/utils/edit/setFiles.js +56 -0
  187. package/dist/esm/utils/edit/timeValue.js +37 -0
  188. package/dist/esm/utils/focus/cursor.js +124 -0
  189. package/dist/esm/utils/focus/getActiveElement.js +22 -0
  190. package/dist/esm/utils/focus/getTabDestination.js +78 -0
  191. package/dist/esm/utils/focus/isFocusable.js +7 -0
  192. package/dist/esm/utils/focus/selection.js +17 -0
  193. package/dist/esm/utils/focus/selector.js +13 -0
  194. package/dist/esm/utils/index.js +29 -0
  195. package/dist/esm/utils/keyDef/readNextDescriptor.js +89 -0
  196. package/dist/esm/utils/misc/cloneEvent.js +5 -0
  197. package/dist/esm/utils/misc/findClosest.js +12 -0
  198. package/dist/esm/utils/misc/getDocumentFromNode.js +8 -0
  199. package/dist/esm/utils/misc/getTreeDiff.js +23 -0
  200. package/dist/esm/utils/misc/getWindow.js +17 -0
  201. package/dist/esm/utils/misc/isDescendantOrSelf.js +12 -0
  202. package/dist/esm/utils/misc/isDisabled.js +31 -0
  203. package/dist/esm/utils/misc/isElementType.js +18 -0
  204. package/dist/esm/utils/misc/isVisible.js +17 -0
  205. package/dist/esm/utils/misc/level.js +13 -0
  206. package/dist/esm/utils/misc/wait.js +12 -0
  207. package/dist/esm/utils/pointer/cssPointerEvents.js +99 -0
  208. package/dist/types/clipboard/copy.d.ts +2 -0
  209. package/dist/types/clipboard/cut.d.ts +2 -0
  210. package/dist/types/clipboard/index.d.ts +3 -0
  211. package/dist/types/clipboard/paste.d.ts +2 -0
  212. package/dist/types/convenience/click.d.ts +4 -0
  213. package/dist/types/convenience/hover.d.ts +3 -0
  214. package/dist/types/convenience/index.d.ts +3 -0
  215. package/dist/types/convenience/tab.d.ts +4 -0
  216. package/dist/types/document/UI.d.ts +42 -0
  217. package/dist/types/document/copySelection.d.ts +1 -0
  218. package/dist/types/document/getValueOrTextContent.d.ts +1 -0
  219. package/dist/types/document/index.d.ts +5 -0
  220. package/dist/types/document/interceptor.d.ts +19 -0
  221. package/dist/types/document/patchFocus.d.ts +9 -0
  222. package/dist/types/document/prepareDocument.d.ts +8 -0
  223. package/dist/types/document/trackValue.d.ts +17 -0
  224. package/dist/types/event/behavior/click.d.ts +1 -0
  225. package/dist/types/event/behavior/cut.d.ts +1 -0
  226. package/dist/types/event/behavior/index.d.ts +8 -0
  227. package/dist/types/event/behavior/keydown.d.ts +1 -0
  228. package/dist/types/event/behavior/keypress.d.ts +1 -0
  229. package/dist/types/event/behavior/keyup.d.ts +1 -0
  230. package/dist/types/event/behavior/paste.d.ts +1 -0
  231. package/dist/types/event/behavior/registry.d.ts +8 -0
  232. package/dist/types/event/createEvent.d.ts +2 -0
  233. package/dist/types/event/dispatchEvent.d.ts +5 -0
  234. package/dist/types/event/eventMap.d.ts +265 -0
  235. package/dist/types/event/focus.d.ts +5 -0
  236. package/dist/types/event/index.d.ts +7 -0
  237. package/dist/types/event/input.d.ts +2 -0
  238. package/dist/types/event/radio.d.ts +4 -0
  239. package/dist/types/event/selection/getInputRange.d.ts +5 -0
  240. package/dist/types/event/selection/getTargetTypeAndSelection.d.ts +10 -0
  241. package/dist/types/event/selection/index.d.ts +15 -0
  242. package/dist/types/event/selection/modifySelection.d.ts +8 -0
  243. package/dist/types/event/selection/modifySelectionPerMouse.d.ts +7 -0
  244. package/dist/types/event/selection/moveSelection.d.ts +4 -0
  245. package/dist/types/event/selection/resolveCaretPosition.d.ts +8 -0
  246. package/dist/types/event/selection/selectAll.d.ts +5 -0
  247. package/dist/types/event/selection/setSelection.d.ts +10 -0
  248. package/dist/types/event/selection/setSelectionPerMouse.d.ts +8 -0
  249. package/dist/types/event/selection/setSelectionRange.d.ts +6 -0
  250. package/dist/types/event/selection/updateSelectionOnFocus.d.ts +5 -0
  251. package/dist/types/event/types.d.ts +20 -0
  252. package/dist/types/event/wrapEvent.d.ts +1 -0
  253. package/dist/types/index.d.ts +6 -0
  254. package/dist/types/keyboard/index.d.ts +3 -0
  255. package/dist/types/keyboard/keyMap.d.ts +5 -0
  256. package/dist/types/keyboard/parseKeyDef.d.ts +17 -0
  257. package/dist/types/options.d.ts +115 -0
  258. package/dist/types/pointer/index.d.ts +28 -0
  259. package/dist/types/pointer/keyMap.d.ts +2 -0
  260. package/dist/types/pointer/parseKeyDef.d.ts +6 -0
  261. package/dist/types/setup/api.d.ts +23 -0
  262. package/dist/types/setup/directApi.d.ts +24 -0
  263. package/dist/types/setup/index.d.ts +22 -0
  264. package/dist/types/setup/setup.d.ts +44 -0
  265. package/dist/types/setup/wrapAsync.d.ts +4 -0
  266. package/dist/types/system/index.d.ts +10 -0
  267. package/dist/types/system/keyboard.d.ts +50 -0
  268. package/dist/types/system/pointer/buttons.d.ts +23 -0
  269. package/dist/types/system/pointer/device.d.ts +8 -0
  270. package/dist/types/system/pointer/index.d.ts +21 -0
  271. package/dist/types/system/pointer/mouse.d.ts +31 -0
  272. package/dist/types/system/pointer/pointer.d.ts +32 -0
  273. package/dist/types/system/pointer/shared.d.ts +20 -0
  274. package/dist/types/utility/clear.d.ts +2 -0
  275. package/dist/types/utility/index.d.ts +4 -0
  276. package/dist/types/utility/selectOptions.d.ts +3 -0
  277. package/dist/types/utility/type.d.ts +9 -0
  278. package/dist/types/utility/upload.d.ts +5 -0
  279. package/dist/types/utils/click/isClickableInput.d.ts +15 -0
  280. package/dist/types/utils/dataTransfer/Blob.d.ts +3 -0
  281. package/dist/types/utils/dataTransfer/Clipboard.d.ts +11 -0
  282. package/dist/types/utils/dataTransfer/DataTransfer.d.ts +2 -0
  283. package/dist/types/utils/dataTransfer/FileList.d.ts +1 -0
  284. package/dist/types/utils/edit/isContentEditable.d.ts +7 -0
  285. package/dist/types/utils/edit/isEditable.d.ts +24 -0
  286. package/dist/types/utils/edit/maxLength.d.ts +14 -0
  287. package/dist/types/utils/edit/setFiles.d.ts +12 -0
  288. package/dist/types/utils/edit/timeValue.d.ts +4 -0
  289. package/dist/types/utils/focus/cursor.d.ts +9 -0
  290. package/dist/types/utils/focus/getActiveElement.d.ts +2 -0
  291. package/dist/types/utils/focus/getTabDestination.d.ts +1 -0
  292. package/dist/types/utils/focus/isFocusable.d.ts +1 -0
  293. package/dist/types/utils/focus/selection.d.ts +8 -0
  294. package/dist/types/utils/focus/selector.d.ts +1 -0
  295. package/dist/types/utils/index.d.ts +29 -0
  296. package/dist/types/utils/keyDef/readNextDescriptor.d.ts +21 -0
  297. package/dist/types/utils/misc/cloneEvent.d.ts +1 -0
  298. package/dist/types/utils/misc/findClosest.d.ts +1 -0
  299. package/dist/types/utils/misc/getDocumentFromNode.d.ts +1 -0
  300. package/dist/types/utils/misc/getTreeDiff.d.ts +1 -0
  301. package/dist/types/utils/misc/getWindow.d.ts +1 -0
  302. package/dist/types/utils/misc/isDescendantOrSelf.d.ts +1 -0
  303. package/dist/types/utils/misc/isDisabled.d.ts +1 -0
  304. package/dist/types/utils/misc/isElementType.d.ts +5 -0
  305. package/dist/types/utils/misc/isVisible.d.ts +1 -0
  306. package/dist/types/utils/misc/level.d.ts +8 -0
  307. package/dist/types/utils/misc/wait.d.ts +2 -0
  308. package/dist/types/utils/pointer/cssPointerEvents.d.ts +19 -0
  309. package/package.json +131 -0
@@ -0,0 +1,8 @@
1
+ export declare function resolveCaretPosition({ target, node, offset, }: {
2
+ target: Element;
3
+ node?: Node;
4
+ offset?: number;
5
+ }): {
6
+ node: Node;
7
+ offset: number;
8
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Expand a selection like the browser does when pressing Ctrl+A.
3
+ */
4
+ export declare function selectAll(target: Element): void;
5
+ export declare function isAllSelected(target: Element): boolean;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Set the selection
3
+ */
4
+ export declare function setSelection({ focusNode, focusOffset, anchorNode, anchorOffset, }: {
5
+ anchorNode?: Node;
6
+ /** DOM offset */
7
+ anchorOffset?: number;
8
+ focusNode: Node;
9
+ focusOffset: number;
10
+ }): void;
@@ -0,0 +1,8 @@
1
+ import { type SelectionRange } from '.';
2
+ export declare function setSelectionPerMouseDown({ document, target, clickCount, node, offset, }: {
3
+ document: Document;
4
+ target: Element;
5
+ clickCount: number;
6
+ node?: Node;
7
+ offset?: number;
8
+ }): Range | SelectionRange | undefined;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Backward-compatible selection.
3
+ *
4
+ * Handles input elements and contenteditable if it only contains a single text node.
5
+ */
6
+ export declare function setSelectionRange(element: Element, anchorOffset: number, focusOffset: number): void;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Reset the Document Selection when moving focus into an element
3
+ * with own selection implementation.
4
+ */
5
+ export declare function updateSelectionOnFocus(element: Element): void;
@@ -0,0 +1,20 @@
1
+ import { eventMap } from './eventMap';
2
+ export type EventType = keyof typeof eventMap;
3
+ export type EventTypeInit<K extends EventType> = SpecificEventInit<FixedDocumentEventMap[K]>;
4
+ export interface FixedDocumentEventMap extends DocumentEventMap {
5
+ input: InputEvent;
6
+ }
7
+ 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 FocusEvent ? FocusEventInit : E extends UIEvent ? UIEventInit : EventInit;
8
+ export interface PointerCoords {
9
+ x?: number;
10
+ y?: number;
11
+ clientX?: number;
12
+ clientY?: number;
13
+ offsetX?: number;
14
+ offsetY?: number;
15
+ pageX?: number;
16
+ pageY?: number;
17
+ screenX?: number;
18
+ screenY?: number;
19
+ }
20
+ export {};
@@ -0,0 +1 @@
1
+ export declare function wrapEvent<R>(cb: () => R, _element: Element): R;
@@ -0,0 +1,6 @@
1
+ export { userEvent as default } from './setup';
2
+ export { userEvent } from './setup';
3
+ export type { UserEvent } from './setup/setup';
4
+ export type { keyboardKey } from './system/keyboard';
5
+ export type { pointerKey } from './system/pointer';
6
+ export { PointerEventsCheckLevel, type Options } from './options';
@@ -0,0 +1,3 @@
1
+ import { type Instance } from '../setup';
2
+ export declare function keyboard(this: Instance, text: string): Promise<void>;
3
+ export declare function releaseAllKeys(instance: Instance): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { keyboardKey } from '../system/keyboard';
2
+ /**
3
+ * Mapping for a default US-104-QWERTY keyboard
4
+ */
5
+ export declare const defaultKeyMap: keyboardKey[];
@@ -0,0 +1,17 @@
1
+ import { keyboardKey } from '../system/keyboard';
2
+ /**
3
+ * Parse key definitions per `keyboardMap`
4
+ *
5
+ * Keys can be referenced by `{key}` or `{special}` as well as physical locations per `[code]`.
6
+ * Everything else will be interpreted as a typed character - e.g. `a`.
7
+ * Brackets `{` and `[` can be escaped by doubling - e.g. `foo[[bar` translates to `foo[bar`.
8
+ * Keeping the key pressed can be written as `{key>}`.
9
+ * When keeping the key pressed you can choose how long (how many keydown and keypress) the key is pressed `{key>3}`.
10
+ * You can then release the key per `{key>3/}` or keep it pressed and continue with the next key.
11
+ */
12
+ export declare function parseKeyDef(keyboardMap: keyboardKey[], text: string): {
13
+ keyDef: keyboardKey;
14
+ releasePrevious: boolean;
15
+ releaseSelf: boolean;
16
+ repeat: number;
17
+ }[];
@@ -0,0 +1,115 @@
1
+ import { type keyboardKey } from './system/keyboard';
2
+ import { type pointerKey } from './system/pointer';
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` milliseconds.
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??globalThis.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.EachApiCall
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` implies 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` implies 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
+ * A function to be called internally to advance your fake timers (if applicable)
111
+ *
112
+ * @example jest.advanceTimersByTime
113
+ */
114
+ advanceTimers?: ((delay: number) => Promise<void>) | ((delay: number) => void);
115
+ }
@@ -0,0 +1,28 @@
1
+ import { type PointerCoords } from '../event';
2
+ import { type Instance } from '../setup';
3
+ import { type pointerKey } from '../system/pointer';
4
+ type PointerActionInput = string | ({
5
+ keys: string;
6
+ } & PointerActionPosition) | PointerAction;
7
+ export type PointerInput = PointerActionInput | Array<PointerActionInput>;
8
+ type PointerAction = PointerPressAction | PointerMoveAction;
9
+ type PointerActionPosition = {
10
+ target?: Element;
11
+ coords?: PointerCoords;
12
+ node?: Node;
13
+ /**
14
+ * If `node` is set, this is the DOM offset.
15
+ * Otherwise this is the `textContent`/`value` offset on the `target`.
16
+ */
17
+ offset?: number;
18
+ };
19
+ interface PointerPressAction extends PointerActionPosition {
20
+ keyDef: pointerKey;
21
+ releasePrevious: boolean;
22
+ releaseSelf: boolean;
23
+ }
24
+ interface PointerMoveAction extends PointerActionPosition {
25
+ pointerName?: string;
26
+ }
27
+ export declare function pointer(this: Instance, input: PointerInput): Promise<void>;
28
+ export {};
@@ -0,0 +1,2 @@
1
+ import { pointerKey } from '../system/pointer';
2
+ export declare const defaultKeyMap: pointerKey[];
@@ -0,0 +1,6 @@
1
+ import { pointerKey } from '../system/pointer';
2
+ export declare function parseKeyDef(pointerMap: pointerKey[], keys: string): {
3
+ keyDef: pointerKey;
4
+ releasePrevious: boolean;
5
+ releaseSelf: boolean;
6
+ }[];
@@ -0,0 +1,23 @@
1
+ import { click, dblClick, tripleClick, hover, unhover, tab } from '../convenience';
2
+ import { keyboard } from '../keyboard';
3
+ import { copy, cut, paste } from '../clipboard';
4
+ import { pointer } from '../pointer';
5
+ import { clear, deselectOptions, selectOptions, type, upload } from '../utility';
6
+ export declare const userEventApi: {
7
+ click: typeof click;
8
+ dblClick: typeof dblClick;
9
+ tripleClick: typeof tripleClick;
10
+ hover: typeof hover;
11
+ unhover: typeof unhover;
12
+ tab: typeof tab;
13
+ keyboard: typeof keyboard;
14
+ copy: typeof copy;
15
+ cut: typeof cut;
16
+ paste: typeof paste;
17
+ pointer: typeof pointer;
18
+ clear: typeof clear;
19
+ deselectOptions: typeof deselectOptions;
20
+ selectOptions: typeof selectOptions;
21
+ type: typeof type;
22
+ upload: typeof upload;
23
+ };
@@ -0,0 +1,24 @@
1
+ import { type Options } from '../options';
2
+ import { type PointerInput } from '../pointer';
3
+ import { type System } from '../system';
4
+ import { type UserEventApi } from './setup';
5
+ export type DirectOptions = Options & {
6
+ keyboardState?: System;
7
+ pointerState?: System;
8
+ };
9
+ export declare function clear(element: Element): Promise<void>;
10
+ export declare function click(element: Element, options?: DirectOptions): Promise<void>;
11
+ export declare function copy(options?: DirectOptions): Promise<DataTransfer | undefined>;
12
+ export declare function cut(options?: DirectOptions): Promise<DataTransfer | undefined>;
13
+ export declare function dblClick(element: Element, options?: DirectOptions): Promise<void>;
14
+ export declare function deselectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: DirectOptions): Promise<void>;
15
+ export declare function hover(element: Element, options?: DirectOptions): Promise<void>;
16
+ export declare function keyboard(text: string, options?: DirectOptions): Promise<System>;
17
+ export declare function pointer(input: PointerInput, options?: DirectOptions): Promise<System>;
18
+ export declare function paste(clipboardData?: DataTransfer | string, options?: DirectOptions): Promise<void>;
19
+ export declare function selectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: DirectOptions): Promise<void>;
20
+ export declare function tripleClick(element: Element, options?: DirectOptions): Promise<void>;
21
+ export declare function type(element: Element, text: string, options?: DirectOptions & Parameters<UserEventApi['type']>[2]): Promise<void>;
22
+ export declare function unhover(element: Element, options?: DirectOptions): Promise<void>;
23
+ export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?: DirectOptions): Promise<void>;
24
+ export declare function tab(options?: DirectOptions & Parameters<UserEventApi['tab']>[0]): Promise<void>;
@@ -0,0 +1,22 @@
1
+ import { setupMain } from './setup';
2
+ import * as directApi from './directApi';
3
+ export type { Instance } from './setup';
4
+ export declare const userEvent: {
5
+ readonly setup: typeof setupMain;
6
+ readonly clear: typeof directApi.clear;
7
+ readonly click: typeof directApi.click;
8
+ readonly copy: typeof directApi.copy;
9
+ readonly cut: typeof directApi.cut;
10
+ readonly dblClick: typeof directApi.dblClick;
11
+ readonly deselectOptions: typeof directApi.deselectOptions;
12
+ readonly hover: typeof directApi.hover;
13
+ readonly keyboard: typeof directApi.keyboard;
14
+ readonly pointer: typeof directApi.pointer;
15
+ readonly paste: typeof directApi.paste;
16
+ readonly selectOptions: typeof directApi.selectOptions;
17
+ readonly tripleClick: typeof directApi.tripleClick;
18
+ readonly type: typeof directApi.type;
19
+ readonly unhover: typeof directApi.unhover;
20
+ readonly upload: typeof directApi.upload;
21
+ readonly tab: typeof directApi.tab;
22
+ };
@@ -0,0 +1,44 @@
1
+ import { dispatchEvent, dispatchUIEvent } from '../event';
2
+ import { Options } from '../options';
3
+ import { System } from '../system';
4
+ import { userEventApi } from './api';
5
+ import { DirectOptions } from './directApi';
6
+ export type UserEventApi = typeof userEventApi;
7
+ export type UserEvent = {
8
+ readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;
9
+ } & {
10
+ readonly [k in keyof UserEventApi]: (...args: Parameters<UserEventApi[k]>) => ReturnType<UserEventApi[k]>;
11
+ };
12
+ export type Instance = UserEventApi & {
13
+ config: Config;
14
+ dispatchEvent: OmitThisParameter<typeof dispatchEvent>;
15
+ dispatchUIEvent: OmitThisParameter<typeof dispatchUIEvent>;
16
+ system: System;
17
+ levelRefs: Record<number, object | undefined>;
18
+ };
19
+ export type Config = Required<Options>;
20
+ export declare function createConfig(options?: Options, defaults?: Required<Options>, node?: Node): Config;
21
+ /**
22
+ * Start a "session" with userEvent.
23
+ * All APIs returned by this function share an input device state and a default configuration.
24
+ */
25
+ export declare function setupMain(options?: Options): UserEvent;
26
+ /**
27
+ * Setup in direct call per `userEvent.anyApi()`
28
+ */
29
+ export declare function setupDirect({ keyboardState, pointerState, ...options }?: DirectOptions & {
30
+ keyboardState?: System;
31
+ pointerState?: System;
32
+ }, // backward-compatibility
33
+ node?: Node): {
34
+ api: UserEvent;
35
+ system: System;
36
+ };
37
+ /**
38
+ * Create a set of callbacks with different default settings but the same state.
39
+ */
40
+ export declare function setupSub(this: Instance, options: Options): UserEvent;
41
+ export declare function createInstance(config: Config, system?: System): {
42
+ instance: Instance;
43
+ api: UserEvent;
44
+ };
@@ -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,10 @@
1
+ import { KeyboardHost } from './keyboard';
2
+ import { PointerHost } from './pointer';
3
+ /**
4
+ * @internal Do not create/alter this by yourself as this type might be subject to changes.
5
+ */
6
+ export declare class System {
7
+ readonly keyboard: KeyboardHost;
8
+ readonly pointer: PointerHost;
9
+ getUIEventModifiers(): EventModifierInit;
10
+ }
@@ -0,0 +1,50 @@
1
+ import { type Instance } from '../setup';
2
+ import { type System } from '.';
3
+ export declare enum DOM_KEY_LOCATION {
4
+ STANDARD = 0,
5
+ LEFT = 1,
6
+ RIGHT = 2,
7
+ NUMPAD = 3
8
+ }
9
+ export interface keyboardKey {
10
+ /** Physical location on a keyboard */
11
+ code?: string;
12
+ /** Character or functional key descriptor */
13
+ key?: string;
14
+ /** Location on the keyboard for keys with multiple representation */
15
+ location?: DOM_KEY_LOCATION;
16
+ /** Does the character in `key` require/imply AltRight to be pressed? */
17
+ altGr?: boolean;
18
+ /** Does the character in `key` require/imply a shiftKey to be pressed? */
19
+ shift?: boolean;
20
+ }
21
+ export declare class KeyboardHost {
22
+ readonly system: System;
23
+ constructor(system: System);
24
+ readonly modifiers: {
25
+ Alt: boolean;
26
+ AltGraph: boolean;
27
+ CapsLock: boolean;
28
+ Control: boolean;
29
+ Fn: boolean;
30
+ FnLock: boolean;
31
+ Meta: boolean;
32
+ NumLock: boolean;
33
+ ScrollLock: boolean;
34
+ Shift: boolean;
35
+ Symbol: boolean;
36
+ SymbolLock: boolean;
37
+ };
38
+ private readonly pressed;
39
+ carryChar: string;
40
+ private lastKeydownTarget;
41
+ private readonly modifierLockStart;
42
+ isKeyPressed(keyDef: keyboardKey): boolean;
43
+ getPressedKeys(): keyboardKey[];
44
+ /** Press a key */
45
+ keydown(instance: Instance, keyDef: keyboardKey): Promise<void>;
46
+ /** Release a key */
47
+ keyup(instance: Instance, keyDef: keyboardKey): Promise<void>;
48
+ private setKeydownTarget;
49
+ private hasKeyPress;
50
+ }
@@ -0,0 +1,23 @@
1
+ import { type pointerKey } from './shared';
2
+ export declare class Buttons {
3
+ private readonly pressed;
4
+ getButtons(): number;
5
+ down(keyDef: pointerKey): number | undefined;
6
+ up(keyDef: pointerKey): number | undefined;
7
+ }
8
+ export declare const MouseButton: {
9
+ readonly primary: 0;
10
+ readonly secondary: 1;
11
+ readonly auxiliary: 2;
12
+ readonly back: 3;
13
+ readonly X1: 3;
14
+ readonly forward: 4;
15
+ readonly X2: 4;
16
+ };
17
+ export type MouseButton = keyof typeof MouseButton | number;
18
+ export declare function getMouseButtonId(button?: MouseButton): number;
19
+ export declare const MouseButtonFlip: {
20
+ readonly 1: 2;
21
+ readonly 2: 1;
22
+ };
23
+ export declare function getMouseEventButton(button?: MouseButton): number;
@@ -0,0 +1,8 @@
1
+ import { type pointerKey } from '.';
2
+ export declare class Device {
3
+ private pressedKeys;
4
+ get countPressed(): number;
5
+ isPressed(keyDef: pointerKey): boolean;
6
+ addPressed(keyDef: pointerKey): Set<string>;
7
+ removePressed(keyDef: pointerKey): boolean;
8
+ }
@@ -0,0 +1,21 @@
1
+ import { System } from '..';
2
+ import { Instance } from '../../setup';
3
+ import { pointerKey, PointerPosition } from './shared';
4
+ export type { pointerKey, PointerPosition } from './shared';
5
+ export declare class PointerHost {
6
+ readonly system: System;
7
+ constructor(system: System);
8
+ private readonly mouse;
9
+ private readonly buttons;
10
+ private readonly devices;
11
+ private readonly pointers;
12
+ isKeyPressed(keyDef: pointerKey): boolean;
13
+ press(instance: Instance, keyDef: pointerKey, position: PointerPosition): Promise<void>;
14
+ move(instance: Instance, pointerName: string, position: PointerPosition): Promise<void>;
15
+ release(instance: Instance, keyDef: pointerKey, position: PointerPosition): Promise<void>;
16
+ getPointerName(keyDef: pointerKey): string;
17
+ getPreviousPosition(pointerName: string): PointerPosition | undefined;
18
+ resetClickCount(): void;
19
+ getMouseTarget(instance: Instance): Element;
20
+ setMousePosition(position: PointerPosition): void;
21
+ }
@@ -0,0 +1,31 @@
1
+ import { type Instance } from '../../setup';
2
+ import { pointerKey, PointerPosition } from './shared';
3
+ /**
4
+ * This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
5
+ */
6
+ export declare class Mouse {
7
+ position: PointerPosition;
8
+ private readonly buttons;
9
+ private selecting?;
10
+ private buttonDownTarget;
11
+ private readonly clickCount;
12
+ move(instance: Instance, position: PointerPosition,
13
+ /** Whether `preventDefault()` has been called on the `pointerdown` event */
14
+ isPrevented: boolean): {
15
+ leave: () => void;
16
+ enter: () => void;
17
+ move: () => void;
18
+ } | undefined;
19
+ down(instance: Instance, keyDef: pointerKey,
20
+ /** Whether `preventDefault()` has been called on the `pointerdown` event */
21
+ isPrevented: boolean): void;
22
+ up(instance: Instance, keyDef: pointerKey,
23
+ /** Whether `preventDefault()` has been called on the `pointerdown` event */
24
+ isPrevented: boolean): void;
25
+ resetClickCount(): void;
26
+ private getEventInit;
27
+ private getTarget;
28
+ private startSelecting;
29
+ private modifySelecting;
30
+ private endSelecting;
31
+ }
@@ -0,0 +1,32 @@
1
+ import { type Instance } from '../../setup';
2
+ import { PointerPosition } from './shared';
3
+ import { Buttons, MouseButton } from './buttons';
4
+ type PointerInit = {
5
+ pointerId: number;
6
+ pointerType: string;
7
+ isPrimary: boolean;
8
+ };
9
+ export declare class Pointer {
10
+ constructor({ pointerId, pointerType, isPrimary }: PointerInit, buttons: Buttons);
11
+ readonly pointerId: number;
12
+ readonly pointerType: string;
13
+ readonly isPrimary: boolean;
14
+ readonly buttons: Buttons;
15
+ isMultitouch: boolean;
16
+ isCancelled: boolean;
17
+ isDown: boolean;
18
+ isPrevented: boolean;
19
+ position: PointerPosition;
20
+ init(instance: Instance): this;
21
+ move(instance: Instance, position: PointerPosition): {
22
+ leave: () => void;
23
+ enter: () => void;
24
+ move: () => void;
25
+ } | undefined;
26
+ down(instance: Instance, button?: MouseButton): void;
27
+ up(instance: Instance, button?: MouseButton): void;
28
+ release(instance: Instance): void;
29
+ private getTarget;
30
+ private getEventInit;
31
+ }
32
+ export {};
@@ -0,0 +1,20 @@
1
+ import { PointerCoords } from '../../event';
2
+ import { MouseButton } from './buttons';
3
+ export interface pointerKey {
4
+ /** Name of the pointer key */
5
+ name: string;
6
+ /** Type of the pointer device */
7
+ pointerType: 'mouse' | 'pen' | 'touch';
8
+ /** Type of button */
9
+ button?: MouseButton;
10
+ }
11
+ export interface PointerPosition {
12
+ target?: Element;
13
+ coords?: PointerCoords;
14
+ caret?: CaretPosition;
15
+ }
16
+ export interface CaretPosition {
17
+ node?: Node;
18
+ offset?: number;
19
+ }
20
+ export declare function isDifferentPointerPosition(positionA: PointerPosition, positionB: PointerPosition): boolean;
@@ -0,0 +1,2 @@
1
+ import { type 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 { type 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 { type Options } from '../options';
3
+ export interface typeOptions {
4
+ skipClick?: Options['skipClick'];
5
+ skipAutoClose?: Options['skipAutoClose'];
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 { type 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,15 @@
1
+ declare enum clickableInputTypes {
2
+ 'button' = "button",
3
+ 'color' = "color",
4
+ 'file' = "file",
5
+ 'image' = "image",
6
+ 'reset' = "reset",
7
+ 'submit' = "submit",
8
+ 'checkbox' = "checkbox",
9
+ 'radio' = "radio"
10
+ }
11
+ export type ClickableInputOrButton = HTMLButtonElement | (HTMLInputElement & {
12
+ type: clickableInputTypes;
13
+ });
14
+ export declare function isClickableInput(element: Element): element is ClickableInputOrButton;
15
+ export {};
@@ -0,0 +1,3 @@
1
+ export declare function readBlobText(blob: Blob, FileReader: {
2
+ new (): FileReader;
3
+ }): Promise<string>;