@testing-library/user-event 14.4.2 → 14.4.3
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/cjs/clipboard/copy.js +4 -14
- package/dist/cjs/clipboard/cut.js +4 -14
- package/dist/cjs/clipboard/paste.js +2 -12
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/document/{selection.js → UI.js} +43 -57
- package/dist/cjs/document/copySelection.js +37 -0
- package/dist/cjs/document/getValueOrTextContent.js +27 -0
- package/dist/cjs/document/index.js +13 -68
- package/dist/cjs/document/interceptor.js +83 -0
- package/dist/cjs/document/prepareDocument.js +67 -0
- package/dist/cjs/document/trackValue.js +65 -0
- package/dist/cjs/event/behavior/click.js +8 -12
- package/dist/cjs/event/behavior/cut.js +5 -11
- package/dist/cjs/event/behavior/keydown.js +39 -43
- package/dist/cjs/event/behavior/keypress.js +8 -9
- package/dist/cjs/event/behavior/keyup.js +5 -7
- package/dist/cjs/event/behavior/paste.js +5 -11
- package/dist/cjs/event/createEvent.js +2 -9
- package/dist/cjs/event/dispatchEvent.js +20 -2
- package/dist/cjs/event/focus.js +44 -0
- package/dist/cjs/event/index.js +24 -17
- package/dist/cjs/{utils/edit → event}/input.js +48 -46
- package/dist/cjs/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/cjs/event/selection/getInputRange.js +20 -0
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +40 -0
- package/dist/cjs/event/selection/index.js +26 -0
- package/dist/cjs/event/selection/modifySelection.js +30 -0
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +49 -0
- package/dist/cjs/event/selection/moveSelection.js +47 -0
- package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +9 -17
- package/dist/cjs/event/selection/selectAll.js +47 -0
- package/dist/cjs/event/selection/setSelection.js +30 -0
- package/dist/cjs/event/selection/setSelectionPerMouse.js +90 -0
- package/dist/cjs/event/selection/setSelectionRange.js +40 -0
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +45 -0
- package/dist/cjs/keyboard/index.js +13 -23
- package/dist/cjs/keyboard/parseKeyDef.js +1 -9
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +20 -30
- package/dist/cjs/pointer/parseKeyDef.js +1 -9
- package/dist/cjs/setup/directApi.js +6 -6
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +65 -37
- package/dist/cjs/system/keyboard.js +7 -9
- package/dist/cjs/system/pointer/index.js +16 -21
- package/dist/cjs/system/pointer/mouse.js +45 -38
- package/dist/cjs/system/pointer/pointer.js +33 -35
- package/dist/cjs/system/pointer/shared.js +10 -0
- package/dist/cjs/utility/clear.js +10 -11
- package/dist/cjs/utility/selectOptions.js +17 -19
- package/dist/cjs/utility/type.js +6 -15
- package/dist/cjs/utility/upload.js +3 -13
- package/dist/cjs/utils/dataTransfer/Clipboard.js +1 -15
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +4 -15
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +0 -16
- package/dist/cjs/utils/focus/selection.js +1 -271
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/misc/level.js +4 -9
- package/dist/cjs/utils/pointer/cssPointerEvents.js +9 -22
- package/dist/esm/clipboard/copy.js +4 -14
- package/dist/esm/clipboard/cut.js +4 -14
- package/dist/esm/clipboard/paste.js +2 -12
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/document/{selection.js → UI.js} +35 -56
- package/dist/esm/document/copySelection.js +33 -0
- package/dist/esm/document/getValueOrTextContent.js +23 -0
- package/dist/esm/document/index.js +4 -66
- package/dist/esm/document/interceptor.js +81 -1
- package/dist/esm/document/prepareDocument.js +63 -0
- package/dist/esm/document/{value.js → trackValue.js} +3 -61
- package/dist/esm/event/behavior/click.js +8 -12
- package/dist/esm/event/behavior/cut.js +5 -11
- package/dist/esm/event/behavior/keydown.js +32 -36
- package/dist/esm/event/behavior/keypress.js +8 -9
- package/dist/esm/event/behavior/keyup.js +5 -7
- package/dist/esm/event/behavior/paste.js +5 -11
- package/dist/esm/event/createEvent.js +2 -9
- package/dist/esm/event/dispatchEvent.js +19 -3
- package/dist/esm/event/focus.js +39 -0
- package/dist/esm/event/index.js +14 -19
- package/dist/esm/{utils/edit → event}/input.js +35 -33
- package/dist/esm/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/esm/event/selection/getInputRange.js +16 -0
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +36 -0
- package/dist/esm/event/selection/index.js +9 -0
- package/dist/esm/event/selection/modifySelection.js +26 -0
- package/dist/esm/event/selection/modifySelectionPerMouse.js +45 -0
- package/dist/esm/event/selection/moveSelection.js +43 -0
- package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +8 -16
- package/dist/esm/{utils/focus → event/selection}/selectAll.js +12 -21
- package/dist/esm/event/selection/setSelection.js +26 -0
- package/dist/esm/event/selection/setSelectionPerMouse.js +86 -0
- package/dist/esm/event/selection/setSelectionRange.js +36 -0
- package/dist/esm/event/selection/updateSelectionOnFocus.js +41 -0
- package/dist/esm/keyboard/index.js +13 -23
- package/dist/esm/keyboard/parseKeyDef.js +1 -9
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +20 -30
- package/dist/esm/pointer/parseKeyDef.js +1 -9
- package/dist/esm/setup/directApi.js +6 -6
- package/dist/esm/setup/index.js +0 -1
- package/dist/esm/setup/setup.js +59 -32
- package/dist/esm/system/keyboard.js +7 -9
- package/dist/esm/system/pointer/index.js +17 -21
- package/dist/esm/system/pointer/mouse.js +42 -35
- package/dist/esm/system/pointer/pointer.js +32 -34
- package/dist/esm/system/pointer/shared.js +6 -0
- package/dist/esm/utility/clear.js +10 -11
- package/dist/esm/utility/selectOptions.js +17 -19
- package/dist/esm/utility/type.js +5 -14
- package/dist/esm/utility/upload.js +3 -13
- package/dist/esm/utils/dataTransfer/Clipboard.js +1 -15
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +3 -15
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +0 -16
- package/dist/esm/utils/focus/selection.js +3 -265
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/misc/level.js +4 -9
- package/dist/esm/utils/pointer/cssPointerEvents.js +9 -22
- package/dist/types/clipboard/copy.d.ts +1 -1
- package/dist/types/clipboard/cut.d.ts +1 -1
- package/dist/types/clipboard/paste.d.ts +1 -1
- package/dist/types/convenience/click.d.ts +1 -1
- package/dist/types/convenience/hover.d.ts +1 -1
- package/dist/types/document/UI.d.ts +42 -0
- package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -0
- package/dist/types/document/getValueOrTextContent.d.ts +1 -0
- package/dist/types/document/index.d.ts +5 -10
- package/dist/types/document/interceptor.d.ts +3 -0
- package/dist/types/document/prepareDocument.d.ts +8 -0
- package/dist/types/document/trackValue.d.ts +17 -0
- package/dist/types/event/behavior/registry.d.ts +2 -2
- package/dist/types/event/dispatchEvent.d.ts +5 -2
- package/dist/types/event/focus.d.ts +5 -0
- package/dist/types/event/index.d.ts +6 -4
- package/dist/types/event/input.d.ts +2 -0
- package/dist/types/event/radio.d.ts +4 -0
- package/dist/types/event/selection/getInputRange.d.ts +5 -0
- package/dist/types/event/selection/getTargetTypeAndSelection.d.ts +10 -0
- package/dist/types/event/selection/index.d.ts +15 -0
- package/dist/types/event/selection/modifySelection.d.ts +8 -0
- package/dist/types/event/selection/modifySelectionPerMouse.d.ts +7 -0
- package/dist/types/event/selection/moveSelection.d.ts +4 -0
- package/dist/types/{utils/focus → event/selection}/resolveCaretPosition.d.ts +0 -0
- package/dist/types/{utils/focus → event/selection}/selectAll.d.ts +0 -0
- package/dist/types/event/selection/setSelection.d.ts +10 -0
- package/dist/types/event/selection/setSelectionPerMouse.d.ts +8 -0
- package/dist/types/event/selection/setSelectionRange.d.ts +6 -0
- package/dist/types/event/selection/updateSelectionOnFocus.d.ts +5 -0
- package/dist/types/keyboard/index.d.ts +2 -2
- package/dist/types/options.d.ts +0 -8
- package/dist/types/pointer/index.d.ts +3 -3
- package/dist/types/setup/directApi.d.ts +1 -1
- package/dist/types/setup/index.d.ts +2 -15
- package/dist/types/setup/setup.d.ts +25 -7
- package/dist/types/system/keyboard.d.ts +3 -3
- package/dist/types/system/pointer/buttons.d.ts +1 -1
- package/dist/types/system/pointer/index.d.ts +7 -25
- package/dist/types/system/pointer/mouse.d.ts +5 -5
- package/dist/types/system/pointer/pointer.d.ts +7 -7
- package/dist/types/system/pointer/shared.d.ts +20 -0
- package/dist/types/utility/clear.d.ts +1 -1
- package/dist/types/utility/selectOptions.d.ts +1 -1
- package/dist/types/utility/type.d.ts +3 -3
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +2 -2
- package/dist/types/utils/edit/isEditable.d.ts +5 -6
- package/dist/types/utils/edit/maxLength.d.ts +14 -1
- package/dist/types/utils/edit/{isValidDateOrTimeValue.d.ts → timeValue.d.ts} +1 -0
- package/dist/types/utils/focus/selection.d.ts +4 -69
- package/dist/types/utils/index.d.ts +2 -9
- package/dist/types/utils/misc/level.d.ts +4 -13
- package/dist/types/utils/misc/wait.d.ts +2 -2
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +4 -4
- package/package.json +3 -2
- package/dist/cjs/document/setRangeText.js +0 -21
- package/dist/cjs/document/value.js +0 -127
- package/dist/cjs/setup/config.js +0 -7
- package/dist/cjs/utils/edit/getValue.js +0 -35
- package/dist/cjs/utils/edit/isValidDateOrTimeValue.js +0 -11
- package/dist/cjs/utils/focus/blur.js +0 -16
- package/dist/cjs/utils/focus/copySelection.js +0 -46
- package/dist/cjs/utils/focus/focus.js +0 -29
- package/dist/cjs/utils/focus/selectAll.js +0 -56
- package/dist/cjs/utils/misc/eventWrapper.js +0 -15
- package/dist/esm/document/setRangeText.js +0 -17
- package/dist/esm/setup/config.js +0 -3
- package/dist/esm/utils/edit/getValue.js +0 -31
- package/dist/esm/utils/edit/isValidDateOrTimeValue.js +0 -7
- package/dist/esm/utils/focus/blur.js +0 -12
- package/dist/esm/utils/focus/copySelection.js +0 -42
- package/dist/esm/utils/focus/focus.js +0 -25
- package/dist/esm/utils/misc/eventWrapper.js +0 -11
- package/dist/types/document/selection.d.ts +0 -29
- package/dist/types/document/setRangeText.d.ts +0 -1
- package/dist/types/document/value.d.ts +0 -26
- package/dist/types/setup/config.d.ts +0 -6
- package/dist/types/utils/edit/buildTimeValue.d.ts +0 -1
- package/dist/types/utils/edit/getValue.d.ts +0 -1
- package/dist/types/utils/edit/input.d.ts +0 -2
- package/dist/types/utils/edit/walkRadio.d.ts +0 -4
- package/dist/types/utils/focus/blur.d.ts +0 -2
- package/dist/types/utils/focus/focus.d.ts +0 -5
- package/dist/types/utils/misc/eventWrapper.d.ts +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Instance } from '../setup';
|
|
2
|
-
import {
|
|
2
|
+
import type { Options } from '../options';
|
|
3
3
|
export interface typeOptions {
|
|
4
|
-
skipClick?:
|
|
5
|
-
skipAutoClose?:
|
|
4
|
+
skipClick?: Options['skipClick'];
|
|
5
|
+
skipAutoClose?: Options['skipAutoClose'];
|
|
6
6
|
initialSelectionStart?: number;
|
|
7
7
|
initialSelectionEnd?: number;
|
|
8
8
|
}
|
|
@@ -8,8 +8,8 @@ declare enum clickableInputTypes {
|
|
|
8
8
|
'checkbox' = "checkbox",
|
|
9
9
|
'radio' = "radio"
|
|
10
10
|
}
|
|
11
|
-
export declare type
|
|
12
|
-
export declare function isClickableInput(element: Element): element is HTMLButtonElement | (HTMLInputElement & {
|
|
11
|
+
export declare type ClickableInputOrButton = HTMLButtonElement | (HTMLInputElement & {
|
|
13
12
|
type: clickableInputTypes;
|
|
14
13
|
});
|
|
14
|
+
export declare function isClickableInput(element: Element): element is ClickableInputOrButton;
|
|
15
15
|
export {};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isContentEditable } from './isContentEditable';
|
|
2
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> |
|
|
3
|
+
export declare function isEditable(element: Element): element is GuardedType<typeof isContentEditable> | (EditableInputOrTextarea & {
|
|
4
4
|
readOnly: false;
|
|
5
5
|
});
|
|
6
|
-
|
|
6
|
+
declare enum editableInputTypes {
|
|
7
7
|
'text' = "text",
|
|
8
8
|
'date' = "date",
|
|
9
9
|
'datetime-local' = "datetime-local",
|
|
@@ -17,9 +17,8 @@ export declare enum editableInputTypes {
|
|
|
17
17
|
'url' = "url",
|
|
18
18
|
'week' = "week"
|
|
19
19
|
}
|
|
20
|
-
export declare type
|
|
21
|
-
export declare function isEditableInput(element: Element): element is HTMLInputElement & {
|
|
22
|
-
readOnly: false;
|
|
20
|
+
export declare type EditableInputOrTextarea = HTMLTextAreaElement | (HTMLInputElement & {
|
|
23
21
|
type: editableInputTypes;
|
|
24
|
-
};
|
|
22
|
+
});
|
|
23
|
+
export declare function isEditableInputOrTextArea(element: Element): element is EditableInputOrTextarea;
|
|
25
24
|
export {};
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
declare enum maxLengthSupportedTypes {
|
|
2
|
+
'email' = "email",
|
|
3
|
+
'password' = "password",
|
|
4
|
+
'search' = "search",
|
|
5
|
+
'telephone' = "telephone",
|
|
6
|
+
'text' = "text",
|
|
7
|
+
'url' = "url"
|
|
8
|
+
}
|
|
9
|
+
declare type ElementWithMaxLengthSupport = HTMLTextAreaElement | (HTMLInputElement & {
|
|
10
|
+
type: maxLengthSupportedTypes;
|
|
11
|
+
});
|
|
12
|
+
export declare function getMaxLength(element: ElementWithMaxLengthSupport): number | undefined;
|
|
13
|
+
export declare function supportsMaxLength(element: Element): element is ElementWithMaxLengthSupport;
|
|
14
|
+
export {};
|
|
@@ -1,73 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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;
|
|
1
|
+
import { ClickableInputOrButton } from '../click/isClickableInput';
|
|
2
|
+
import { EditableInputOrTextarea } from '../edit/isEditable';
|
|
9
3
|
/**
|
|
10
4
|
* Determine if the element has its own selection implementation
|
|
11
5
|
* and does not interact with the Document Selection API.
|
|
12
6
|
*/
|
|
13
|
-
export declare function hasOwnSelection(node: Node): node is
|
|
14
|
-
|
|
15
|
-
});
|
|
16
|
-
export declare function hasNoSelection(node: Node): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Reset the Document Selection when moving focus into an element
|
|
19
|
-
* with own selection implementation.
|
|
20
|
-
*/
|
|
21
|
-
export declare function updateSelectionOnFocus(element: Element): void;
|
|
22
|
-
/**
|
|
23
|
-
* Get the range that would be overwritten by input.
|
|
24
|
-
*/
|
|
25
|
-
export declare function getInputRange(focusNode: Node): UISelectionRange | Range | undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
|
|
28
|
-
*/
|
|
29
|
-
export declare function modifySelection({ focusNode, focusOffset, }: {
|
|
30
|
-
focusNode: Node;
|
|
31
|
-
/** DOM Offset */
|
|
32
|
-
focusOffset: number;
|
|
33
|
-
}): void;
|
|
34
|
-
/**
|
|
35
|
-
* Set the selection
|
|
36
|
-
*/
|
|
37
|
-
export declare function setSelection({ focusNode, focusOffset, anchorNode, anchorOffset, }: {
|
|
38
|
-
anchorNode?: Node;
|
|
39
|
-
/** DOM offset */
|
|
40
|
-
anchorOffset?: number;
|
|
41
|
-
focusNode: Node;
|
|
42
|
-
focusOffset: number;
|
|
43
|
-
}): void;
|
|
44
|
-
/**
|
|
45
|
-
* Move the selection
|
|
46
|
-
*/
|
|
47
|
-
export declare function moveSelection(node: Element, direction: -1 | 1): void;
|
|
48
|
-
export declare type SelectionRange = {
|
|
49
|
-
node: (HTMLInputElement & {
|
|
50
|
-
type: EditableInputType;
|
|
51
|
-
}) | HTMLTextAreaElement;
|
|
52
|
-
start: number;
|
|
53
|
-
end: number;
|
|
54
|
-
};
|
|
55
|
-
export declare function setSelectionPerMouseDown({ document, target, clickCount, node, offset, }: {
|
|
56
|
-
document: Document;
|
|
57
|
-
target: Element;
|
|
58
|
-
clickCount: number;
|
|
59
|
-
node?: Node;
|
|
60
|
-
offset?: number;
|
|
61
|
-
}): Range | {
|
|
62
|
-
node: HTMLTextAreaElement | (HTMLInputElement & {
|
|
63
|
-
type: editableInputTypes;
|
|
64
|
-
});
|
|
65
|
-
start: number;
|
|
66
|
-
end: number;
|
|
67
|
-
} | undefined;
|
|
68
|
-
export declare function modifySelectionPerMouseMove(selectionRange: Range | SelectionRange, { document, target, node, offset, }: {
|
|
69
|
-
document: Document;
|
|
70
|
-
target: Element;
|
|
71
|
-
node?: Node;
|
|
72
|
-
offset?: number;
|
|
73
|
-
}): void;
|
|
7
|
+
export declare function hasOwnSelection(node: Node): node is EditableInputOrTextarea;
|
|
8
|
+
export declare function hasNoSelection(node: Node): node is ClickableInputOrButton;
|
|
@@ -3,26 +3,19 @@ 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/
|
|
7
|
-
export * from './edit/input';
|
|
6
|
+
export * from './edit/timeValue';
|
|
8
7
|
export * from './edit/isContentEditable';
|
|
9
8
|
export * from './edit/isEditable';
|
|
9
|
+
export * from './edit/maxLength';
|
|
10
10
|
export * from './edit/setFiles';
|
|
11
|
-
export * from './edit/walkRadio';
|
|
12
|
-
export * from './focus/blur';
|
|
13
|
-
export * from './focus/copySelection';
|
|
14
11
|
export * from './focus/cursor';
|
|
15
|
-
export * from './focus/focus';
|
|
16
12
|
export * from './focus/getActiveElement';
|
|
17
13
|
export * from './focus/getTabDestination';
|
|
18
14
|
export * from './focus/isFocusable';
|
|
19
|
-
export * from './focus/selectAll';
|
|
20
|
-
export * from './focus/resolveCaretPosition';
|
|
21
15
|
export * from './focus/selection';
|
|
22
16
|
export * from './focus/selector';
|
|
23
17
|
export * from './keyDef/readNextDescriptor';
|
|
24
18
|
export * from './misc/cloneEvent';
|
|
25
|
-
export * from './misc/eventWrapper';
|
|
26
19
|
export * from './misc/findClosest';
|
|
27
20
|
export * from './misc/getDocumentFromNode';
|
|
28
21
|
export * from './misc/getTreeDiff';
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Instance } from '../../setup';
|
|
2
2
|
export declare enum ApiLevel {
|
|
3
3
|
Trigger = 2,
|
|
4
4
|
Call = 1
|
|
5
5
|
}
|
|
6
|
-
declare
|
|
7
|
-
|
|
8
|
-
|
|
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 {};
|
|
6
|
+
export declare type LevelRefs = Record<ApiLevel, object | undefined>;
|
|
7
|
+
export declare function setLevelRef(instance: Instance, level: ApiLevel): void;
|
|
8
|
+
export declare function getLevelRef(instance: Instance, level: ApiLevel): object | undefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function wait(config:
|
|
1
|
+
import type { Instance } from '../../setup';
|
|
2
|
+
export declare function wait(config: Instance['config']): Promise<[void, void]> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ApiLevel } from '
|
|
3
|
-
export declare function hasPointerEvents(
|
|
1
|
+
import type { Instance } from '../../setup';
|
|
2
|
+
import { ApiLevel } from '../misc/level';
|
|
3
|
+
export declare function hasPointerEvents(instance: Instance, element: Element): boolean;
|
|
4
4
|
declare function closestPointerEventsDeclaration(element: Element): {
|
|
5
5
|
pointerEvents: string;
|
|
6
6
|
tree: Element[];
|
|
@@ -15,5 +15,5 @@ declare global {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
-
export declare function assertPointerEvents(
|
|
18
|
+
export declare function assertPointerEvents(instance: Instance, element: Element): void;
|
|
19
19
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/user-event",
|
|
3
|
-
"version": "14.4.
|
|
3
|
+
"version": "14.4.3",
|
|
4
4
|
"description": "Fire events the same way the user does",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-testing-library",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"validate": "kcd-scripts typecheck"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@ph.fritsche/scripts-config": "^2.
|
|
38
|
+
"@ph.fritsche/scripts-config": "^2.4.0",
|
|
39
39
|
"@testing-library/dom": "^8.11.4",
|
|
40
40
|
"@testing-library/jest-dom": "^5.16.3",
|
|
41
41
|
"@testing-library/react": "^13.0.0",
|
|
@@ -64,6 +64,7 @@
|
|
|
64
64
|
"types": "./dist/types/index.d.ts",
|
|
65
65
|
"exports": {
|
|
66
66
|
".": {
|
|
67
|
+
"types": "./dist/types/index.d.ts",
|
|
67
68
|
"require": "./dist/cjs/index.js",
|
|
68
69
|
"default": "./dist/esm/index.js"
|
|
69
70
|
},
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var interceptor = require('./interceptor.js');
|
|
6
|
-
var selection = require('./selection.js');
|
|
7
|
-
var value = require('./value.js');
|
|
8
|
-
|
|
9
|
-
function prepareRangeTextInterceptor(element) {
|
|
10
|
-
interceptor.prepareInterceptor(element, 'setRangeText', function interceptorImpl(...realArgs) {
|
|
11
|
-
return {
|
|
12
|
-
realArgs,
|
|
13
|
-
then: ()=>{
|
|
14
|
-
value.setUIValueClean(element);
|
|
15
|
-
selection.setUISelectionClean(element);
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
exports.prepareRangeTextInterceptor = prepareRangeTextInterceptor;
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('../utils/click/isClickableInput.js');
|
|
6
|
-
require('../utils/dataTransfer/Clipboard.js');
|
|
7
|
-
require('../event/eventMap.js');
|
|
8
|
-
require('../event/behavior/click.js');
|
|
9
|
-
require('../event/behavior/cut.js');
|
|
10
|
-
require('../event/behavior/keydown.js');
|
|
11
|
-
require('../event/behavior/keypress.js');
|
|
12
|
-
require('../event/behavior/keyup.js');
|
|
13
|
-
require('../event/behavior/paste.js');
|
|
14
|
-
require('@testing-library/dom');
|
|
15
|
-
var selection = require('./selection.js');
|
|
16
|
-
var interceptor = require('./interceptor.js');
|
|
17
|
-
require('../utils/edit/maxLength.js');
|
|
18
|
-
require('../utils/edit/isEditable.js');
|
|
19
|
-
var isElementType = require('../utils/misc/isElementType.js');
|
|
20
|
-
var getWindow = require('../utils/misc/getWindow.js');
|
|
21
|
-
require('../utils/keyDef/readNextDescriptor.js');
|
|
22
|
-
require('../utils/misc/level.js');
|
|
23
|
-
require('../options.js');
|
|
24
|
-
|
|
25
|
-
const UIValue = Symbol('Displayed value in UI');
|
|
26
|
-
const InitialValue = Symbol('Initial value to compare on blur');
|
|
27
|
-
const TrackChanges = Symbol('Track programmatic changes for React workaround');
|
|
28
|
-
function valueInterceptor(v) {
|
|
29
|
-
const isUI = typeof v === 'object' && v[UIValue];
|
|
30
|
-
if (isUI) {
|
|
31
|
-
this[UIValue] = String(v);
|
|
32
|
-
startTrackValue(this);
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
applyNative: !!isUI,
|
|
36
|
-
realArgs: sanitizeValue(this, v),
|
|
37
|
-
then: isUI ? undefined : ()=>trackOrSetValue(this, String(v))
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function sanitizeValue(element, v) {
|
|
41
|
-
// Workaround for JSDOM
|
|
42
|
-
if (isElementType.isElementType(element, 'input', {
|
|
43
|
-
type: 'number'
|
|
44
|
-
}) && String(v) !== '' && !Number.isNaN(Number(v))) {
|
|
45
|
-
// Setting value to "1." results in `null` in JSDOM
|
|
46
|
-
return String(Number(v));
|
|
47
|
-
}
|
|
48
|
-
return String(v);
|
|
49
|
-
}
|
|
50
|
-
function prepareValueInterceptor(element) {
|
|
51
|
-
interceptor.prepareInterceptor(element, 'value', valueInterceptor);
|
|
52
|
-
}
|
|
53
|
-
function setUIValue(element, value) {
|
|
54
|
-
if (element[InitialValue] === undefined) {
|
|
55
|
-
element[InitialValue] = element.value;
|
|
56
|
-
}
|
|
57
|
-
element.value = {
|
|
58
|
-
[UIValue]: UIValue,
|
|
59
|
-
toString: ()=>value
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function getUIValue(element) {
|
|
63
|
-
return element[UIValue] === undefined ? element.value : String(element[UIValue]);
|
|
64
|
-
}
|
|
65
|
-
/** Flag the IDL value as clean. This does not change the value.*/ function setUIValueClean(element) {
|
|
66
|
-
element[UIValue] = undefined;
|
|
67
|
-
}
|
|
68
|
-
function clearInitialValue(element) {
|
|
69
|
-
element[InitialValue] = undefined;
|
|
70
|
-
}
|
|
71
|
-
function getInitialValue(element) {
|
|
72
|
-
return element[InitialValue];
|
|
73
|
-
}
|
|
74
|
-
// When the input event happens in the browser, React executes all event handlers
|
|
75
|
-
// and if they change state of a controlled value, nothing happens.
|
|
76
|
-
// But when we trigger the event handlers in test environment with React@17,
|
|
77
|
-
// the changes are rolled back before the state update is applied.
|
|
78
|
-
// This results in a reset cursor.
|
|
79
|
-
// There might be a better way to work around if we figure out
|
|
80
|
-
// why the batched update is executed differently in our test environment.
|
|
81
|
-
function isReact17Element(element) {
|
|
82
|
-
return Object.getOwnPropertyNames(element).some((k)=>k.startsWith('__react')) && getWindow.getWindow(element).REACT_VERSION === 17;
|
|
83
|
-
}
|
|
84
|
-
function startTrackValue(element) {
|
|
85
|
-
if (!isReact17Element(element)) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
element[TrackChanges] = {
|
|
89
|
-
previousValue: String(element.value),
|
|
90
|
-
tracked: []
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
function trackOrSetValue(element, v) {
|
|
94
|
-
var ref, ref1;
|
|
95
|
-
(ref = element[TrackChanges]) === null || ref === void 0 ? void 0 : (ref1 = ref.tracked) === null || ref1 === void 0 ? void 0 : ref1.push(v);
|
|
96
|
-
if (!element[TrackChanges]) {
|
|
97
|
-
setUIValueClean(element);
|
|
98
|
-
selection.setUISelection(element, {
|
|
99
|
-
focusOffset: v.length
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function commitValueAfterInput(element, cursorOffset) {
|
|
104
|
-
var ref;
|
|
105
|
-
const changes = element[TrackChanges];
|
|
106
|
-
element[TrackChanges] = undefined;
|
|
107
|
-
if (!(changes === null || changes === void 0 ? void 0 : (ref = changes.tracked) === null || ref === void 0 ? void 0 : ref.length)) {
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const isJustReactStateUpdate = changes.tracked.length === 2 && changes.tracked[0] === changes.previousValue && changes.tracked[1] === element.value;
|
|
111
|
-
if (!isJustReactStateUpdate) {
|
|
112
|
-
setUIValueClean(element);
|
|
113
|
-
}
|
|
114
|
-
if (selection.hasUISelection(element)) {
|
|
115
|
-
selection.setUISelection(element, {
|
|
116
|
-
focusOffset: isJustReactStateUpdate ? cursorOffset : element.value.length
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
exports.clearInitialValue = clearInitialValue;
|
|
122
|
-
exports.commitValueAfterInput = commitValueAfterInput;
|
|
123
|
-
exports.getInitialValue = getInitialValue;
|
|
124
|
-
exports.getUIValue = getUIValue;
|
|
125
|
-
exports.prepareValueInterceptor = prepareValueInterceptor;
|
|
126
|
-
exports.setUIValue = setUIValue;
|
|
127
|
-
exports.setUIValueClean = setUIValueClean;
|
package/dist/cjs/setup/config.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('../click/isClickableInput.js');
|
|
6
|
-
require('../dataTransfer/Clipboard.js');
|
|
7
|
-
require('./maxLength.js');
|
|
8
|
-
var isContentEditable = require('./isContentEditable.js');
|
|
9
|
-
require('./isEditable.js');
|
|
10
|
-
require('@testing-library/dom');
|
|
11
|
-
require('@testing-library/dom/dist/helpers.js');
|
|
12
|
-
require('../keyDef/readNextDescriptor.js');
|
|
13
|
-
require('../misc/level.js');
|
|
14
|
-
require('../../options.js');
|
|
15
|
-
require('../../event/eventMap.js');
|
|
16
|
-
require('../../event/behavior/click.js');
|
|
17
|
-
require('../../event/behavior/cut.js');
|
|
18
|
-
require('../../event/behavior/keydown.js');
|
|
19
|
-
require('../../event/behavior/keypress.js');
|
|
20
|
-
require('../../event/behavior/keyup.js');
|
|
21
|
-
require('../../event/behavior/paste.js');
|
|
22
|
-
var value = require('../../document/value.js');
|
|
23
|
-
|
|
24
|
-
function getValue(element) {
|
|
25
|
-
// istanbul ignore if
|
|
26
|
-
if (!element) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
if (isContentEditable.isContentEditable(element)) {
|
|
30
|
-
return element.textContent;
|
|
31
|
-
}
|
|
32
|
-
return value.getUIValue(element);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
exports.getValue = getValue;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
function isValidDateOrTimeValue(element, value) {
|
|
6
|
-
const clone = element.cloneNode();
|
|
7
|
-
clone.value = value;
|
|
8
|
-
return clone.value === value;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
exports.isValidDateOrTimeValue = isValidDateOrTimeValue;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var eventWrapper = require('../misc/eventWrapper.js');
|
|
6
|
-
var getActiveElement = require('./getActiveElement.js');
|
|
7
|
-
var isFocusable = require('./isFocusable.js');
|
|
8
|
-
|
|
9
|
-
function blur(element) {
|
|
10
|
-
if (!isFocusable.isFocusable(element)) return;
|
|
11
|
-
const wasActive = getActiveElement.getActiveElement(element.ownerDocument) === element;
|
|
12
|
-
if (!wasActive) return;
|
|
13
|
-
eventWrapper.eventWrapper(()=>element.blur());
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
exports.blur = blur;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('../click/isClickableInput.js');
|
|
6
|
-
var DataTransfer = require('../dataTransfer/DataTransfer.js');
|
|
7
|
-
require('../dataTransfer/Clipboard.js');
|
|
8
|
-
require('../edit/maxLength.js');
|
|
9
|
-
require('../edit/isEditable.js');
|
|
10
|
-
require('@testing-library/dom');
|
|
11
|
-
var selection = require('./selection.js');
|
|
12
|
-
var getWindow = require('../misc/getWindow.js');
|
|
13
|
-
require('../keyDef/readNextDescriptor.js');
|
|
14
|
-
require('../misc/level.js');
|
|
15
|
-
require('../../options.js');
|
|
16
|
-
require('../../event/eventMap.js');
|
|
17
|
-
require('../../event/behavior/click.js');
|
|
18
|
-
require('../../event/behavior/cut.js');
|
|
19
|
-
require('../../event/behavior/keydown.js');
|
|
20
|
-
require('../../event/behavior/keypress.js');
|
|
21
|
-
require('../../event/behavior/keyup.js');
|
|
22
|
-
require('../../event/behavior/paste.js');
|
|
23
|
-
var selection$1 = require('../../document/selection.js');
|
|
24
|
-
var value = require('../../document/value.js');
|
|
25
|
-
|
|
26
|
-
function copySelection(target) {
|
|
27
|
-
const data = selection.hasOwnSelection(target) ? {
|
|
28
|
-
'text/plain': readSelectedValueFromInput(target)
|
|
29
|
-
} : {
|
|
30
|
-
'text/plain': String(target.ownerDocument.getSelection())
|
|
31
|
-
};
|
|
32
|
-
const dt = DataTransfer.createDataTransfer(getWindow.getWindow(target));
|
|
33
|
-
for(const type in data){
|
|
34
|
-
if (data[type]) {
|
|
35
|
-
dt.setData(type, data[type]);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return dt;
|
|
39
|
-
}
|
|
40
|
-
function readSelectedValueFromInput(target) {
|
|
41
|
-
const sel = selection$1.getUISelection(target);
|
|
42
|
-
const val = value.getUIValue(target);
|
|
43
|
-
return val.substring(sel.startOffset, sel.endOffset);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
exports.copySelection = copySelection;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var eventWrapper = require('../misc/eventWrapper.js');
|
|
6
|
-
var findClosest = require('../misc/findClosest.js');
|
|
7
|
-
var getActiveElement = require('./getActiveElement.js');
|
|
8
|
-
var isFocusable = require('./isFocusable.js');
|
|
9
|
-
var selection = require('./selection.js');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Focus closest focusable element.
|
|
13
|
-
*/ function focus(element) {
|
|
14
|
-
const target = findClosest.findClosest(element, isFocusable.isFocusable);
|
|
15
|
-
const activeElement = getActiveElement.getActiveElement(element.ownerDocument);
|
|
16
|
-
if ((target !== null && target !== void 0 ? target : element.ownerDocument.body) === activeElement) {
|
|
17
|
-
return;
|
|
18
|
-
} else if (target) {
|
|
19
|
-
eventWrapper.eventWrapper(()=>target.focus());
|
|
20
|
-
} else {
|
|
21
|
-
eventWrapper.eventWrapper(()=>{
|
|
22
|
-
var ref;
|
|
23
|
-
return (ref = activeElement) === null || ref === void 0 ? void 0 : ref.blur();
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
selection.updateSelectionOnFocus(target !== null && target !== void 0 ? target : element.ownerDocument.body);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
exports.focus = focus;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('../click/isClickableInput.js');
|
|
6
|
-
require('../dataTransfer/Clipboard.js');
|
|
7
|
-
var isContentEditable = require('../edit/isContentEditable.js');
|
|
8
|
-
require('../edit/maxLength.js');
|
|
9
|
-
var isEditable = require('../edit/isEditable.js');
|
|
10
|
-
require('@testing-library/dom');
|
|
11
|
-
var isElementType = require('../misc/isElementType.js');
|
|
12
|
-
var selection = require('./selection.js');
|
|
13
|
-
require('@testing-library/dom/dist/helpers.js');
|
|
14
|
-
require('../keyDef/readNextDescriptor.js');
|
|
15
|
-
require('../misc/level.js');
|
|
16
|
-
require('../../options.js');
|
|
17
|
-
require('../../event/eventMap.js');
|
|
18
|
-
require('../../event/behavior/click.js');
|
|
19
|
-
require('../../event/behavior/cut.js');
|
|
20
|
-
require('../../event/behavior/keydown.js');
|
|
21
|
-
require('../../event/behavior/keypress.js');
|
|
22
|
-
require('../../event/behavior/keyup.js');
|
|
23
|
-
require('../../event/behavior/paste.js');
|
|
24
|
-
var selection$1 = require('../../document/selection.js');
|
|
25
|
-
var value = require('../../document/value.js');
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Expand a selection like the browser does when pressing Ctrl+A.
|
|
29
|
-
*/ function selectAll(target) {
|
|
30
|
-
if (isElementType.isElementType(target, 'textarea') || isElementType.isElementType(target, 'input') && target.type in isEditable.editableInputTypes) {
|
|
31
|
-
return selection.setSelection({
|
|
32
|
-
focusNode: target,
|
|
33
|
-
anchorOffset: 0,
|
|
34
|
-
focusOffset: value.getUIValue(target).length
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
var ref;
|
|
38
|
-
const focusNode = (ref = isContentEditable.getContentEditable(target)) !== null && ref !== void 0 ? ref : target.ownerDocument.body;
|
|
39
|
-
selection.setSelection({
|
|
40
|
-
focusNode,
|
|
41
|
-
anchorOffset: 0,
|
|
42
|
-
focusOffset: focusNode.childNodes.length
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function isAllSelected(target) {
|
|
46
|
-
if (isElementType.isElementType(target, 'textarea') || isElementType.isElementType(target, 'input') && target.type in isEditable.editableInputTypes) {
|
|
47
|
-
return selection$1.getUISelection(target).startOffset === 0 && selection$1.getUISelection(target).endOffset === value.getUIValue(target).length;
|
|
48
|
-
}
|
|
49
|
-
var ref;
|
|
50
|
-
const focusNode = (ref = isContentEditable.getContentEditable(target)) !== null && ref !== void 0 ? ref : target.ownerDocument.body;
|
|
51
|
-
const selection = target.ownerDocument.getSelection();
|
|
52
|
-
return (selection === null || selection === void 0 ? void 0 : selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
exports.isAllSelected = isAllSelected;
|
|
56
|
-
exports.selectAll = selectAll;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var dom = require('@testing-library/dom');
|
|
6
|
-
|
|
7
|
-
function eventWrapper(cb) {
|
|
8
|
-
let result;
|
|
9
|
-
dom.getConfig().eventWrapper(()=>{
|
|
10
|
-
result = cb();
|
|
11
|
-
});
|
|
12
|
-
return result;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
exports.eventWrapper = eventWrapper;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { prepareInterceptor } from './interceptor.js';
|
|
2
|
-
import { setUISelectionClean } from './selection.js';
|
|
3
|
-
import { setUIValueClean } from './value.js';
|
|
4
|
-
|
|
5
|
-
function prepareRangeTextInterceptor(element) {
|
|
6
|
-
prepareInterceptor(element, 'setRangeText', function interceptorImpl(...realArgs) {
|
|
7
|
-
return {
|
|
8
|
-
realArgs,
|
|
9
|
-
then: ()=>{
|
|
10
|
-
setUIValueClean(element);
|
|
11
|
-
setUISelectionClean(element);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { prepareRangeTextInterceptor };
|
package/dist/esm/setup/config.js
DELETED