@testing-library/user-event 14.0.0-beta.4 → 14.0.0-beta.8

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 (96) hide show
  1. package/README.md +5 -192
  2. package/dist/index.cjs +2943 -0
  3. package/dist/{index.js → index.mjs} +397 -214
  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/types/document/index.d.ts +10 -0
  13. package/dist/types/document/interceptor.d.ts +15 -0
  14. package/dist/types/document/selection.d.ts +27 -0
  15. package/dist/types/document/value.d.ts +18 -0
  16. package/dist/types/index.d.ts +4 -0
  17. package/dist/types/keyboard/index.d.ts +7 -0
  18. package/dist/types/keyboard/keyMap.d.ts +5 -0
  19. package/dist/types/keyboard/keyboardAction.d.ts +10 -0
  20. package/dist/types/keyboard/parseKeyDef.d.ts +17 -0
  21. package/dist/types/keyboard/plugins/arrow.d.ts +6 -0
  22. package/dist/types/keyboard/plugins/character.d.ts +5 -0
  23. package/dist/types/keyboard/plugins/combination.d.ts +5 -0
  24. package/dist/types/keyboard/plugins/control.d.ts +6 -0
  25. package/dist/types/keyboard/plugins/functional.d.ts +8 -0
  26. package/dist/types/keyboard/plugins/index.d.ts +7 -0
  27. package/dist/types/keyboard/plugins/modifiers.d.ts +8 -0
  28. package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +3 -0
  29. package/dist/types/keyboard/shared/index.d.ts +1 -0
  30. package/dist/types/keyboard/types.d.ts +78 -0
  31. package/dist/types/options.d.ts +117 -0
  32. package/dist/types/pointer/index.d.ts +10 -0
  33. package/dist/types/pointer/keyMap.d.ts +2 -0
  34. package/dist/types/pointer/parseKeyDef.d.ts +6 -0
  35. package/dist/types/pointer/pointerAction.d.ts +7 -0
  36. package/dist/types/pointer/pointerMove.d.ts +6 -0
  37. package/dist/types/pointer/pointerPress.d.ts +8 -0
  38. package/dist/types/pointer/resolveSelectionTarget.d.ts +5 -0
  39. package/dist/types/pointer/types.d.ts +61 -0
  40. package/dist/types/setup/api.d.ts +5 -0
  41. package/dist/types/setup/config.d.ts +10 -0
  42. package/dist/types/setup/directApi.d.ts +19 -0
  43. package/dist/types/setup/index.d.ts +34 -0
  44. package/dist/types/setup/setup.d.ts +19 -0
  45. package/dist/types/setup/wrapAsync.d.ts +4 -0
  46. package/dist/types/utility/clear.d.ts +2 -0
  47. package/dist/types/utility/index.d.ts +4 -0
  48. package/dist/types/utility/selectOptions.d.ts +3 -0
  49. package/dist/types/utility/type.d.ts +9 -0
  50. package/dist/types/utility/upload.d.ts +5 -0
  51. package/dist/types/utils/click/isClickableInput.d.ts +1 -0
  52. package/dist/types/utils/dataTransfer/Blob.d.ts +1 -0
  53. package/dist/types/utils/dataTransfer/Clipboard.d.ts +9 -0
  54. package/dist/types/utils/dataTransfer/DataTransfer.d.ts +2 -0
  55. package/dist/types/utils/dataTransfer/FileList.d.ts +1 -0
  56. package/dist/types/utils/edit/buildTimeValue.d.ts +1 -0
  57. package/dist/types/utils/edit/calculateNewValue.d.ts +14 -0
  58. package/dist/types/utils/edit/editInputElement.d.ts +16 -0
  59. package/dist/types/utils/edit/getValue.d.ts +1 -0
  60. package/dist/types/utils/edit/isContentEditable.d.ts +7 -0
  61. package/dist/types/utils/edit/isEditable.d.ts +25 -0
  62. package/dist/types/utils/edit/isValidDateValue.d.ts +3 -0
  63. package/dist/types/utils/edit/isValidInputTimeValue.d.ts +3 -0
  64. package/dist/types/utils/edit/maxLength.d.ts +1 -0
  65. package/dist/types/utils/edit/prepareInput.d.ts +7 -0
  66. package/dist/types/utils/edit/setFiles.d.ts +12 -0
  67. package/dist/types/utils/focus/blur.d.ts +2 -0
  68. package/dist/types/utils/focus/copySelection.d.ts +1 -0
  69. package/dist/types/utils/focus/cursor.d.ts +9 -0
  70. package/dist/types/utils/focus/focus.d.ts +5 -0
  71. package/dist/types/utils/focus/getActiveElement.d.ts +1 -0
  72. package/dist/types/utils/focus/getTabDestination.d.ts +1 -0
  73. package/dist/types/utils/focus/isFocusable.d.ts +1 -0
  74. package/dist/types/utils/focus/selectAll.d.ts +5 -0
  75. package/dist/types/utils/focus/selection.d.ts +42 -0
  76. package/dist/types/utils/focus/selector.d.ts +1 -0
  77. package/dist/types/utils/index.d.ts +42 -0
  78. package/dist/types/utils/keyDef/readNextDescriptor.d.ts +19 -0
  79. package/dist/types/utils/keyboard/getKeyEventProps.d.ts +17 -0
  80. package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
  81. package/dist/types/utils/misc/eventWrapper.d.ts +1 -0
  82. package/dist/types/utils/misc/findClosest.d.ts +1 -0
  83. package/dist/types/utils/misc/getDocumentFromNode.d.ts +1 -0
  84. package/dist/types/utils/misc/hasFormSubmit.d.ts +1 -0
  85. package/dist/types/utils/misc/isDescendantOrSelf.d.ts +1 -0
  86. package/dist/types/utils/misc/isDisabled.d.ts +1 -0
  87. package/dist/types/utils/misc/isElementType.d.ts +5 -0
  88. package/dist/types/utils/misc/isVisible.d.ts +1 -0
  89. package/dist/types/utils/misc/level.d.ts +17 -0
  90. package/dist/types/utils/misc/wait.d.ts +1 -0
  91. package/dist/types/utils/pointer/cssPointerEvents.d.ts +15 -0
  92. package/dist/types/utils/pointer/firePointerEvents.d.ts +25 -0
  93. package/dist/types/utils/pointer/mouseButtons.d.ts +12 -0
  94. package/package.json +10 -3
  95. package/dist/index.d.ts +0 -1110
  96. package/dist/package.json +0 -1
@@ -0,0 +1,2 @@
1
+ import { Instance } from '../setup';
2
+ export declare function copy(this: Instance): Promise<DataTransfer | undefined>;
@@ -0,0 +1,2 @@
1
+ import { Instance } from '../setup';
2
+ export declare function cut(this: Instance): Promise<DataTransfer | undefined>;
@@ -0,0 +1,3 @@
1
+ export * from './copy';
2
+ export * from './cut';
3
+ export * from './paste';
@@ -0,0 +1,2 @@
1
+ import { Instance } from '../setup';
2
+ export declare function paste(this: Instance, clipboardData?: DataTransfer | string): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { Instance } from '../setup';
2
+ export declare function click(this: Instance, element: Element): Promise<void>;
3
+ export declare function dblClick(this: Instance, element: Element): Promise<void>;
4
+ export declare function tripleClick(this: Instance, element: Element): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { Instance } from '../setup';
2
+ export declare function hover(this: Instance, element: Element): Promise<void>;
3
+ export declare function unhover(this: Instance, element: Element): Promise<void>;
@@ -0,0 +1,3 @@
1
+ export * from './click';
2
+ export * from './hover';
3
+ export * from './tab';
@@ -0,0 +1,4 @@
1
+ import type { Instance } from '../setup';
2
+ export declare function tab(this: Instance, { shift, }?: {
3
+ shift?: boolean;
4
+ }): Promise<void>;
@@ -0,0 +1,10 @@
1
+ declare const isPrepared: unique symbol;
2
+ declare global {
3
+ interface Node {
4
+ [isPrepared]?: typeof isPrepared;
5
+ }
6
+ }
7
+ export declare function prepareDocument(document: Document): void;
8
+ export { getUIValue, setUIValue, startTrackValue, endTrackValue } from './value';
9
+ export { getUISelection, setUISelection } from './selection';
10
+ export type { UISelectionRange } from './selection';
@@ -0,0 +1,15 @@
1
+ declare type anyFunc = (...a: any[]) => any;
2
+ declare type Params<Prop> = Prop extends anyFunc ? Parameters<Prop> : [Prop];
3
+ declare type ImplReturn<Prop> = Prop extends anyFunc ? Parameters<Prop> : Prop;
4
+ export declare function prepareInterceptor<ElementType extends Node, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => {
5
+ /**
6
+ * React tracks the changes on element properties.
7
+ * This workaround tries to alter the DOM element without React noticing,
8
+ * so that it later picks up the change.
9
+ *
10
+ * @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104
11
+ */
12
+ applyNative?: boolean;
13
+ realArgs?: ImplReturn<ElementType[PropName]>;
14
+ }): void;
15
+ export {};
@@ -0,0 +1,27 @@
1
+ declare const UISelection: unique symbol;
2
+ export interface UISelectionRange {
3
+ startOffset: number;
4
+ endOffset: number;
5
+ }
6
+ export interface UISelection {
7
+ anchorOffset: number;
8
+ focusOffset: number;
9
+ }
10
+ declare global {
11
+ interface Element {
12
+ [UISelection]?: UISelection;
13
+ }
14
+ }
15
+ export declare function prepareSelectionInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
16
+ export declare function setUISelection(element: HTMLInputElement | HTMLTextAreaElement, { focusOffset: focusOffsetParam, anchorOffset: anchorOffsetParam, }: {
17
+ anchorOffset?: number;
18
+ focusOffset: number;
19
+ }, mode?: 'replace' | 'modify'): void;
20
+ export declare function getUISelection(element: HTMLInputElement | HTMLTextAreaElement): {
21
+ startOffset: number;
22
+ endOffset: number;
23
+ anchorOffset: number;
24
+ focusOffset: number;
25
+ };
26
+ export declare function clearUISelection(element: HTMLInputElement | HTMLTextAreaElement): void;
27
+ export {};
@@ -0,0 +1,18 @@
1
+ declare const UIValue: unique symbol;
2
+ declare const InitialValue: unique symbol;
3
+ declare const TrackChanges: unique symbol;
4
+ declare global {
5
+ interface Element {
6
+ [UIValue]?: string;
7
+ [InitialValue]?: string;
8
+ [TrackChanges]?: string[];
9
+ }
10
+ }
11
+ export declare function prepareValueInterceptor(element: HTMLInputElement): void;
12
+ export declare function setUIValue(element: HTMLInputElement | HTMLTextAreaElement, value: string): void;
13
+ export declare function getUIValue(element: HTMLInputElement | HTMLTextAreaElement): string;
14
+ export declare function setInitialValue(element: HTMLInputElement | HTMLTextAreaElement): void;
15
+ export declare function getInitialValue(element: HTMLInputElement | HTMLTextAreaElement): string | undefined;
16
+ export declare function startTrackValue(element: HTMLInputElement | HTMLTextAreaElement): void;
17
+ export declare function endTrackValue(element: HTMLInputElement | HTMLTextAreaElement): string[] | undefined;
18
+ export {};
@@ -0,0 +1,4 @@
1
+ export { userEvent as default } from './setup';
2
+ export type { keyboardKey } from './keyboard';
3
+ export type { pointerKey } from './pointer';
4
+ export { PointerEventsCheckLevel } from './options';
@@ -0,0 +1,7 @@
1
+ import { Instance } from '../setup';
2
+ import { releaseAllKeys } from './keyboardAction';
3
+ import type { keyboardState, keyboardKey } from './types';
4
+ export { releaseAllKeys };
5
+ export type { keyboardKey, keyboardState };
6
+ export declare function keyboard(this: Instance, text: string): Promise<void>;
7
+ export declare function createKeyboardState(): keyboardState;
@@ -0,0 +1,5 @@
1
+ import { keyboardKey } from './types';
2
+ /**
3
+ * Mapping for a default US-104-QWERTY keyboard
4
+ */
5
+ export declare const defaultKeyMap: keyboardKey[];
@@ -0,0 +1,10 @@
1
+ import { Config } from '../setup';
2
+ import { keyboardKey } from './types';
3
+ export interface KeyboardAction {
4
+ keyDef: keyboardKey;
5
+ releasePrevious: boolean;
6
+ releaseSelf: boolean;
7
+ repeat: number;
8
+ }
9
+ export declare function keyboardAction(config: Config, actions: KeyboardAction[]): Promise<void>;
10
+ export declare function releaseAllKeys(config: Config): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import { keyboardKey } from './types';
2
+ /**
3
+ * Parse key defintions 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,6 @@
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[];
@@ -0,0 +1,5 @@
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[];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Default behavior for key combinations
3
+ */
4
+ import { behaviorPlugin } from '../types';
5
+ export declare const keydownBehavior: behaviorPlugin[];
@@ -0,0 +1,6 @@
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[];
@@ -0,0 +1,8 @@
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[];
@@ -0,0 +1,7 @@
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[];
@@ -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,3 @@
1
+ export declare function fireChangeForInputTimeIfValid(el: HTMLInputElement & {
2
+ type: 'time';
3
+ }, prevValue: unknown, timeNewEntry: string): void;
@@ -0,0 +1 @@
1
+ export * from './fireChangeForInputTimeIfValid';
@@ -0,0 +1,78 @@
1
+ import { Config } from '../setup';
2
+ /**
3
+ * @internal Do not create/alter this by yourself as this type might be subject to changes.
4
+ */
5
+ export declare type keyboardState = {
6
+ /**
7
+ All keys that have been pressed and not been lifted up yet.
8
+ */
9
+ pressed: {
10
+ keyDef: keyboardKey;
11
+ unpreventedDefault: boolean;
12
+ }[];
13
+ /**
14
+ Active modifiers
15
+ */
16
+ modifiers: {
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;
36
+ };
37
+ /**
38
+ The element the keyboard input is performed on.
39
+ Some behavior might differ if the activeElement changes between corresponding keyboard events.
40
+ */
41
+ activeElement: Element | null;
42
+ /**
43
+ For HTMLInputElements type='number':
44
+ If the last input char is '.', '-' or 'e',
45
+ the IDL value attribute does not reflect the input value.
46
+
47
+ @deprecated The document state workaround in `src/document/value.ts` keeps track
48
+ of UI value diverging from value property.
49
+ */
50
+ carryValue?: string;
51
+ /**
52
+ Carry over characters to following key handlers.
53
+ E.g. ^1
54
+ */
55
+ carryChar: string;
56
+ };
57
+ export declare enum DOM_KEY_LOCATION {
58
+ STANDARD = 0,
59
+ LEFT = 1,
60
+ RIGHT = 2,
61
+ NUMPAD = 3
62
+ }
63
+ export interface keyboardKey {
64
+ /** Physical location on a keyboard */
65
+ code?: string;
66
+ /** Character or functional key descriptor */
67
+ key?: string;
68
+ /** Location on the keyboard for keys with multiple representation */
69
+ location?: DOM_KEY_LOCATION;
70
+ /** Does the character in `key` require/imply AltRight to be pressed? */
71
+ altGr?: boolean;
72
+ /** Does the character in `key` require/imply a shiftKey to be pressed? */
73
+ shift?: boolean;
74
+ }
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,117 @@
1
+ import type { keyboardKey } from './keyboard/types';
2
+ import type { pointerKey } from './pointer/types';
3
+ export declare enum PointerEventsCheckLevel {
4
+ /**
5
+ * Check pointer events on every user interaction that triggers a bunch of events.
6
+ * E.g. once for releasing a mouse button even though this triggers `pointerup`, `mouseup`, `click`, etc...
7
+ */
8
+ EachTrigger = 4,
9
+ /** Check each target once per call to pointer (related) API */
10
+ EachApiCall = 2,
11
+ /** Check each event target once */
12
+ EachTarget = 1,
13
+ /** No pointer events check */
14
+ Never = 0
15
+ }
16
+ export interface Options {
17
+ /**
18
+ * When using `userEvent.upload`, automatically discard files
19
+ * that don't match an `accept` property if it exists.
20
+ *
21
+ * @default true
22
+ */
23
+ applyAccept?: boolean;
24
+ /**
25
+ * We intend to automatically apply modifier keys for printable characters in the future.
26
+ * I.e. `A` implying `{Shift>}a{/Shift}` if caps lock is not active.
27
+ *
28
+ * This options allows you to opt out of this change in foresight.
29
+ * The feature therefore will not constitute a breaking change.
30
+ *
31
+ * @default true
32
+ */
33
+ autoModify?: boolean;
34
+ /**
35
+ * Between some subsequent inputs like typing a series of characters
36
+ * the code execution is delayed per `setTimeout` for (at least) `delay` seconds.
37
+ * This moves the next changes at least to next macro task
38
+ * and allows other (asynchronous) code to run between events.
39
+ *
40
+ * `null` prevents `setTimeout` from being called.
41
+ *
42
+ * @default 0
43
+ */
44
+ delay?: number | null;
45
+ /**
46
+ * The document.
47
+ *
48
+ * This defaults to the owner document of an element if an API is called directly with an element and without setup.
49
+ * Otherwise it falls back to the global document.
50
+ *
51
+ * @default element.ownerDocument??global.document
52
+ */
53
+ document?: Document;
54
+ /**
55
+ * An array of keyboard keys the keyboard device consists of.
56
+ *
57
+ * This allows to plug in different layouts / localizations.
58
+ *
59
+ * Defaults to a "standard" US-104-QWERTY keyboard.
60
+ */
61
+ keyboardMap?: keyboardKey[];
62
+ /**
63
+ * An array of available pointer keys.
64
+ *
65
+ * This allows to plug in different pointer devices.
66
+ */
67
+ pointerMap?: pointerKey[];
68
+ /**
69
+ * The pointer API includes a check if an element has or inherits `pointer-events: none`.
70
+ * This check is known to be expensive and very expensive when checking deeply nested nodes.
71
+ * This option determines how often the pointer related APIs perform the check.
72
+ *
73
+ * This is a binary flag option. You can combine multiple Levels.
74
+ *
75
+ * @default PointerEventsCheckLevel.EachCall
76
+ */
77
+ pointerEventsCheck?: PointerEventsCheckLevel | number;
78
+ /**
79
+ * `userEvent.type` automatically releases any keys still pressed at the end of the call.
80
+ * This option allows to opt out of this feature.
81
+ *
82
+ * @default false
83
+ */
84
+ skipAutoClose?: boolean;
85
+ /**
86
+ * `userEvent.type` implys a click at the end of the element content/value.
87
+ * This option allows to opt out of this feature.
88
+ *
89
+ * @default false
90
+ */
91
+ skipClick?: boolean;
92
+ /**
93
+ * `userEvent.click` implys moving the cursor to the target element first.
94
+ * This options allows to opt out of this feature.
95
+ *
96
+ * @default false
97
+ */
98
+ skipHover?: boolean;
99
+ /**
100
+ * Write selected data to Clipboard API when a `cut` or `copy` is triggered.
101
+ *
102
+ * The Clipboard API is usually not available to test code.
103
+ * Our `setup` replaces the `navigator.clipboard` property with a stub.
104
+ *
105
+ * Defaults to `false` when calling the APIs directly.
106
+ * Defaults to `true` when calling the APIs per `setup`.
107
+ */
108
+ writeToClipboard?: boolean;
109
+ }
110
+ /**
111
+ * Default options applied when API is called per `userEvent.anyApi()`
112
+ */
113
+ export declare const defaultOptionsDirect: Required<Options>;
114
+ /**
115
+ * Default options applied when API is called per `userEvent().anyApi()`
116
+ */
117
+ export declare const defaultOptionsSetup: Required<Options>;
@@ -0,0 +1,10 @@
1
+ import { Instance } from '../setup';
2
+ import { PointerAction, PointerActionTarget } from './pointerAction';
3
+ import type { pointerState, pointerKey } from './types';
4
+ export type { pointerState, pointerKey };
5
+ declare type PointerActionInput = string | ({
6
+ keys: string;
7
+ } & PointerActionTarget) | PointerAction;
8
+ export declare type PointerInput = PointerActionInput | Array<PointerActionInput>;
9
+ export declare function pointer(this: Instance, input: PointerInput): Promise<void>;
10
+ export declare function createPointerState(document: Document): pointerState;
@@ -0,0 +1,2 @@
1
+ import { pointerKey } from './types';
2
+ export declare const defaultKeyMap: pointerKey[];
@@ -0,0 +1,6 @@
1
+ import { pointerKey } from './types';
2
+ export declare function parseKeyDef(pointerMap: pointerKey[], keys: string): {
3
+ keyDef: pointerKey;
4
+ releasePrevious: boolean;
5
+ releaseSelf: boolean;
6
+ }[];
@@ -0,0 +1,7 @@
1
+ import { Config } from '../setup';
2
+ import { PointerMoveAction } from './pointerMove';
3
+ import { PointerPressAction } from './pointerPress';
4
+ import { PointerTarget, SelectionTarget } from './types';
5
+ export declare type PointerActionTarget = Partial<PointerTarget> & Partial<SelectionTarget>;
6
+ export declare type PointerAction = PointerActionTarget & (Omit<PointerPressAction, 'target' | 'coords'> | Omit<PointerMoveAction, 'target' | 'coords'>);
7
+ export declare function pointerAction(config: Config, actions: PointerAction[]): Promise<void>;
@@ -0,0 +1,6 @@
1
+ import { Config } from '../setup';
2
+ import { PointerTarget, SelectionTarget } from './types';
3
+ export interface PointerMoveAction extends PointerTarget, SelectionTarget {
4
+ pointerName?: string;
5
+ }
6
+ export declare function pointerMove(config: Config, { pointerName, target, coords, node, offset }: PointerMoveAction): Promise<void>;
@@ -0,0 +1,8 @@
1
+ import { Config } from '../setup';
2
+ import type { pointerKey, PointerTarget, SelectionTarget } from './types';
3
+ export interface PointerPressAction extends PointerTarget, SelectionTarget {
4
+ keyDef: pointerKey;
5
+ releasePrevious: boolean;
6
+ releaseSelf: boolean;
7
+ }
8
+ export declare function pointerPress(config: Config, action: PointerPressAction): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { PointerTarget, SelectionTarget } from './types';
2
+ export declare function resolveSelectionTarget({ target, node, offset, }: PointerTarget & SelectionTarget): {
3
+ node: Node;
4
+ offset: number;
5
+ };
@@ -0,0 +1,61 @@
1
+ import { PointerCoords, MouseButton } from '../utils';
2
+ /**
3
+ * @internal Do not create/alter this by yourself as this type might be subject to changes.
4
+ */
5
+ export declare type pointerState = {
6
+ /**
7
+ All keys that have been pressed and not been lifted up yet.
8
+ */
9
+ pressed: {
10
+ keyDef: pointerKey;
11
+ pointerId: number;
12
+ isMultiTouch: boolean;
13
+ isPrimary: boolean;
14
+ clickCount: number;
15
+ unpreventedDefault: boolean;
16
+ /** Target the key was pressed on */
17
+ downTarget: Element;
18
+ }[];
19
+ activeClickCount?: [string, number];
20
+ /**
21
+ * Position of each pointer.
22
+ * The mouse is always pointer 1 and keeps its position.
23
+ * Pen and touch devices receive a new pointerId for every interaction.
24
+ */
25
+ position: Record<string, {
26
+ pointerId: number;
27
+ pointerType: 'mouse' | 'pen' | 'touch';
28
+ } & Partial<PointerTarget> & {
29
+ selectionRange?: Range | SelectionInputRange;
30
+ }>;
31
+ /**
32
+ * Last applied pointer id
33
+ */
34
+ pointerId: number;
35
+ };
36
+ export interface pointerKey {
37
+ /** Name of the pointer key */
38
+ name: string;
39
+ /** Type of the pointer device */
40
+ pointerType: 'mouse' | 'pen' | 'touch';
41
+ /** Type of button */
42
+ button?: MouseButton;
43
+ }
44
+ export interface PointerTarget {
45
+ target: Element;
46
+ coords?: PointerCoords;
47
+ }
48
+ export interface SelectionTarget {
49
+ node?: Node;
50
+ /**
51
+ * If `node` is set, this is the DOM offset.
52
+ * Otherwise this is the `textContent`/`value` offset on the `target`.
53
+ */
54
+ offset?: number;
55
+ }
56
+ /** Describes a selection inside `HTMLInputElement`/`HTMLTextareaElement` */
57
+ export interface SelectionInputRange {
58
+ node: HTMLInputElement | HTMLTextAreaElement;
59
+ start: number;
60
+ end: number;
61
+ }
@@ -0,0 +1,5 @@
1
+ export { click, dblClick, tripleClick, hover, unhover, tab } from '../convenience';
2
+ export { keyboard } from '../keyboard';
3
+ export { copy, cut, paste } from '../clipboard';
4
+ export { pointer } from '../pointer';
5
+ export { clear, deselectOptions, selectOptions, type, upload } from '../utility';
@@ -0,0 +1,10 @@
1
+ import type { keyboardState } from '../keyboard/types';
2
+ import type { pointerState } from '../pointer/types';
3
+ import type { Options } from '../options';
4
+ export interface inputDeviceState {
5
+ pointerState: pointerState;
6
+ keyboardState: keyboardState;
7
+ }
8
+ export interface Config extends Required<Options>, inputDeviceState {
9
+ }
10
+ export declare const Config: unique symbol;
@@ -0,0 +1,19 @@
1
+ import type { PointerInput } from '../pointer';
2
+ import type { UserEventApi } from '.';
3
+ import { Config } from './config';
4
+ export declare function clear(element: Element): Promise<void>;
5
+ export declare function click(element: Element, options?: Partial<Config>): Promise<void>;
6
+ export declare function copy(options?: Partial<Config>): Promise<DataTransfer | undefined>;
7
+ export declare function cut(options?: Partial<Config>): Promise<DataTransfer | undefined>;
8
+ export declare function dblClick(element: Element, options?: Partial<Config>): Promise<void>;
9
+ export declare function deselectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
10
+ export declare function hover(element: Element, options?: Partial<Config>): Promise<void>;
11
+ export declare function keyboard(text: string, options?: Partial<Config>): Promise<import("../keyboard").keyboardState>;
12
+ export declare function pointer(input: PointerInput, options?: Partial<Config>): Promise<import("../pointer").pointerState>;
13
+ export declare function paste(clipboardData?: DataTransfer | string, options?: Partial<Config>): Promise<void>;
14
+ export declare function selectOptions(select: Element, values: HTMLElement | HTMLElement[] | string[] | string, options?: Partial<Config>): Promise<void>;
15
+ export declare function tripleClick(element: Element, options?: Partial<Config>): Promise<void>;
16
+ export declare function type(element: Element, text: string, options?: Partial<Config> & Parameters<UserEventApi['type']>[2]): Promise<void>;
17
+ export declare function unhover(element: Element, options?: Partial<Config>): Promise<void>;
18
+ export declare function upload(element: HTMLElement, fileOrFiles: File | File[], options?: Partial<Config>): Promise<void>;
19
+ export declare function tab(options?: Partial<Config> & Parameters<UserEventApi['tab']>[0]): Promise<void>;
@@ -0,0 +1,34 @@
1
+ import type * as userEventApi from './api';
2
+ import { setupMain, setupSub } from './setup';
3
+ import { Config, inputDeviceState } from './config';
4
+ import * as directApi from './directApi';
5
+ export type { inputDeviceState };
6
+ export { Config };
7
+ export declare type UserEventApi = typeof userEventApi;
8
+ export declare type Instance = UserEventApi & {
9
+ [Config]: Config;
10
+ };
11
+ export declare type UserEvent = {
12
+ readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;
13
+ } & {
14
+ readonly [k in keyof UserEventApi]: (...args: Parameters<UserEventApi[k]>) => ReturnType<UserEventApi[k]>;
15
+ };
16
+ export declare const userEvent: {
17
+ readonly setup: typeof setupMain;
18
+ readonly clear: typeof directApi.clear;
19
+ readonly click: typeof directApi.click;
20
+ readonly copy: typeof directApi.copy;
21
+ readonly cut: typeof directApi.cut;
22
+ readonly dblClick: typeof directApi.dblClick;
23
+ readonly deselectOptions: typeof directApi.deselectOptions;
24
+ readonly hover: typeof directApi.hover;
25
+ readonly keyboard: typeof directApi.keyboard;
26
+ readonly pointer: typeof directApi.pointer;
27
+ readonly paste: typeof directApi.paste;
28
+ readonly selectOptions: typeof directApi.selectOptions;
29
+ readonly tripleClick: typeof directApi.tripleClick;
30
+ readonly type: typeof directApi.type;
31
+ readonly unhover: typeof directApi.unhover;
32
+ readonly upload: typeof directApi.upload;
33
+ readonly tab: typeof directApi.tab;
34
+ };
@@ -0,0 +1,19 @@
1
+ import { Options } from '../options';
2
+ import type { Instance, UserEvent } from './index';
3
+ import { Config } from './config';
4
+ /**
5
+ * Start a "session" with userEvent.
6
+ * All APIs returned by this function share an input device state and a default configuration.
7
+ */
8
+ export declare function setupMain(options?: Options): UserEvent;
9
+ /**
10
+ * Setup in direct call per `userEvent.anyApi()`
11
+ */
12
+ export declare function setupDirect(options?: Partial<Config>, node?: Node): {
13
+ config: Config;
14
+ api: UserEvent;
15
+ };
16
+ /**
17
+ * Create a set of callbacks with different default settings but the same state.
18
+ */
19
+ export declare function setupSub(this: Instance, options: Options): UserEvent;