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

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 (31) hide show
  1. package/dist/index.cjs +561 -700
  2. package/dist/index.mjs +562 -701
  3. package/dist/types/event/behavior/index.d.ts +3 -0
  4. package/dist/types/event/behavior/keydown.d.ts +1 -0
  5. package/dist/types/event/behavior/keypress.d.ts +1 -0
  6. package/dist/types/event/behavior/keyup.d.ts +1 -0
  7. package/dist/types/event/dispatchEvent.d.ts +1 -1
  8. package/dist/types/event/eventMap.d.ts +342 -0
  9. package/dist/types/event/index.d.ts +2 -2
  10. package/dist/types/keyboard/modifiers.d.ts +9 -0
  11. package/dist/types/keyboard/types.d.ts +0 -5
  12. package/dist/types/utils/edit/input.d.ts +2 -0
  13. package/dist/types/utils/edit/isValidDateOrTimeValue.d.ts +3 -0
  14. package/dist/types/utils/focus/selection.d.ts +4 -0
  15. package/dist/types/utils/index.d.ts +1 -8
  16. package/package.json +1 -1
  17. package/dist/types/keyboard/plugins/arrow.d.ts +0 -6
  18. package/dist/types/keyboard/plugins/character.d.ts +0 -5
  19. package/dist/types/keyboard/plugins/combination.d.ts +0 -5
  20. package/dist/types/keyboard/plugins/control.d.ts +0 -6
  21. package/dist/types/keyboard/plugins/functional.d.ts +0 -8
  22. package/dist/types/keyboard/plugins/index.d.ts +0 -7
  23. package/dist/types/keyboard/plugins/modifiers.d.ts +0 -8
  24. package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -4
  25. package/dist/types/keyboard/shared/index.d.ts +0 -1
  26. package/dist/types/utils/edit/calculateNewValue.d.ts +0 -14
  27. package/dist/types/utils/edit/editInputElement.d.ts +0 -14
  28. package/dist/types/utils/edit/isValidDateValue.d.ts +0 -3
  29. package/dist/types/utils/edit/isValidInputTimeValue.d.ts +0 -3
  30. package/dist/types/utils/edit/prepareInput.d.ts +0 -8
  31. package/dist/types/utils/misc/hasFormSubmit.d.ts +0 -1
@@ -1,3 +1,6 @@
1
1
  import './click';
2
+ import './keydown';
3
+ import './keypress';
4
+ import './keyup';
2
5
  export { behavior } from './registry';
3
6
  export type { BehaviorPlugin } from './registry';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1,2 @@
1
1
  import { Config } from '../setup';
2
- export declare function dispatchEvent(config: Config, target: Element, event: Event): boolean;
2
+ export declare function dispatchEvent(config: Config, target: Element, event: Event, preventDefault?: boolean): boolean;
@@ -0,0 +1,342 @@
1
+ export declare const eventMap: {
2
+ beforeInput: {
3
+ EventType: string;
4
+ defaultInit: {
5
+ bubbles: boolean;
6
+ cancelable: boolean;
7
+ composed: boolean;
8
+ };
9
+ };
10
+ input: {
11
+ EventType: string;
12
+ defaultInit: EventInit;
13
+ };
14
+ progress: {
15
+ EventType: string;
16
+ defaultInit: EventInit;
17
+ };
18
+ select: {
19
+ EventType: string;
20
+ defaultInit: EventInit;
21
+ };
22
+ scroll: {
23
+ EventType: string;
24
+ defaultInit: EventInit;
25
+ };
26
+ reset: {
27
+ EventType: string;
28
+ defaultInit: EventInit;
29
+ };
30
+ submit: {
31
+ EventType: string;
32
+ defaultInit: EventInit;
33
+ };
34
+ copy: {
35
+ EventType: string;
36
+ defaultInit: EventInit;
37
+ };
38
+ click: {
39
+ EventType: string;
40
+ defaultInit: EventInit;
41
+ };
42
+ blur: {
43
+ EventType: string;
44
+ defaultInit: EventInit;
45
+ };
46
+ focus: {
47
+ EventType: string;
48
+ defaultInit: EventInit;
49
+ };
50
+ cut: {
51
+ EventType: string;
52
+ defaultInit: EventInit;
53
+ };
54
+ paste: {
55
+ EventType: string;
56
+ defaultInit: EventInit;
57
+ };
58
+ abort: {
59
+ EventType: string;
60
+ defaultInit: EventInit;
61
+ };
62
+ change: {
63
+ EventType: string;
64
+ defaultInit: EventInit;
65
+ };
66
+ drag: {
67
+ EventType: string;
68
+ defaultInit: EventInit;
69
+ };
70
+ drop: {
71
+ EventType: string;
72
+ defaultInit: EventInit;
73
+ };
74
+ emptied: {
75
+ EventType: string;
76
+ defaultInit: EventInit;
77
+ };
78
+ ended: {
79
+ EventType: string;
80
+ defaultInit: EventInit;
81
+ };
82
+ error: {
83
+ EventType: string;
84
+ defaultInit: EventInit;
85
+ };
86
+ invalid: {
87
+ EventType: string;
88
+ defaultInit: EventInit;
89
+ };
90
+ load: {
91
+ EventType: string;
92
+ defaultInit: EventInit;
93
+ };
94
+ pause: {
95
+ EventType: string;
96
+ defaultInit: EventInit;
97
+ };
98
+ play: {
99
+ EventType: string;
100
+ defaultInit: EventInit;
101
+ };
102
+ playing: {
103
+ EventType: string;
104
+ defaultInit: EventInit;
105
+ };
106
+ seeked: {
107
+ EventType: string;
108
+ defaultInit: EventInit;
109
+ };
110
+ seeking: {
111
+ EventType: string;
112
+ defaultInit: EventInit;
113
+ };
114
+ stalled: {
115
+ EventType: string;
116
+ defaultInit: EventInit;
117
+ };
118
+ suspend: {
119
+ EventType: string;
120
+ defaultInit: EventInit;
121
+ };
122
+ waiting: {
123
+ EventType: string;
124
+ defaultInit: EventInit;
125
+ };
126
+ wheel: {
127
+ EventType: string;
128
+ defaultInit: EventInit;
129
+ };
130
+ compositionEnd: {
131
+ EventType: string;
132
+ defaultInit: EventInit;
133
+ };
134
+ compositionStart: {
135
+ EventType: string;
136
+ defaultInit: EventInit;
137
+ };
138
+ compositionUpdate: {
139
+ EventType: string;
140
+ defaultInit: EventInit;
141
+ };
142
+ keyDown: {
143
+ EventType: string;
144
+ defaultInit: EventInit;
145
+ };
146
+ keyPress: {
147
+ EventType: string;
148
+ defaultInit: EventInit;
149
+ };
150
+ keyUp: {
151
+ EventType: string;
152
+ defaultInit: EventInit;
153
+ };
154
+ focusIn: {
155
+ EventType: string;
156
+ defaultInit: EventInit;
157
+ };
158
+ focusOut: {
159
+ EventType: string;
160
+ defaultInit: EventInit;
161
+ };
162
+ contextMenu: {
163
+ EventType: string;
164
+ defaultInit: EventInit;
165
+ };
166
+ dblClick: {
167
+ EventType: string;
168
+ defaultInit: EventInit;
169
+ };
170
+ dragEnd: {
171
+ EventType: string;
172
+ defaultInit: EventInit;
173
+ };
174
+ dragEnter: {
175
+ EventType: string;
176
+ defaultInit: EventInit;
177
+ };
178
+ dragExit: {
179
+ EventType: string;
180
+ defaultInit: EventInit;
181
+ };
182
+ dragLeave: {
183
+ EventType: string;
184
+ defaultInit: EventInit;
185
+ };
186
+ dragOver: {
187
+ EventType: string;
188
+ defaultInit: EventInit;
189
+ };
190
+ dragStart: {
191
+ EventType: string;
192
+ defaultInit: EventInit;
193
+ };
194
+ mouseDown: {
195
+ EventType: string;
196
+ defaultInit: EventInit;
197
+ };
198
+ mouseEnter: {
199
+ EventType: string;
200
+ defaultInit: EventInit;
201
+ };
202
+ mouseLeave: {
203
+ EventType: string;
204
+ defaultInit: EventInit;
205
+ };
206
+ mouseMove: {
207
+ EventType: string;
208
+ defaultInit: EventInit;
209
+ };
210
+ mouseOut: {
211
+ EventType: string;
212
+ defaultInit: EventInit;
213
+ };
214
+ mouseOver: {
215
+ EventType: string;
216
+ defaultInit: EventInit;
217
+ };
218
+ mouseUp: {
219
+ EventType: string;
220
+ defaultInit: EventInit;
221
+ };
222
+ popState: {
223
+ EventType: string;
224
+ defaultInit: EventInit;
225
+ };
226
+ touchCancel: {
227
+ EventType: string;
228
+ defaultInit: EventInit;
229
+ };
230
+ touchEnd: {
231
+ EventType: string;
232
+ defaultInit: EventInit;
233
+ };
234
+ touchMove: {
235
+ EventType: string;
236
+ defaultInit: EventInit;
237
+ };
238
+ touchStart: {
239
+ EventType: string;
240
+ defaultInit: EventInit;
241
+ };
242
+ canPlay: {
243
+ EventType: string;
244
+ defaultInit: EventInit;
245
+ };
246
+ canPlayThrough: {
247
+ EventType: string;
248
+ defaultInit: EventInit;
249
+ };
250
+ durationChange: {
251
+ EventType: string;
252
+ defaultInit: EventInit;
253
+ };
254
+ encrypted: {
255
+ EventType: string;
256
+ defaultInit: EventInit;
257
+ };
258
+ loadedData: {
259
+ EventType: string;
260
+ defaultInit: EventInit;
261
+ };
262
+ loadedMetadata: {
263
+ EventType: string;
264
+ defaultInit: EventInit;
265
+ };
266
+ loadStart: {
267
+ EventType: string;
268
+ defaultInit: EventInit;
269
+ };
270
+ rateChange: {
271
+ EventType: string;
272
+ defaultInit: EventInit;
273
+ };
274
+ timeUpdate: {
275
+ EventType: string;
276
+ defaultInit: EventInit;
277
+ };
278
+ volumeChange: {
279
+ EventType: string;
280
+ defaultInit: EventInit;
281
+ };
282
+ animationStart: {
283
+ EventType: string;
284
+ defaultInit: EventInit;
285
+ };
286
+ animationEnd: {
287
+ EventType: string;
288
+ defaultInit: EventInit;
289
+ };
290
+ animationIteration: {
291
+ EventType: string;
292
+ defaultInit: EventInit;
293
+ };
294
+ transitionEnd: {
295
+ EventType: string;
296
+ defaultInit: EventInit;
297
+ };
298
+ doubleClick: {
299
+ EventType: string;
300
+ defaultInit: EventInit;
301
+ };
302
+ pointerOver: {
303
+ EventType: string;
304
+ defaultInit: EventInit;
305
+ };
306
+ pointerEnter: {
307
+ EventType: string;
308
+ defaultInit: EventInit;
309
+ };
310
+ pointerDown: {
311
+ EventType: string;
312
+ defaultInit: EventInit;
313
+ };
314
+ pointerMove: {
315
+ EventType: string;
316
+ defaultInit: EventInit;
317
+ };
318
+ pointerUp: {
319
+ EventType: string;
320
+ defaultInit: EventInit;
321
+ };
322
+ pointerCancel: {
323
+ EventType: string;
324
+ defaultInit: EventInit;
325
+ };
326
+ pointerOut: {
327
+ EventType: string;
328
+ defaultInit: EventInit;
329
+ };
330
+ pointerLeave: {
331
+ EventType: string;
332
+ defaultInit: EventInit;
333
+ };
334
+ gotPointerCapture: {
335
+ EventType: string;
336
+ defaultInit: EventInit;
337
+ };
338
+ lostPointerCapture: {
339
+ EventType: string;
340
+ defaultInit: EventInit;
341
+ };
342
+ };
@@ -2,5 +2,5 @@ import { Config } from '../setup';
2
2
  import { EventTypeInit } from './createEvent';
3
3
  import { EventType, PointerCoords } from './types';
4
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;
5
+ export declare function dispatchUIEvent<K extends EventType>(config: Config, target: Element, type: K, init?: EventTypeInit<K>, preventDefault?: boolean): boolean;
6
+ export declare function bindDispatchUIEvent(config: Config): (target: Element, type: keyof DocumentEventMap, init?: InputEventInit | UIEventInit | EventInit | ClipboardEventInit | MouseEventInit | PointerEventInit | KeyboardEventInit | undefined, preventDefault?: boolean | undefined) => boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file should contain behavior for modifier keys:
3
+ * https://www.w3.org/TR/uievents-key/#keys-modifier
4
+ */
5
+ import { Config } from '../setup';
6
+ import { keyboardKey } from '.';
7
+ export declare function preKeydownBehavior(config: Config, { key }: keyboardKey, element: Element): void;
8
+ export declare function preKeyupBehavior(config: Config, { key }: keyboardKey): void;
9
+ export declare function postKeyupBehavior(config: Config, { key }: keyboardKey, element: Element): void;
@@ -1,4 +1,3 @@
1
- import { Config } from '../setup';
2
1
  /**
3
2
  * @internal Do not create/alter this by yourself as this type might be subject to changes.
4
3
  */
@@ -72,7 +71,3 @@ export interface keyboardKey {
72
71
  /** Does the character in `key` require/imply a shiftKey to be pressed? */
73
72
  shift?: boolean;
74
73
  }
75
- export interface behaviorPlugin {
76
- matches: (keyDef: keyboardKey, element: Element, config: Config) => boolean;
77
- handle: (keyDef: keyboardKey, element: Element, config: Config) => void;
78
- }
@@ -0,0 +1,2 @@
1
+ import { Config } from '../../setup';
2
+ export declare function input(config: Config, element: Element, data: string, inputType?: string): void;
@@ -0,0 +1,3 @@
1
+ export declare function isValidDateOrTimeValue(element: HTMLInputElement & {
2
+ type: 'date' | 'time';
3
+ }, value: string): boolean;
@@ -40,3 +40,7 @@ export declare function setSelection({ focusNode, focusOffset, anchorNode, ancho
40
40
  focusNode: Node;
41
41
  focusOffset: number;
42
42
  }): void;
43
+ /**
44
+ * Move the selection
45
+ */
46
+ export declare function moveSelection(node: Element, direction: -1 | 1): void;
@@ -3,16 +3,10 @@ export * from './dataTransfer/Blob';
3
3
  export * from './dataTransfer/DataTransfer';
4
4
  export * from './dataTransfer/FileList';
5
5
  export * from './dataTransfer/Clipboard';
6
- export * from './edit/buildTimeValue';
7
- export * from './edit/calculateNewValue';
8
- export * from './edit/editInputElement';
9
6
  export * from './edit/getValue';
7
+ export * from './edit/input';
10
8
  export * from './edit/isContentEditable';
11
9
  export * from './edit/isEditable';
12
- export * from './edit/isValidDateValue';
13
- export * from './edit/isValidInputTimeValue';
14
- export * from './edit/maxLength';
15
- export * from './edit/prepareInput';
16
10
  export * from './edit/setFiles';
17
11
  export * from './focus/blur';
18
12
  export * from './focus/copySelection';
@@ -37,6 +31,5 @@ export * from './misc/isVisible';
37
31
  export * from './misc/isDisabled';
38
32
  export * from './misc/level';
39
33
  export * from './misc/wait';
40
- export * from './misc/hasFormSubmit';
41
34
  export * from './pointer/cssPointerEvents';
42
35
  export * from './pointer/mouseButtons';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "14.0.0-beta.10",
3
+ "version": "14.0.0-beta.11",
4
4
  "description": "Fire events the same way the user does",
5
5
  "keywords": [
6
6
  "react-testing-library",
@@ -1,6 +0,0 @@
1
- /**
2
- * This file should contain behavior for arrow keys as described here:
3
- * https://w3c.github.io/uievents-code/#key-arrowpad-section
4
- */
5
- import { behaviorPlugin } from '../types';
6
- export declare const keydownBehavior: behaviorPlugin[];
@@ -1,5 +0,0 @@
1
- /**
2
- * This file should cover the behavior for keys that produce character input
3
- */
4
- import { behaviorPlugin } from '../types';
5
- export declare const keypressBehavior: behaviorPlugin[];
@@ -1,5 +0,0 @@
1
- /**
2
- * Default behavior for key combinations
3
- */
4
- import { behaviorPlugin } from '../types';
5
- export declare const keydownBehavior: behaviorPlugin[];
@@ -1,6 +0,0 @@
1
- /**
2
- * This file should contain behavior for arrow keys as described here:
3
- * https://w3c.github.io/uievents-code/#key-controlpad-section
4
- */
5
- import { behaviorPlugin } from '../types';
6
- export declare const keydownBehavior: behaviorPlugin[];
@@ -1,8 +0,0 @@
1
- /**
2
- * This file should contain behavior for functional keys as described here:
3
- * https://w3c.github.io/uievents-code/#key-alphanumeric-functional
4
- */
5
- import { behaviorPlugin } from '../types';
6
- export declare const keydownBehavior: behaviorPlugin[];
7
- export declare const keypressBehavior: behaviorPlugin[];
8
- export declare const keyupBehavior: behaviorPlugin[];
@@ -1,7 +0,0 @@
1
- import { behaviorPlugin } from '../types';
2
- export declare const preKeydownBehavior: behaviorPlugin[];
3
- export declare const keydownBehavior: behaviorPlugin[];
4
- export declare const keypressBehavior: behaviorPlugin[];
5
- export declare const preKeyupBehavior: behaviorPlugin[];
6
- export declare const keyupBehavior: behaviorPlugin[];
7
- export declare const postKeyupBehavior: behaviorPlugin[];
@@ -1,8 +0,0 @@
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[];
@@ -1,4 +0,0 @@
1
- import { Config } from '../../setup';
2
- export declare function fireChangeForInputTimeIfValid(config: Config, el: HTMLInputElement & {
3
- type: 'time';
4
- }, prevValue: unknown, timeNewEntry: string): void;
@@ -1 +0,0 @@
1
- export * from './fireChangeForInputTimeIfValid';
@@ -1,14 +0,0 @@
1
- import { EditableInputType } from './isEditable';
2
- /**
3
- * Calculate a new text value.
4
- */
5
- export declare function calculateNewValue(inputData: string, node: (HTMLInputElement & {
6
- type: EditableInputType;
7
- }) | HTMLTextAreaElement, { startOffset, endOffset, }: {
8
- startOffset: number;
9
- endOffset: number;
10
- }, inputType?: string): {
11
- oldValue: string;
12
- newValue: string;
13
- newOffset: number;
14
- };
@@ -1,14 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- export declare function isValidDateValue(element: HTMLInputElement & {
2
- type: 'date';
3
- }, value: string): boolean;
@@ -1,3 +0,0 @@
1
- export declare function isValidInputTimeValue(element: HTMLInputElement & {
2
- type: 'time';
3
- }, timeValue: string): boolean;
@@ -1,8 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export declare const hasFormSubmit: (form: HTMLFormElement | null) => form is HTMLFormElement;