@testing-library/user-event 14.0.0-beta.4 → 14.0.0-beta.5
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.
- package/dist/index.cjs +2760 -0
- package/dist/{index.js → index.mjs} +0 -0
- package/dist/types/clipboard/copy.d.ts +2 -0
- package/dist/types/clipboard/cut.d.ts +2 -0
- package/dist/types/clipboard/index.d.ts +3 -0
- package/dist/types/clipboard/paste.d.ts +2 -0
- package/dist/types/convenience/click.d.ts +4 -0
- package/dist/types/convenience/hover.d.ts +3 -0
- package/dist/types/convenience/index.d.ts +3 -0
- package/dist/types/convenience/tab.d.ts +4 -0
- package/dist/types/document/index.d.ts +10 -0
- package/dist/types/document/interceptor.d.ts +15 -0
- package/dist/types/document/selection.d.ts +27 -0
- package/dist/types/document/value.d.ts +18 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/keyboard/index.d.ts +7 -0
- package/dist/types/keyboard/keyMap.d.ts +5 -0
- package/dist/types/keyboard/keyboardAction.d.ts +10 -0
- package/dist/types/keyboard/parseKeyDef.d.ts +17 -0
- package/dist/types/keyboard/plugins/arrow.d.ts +6 -0
- package/dist/types/keyboard/plugins/character.d.ts +5 -0
- package/dist/types/keyboard/plugins/combination.d.ts +5 -0
- package/dist/types/keyboard/plugins/control.d.ts +6 -0
- package/dist/types/keyboard/plugins/functional.d.ts +8 -0
- package/dist/types/keyboard/plugins/index.d.ts +7 -0
- package/dist/types/keyboard/plugins/modifiers.d.ts +8 -0
- package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +3 -0
- package/dist/types/keyboard/shared/index.d.ts +1 -0
- package/dist/types/keyboard/types.d.ts +78 -0
- package/dist/types/options.d.ts +102 -0
- package/dist/types/pointer/index.d.ts +10 -0
- package/dist/types/pointer/keyMap.d.ts +2 -0
- package/dist/types/pointer/parseKeyDef.d.ts +6 -0
- package/dist/types/pointer/pointerAction.d.ts +7 -0
- package/dist/types/pointer/pointerMove.d.ts +6 -0
- package/dist/types/pointer/pointerPress.d.ts +8 -0
- package/dist/types/pointer/resolveSelectionTarget.d.ts +5 -0
- package/dist/types/pointer/types.d.ts +61 -0
- package/dist/types/setup/api.d.ts +5 -0
- package/dist/types/setup/config.d.ts +10 -0
- package/dist/types/setup/directApi.d.ts +20 -0
- package/dist/types/setup/index.d.ts +30 -0
- package/dist/types/setup/setup.d.ts +74 -0
- package/dist/types/setup/wrapAsync.d.ts +4 -0
- package/dist/types/utility/clear.d.ts +2 -0
- package/dist/types/utility/index.d.ts +4 -0
- package/dist/types/utility/selectOptions.d.ts +3 -0
- package/dist/types/utility/type.d.ts +9 -0
- package/dist/types/utility/upload.d.ts +5 -0
- package/dist/types/utils/click/isClickableInput.d.ts +1 -0
- package/dist/types/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +9 -0
- package/dist/types/utils/dataTransfer/DataTransfer.d.ts +2 -0
- package/dist/types/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/types/utils/edit/buildTimeValue.d.ts +1 -0
- package/dist/types/utils/edit/calculateNewValue.d.ts +14 -0
- package/dist/types/utils/edit/editInputElement.d.ts +16 -0
- package/dist/types/utils/edit/getValue.d.ts +1 -0
- package/dist/types/utils/edit/isContentEditable.d.ts +7 -0
- package/dist/types/utils/edit/isEditable.d.ts +25 -0
- package/dist/types/utils/edit/isValidDateValue.d.ts +3 -0
- package/dist/types/utils/edit/isValidInputTimeValue.d.ts +3 -0
- package/dist/types/utils/edit/maxLength.d.ts +1 -0
- package/dist/types/utils/edit/prepareInput.d.ts +7 -0
- package/dist/types/utils/edit/setFiles.d.ts +12 -0
- package/dist/types/utils/focus/blur.d.ts +2 -0
- package/dist/types/utils/focus/copySelection.d.ts +1 -0
- package/dist/types/utils/focus/focus.d.ts +2 -0
- package/dist/types/utils/focus/getActiveElement.d.ts +1 -0
- package/dist/types/utils/focus/getTabDestination.d.ts +1 -0
- package/dist/types/utils/focus/isFocusable.d.ts +1 -0
- package/dist/types/utils/focus/selectAll.d.ts +5 -0
- package/dist/types/utils/focus/selection.d.ts +42 -0
- package/dist/types/utils/focus/selector.d.ts +1 -0
- package/dist/types/utils/index.d.ts +40 -0
- package/dist/types/utils/keyDef/readNextDescriptor.d.ts +19 -0
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +17 -0
- package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
- package/dist/types/utils/misc/eventWrapper.d.ts +1 -0
- package/dist/types/utils/misc/findClosest.d.ts +1 -0
- package/dist/types/utils/misc/getDocumentFromNode.d.ts +1 -0
- package/dist/types/utils/misc/hasFormSubmit.d.ts +1 -0
- package/dist/types/utils/misc/hasPointerEvents.d.ts +15 -0
- package/dist/types/utils/misc/isDescendantOrSelf.d.ts +1 -0
- package/dist/types/utils/misc/isDisabled.d.ts +1 -0
- package/dist/types/utils/misc/isElementType.d.ts +5 -0
- package/dist/types/utils/misc/isVisible.d.ts +1 -0
- package/dist/types/utils/misc/wait.d.ts +1 -0
- package/dist/types/utils/pointer/firePointerEvents.d.ts +25 -0
- package/dist/types/utils/pointer/mouseButtons.d.ts +12 -0
- package/package.json +10 -3
- package/dist/index.d.ts +0 -1110
- package/dist/package.json +0 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Options } from '../options';
|
|
2
|
+
import type { UserEvent } from './index';
|
|
3
|
+
import { Config } from './config';
|
|
4
|
+
import * as userEventApi from './api';
|
|
5
|
+
/**
|
|
6
|
+
* Start a "session" with userEvent.
|
|
7
|
+
* All APIs returned by this function share an input device state and a default configuration.
|
|
8
|
+
*/
|
|
9
|
+
export declare function setupMain(options?: Options): {
|
|
10
|
+
setup: typeof setupSub;
|
|
11
|
+
[Config]: Config;
|
|
12
|
+
click: typeof userEventApi.click;
|
|
13
|
+
dblClick: typeof userEventApi.dblClick;
|
|
14
|
+
tripleClick: typeof userEventApi.tripleClick;
|
|
15
|
+
hover: typeof userEventApi.hover;
|
|
16
|
+
unhover: typeof userEventApi.unhover;
|
|
17
|
+
tab: typeof userEventApi.tab;
|
|
18
|
+
keyboard: typeof userEventApi.keyboard;
|
|
19
|
+
copy: typeof userEventApi.copy;
|
|
20
|
+
cut: typeof userEventApi.cut;
|
|
21
|
+
paste: typeof userEventApi.paste;
|
|
22
|
+
pointer: typeof userEventApi.pointer;
|
|
23
|
+
clear: typeof userEventApi.clear;
|
|
24
|
+
deselectOptions: typeof userEventApi.deselectOptions;
|
|
25
|
+
selectOptions: typeof userEventApi.selectOptions;
|
|
26
|
+
type: typeof userEventApi.type;
|
|
27
|
+
upload: typeof userEventApi.upload;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Setup in direct call per `userEvent.anyApi()`
|
|
31
|
+
*/
|
|
32
|
+
export declare function setupDirect(options?: Partial<Config>, node?: Node): {
|
|
33
|
+
setup: typeof setupSub;
|
|
34
|
+
[Config]: Config;
|
|
35
|
+
click: typeof userEventApi.click;
|
|
36
|
+
dblClick: typeof userEventApi.dblClick;
|
|
37
|
+
tripleClick: typeof userEventApi.tripleClick;
|
|
38
|
+
hover: typeof userEventApi.hover;
|
|
39
|
+
unhover: typeof userEventApi.unhover;
|
|
40
|
+
tab: typeof userEventApi.tab;
|
|
41
|
+
keyboard: typeof userEventApi.keyboard;
|
|
42
|
+
copy: typeof userEventApi.copy;
|
|
43
|
+
cut: typeof userEventApi.cut;
|
|
44
|
+
paste: typeof userEventApi.paste;
|
|
45
|
+
pointer: typeof userEventApi.pointer;
|
|
46
|
+
clear: typeof userEventApi.clear;
|
|
47
|
+
deselectOptions: typeof userEventApi.deselectOptions;
|
|
48
|
+
selectOptions: typeof userEventApi.selectOptions;
|
|
49
|
+
type: typeof userEventApi.type;
|
|
50
|
+
upload: typeof userEventApi.upload;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Create a set of callbacks with different default settings but the same state.
|
|
54
|
+
*/
|
|
55
|
+
export declare function setupSub(this: UserEvent, options: Options): {
|
|
56
|
+
setup: typeof setupSub;
|
|
57
|
+
[Config]: Config;
|
|
58
|
+
click: typeof userEventApi.click;
|
|
59
|
+
dblClick: typeof userEventApi.dblClick;
|
|
60
|
+
tripleClick: typeof userEventApi.tripleClick;
|
|
61
|
+
hover: typeof userEventApi.hover;
|
|
62
|
+
unhover: typeof userEventApi.unhover;
|
|
63
|
+
tab: typeof userEventApi.tab;
|
|
64
|
+
keyboard: typeof userEventApi.keyboard;
|
|
65
|
+
copy: typeof userEventApi.copy;
|
|
66
|
+
cut: typeof userEventApi.cut;
|
|
67
|
+
paste: typeof userEventApi.paste;
|
|
68
|
+
pointer: typeof userEventApi.pointer;
|
|
69
|
+
clear: typeof userEventApi.clear;
|
|
70
|
+
deselectOptions: typeof userEventApi.deselectOptions;
|
|
71
|
+
selectOptions: typeof userEventApi.selectOptions;
|
|
72
|
+
type: typeof userEventApi.type;
|
|
73
|
+
upload: typeof userEventApi.upload;
|
|
74
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { UserEvent } from '../setup';
|
|
2
|
+
export declare function selectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
3
|
+
export declare function deselectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { UserEvent } from '../setup';
|
|
2
|
+
import { Config } from '../setup/config';
|
|
3
|
+
export interface typeOptions {
|
|
4
|
+
skipClick?: Config['skipClick'];
|
|
5
|
+
skipAutoClose?: Config['skipClick'];
|
|
6
|
+
initialSelectionStart?: number;
|
|
7
|
+
initialSelectionEnd?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function type(this: UserEvent, element: Element, text: string, { skipClick, skipAutoClose, initialSelectionStart, initialSelectionEnd, }?: typeOptions): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isClickableInput(element: Element): boolean;
|
|
@@ -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 @@
|
|
|
1
|
+
export declare function createFileList(files: File[]): FileList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function buildTimeValue(value: string): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fireEvent } from '@testing-library/dom';
|
|
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(element: HTMLInputElement | HTMLTextAreaElement, { newValue, newSelection, eventOverrides, }: {
|
|
8
|
+
newValue: string;
|
|
9
|
+
newSelection: {
|
|
10
|
+
node: Node;
|
|
11
|
+
offset: number;
|
|
12
|
+
};
|
|
13
|
+
eventOverrides: Partial<Parameters<typeof fireEvent>[1]> & {
|
|
14
|
+
[k: string]: unknown;
|
|
15
|
+
};
|
|
16
|
+
}): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getValue<T extends Element | null>(element: T): T extends HTMLInputElement | HTMLTextAreaElement ? string : string | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function isContentEditable(element: Element): element is HTMLElement & {
|
|
2
|
+
contenteditable: 'true';
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* If a node is a contenteditable or inside one, return that element.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getContentEditable(node: Node): Element | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { isContentEditable } from './isContentEditable';
|
|
2
|
+
declare type GuardedType<T> = T extends (x: any) => x is infer R ? R : never;
|
|
3
|
+
export declare function isEditable(element: Element): element is GuardedType<typeof isContentEditable> | GuardedType<typeof isEditableInput> | (HTMLTextAreaElement & {
|
|
4
|
+
readOnly: false;
|
|
5
|
+
});
|
|
6
|
+
export declare enum editableInputTypes {
|
|
7
|
+
'text' = "text",
|
|
8
|
+
'date' = "date",
|
|
9
|
+
'datetime-local' = "datetime-local",
|
|
10
|
+
'email' = "email",
|
|
11
|
+
'month' = "month",
|
|
12
|
+
'number' = "number",
|
|
13
|
+
'password' = "password",
|
|
14
|
+
'search' = "search",
|
|
15
|
+
'tel' = "tel",
|
|
16
|
+
'time' = "time",
|
|
17
|
+
'url' = "url",
|
|
18
|
+
'week' = "week"
|
|
19
|
+
}
|
|
20
|
+
export declare type EditableInputType = keyof typeof editableInputTypes;
|
|
21
|
+
export declare function isEditableInput(element: Element): element is HTMLInputElement & {
|
|
22
|
+
readOnly: false;
|
|
23
|
+
type: editableInputTypes;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getSpaceUntilMaxLength(element: Element): number | 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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function copySelection(target: Element): DataTransfer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getActiveElement(document: Document | ShadowRoot): Element | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTabDestination(activeElement: Element, shift: boolean): HTMLElement;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isFocusable(element: Element): element is HTMLElement;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UISelectionRange } from '../../document';
|
|
2
|
+
import { editableInputTypes } from '../edit/isEditable';
|
|
3
|
+
/**
|
|
4
|
+
* Backward-compatible selection.
|
|
5
|
+
*
|
|
6
|
+
* Handles input elements and contenteditable if it only contains a single text node.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setSelectionRange(element: Element, anchorOffset: number, focusOffset: number): void;
|
|
9
|
+
/**
|
|
10
|
+
* Determine if the element has its own selection implementation
|
|
11
|
+
* and does not interact with the Document Selection API.
|
|
12
|
+
*/
|
|
13
|
+
export declare function hasOwnSelection(node: Node): node is HTMLTextAreaElement | (HTMLInputElement & {
|
|
14
|
+
type: editableInputTypes;
|
|
15
|
+
});
|
|
16
|
+
/**
|
|
17
|
+
* Reset the Document Selection when moving focus into an element
|
|
18
|
+
* with own selection implementation.
|
|
19
|
+
*/
|
|
20
|
+
export declare function updateSelectionOnFocus(element: Element): void;
|
|
21
|
+
/**
|
|
22
|
+
* Get the range that would be overwritten by input.
|
|
23
|
+
*/
|
|
24
|
+
export declare function getInputRange(focusNode: Node): UISelectionRange | Range | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
|
|
27
|
+
*/
|
|
28
|
+
export declare function modifySelection({ focusNode, focusOffset, }: {
|
|
29
|
+
focusNode: Node;
|
|
30
|
+
/** DOM Offset */
|
|
31
|
+
focusOffset: number;
|
|
32
|
+
}): void;
|
|
33
|
+
/**
|
|
34
|
+
* Set the selection
|
|
35
|
+
*/
|
|
36
|
+
export declare function setSelection({ focusNode, focusOffset, anchorNode, anchorOffset, }: {
|
|
37
|
+
anchorNode?: Node;
|
|
38
|
+
/** DOM offset */
|
|
39
|
+
anchorOffset?: number;
|
|
40
|
+
focusNode: Node;
|
|
41
|
+
focusOffset: number;
|
|
42
|
+
}): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const FOCUSABLE_SELECTOR: string;
|
|
@@ -0,0 +1,40 @@
|
|
|
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';
|
|
6
|
+
export * from './edit/buildTimeValue';
|
|
7
|
+
export * from './edit/calculateNewValue';
|
|
8
|
+
export * from './edit/editInputElement';
|
|
9
|
+
export * from './edit/getValue';
|
|
10
|
+
export * from './edit/isContentEditable';
|
|
11
|
+
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
|
+
export * from './edit/setFiles';
|
|
17
|
+
export * from './focus/blur';
|
|
18
|
+
export * from './focus/copySelection';
|
|
19
|
+
export * from './focus/focus';
|
|
20
|
+
export * from './focus/getActiveElement';
|
|
21
|
+
export * from './focus/getTabDestination';
|
|
22
|
+
export * from './focus/isFocusable';
|
|
23
|
+
export * from './focus/selectAll';
|
|
24
|
+
export * from './focus/selection';
|
|
25
|
+
export * from './focus/selector';
|
|
26
|
+
export * from './keyboard/getKeyEventProps';
|
|
27
|
+
export * from './keyboard/getUIEventModifiers';
|
|
28
|
+
export * from './keyDef/readNextDescriptor';
|
|
29
|
+
export * from './misc/eventWrapper';
|
|
30
|
+
export * from './misc/findClosest';
|
|
31
|
+
export * from './misc/getDocumentFromNode';
|
|
32
|
+
export * from './misc/isDescendantOrSelf';
|
|
33
|
+
export * from './misc/isElementType';
|
|
34
|
+
export * from './misc/isVisible';
|
|
35
|
+
export * from './misc/isDisabled';
|
|
36
|
+
export * from './misc/wait';
|
|
37
|
+
export * from './misc/hasPointerEvents';
|
|
38
|
+
export * from './misc/hasFormSubmit';
|
|
39
|
+
export * from './pointer/firePointerEvents';
|
|
40
|
+
export * from './pointer/mouseButtons';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the next key definition from user input
|
|
3
|
+
*
|
|
4
|
+
* Describe key per `{descriptor}` or `[descriptor]`.
|
|
5
|
+
* Everything else will be interpreted as a single character as descriptor - e.g. `a`.
|
|
6
|
+
* Brackets `{` and `[` can be escaped by doubling - e.g. `foo[[bar` translates to `foo[bar`.
|
|
7
|
+
* A previously pressed key can be released per `{/descriptor}`.
|
|
8
|
+
* Keeping the key pressed can be written as `{descriptor>}`.
|
|
9
|
+
* When keeping the key pressed you can choose how long the key is pressed `{descriptor>3}`.
|
|
10
|
+
* You can then release the key per `{descriptor>3/}` or keep it pressed and continue with the next key.
|
|
11
|
+
*/
|
|
12
|
+
export declare function readNextDescriptor(text: string): {
|
|
13
|
+
consumedLength: number;
|
|
14
|
+
descriptor: string;
|
|
15
|
+
releasePrevious: boolean;
|
|
16
|
+
repeat: number;
|
|
17
|
+
releaseSelf: boolean | undefined;
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { keyboardKey, keyboardState } from '../../keyboard/types';
|
|
2
|
+
export declare function getKeyEventProps(keyDef: keyboardKey, state: 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
|
+
key: string | undefined;
|
|
16
|
+
code: string | undefined;
|
|
17
|
+
};
|
|
@@ -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 eventWrapper<T>(cb: () => T): T | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findClosest(element: Element, callback: (e: Element) => boolean): Element | undefined;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDocumentFromNode(el: Node): Document | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hasFormSubmit: (form: HTMLFormElement | null) => form is HTMLFormElement;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options that can be passed to any event that relies
|
|
3
|
+
* on pointer-events property
|
|
4
|
+
*/
|
|
5
|
+
export declare interface PointerOptions {
|
|
6
|
+
/**
|
|
7
|
+
* When set to `true` the event skips checking if any element
|
|
8
|
+
* in the DOM-tree has `'pointer-events: none'` set. This check is
|
|
9
|
+
* costly in general and very costly when rendering large DOM-trees.
|
|
10
|
+
* Can be used to speed up tests.
|
|
11
|
+
* Default: `false`
|
|
12
|
+
* */
|
|
13
|
+
skipPointerEventsCheck?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function hasPointerEvents(element: Element): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDescendantOrSelf(potentialDescendant: Element, potentialAncestor: Element): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDisabled(element: Element | null): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
declare type tag = keyof HTMLElementTagNameMap;
|
|
2
|
+
export declare function isElementType<T extends tag, P extends {
|
|
3
|
+
[k: string]: unknown;
|
|
4
|
+
} | undefined = undefined>(element: Element, tag: T | T[], props?: P): element is P extends undefined ? HTMLElementTagNameMap[T] : HTMLElementTagNameMap[T] & P;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isVisible(element: Element): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function wait(time?: number): Promise<void>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { pointerState } from '../../pointer/types';
|
|
2
|
+
import type { keyboardState } from '../../keyboard/types';
|
|
3
|
+
import { MouseButton } from './mouseButtons';
|
|
4
|
+
export declare function firePointerEvent(target: Element, type: string, { pointerState, keyboardState, pointerType, button, coords, pointerId, isPrimary, clickCount, }: {
|
|
5
|
+
pointerState: pointerState;
|
|
6
|
+
keyboardState: keyboardState;
|
|
7
|
+
pointerType?: 'mouse' | 'pen' | 'touch';
|
|
8
|
+
button?: MouseButton;
|
|
9
|
+
coords?: PointerCoords;
|
|
10
|
+
pointerId?: number;
|
|
11
|
+
isPrimary?: boolean;
|
|
12
|
+
clickCount?: number;
|
|
13
|
+
}): boolean;
|
|
14
|
+
export interface PointerCoords {
|
|
15
|
+
x?: number;
|
|
16
|
+
y?: number;
|
|
17
|
+
clientX?: number;
|
|
18
|
+
clientY?: number;
|
|
19
|
+
offsetX?: number;
|
|
20
|
+
offsetY?: number;
|
|
21
|
+
pageX?: number;
|
|
22
|
+
pageY?: number;
|
|
23
|
+
screenX?: number;
|
|
24
|
+
screenY?: number;
|
|
25
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const MouseButton: {
|
|
2
|
+
readonly primary: 0;
|
|
3
|
+
readonly secondary: 1;
|
|
4
|
+
readonly auxiliary: 2;
|
|
5
|
+
readonly back: 3;
|
|
6
|
+
readonly X1: 3;
|
|
7
|
+
readonly forward: 4;
|
|
8
|
+
readonly X2: 4;
|
|
9
|
+
};
|
|
10
|
+
export declare type MouseButton = keyof typeof MouseButton | number;
|
|
11
|
+
export declare function getMouseButton(button: MouseButton): number;
|
|
12
|
+
export declare function getMouseButtons(...buttons: Array<MouseButton>): number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/user-event",
|
|
3
|
-
"version": "14.0.0-beta.
|
|
3
|
+
"version": "14.0.0-beta.5",
|
|
4
4
|
"description": "Fire events the same way the user does",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-testing-library",
|
|
@@ -25,8 +25,15 @@
|
|
|
25
25
|
"files": [
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
|
-
"main": "./dist/index.
|
|
29
|
-
"
|
|
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",
|
|
30
37
|
"scripts": {
|
|
31
38
|
"build": "node build.js",
|
|
32
39
|
"lint": "kcd-scripts lint",
|