@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,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 @@
1
+ export declare function readBlobText(blob: Blob): Promise<string>;
@@ -0,0 +1,9 @@
1
+ export declare function createClipboardItem(...blobs: Array<Blob | string>): ClipboardItem;
2
+ export declare function attachClipboardStubToView(window: Window & typeof globalThis): {
3
+ resetClipboardStub: () => void;
4
+ detachClipboardStub: () => void;
5
+ };
6
+ export declare function resetClipboardStubOnView(window: Window & typeof globalThis): void;
7
+ export declare function detachClipboardStubFromView(window: Window & typeof globalThis): void;
8
+ export declare function readDataTransferFromClipboard(document: Document): Promise<DataTransfer>;
9
+ export declare function writeDataTransferToClipboard(document: Document, clipboardData: DataTransfer): Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare function createDataTransfer(files?: File[]): DataTransfer;
2
+ export declare function getBlobFromDataTransferItem(item: DataTransferItem): Blob;
@@ -0,0 +1 @@
1
+ export declare function createFileList(files: File[]): FileList;
@@ -4,9 +4,7 @@ import { EditableInputType } from './isEditable';
4
4
  */
5
5
  export declare function calculateNewValue(inputData: string, node: (HTMLInputElement & {
6
6
  type: EditableInputType;
7
- }) | HTMLTextAreaElement | (Node & {
8
- nodeType: 3;
9
- }) | Text, { startOffset, endOffset, }: {
7
+ }) | HTMLTextAreaElement, { startOffset, endOffset, }: {
10
8
  startOffset: number;
11
9
  endOffset: number;
12
10
  }, inputType?: string): {
@@ -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;
@@ -0,0 +1,12 @@
1
+ declare const fakeFiles: unique symbol;
2
+ declare global {
3
+ interface HTMLInputElement {
4
+ [fakeFiles]?: {
5
+ restore: () => void;
6
+ };
7
+ }
8
+ }
9
+ export declare function setFiles(el: HTMLInputElement & {
10
+ type: 'file';
11
+ }, files: FileList): void;
12
+ export {};
File without changes
@@ -0,0 +1 @@
1
+ export declare function copySelection(target: Element): DataTransfer;
@@ -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 };
@@ -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;
File without changes
File without changes
@@ -1,7 +1,11 @@
1
1
  export * from './click/isClickableInput';
2
+ export * from './dataTransfer/Blob';
3
+ export * from './dataTransfer/DataTransfer';
4
+ export * from './dataTransfer/FileList';
5
+ export * from './dataTransfer/Clipboard';
2
6
  export * from './edit/buildTimeValue';
3
7
  export * from './edit/calculateNewValue';
4
- export * from './edit/fireInputEvent';
8
+ export * from './edit/editInputElement';
5
9
  export * from './edit/getValue';
6
10
  export * from './edit/isContentEditable';
7
11
  export * from './edit/isEditable';
@@ -9,23 +13,30 @@ export * from './edit/isValidDateValue';
9
13
  export * from './edit/isValidInputTimeValue';
10
14
  export * from './edit/maxLength';
11
15
  export * from './edit/prepareInput';
16
+ export * from './edit/setFiles';
12
17
  export * from './focus/blur';
18
+ export * from './focus/copySelection';
19
+ export * from './focus/cursor';
13
20
  export * from './focus/focus';
14
21
  export * from './focus/getActiveElement';
15
22
  export * from './focus/getTabDestination';
16
23
  export * from './focus/isFocusable';
24
+ export * from './focus/selectAll';
17
25
  export * from './focus/selection';
18
26
  export * from './focus/selector';
27
+ export * from './keyboard/getKeyEventProps';
28
+ export * from './keyboard/getUIEventModifiers';
19
29
  export * from './keyDef/readNextDescriptor';
30
+ export * from './misc/cloneEvent';
20
31
  export * from './misc/eventWrapper';
21
32
  export * from './misc/findClosest';
33
+ export * from './misc/getDocumentFromNode';
22
34
  export * from './misc/isDescendantOrSelf';
23
35
  export * from './misc/isElementType';
24
36
  export * from './misc/isVisible';
25
37
  export * from './misc/isDisabled';
38
+ export * from './misc/level';
26
39
  export * from './misc/wait';
27
- export * from './misc/hasPointerEvents';
28
40
  export * from './misc/hasFormSubmit';
29
- export * from './pointer/fakeEvent';
30
- export * from './pointer/firePointerEvents';
41
+ export * from './pointer/cssPointerEvents';
31
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;
@@ -0,0 +1 @@
1
+ export declare function getDocumentFromNode(el: Node): Document | null;
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 {};
File without changes
@@ -0,0 +1,15 @@
1
+ import { Config } from '../../setup';
2
+ import { ApiLevel } from '..';
3
+ export declare function hasPointerEvents(element: Element): boolean;
4
+ declare const PointerEventsCheck: unique symbol;
5
+ declare global {
6
+ interface Element {
7
+ [PointerEventsCheck]?: {
8
+ [k in ApiLevel]?: object;
9
+ } & {
10
+ result: boolean;
11
+ };
12
+ }
13
+ }
14
+ export declare function assertPointerEvents(config: Config, element: Element): void;
15
+ export {};
package/package.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "14.0.0-alpha.7",
3
+ "version": "14.0.0-beta.10",
4
4
  "description": "Fire events the same way the user does",
5
- "main": "dist/index.js",
6
5
  "keywords": [
7
6
  "react-testing-library",
8
7
  "dom-testing-library",
@@ -26,8 +25,17 @@
26
25
  "files": [
27
26
  "dist"
28
27
  ],
28
+ "main": "./dist/index.cjs",
29
+ "module": "./dist/index.mjs",
30
+ "exports": {
31
+ ".": {
32
+ "require": "./dist/index.cjs",
33
+ "default": "./dist/index.mjs"
34
+ }
35
+ },
36
+ "types": "./dist/types/index.d.ts",
29
37
  "scripts": {
30
- "build": "kcd-scripts build --no-ts-defs && tsc -p tsconfig.build.json",
38
+ "build": "node build.js",
31
39
  "lint": "kcd-scripts lint",
32
40
  "setup": "npm install && npm run validate -s",
33
41
  "test": "kcd-scripts test",
@@ -46,6 +54,7 @@
46
54
  "@types/estree": "0.0.45",
47
55
  "@types/jest-in-case": "^1.0.3",
48
56
  "@types/react": "^17.0.3",
57
+ "esbuild": "^0.14.9",
49
58
  "eslint-import-resolver-typescript": "^2.5.0",
50
59
  "is-ci": "^2.0.0",
51
60
  "jest-in-case": "^1.0.2",
@@ -57,31 +66,5 @@
57
66
  },
58
67
  "peerDependencies": {
59
68
  "@testing-library/dom": ">=7.21.4"
60
- },
61
- "eslintConfig": {
62
- "extends": "./node_modules/kcd-scripts/eslint.js",
63
- "rules": {
64
- "jsx-a11y/click-events-have-key-events": "off",
65
- "jsx-a11y/tabindex-no-positive": "off",
66
- "no-func-assign": "off",
67
- "no-return-assign": "off",
68
- "react/prop-types": "off",
69
- "testing-library/no-dom-import": "off"
70
- },
71
- "overrides": [
72
- {
73
- "files": [
74
- "**/__tests__/**"
75
- ],
76
- "rules": {
77
- "no-console": "off"
78
- }
79
- }
80
- ]
81
- },
82
- "eslintIgnore": [
83
- "node_modules",
84
- "coverage",
85
- "dist"
86
- ]
69
+ }
87
70
  }
package/CHANGELOG.md DELETED
@@ -1,5 +0,0 @@
1
- # CHANGELOG
2
-
3
- The changelog is automatically updated using
4
- [semantic-release](https://github.com/semantic-release/semantic-release). You
5
- can see it on the [releases page](../../releases).
package/dist/clear.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import type { UserEvent } from './setup';
2
- export declare function clear(this: UserEvent, element: Element): void;
package/dist/clear.js DELETED
@@ -1,46 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.clear = clear;
7
-
8
- var _utils = require("./utils");
9
-
10
- function clear(element) {
11
- var _element$selectionSta, _element$selectionEnd;
12
-
13
- if (!(0, _utils.isElementType)(element, ['input', 'textarea'])) {
14
- // TODO: support contenteditable
15
- throw new Error('clear currently only supports input and textarea elements.');
16
- }
17
-
18
- if ((0, _utils.isDisabled)(element)) {
19
- return;
20
- } // TODO: track the selection range ourselves so we don't have to do this input "type" trickery
21
- // just like cypress does: https://github.com/cypress-io/cypress/blob/8d7f1a0bedc3c45a2ebf1ff50324b34129fdc683/packages/driver/src/dom/selection.ts#L16-L37
22
-
23
-
24
- const elementType = element.type;
25
-
26
- if (elementType !== 'textarea') {
27
- // setSelectionRange is not supported on certain types of inputs, e.g. "number" or "email"
28
- ;
29
- element.type = 'text';
30
- }
31
-
32
- this.type(element, '{selectall}{del}', {
33
- delay: 0,
34
- initialSelectionStart: (_element$selectionSta = element.selectionStart) != null ? _element$selectionSta :
35
- /* istanbul ignore next */
36
- undefined,
37
- initialSelectionEnd: (_element$selectionEnd = element.selectionEnd) != null ? _element$selectionEnd :
38
- /* istanbul ignore next */
39
- undefined
40
- });
41
-
42
- if (elementType !== 'textarea') {
43
- ;
44
- element.type = elementType;
45
- }
46
- }
package/dist/click.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { PointerOptions } from './utils';
2
- import type { UserEvent } from './setup';
3
- export declare interface clickOptions {
4
- skipHover?: boolean;
5
- clickCount?: number;
6
- }
7
- export declare function click(this: UserEvent, element: Element, init?: MouseEventInit, { skipHover, skipPointerEventsCheck, }?: clickOptions & PointerOptions): void;
8
- export declare function dblClick(this: UserEvent, element: Element, init?: MouseEventInit, { skipPointerEventsCheck }?: clickOptions & PointerOptions): void;
9
- export declare function tripleClick(this: UserEvent, element: Element, init?: MouseEventInit, { skipPointerEventsCheck }?: clickOptions & PointerOptions): void;
package/dist/click.js DELETED
@@ -1,62 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.click = click;
7
- exports.dblClick = dblClick;
8
- exports.tripleClick = tripleClick;
9
-
10
- var _utils = require("./utils");
11
-
12
- function click(element, init, {
13
- skipHover = false,
14
- skipPointerEventsCheck = false
15
- } = {}) {
16
- if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
17
- throw new Error('unable to click element as it has or inherits pointer-events set to "none".');
18
- } // istanbul ignore else
19
-
20
-
21
- if (!skipHover) // We just checked for `pointerEvents`. We can always skip this one in `hover`.
22
- this.hover(element, init, {
23
- skipPointerEventsCheck: true
24
- });
25
- const keys = (init == null ? void 0 : init.button) === 2 || (init == null ? void 0 : init.buttons) === 2 ? '[MouseRight]' : '[MouseLeft]';
26
- this.pointer({
27
- keys,
28
- target: element
29
- });
30
- }
31
-
32
- function dblClick(element, init, {
33
- skipPointerEventsCheck = false
34
- } = {}) {
35
- if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
36
- throw new Error('unable to double-click element as it has or inherits pointer-events set to "none".');
37
- }
38
-
39
- this.hover(element, init, {
40
- skipPointerEventsCheck
41
- });
42
- this.pointer({
43
- keys: '[MouseLeft][MouseLeft]',
44
- target: element
45
- });
46
- }
47
-
48
- function tripleClick(element, init, {
49
- skipPointerEventsCheck = false
50
- } = {}) {
51
- if (!skipPointerEventsCheck && !(0, _utils.hasPointerEvents)(element)) {
52
- throw new Error('unable to triple-click element as it has or inherits pointer-events set to "none".');
53
- }
54
-
55
- this.hover(element, init, {
56
- skipPointerEventsCheck: true
57
- });
58
- this.pointer({
59
- keys: '[MouseLeft][MouseLeft][MouseLeft]',
60
- target: element
61
- });
62
- }
@@ -1,100 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "endTrackValue", {
7
- enumerable: true,
8
- get: function () {
9
- return _value.endTrackValue;
10
- }
11
- });
12
- Object.defineProperty(exports, "getUISelection", {
13
- enumerable: true,
14
- get: function () {
15
- return _selection.getUISelection;
16
- }
17
- });
18
- Object.defineProperty(exports, "getUIValue", {
19
- enumerable: true,
20
- get: function () {
21
- return _value.getUIValue;
22
- }
23
- });
24
- exports.prepareDocument = prepareDocument;
25
- Object.defineProperty(exports, "setUISelection", {
26
- enumerable: true,
27
- get: function () {
28
- return _selection.setUISelection;
29
- }
30
- });
31
- Object.defineProperty(exports, "setUIValue", {
32
- enumerable: true,
33
- get: function () {
34
- return _value.setUIValue;
35
- }
36
- });
37
- Object.defineProperty(exports, "startTrackValue", {
38
- enumerable: true,
39
- get: function () {
40
- return _value.startTrackValue;
41
- }
42
- });
43
-
44
- var _dom = require("@testing-library/dom");
45
-
46
- var _selection = require("./selection");
47
-
48
- var _value = require("./value");
49
-
50
- const isPrepared = Symbol('Node prepared with document state workarounds');
51
-
52
- function prepareDocument(document) {
53
- if (document[isPrepared]) {
54
- return;
55
- }
56
-
57
- document.addEventListener('focus', e => {
58
- const el = e.target;
59
- prepareElement(el);
60
- }, {
61
- capture: true,
62
- passive: true
63
- }); // Our test environment defaults to `document.body` as `activeElement`.
64
- // In other environments this might be `null` when preparing.
65
- // istanbul ignore else
66
-
67
- if (document.activeElement) {
68
- prepareElement(document.activeElement);
69
- }
70
-
71
- document.addEventListener('blur', e => {
72
- const el = e.target;
73
- const initialValue = (0, _value.getInitialValue)(el);
74
-
75
- if (typeof initialValue === 'string' && el.value !== initialValue) {
76
- _dom.fireEvent.change(el);
77
- }
78
- }, {
79
- capture: true,
80
- passive: true
81
- });
82
- document[isPrepared] = isPrepared;
83
- }
84
-
85
- function prepareElement(el) {
86
- if ('value' in el) {
87
- (0, _value.setInitialValue)(el);
88
- }
89
-
90
- if (el[isPrepared]) {
91
- return;
92
- }
93
-
94
- if ('value' in el) {
95
- (0, _value.prepareValueInterceptor)(el);
96
- (0, _selection.prepareSelectionInterceptor)(el);
97
- }
98
-
99
- el[isPrepared] = isPrepared;
100
- }
@@ -1,37 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.prepareInterceptor = prepareInterceptor;
7
- const Interceptor = Symbol('Interceptor for programmatical calls');
8
-
9
- function prepareInterceptor(element, propName, interceptorImpl) {
10
- const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
11
- const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
12
- const target = prototypeDescriptor != null && prototypeDescriptor.set ? 'set' : 'value';
13
-
14
- if (typeof (prototypeDescriptor == null ? void 0 : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
15
- return;
16
- }
17
-
18
- function intercept(...args) {
19
- const {
20
- applyNative = true,
21
- realArgs
22
- } = interceptorImpl.call(this, ...args);
23
- const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];
24
-
25
- if (target === 'set') {
26
- realFunc.call(this, realArgs);
27
- } else {
28
- realFunc.call(this, ...realArgs);
29
- }
30
- }
31
-
32
- ;
33
- intercept[Interceptor] = Interceptor;
34
- Object.defineProperty(element, propName, { ...(objectDescriptor != null ? objectDescriptor : prototypeDescriptor),
35
- [target]: intercept
36
- });
37
- }