@testing-library/user-event 14.0.0-alpha.1 → 14.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{src/clear.d.ts → clear.d.ts} +0 -0
- package/dist/clear.js +14 -27
- package/dist/{src/click.d.ts → click.d.ts} +1 -0
- package/dist/click.js +17 -0
- package/dist/document/index.d.ts +10 -0
- package/dist/document/index.js +8 -10
- package/dist/document/interceptor.d.ts +15 -0
- package/dist/document/interceptor.js +7 -4
- package/dist/document/selection.d.ts +27 -0
- package/dist/document/selection.js +51 -28
- package/dist/{src/document → document}/value.d.ts +5 -1
- package/dist/document/value.js +27 -6
- package/dist/{src/hover.d.ts → hover.d.ts} +0 -0
- package/dist/{src/index.d.ts → index.d.ts} +0 -0
- package/dist/{src/keyboard → keyboard}/getEventProps.d.ts +0 -0
- package/dist/{src/keyboard → keyboard}/getNextKeyDef.d.ts +0 -0
- package/dist/{src/keyboard → keyboard}/index.d.ts +0 -0
- package/dist/{src/keyboard → keyboard}/keyMap.d.ts +0 -0
- package/dist/keyboard/keyMap.js +4 -0
- package/dist/{src/keyboard → keyboard}/keyboardImplementation.d.ts +0 -0
- package/dist/keyboard/keyboardImplementation.js +3 -1
- package/dist/{src/keyboard → keyboard}/plugins/arrow.d.ts +0 -0
- package/dist/keyboard/plugins/arrow.js +7 -12
- package/dist/{src/keyboard → keyboard}/plugins/character.d.ts +0 -0
- package/dist/keyboard/plugins/character.js +27 -45
- package/dist/keyboard/plugins/combination.d.ts +5 -0
- package/dist/keyboard/plugins/combination.js +17 -0
- package/dist/{src/keyboard → keyboard}/plugins/control.d.ts +0 -0
- package/dist/keyboard/plugins/control.js +4 -12
- package/dist/{src/keyboard → keyboard}/plugins/functional.d.ts +0 -0
- package/dist/keyboard/plugins/functional.js +23 -11
- package/dist/{src/keyboard → keyboard}/plugins/index.d.ts +0 -0
- package/dist/keyboard/plugins/index.js +3 -1
- package/dist/{src/keyboard → keyboard}/shared/fireChangeForInputTimeIfValid.d.ts +0 -0
- package/dist/{src/keyboard → keyboard}/shared/index.d.ts +0 -0
- package/dist/{src/keyboard → keyboard}/specialCharMap.d.ts +0 -0
- package/dist/{src/keyboard → keyboard}/types.d.ts +0 -0
- package/dist/{src/paste.d.ts → paste.d.ts} +0 -0
- package/dist/paste.js +8 -15
- package/dist/{src/pointer → pointer}/index.d.ts +0 -0
- package/dist/{src/pointer → pointer}/keyMap.d.ts +0 -0
- package/dist/{src/pointer → pointer}/parseKeyDef.d.ts +0 -0
- package/dist/{src/pointer → pointer}/pointerAction.d.ts +2 -6
- package/dist/pointer/pointerAction.js +2 -26
- package/dist/pointer/pointerMove.d.ts +5 -0
- package/dist/pointer/pointerMove.js +49 -5
- package/dist/pointer/pointerPress.d.ts +7 -0
- package/dist/pointer/pointerPress.js +135 -29
- package/dist/pointer/resolveSelectionTarget.d.ts +5 -0
- package/dist/pointer/resolveSelectionTarget.js +75 -0
- package/dist/{src/pointer → pointer}/types.d.ts +18 -4
- package/dist/{src/selectOptions.d.ts → selectOptions.d.ts} +0 -0
- package/dist/{src/setup.d.ts → setup.d.ts} +5 -2
- package/dist/setup.js +4 -7
- package/dist/tab.d.ts +5 -0
- package/dist/tab.js +3 -132
- package/dist/{src/type.d.ts → type.d.ts} +0 -0
- package/dist/type.js +3 -19
- package/dist/{src/upload.d.ts → upload.d.ts} +0 -0
- package/dist/{src/utils → utils}/click/isClickableInput.d.ts +0 -0
- package/dist/{src/utils → utils}/edit/buildTimeValue.d.ts +0 -0
- package/dist/utils/edit/calculateNewValue.d.ts +14 -0
- package/dist/utils/edit/calculateNewValue.js +19 -21
- package/dist/utils/edit/editInputElement.d.ts +16 -0
- package/dist/utils/edit/editInputElement.js +53 -0
- package/dist/{src/utils → utils}/edit/getValue.d.ts +0 -0
- package/dist/utils/edit/getValue.js +1 -3
- package/dist/utils/edit/isContentEditable.d.ts +7 -0
- package/dist/utils/edit/isContentEditable.js +14 -0
- package/dist/{src/utils → utils}/edit/isEditable.d.ts +1 -0
- package/dist/{src/utils → utils}/edit/isValidDateValue.d.ts +0 -0
- package/dist/{src/utils → utils}/edit/isValidInputTimeValue.d.ts +0 -0
- package/dist/{src/utils → utils}/edit/maxLength.d.ts +0 -0
- package/dist/utils/edit/prepareInput.d.ts +7 -0
- package/dist/utils/edit/prepareInput.js +77 -0
- package/dist/{src/utils → utils}/focus/blur.d.ts +0 -0
- package/dist/{src/utils → utils}/focus/focus.d.ts +0 -0
- package/dist/utils/focus/focus.js +3 -0
- package/dist/{src/utils → utils}/focus/getActiveElement.d.ts +0 -0
- package/dist/utils/focus/getTabDestination.d.ts +1 -0
- package/dist/utils/focus/getTabDestination.js +71 -0
- package/dist/{src/utils → utils}/focus/isFocusable.d.ts +0 -0
- package/dist/utils/focus/selectAll.d.ts +5 -0
- package/dist/utils/focus/selectAll.js +51 -0
- package/dist/utils/focus/selection.d.ts +42 -0
- package/dist/utils/focus/selection.js +190 -0
- package/dist/{src/utils → utils}/focus/selector.d.ts +0 -0
- package/dist/{src/utils → utils}/index.d.ts +5 -5
- package/dist/utils/index.js +47 -47
- package/dist/{src/utils → utils}/keyDef/readNextDescriptor.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/eventWrapper.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/findClosest.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/hasFormSubmit.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/hasPointerEvents.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isDescendantOrSelf.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isDisabled.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isElementType.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/isVisible.d.ts +0 -0
- package/dist/{src/utils → utils}/misc/wait.d.ts +0 -0
- package/dist/{src/utils → utils}/pointer/firePointerEvents.d.ts +13 -11
- package/dist/utils/pointer/firePointerEvents.js +62 -5
- package/dist/{src/utils → utils}/pointer/mouseButtons.d.ts +0 -0
- package/package.json +2 -2
- package/dist/document/applyNative.js +0 -28
- package/dist/src/document/applyNative.d.ts +0 -8
- package/dist/src/document/index.d.ts +0 -10
- package/dist/src/document/interceptor.d.ts +0 -5
- package/dist/src/document/selection.d.ts +0 -18
- package/dist/src/pointer/pointerMove.d.ts +0 -5
- package/dist/src/pointer/pointerPress.d.ts +0 -7
- package/dist/src/tab.d.ts +0 -6
- package/dist/src/utils/edit/calculateNewValue.d.ts +0 -7
- package/dist/src/utils/edit/cursorPosition.d.ts +0 -2
- package/dist/src/utils/edit/fireInputEvent.d.ts +0 -8
- package/dist/src/utils/edit/isContentEditable.d.ts +0 -3
- package/dist/src/utils/edit/selectionRange.d.ts +0 -5
- package/dist/src/utils/misc/isDocument.d.ts +0 -1
- package/dist/src/utils/pointer/fakeEvent.d.ts +0 -16
- package/dist/tests/_helpers/custom-element.d.ts +0 -8
- package/dist/tests/_helpers/utils.d.ts +0 -73
- package/dist/tests/_setup-env.d.ts +0 -1
- package/dist/tests/clear.d.ts +0 -1
- package/dist/tests/click/click.d.ts +0 -1
- package/dist/tests/click/dblclick.d.ts +0 -1
- package/dist/tests/document/index.d.ts +0 -1
- package/dist/tests/document/selectionRange.d.ts +0 -1
- package/dist/tests/hover/hover.d.ts +0 -1
- package/dist/tests/hover/unhover.d.ts +0 -1
- package/dist/tests/keyboard/getNextKeyDef.d.ts +0 -1
- package/dist/tests/keyboard/index.d.ts +0 -1
- package/dist/tests/keyboard/keyboardImplementation.d.ts +0 -1
- package/dist/tests/keyboard/plugin/arrow.d.ts +0 -1
- package/dist/tests/keyboard/plugin/character.d.ts +0 -1
- package/dist/tests/keyboard/plugin/control.d.ts +0 -1
- package/dist/tests/keyboard/plugin/functional.d.ts +0 -1
- package/dist/tests/keyboard/shared/fireInputEvent.d.ts +0 -1
- package/dist/tests/paste.d.ts +0 -1
- package/dist/tests/pointer/index.d.ts +0 -1
- package/dist/tests/react/keyboard.d.ts +0 -1
- package/dist/tests/react/type.d.ts +0 -1
- package/dist/tests/selectOptions/deselect.d.ts +0 -1
- package/dist/tests/selectOptions/select.d.ts +0 -1
- package/dist/tests/setup.d.ts +0 -10
- package/dist/tests/tab.d.ts +0 -1
- package/dist/tests/type/index.d.ts +0 -1
- package/dist/tests/type/modifiers.d.ts +0 -1
- package/dist/tests/upload.d.ts +0 -1
- package/dist/tests/utils/edit/calculateNewValue.d.ts +0 -1
- package/dist/tests/utils/edit/isContentEditable.d.ts +0 -1
- package/dist/tests/utils/focus/blur.d.ts +0 -1
- package/dist/tests/utils/focus/focus.d.ts +0 -1
- package/dist/tests/utils/misc/hasPointerEvents.d.ts +0 -1
- package/dist/tests/utils/misc/isDescendantOrSelf.d.ts +0 -1
- package/dist/tests/utils/misc/isElementType.d.ts +0 -1
- package/dist/tests/utils/misc/isVisible.d.ts +0 -1
- package/dist/utils/edit/cursorPosition.js +0 -35
- package/dist/utils/edit/fireInputEvent.js +0 -55
- package/dist/utils/edit/selectionRange.js +0 -64
- package/dist/utils/misc/dom-helpers.d.ts +0 -3
- package/dist/utils/misc/isDocument.js +0 -10
- package/dist/utils/pointer/fakeEvent.js +0 -82
|
@@ -7,7 +7,7 @@ exports.firePointerEvent = firePointerEvent;
|
|
|
7
7
|
|
|
8
8
|
var _dom = require("@testing-library/dom");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _eventMap = require("@testing-library/dom/dist/event-map");
|
|
11
11
|
|
|
12
12
|
var _mouseButtons = require("./mouseButtons");
|
|
13
13
|
|
|
@@ -21,7 +21,6 @@ function firePointerEvent(target, type, {
|
|
|
21
21
|
isPrimary,
|
|
22
22
|
clickCount
|
|
23
23
|
}) {
|
|
24
|
-
const Event = type === 'click' || type.startsWith('mouse') ? _fakeEvent.FakeMouseEvent : _fakeEvent.FakePointerEvent;
|
|
25
24
|
const init = { ...coords,
|
|
26
25
|
altKey: keyboardState.modifiers.alt,
|
|
27
26
|
ctrlKey: keyboardState.modifiers.ctrl,
|
|
@@ -29,7 +28,7 @@ function firePointerEvent(target, type, {
|
|
|
29
28
|
shiftKey: keyboardState.modifiers.shift
|
|
30
29
|
};
|
|
31
30
|
|
|
32
|
-
if (
|
|
31
|
+
if (type === 'click' || type.startsWith('pointer')) {
|
|
33
32
|
init.pointerId = pointerId;
|
|
34
33
|
init.pointerType = pointerType;
|
|
35
34
|
}
|
|
@@ -47,9 +46,67 @@ function firePointerEvent(target, type, {
|
|
|
47
46
|
}));
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
if (['mousedown', 'mouseup', 'click'].includes(type)) {
|
|
49
|
+
if (['mousedown', 'mouseup', 'click', 'dblclick'].includes(type)) {
|
|
51
50
|
init.detail = clickCount;
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
|
|
53
|
+
const eventKey = Object.keys(_eventMap.eventMap).find(k => k.toLowerCase() === type);
|
|
54
|
+
|
|
55
|
+
const event = _dom.createEvent[eventKey](target, init); // see https://github.com/testing-library/react-testing-library/issues/268
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
assignPositionInit(event, init);
|
|
59
|
+
assignPointerInit(event, init);
|
|
60
|
+
return (0, _dom.fireEvent)(target, event);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function assignProps(obj, props) {
|
|
64
|
+
for (const [key, value] of Object.entries(props)) {
|
|
65
|
+
Object.defineProperty(obj, key, {
|
|
66
|
+
get: () => value
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function assignPositionInit(obj, {
|
|
72
|
+
x,
|
|
73
|
+
y,
|
|
74
|
+
clientX,
|
|
75
|
+
clientY,
|
|
76
|
+
offsetX,
|
|
77
|
+
offsetY,
|
|
78
|
+
pageX,
|
|
79
|
+
pageY,
|
|
80
|
+
screenX,
|
|
81
|
+
screenY
|
|
82
|
+
}) {
|
|
83
|
+
var _ref, _ref2, _ref3, _ref4;
|
|
84
|
+
|
|
85
|
+
assignProps(obj, {
|
|
86
|
+
/* istanbul ignore start */
|
|
87
|
+
x: (_ref = x != null ? x : clientX) != null ? _ref : 0,
|
|
88
|
+
y: (_ref2 = y != null ? y : clientY) != null ? _ref2 : 0,
|
|
89
|
+
clientX: (_ref3 = x != null ? x : clientX) != null ? _ref3 : 0,
|
|
90
|
+
clientY: (_ref4 = y != null ? y : clientY) != null ? _ref4 : 0,
|
|
91
|
+
offsetX: offsetX != null ? offsetX : 0,
|
|
92
|
+
offsetY: offsetY != null ? offsetY : 0,
|
|
93
|
+
pageX: pageX != null ? pageX : 0,
|
|
94
|
+
pageY: pageY != null ? pageY : 0,
|
|
95
|
+
screenX: screenX != null ? screenX : 0,
|
|
96
|
+
screenY: screenY != null ? screenY : 0
|
|
97
|
+
/* istanbul ignore end */
|
|
98
|
+
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function assignPointerInit(obj, {
|
|
103
|
+
isPrimary,
|
|
104
|
+
pointerId,
|
|
105
|
+
pointerType
|
|
106
|
+
}) {
|
|
107
|
+
assignProps(obj, {
|
|
108
|
+
isPrimary,
|
|
109
|
+
pointerId,
|
|
110
|
+
pointerType
|
|
111
|
+
});
|
|
55
112
|
}
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/user-event",
|
|
3
|
-
"version": "14.0.0-alpha.
|
|
3
|
+
"version": "14.0.0-alpha.10",
|
|
4
4
|
"description": "Fire events the same way the user does",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
|
-
"build": "kcd-scripts build",
|
|
30
|
+
"build": "kcd-scripts build --no-ts-defs && tsc -p tsconfig.build.json",
|
|
31
31
|
"lint": "kcd-scripts lint",
|
|
32
32
|
"setup": "npm install && npm run validate -s",
|
|
33
33
|
"test": "kcd-scripts test",
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.applyNative = applyNative;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* React tracks the changes on element properties.
|
|
10
|
-
* This workaround tries to alter the DOM element without React noticing,
|
|
11
|
-
* so that it later picks up the change.
|
|
12
|
-
*
|
|
13
|
-
* @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104
|
|
14
|
-
*/
|
|
15
|
-
function applyNative(element, propName, propValue) {
|
|
16
|
-
const descriptor = Object.getOwnPropertyDescriptor(element, propName);
|
|
17
|
-
const nativeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
|
|
18
|
-
|
|
19
|
-
if (descriptor && nativeDescriptor) {
|
|
20
|
-
Object.defineProperty(element, propName, nativeDescriptor);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
element[propName] = propValue;
|
|
24
|
-
|
|
25
|
-
if (descriptor) {
|
|
26
|
-
Object.defineProperty(element, propName, descriptor);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* React tracks the changes on element properties.
|
|
3
|
-
* This workaround tries to alter the DOM element without React noticing,
|
|
4
|
-
* so that it later picks up the change.
|
|
5
|
-
*
|
|
6
|
-
* @see https://github.com/facebook/react/blob/148f8e497c7d37a3c7ab99f01dec2692427272b1/packages/react-dom/src/client/inputValueTracking.js#L51-L104
|
|
7
|
-
*/
|
|
8
|
-
export declare function applyNative<T extends Element, P extends keyof T>(element: T, propName: P, propValue: T[P]): void;
|
|
@@ -1,10 +0,0 @@
|
|
|
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 { applyNative } from './applyNative';
|
|
9
|
-
export { getUIValue, setUIValue } from './value';
|
|
10
|
-
export { getUISelection, hasUISelection, setUISelection } from './selection';
|
|
@@ -1,5 +0,0 @@
|
|
|
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 Element, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => ImplReturn<ElementType[PropName]>): void;
|
|
5
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare const UISelection: unique symbol;
|
|
2
|
-
declare global {
|
|
3
|
-
interface Element {
|
|
4
|
-
[UISelection]?: {
|
|
5
|
-
start: number;
|
|
6
|
-
end: number;
|
|
7
|
-
};
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
export declare function prepareSelectionInterceptor(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
11
|
-
export declare function setUISelection(element: HTMLInputElement | HTMLTextAreaElement, start: number, end: number): void;
|
|
12
|
-
export declare function getUISelection(element: HTMLInputElement | HTMLTextAreaElement): {
|
|
13
|
-
selectionStart: number | null;
|
|
14
|
-
selectionEnd: number | null;
|
|
15
|
-
};
|
|
16
|
-
export declare function clearUISelection(element: HTMLInputElement | HTMLTextAreaElement): void;
|
|
17
|
-
export declare function hasUISelection(element: HTMLInputElement | HTMLTextAreaElement): boolean;
|
|
18
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { inputDeviceState, PointerTarget } from './types';
|
|
2
|
-
export interface PointerMoveAction extends PointerTarget {
|
|
3
|
-
pointerName?: string;
|
|
4
|
-
}
|
|
5
|
-
export declare function pointerMove({ pointerName, target, coords }: PointerMoveAction, { pointerState, keyboardState }: inputDeviceState): Promise<void>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { inputDeviceState, pointerKey, PointerTarget } from './types';
|
|
2
|
-
export interface PointerPressAction extends PointerTarget {
|
|
3
|
-
keyDef: pointerKey;
|
|
4
|
-
releasePrevious: boolean;
|
|
5
|
-
releaseSelf: boolean;
|
|
6
|
-
}
|
|
7
|
-
export declare function pointerPress({ keyDef, releasePrevious, releaseSelf, target, coords }: PointerPressAction, state: inputDeviceState): Promise<void>;
|
package/dist/src/tab.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare function calculateNewValue(newEntry: string, element: HTMLElement, value?: string, selectionRange?: {
|
|
2
|
-
selectionStart: number | null;
|
|
3
|
-
selectionEnd: number | null;
|
|
4
|
-
}, deleteContent?: 'backward' | 'forward'): {
|
|
5
|
-
newValue: string;
|
|
6
|
-
newSelectionStart: number;
|
|
7
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { fireEvent } from '@testing-library/dom';
|
|
2
|
-
export declare function fireInputEvent(element: HTMLElement, { newValue, newSelectionStart, eventOverrides, }: {
|
|
3
|
-
newValue: string;
|
|
4
|
-
newSelectionStart: number;
|
|
5
|
-
eventOverrides: Partial<Parameters<typeof fireEvent>[1]> & {
|
|
6
|
-
[k: string]: unknown;
|
|
7
|
-
};
|
|
8
|
-
}): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isDocument(el: Document | Element): el is Document;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export interface FakeEventInit extends MouseEventInit, PointerEventInit {
|
|
2
|
-
x?: number;
|
|
3
|
-
y?: number;
|
|
4
|
-
clientX?: number;
|
|
5
|
-
clientY?: number;
|
|
6
|
-
offsetX?: number;
|
|
7
|
-
offsetY?: number;
|
|
8
|
-
pageX?: number;
|
|
9
|
-
pageY?: number;
|
|
10
|
-
}
|
|
11
|
-
export declare class FakeMouseEvent extends MouseEvent {
|
|
12
|
-
constructor(type: string, init: FakeEventInit);
|
|
13
|
-
}
|
|
14
|
-
export declare class FakePointerEvent extends MouseEvent {
|
|
15
|
-
constructor(type: string, init: FakeEventInit);
|
|
16
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
declare const observed: string[];
|
|
2
|
-
declare class CustomEl extends HTMLElement {
|
|
3
|
-
static getObservedAttributes(): string[];
|
|
4
|
-
$input: HTMLInputElement | null;
|
|
5
|
-
connectedCallback(): void;
|
|
6
|
-
attributeChangedCallback(name: any, oldVal: any, newVal: any): void;
|
|
7
|
-
render(name: any, value: any): void;
|
|
8
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
declare type EventHandlers = Record<string, EventListener>;
|
|
2
|
-
declare type HTMLCollection<Elements extends Array<Element>> = Elements & {
|
|
3
|
-
item<N extends number>(i: N): Elements[N];
|
|
4
|
-
};
|
|
5
|
-
declare function setup<Elements extends Element | Element[] = HTMLElement>(ui: string, { eventHandlers, }?: {
|
|
6
|
-
eventHandlers?: EventHandlers;
|
|
7
|
-
}): {
|
|
8
|
-
getEventSnapshot: () => {
|
|
9
|
-
snapshot: string;
|
|
10
|
-
};
|
|
11
|
-
getClickEventsSnapshot: () => {
|
|
12
|
-
snapshot: string;
|
|
13
|
-
};
|
|
14
|
-
clearEventCalls: () => void;
|
|
15
|
-
getEvents: (type?: string | undefined) => Event[];
|
|
16
|
-
eventWasFired: (eventType: string) => boolean;
|
|
17
|
-
element: (Elements extends Element[] ? Elements : [Elements])[0];
|
|
18
|
-
elements: HTMLCollection<Elements extends Element[] ? Elements : [Elements]>;
|
|
19
|
-
};
|
|
20
|
-
declare function setupSelect({ disabled, disabledOptions, multiple, pointerEvents, }?: {
|
|
21
|
-
disabled?: boolean | undefined;
|
|
22
|
-
disabledOptions?: boolean | undefined;
|
|
23
|
-
multiple?: boolean | undefined;
|
|
24
|
-
pointerEvents?: string | undefined;
|
|
25
|
-
}): {
|
|
26
|
-
form: HTMLFormElement;
|
|
27
|
-
select: HTMLSelectElement;
|
|
28
|
-
options: HTMLOptionElement[];
|
|
29
|
-
getEventSnapshot: () => {
|
|
30
|
-
snapshot: string;
|
|
31
|
-
};
|
|
32
|
-
getClickEventsSnapshot: () => {
|
|
33
|
-
snapshot: string;
|
|
34
|
-
};
|
|
35
|
-
clearEventCalls: () => void;
|
|
36
|
-
getEvents: (type?: string | undefined) => Event[];
|
|
37
|
-
eventWasFired: (eventType: string) => boolean;
|
|
38
|
-
};
|
|
39
|
-
declare function setupListbox(): {
|
|
40
|
-
listbox: HTMLUListElement;
|
|
41
|
-
options: HTMLElement[];
|
|
42
|
-
getEventSnapshot: () => {
|
|
43
|
-
snapshot: string;
|
|
44
|
-
};
|
|
45
|
-
getClickEventsSnapshot: () => {
|
|
46
|
-
snapshot: string;
|
|
47
|
-
};
|
|
48
|
-
clearEventCalls: () => void;
|
|
49
|
-
getEvents: (type?: string | undefined) => Event[];
|
|
50
|
-
eventWasFired: (eventType: string) => boolean;
|
|
51
|
-
};
|
|
52
|
-
declare function addEventListener(el: EventTarget, type: string, listener: EventListener, options?: AddEventListenerOptions): void;
|
|
53
|
-
declare type TestData = {
|
|
54
|
-
handled?: boolean;
|
|
55
|
-
before?: Element;
|
|
56
|
-
after?: Element;
|
|
57
|
-
};
|
|
58
|
-
declare function addListeners(element: Element & {
|
|
59
|
-
testData?: TestData;
|
|
60
|
-
}, { eventHandlers, }?: {
|
|
61
|
-
eventHandlers?: EventHandlers;
|
|
62
|
-
}): {
|
|
63
|
-
getEventSnapshot: () => {
|
|
64
|
-
snapshot: string;
|
|
65
|
-
};
|
|
66
|
-
getClickEventsSnapshot: () => {
|
|
67
|
-
snapshot: string;
|
|
68
|
-
};
|
|
69
|
-
clearEventCalls: () => void;
|
|
70
|
-
getEvents: (type?: string | undefined) => Event[];
|
|
71
|
-
eventWasFired: (eventType: string) => boolean;
|
|
72
|
-
};
|
|
73
|
-
export { setup, setupSelect, setupListbox, addEventListener, addListeners };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tests/clear.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tests/paste.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tests/setup.d.ts
DELETED
package/dist/tests/tab.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/tests/upload.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isCursorAtEnd = isCursorAtEnd;
|
|
7
|
-
exports.isCursorAtStart = isCursorAtStart;
|
|
8
|
-
|
|
9
|
-
var _selectionRange = require("./selectionRange");
|
|
10
|
-
|
|
11
|
-
var _getValue2 = require("./getValue");
|
|
12
|
-
|
|
13
|
-
function isCursorAtEnd(element) {
|
|
14
|
-
var _getValue;
|
|
15
|
-
|
|
16
|
-
const {
|
|
17
|
-
selectionStart,
|
|
18
|
-
selectionEnd
|
|
19
|
-
} = (0, _selectionRange.getSelectionRange)(element);
|
|
20
|
-
return selectionStart === selectionEnd && (selectionStart != null ? selectionStart :
|
|
21
|
-
/* istanbul ignore next */
|
|
22
|
-
0) === ((_getValue = (0, _getValue2.getValue)(element)) != null ? _getValue :
|
|
23
|
-
/* istanbul ignore next */
|
|
24
|
-
'').length;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function isCursorAtStart(element) {
|
|
28
|
-
const {
|
|
29
|
-
selectionStart,
|
|
30
|
-
selectionEnd
|
|
31
|
-
} = (0, _selectionRange.getSelectionRange)(element);
|
|
32
|
-
return selectionStart === selectionEnd && (selectionStart != null ? selectionStart :
|
|
33
|
-
/* istanbul ignore next */
|
|
34
|
-
0) === 0;
|
|
35
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fireInputEvent = fireInputEvent;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _isElementType = require("../misc/isElementType");
|
|
11
|
-
|
|
12
|
-
var _document = require("../../document");
|
|
13
|
-
|
|
14
|
-
var _isContentEditable = require("./isContentEditable");
|
|
15
|
-
|
|
16
|
-
var _selectionRange = require("./selectionRange");
|
|
17
|
-
|
|
18
|
-
function fireInputEvent(element, {
|
|
19
|
-
newValue,
|
|
20
|
-
newSelectionStart,
|
|
21
|
-
eventOverrides
|
|
22
|
-
}) {
|
|
23
|
-
// apply the changes before firing the input event, so that input handlers can access the altered dom and selection
|
|
24
|
-
if ((0, _isContentEditable.isContentEditable)(element)) {
|
|
25
|
-
(0, _document.applyNative)(element, 'textContent', newValue);
|
|
26
|
-
} else
|
|
27
|
-
/* istanbul ignore else */
|
|
28
|
-
if ((0, _isElementType.isElementType)(element, ['input', 'textarea'])) {
|
|
29
|
-
(0, _document.setUIValue)(element, newValue);
|
|
30
|
-
} else {
|
|
31
|
-
// TODO: properly type guard
|
|
32
|
-
throw new Error('Invalid Element');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
setSelectionRangeAfterInput(element, newSelectionStart);
|
|
36
|
-
|
|
37
|
-
_dom.fireEvent.input(element, { ...eventOverrides
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
setSelectionRangeAfterInputHandler(element, newSelectionStart);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function setSelectionRangeAfterInput(element, newSelectionStart) {
|
|
44
|
-
(0, _selectionRange.setSelectionRange)(element, newSelectionStart, newSelectionStart);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function setSelectionRangeAfterInputHandler(element, newSelectionStart) {
|
|
48
|
-
// On controlled inputs the selection changes without a call to
|
|
49
|
-
// either the `value` setter or the `setSelectionRange` method.
|
|
50
|
-
// So if our tracked position for UI still exists and derives from a valid selectionStart,
|
|
51
|
-
// the cursor was moved due to an input being controlled.
|
|
52
|
-
if ((0, _isElementType.isElementType)(element, ['input', 'textarea']) && typeof element.selectionStart === 'number' && element.selectionStart !== newSelectionStart && (0, _document.hasUISelection)(element)) {
|
|
53
|
-
(0, _selectionRange.setSelectionRange)(element, newSelectionStart, newSelectionStart);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getSelectionRange = getSelectionRange;
|
|
7
|
-
exports.setSelectionRange = setSelectionRange;
|
|
8
|
-
|
|
9
|
-
var _isElementType = require("../misc/isElementType");
|
|
10
|
-
|
|
11
|
-
var _document = require("../../document");
|
|
12
|
-
|
|
13
|
-
function getSelectionRange(element) {
|
|
14
|
-
if ((0, _isElementType.isElementType)(element, ['input', 'textarea'])) {
|
|
15
|
-
return (0, _document.getUISelection)(element);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const selection = element.ownerDocument.getSelection(); // there should be no editing if the focusNode is outside of element
|
|
19
|
-
// TODO: properly handle selection ranges
|
|
20
|
-
|
|
21
|
-
if (selection != null && selection.rangeCount && element.contains(selection.focusNode)) {
|
|
22
|
-
const range = selection.getRangeAt(0);
|
|
23
|
-
return {
|
|
24
|
-
selectionStart: range.startOffset,
|
|
25
|
-
selectionEnd: range.endOffset
|
|
26
|
-
};
|
|
27
|
-
} else {
|
|
28
|
-
return {
|
|
29
|
-
selectionStart: null,
|
|
30
|
-
selectionEnd: null
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function setSelectionRange(element, newSelectionStart, newSelectionEnd) {
|
|
36
|
-
if ((0, _isElementType.isElementType)(element, ['input', 'textarea'])) {
|
|
37
|
-
return (0, _document.setUISelection)(element, newSelectionStart, newSelectionEnd);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
selectionStart,
|
|
42
|
-
selectionEnd
|
|
43
|
-
} = getSelectionRange(element); // Prevent unnecessary select events
|
|
44
|
-
// istanbul ignore next
|
|
45
|
-
|
|
46
|
-
if (selectionStart === newSelectionStart && selectionEnd === newSelectionEnd) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const range = element.ownerDocument.createRange();
|
|
51
|
-
range.selectNodeContents(element); // istanbul ignore else
|
|
52
|
-
|
|
53
|
-
if (element.firstChild) {
|
|
54
|
-
range.setStart(element.firstChild, newSelectionStart);
|
|
55
|
-
range.setEnd(element.firstChild, newSelectionEnd);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const selection = element.ownerDocument.getSelection(); // istanbul ignore else
|
|
59
|
-
|
|
60
|
-
if (selection) {
|
|
61
|
-
selection.removeAllRanges();
|
|
62
|
-
selection.addRange(range);
|
|
63
|
-
}
|
|
64
|
-
}
|