@testing-library/user-event 14.5.0 → 14.5.2
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 +0 -3
- package/dist/cjs/clipboard/cut.js +0 -3
- package/dist/cjs/clipboard/index.js +0 -2
- package/dist/cjs/clipboard/paste.js +0 -2
- package/dist/cjs/convenience/click.js +0 -2
- package/dist/cjs/convenience/hover.js +0 -3
- package/dist/cjs/convenience/index.js +0 -2
- package/dist/cjs/convenience/tab.js +0 -2
- package/dist/cjs/document/UI.js +0 -2
- package/dist/cjs/document/copySelection.js +0 -2
- package/dist/cjs/document/getValueOrTextContent.js +0 -3
- package/dist/cjs/document/index.js +0 -2
- package/dist/cjs/document/interceptor.js +3 -8
- package/dist/cjs/document/prepareDocument.js +0 -3
- package/dist/cjs/document/trackValue.js +2 -4
- package/dist/cjs/event/behavior/cut.js +0 -1
- package/dist/cjs/event/behavior/index.js +0 -2
- package/dist/cjs/event/behavior/keydown.js +2 -3
- package/dist/cjs/event/behavior/keypress.js +1 -3
- package/dist/cjs/event/behavior/keyup.js +2 -3
- package/dist/cjs/event/behavior/paste.js +0 -1
- package/dist/cjs/event/behavior/registry.js +0 -2
- package/dist/cjs/event/createEvent.js +3 -5
- package/dist/cjs/event/dispatchEvent.js +2 -4
- package/dist/cjs/event/eventMap.js +200 -15
- package/dist/cjs/event/focus.js +1 -7
- package/dist/cjs/event/index.js +0 -3
- package/dist/cjs/event/input.js +0 -3
- package/dist/cjs/event/radio.js +0 -2
- package/dist/cjs/event/selection/getInputRange.js +0 -2
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +2 -6
- package/dist/cjs/event/selection/index.js +0 -2
- package/dist/cjs/event/selection/modifySelection.js +0 -3
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +2 -6
- package/dist/cjs/event/selection/moveSelection.js +1 -5
- package/dist/cjs/event/selection/resolveCaretPosition.js +0 -3
- package/dist/cjs/event/selection/selectAll.js +1 -5
- package/dist/cjs/event/selection/setSelection.js +0 -3
- package/dist/cjs/event/selection/setSelectionPerMouse.js +2 -6
- package/dist/cjs/event/selection/setSelectionRange.js +0 -3
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +1 -5
- package/dist/cjs/event/wrapEvent.js +2 -5
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/keyboard/index.js +0 -3
- package/dist/cjs/keyboard/keyMap.js +0 -2
- package/dist/cjs/keyboard/parseKeyDef.js +0 -3
- package/dist/cjs/options.js +5 -7
- package/dist/cjs/pointer/index.js +4 -7
- package/dist/cjs/pointer/keyMap.js +0 -2
- package/dist/cjs/pointer/parseKeyDef.js +0 -3
- package/dist/cjs/setup/api.js +0 -2
- package/dist/cjs/setup/directApi.js +0 -2
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +0 -3
- package/dist/cjs/setup/wrapAsync.js +2 -5
- package/dist/cjs/system/index.js +0 -2
- package/dist/cjs/system/keyboard.js +0 -3
- package/dist/cjs/system/pointer/buttons.js +0 -2
- package/dist/cjs/system/pointer/device.js +0 -2
- package/dist/cjs/system/pointer/index.js +12 -17
- package/dist/cjs/system/pointer/mouse.js +0 -4
- package/dist/cjs/system/pointer/pointer.js +0 -3
- package/dist/cjs/system/pointer/shared.js +0 -2
- package/dist/cjs/utility/clear.js +0 -4
- package/dist/cjs/utility/index.js +0 -2
- package/dist/cjs/utility/selectOptions.js +5 -10
- package/dist/cjs/utility/type.js +0 -3
- package/dist/cjs/utility/upload.js +1 -4
- package/dist/cjs/utils/click/isClickableInput.js +8 -10
- package/dist/cjs/utils/dataTransfer/Blob.js +0 -2
- package/dist/cjs/utils/dataTransfer/Clipboard.js +2 -6
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +1 -4
- package/dist/cjs/utils/dataTransfer/FileList.js +0 -2
- package/dist/cjs/utils/edit/isContentEditable.js +0 -2
- package/dist/cjs/utils/edit/isEditable.js +12 -14
- package/dist/cjs/utils/edit/maxLength.js +6 -8
- package/dist/cjs/utils/edit/setFiles.js +2 -4
- package/dist/cjs/utils/edit/timeValue.js +0 -2
- package/dist/cjs/utils/focus/cursor.js +0 -2
- package/dist/cjs/utils/focus/getActiveElement.js +1 -4
- package/dist/cjs/utils/focus/getTabDestination.js +0 -2
- package/dist/cjs/utils/focus/isFocusable.js +0 -2
- package/dist/cjs/utils/focus/selection.js +0 -2
- package/dist/cjs/utils/focus/selector.js +0 -2
- package/dist/cjs/utils/index.js +1 -3
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +2 -4
- package/dist/cjs/utils/misc/cloneEvent.js +0 -2
- package/dist/cjs/utils/misc/findClosest.js +0 -2
- package/dist/cjs/utils/misc/getDocumentFromNode.js +0 -2
- package/dist/cjs/utils/misc/getTreeDiff.js +0 -2
- package/dist/cjs/utils/misc/getWindow.js +13 -6
- package/dist/cjs/utils/misc/isDescendantOrSelf.js +0 -2
- package/dist/cjs/utils/misc/isDisabled.js +0 -2
- package/dist/cjs/utils/misc/isElementType.js +0 -2
- package/dist/cjs/utils/misc/isVisible.js +1 -4
- package/dist/cjs/utils/misc/level.js +0 -2
- package/dist/cjs/utils/misc/wait.js +0 -2
- package/dist/cjs/utils/pointer/cssPointerEvents.js +7 -13
- package/dist/esm/clipboard/copy.js +0 -1
- package/dist/esm/clipboard/cut.js +0 -1
- package/dist/esm/convenience/hover.js +0 -1
- package/dist/esm/document/getValueOrTextContent.js +0 -1
- package/dist/esm/document/interceptor.js +3 -6
- package/dist/esm/document/prepareDocument.js +0 -1
- package/dist/esm/document/trackValue.js +2 -2
- package/dist/esm/event/behavior/cut.js +0 -1
- package/dist/esm/event/behavior/keydown.js +2 -3
- package/dist/esm/event/behavior/keypress.js +1 -3
- package/dist/esm/event/behavior/keyup.js +2 -3
- package/dist/esm/event/behavior/paste.js +0 -1
- package/dist/esm/event/createEvent.js +4 -4
- package/dist/esm/event/dispatchEvent.js +2 -2
- package/dist/esm/event/eventMap.js +201 -13
- package/dist/esm/event/focus.js +1 -5
- package/dist/esm/event/index.js +0 -1
- package/dist/esm/event/input.js +0 -1
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +2 -4
- package/dist/esm/event/selection/modifySelection.js +0 -1
- package/dist/esm/event/selection/modifySelectionPerMouse.js +2 -4
- package/dist/esm/event/selection/moveSelection.js +1 -3
- package/dist/esm/event/selection/resolveCaretPosition.js +0 -1
- package/dist/esm/event/selection/selectAll.js +1 -3
- package/dist/esm/event/selection/setSelection.js +0 -1
- package/dist/esm/event/selection/setSelectionPerMouse.js +2 -4
- package/dist/esm/event/selection/setSelectionRange.js +0 -1
- package/dist/esm/event/selection/updateSelectionOnFocus.js +1 -3
- package/dist/esm/event/wrapEvent.js +1 -2
- package/dist/esm/keyboard/index.js +0 -1
- package/dist/esm/keyboard/parseKeyDef.js +0 -1
- package/dist/esm/options.js +5 -5
- package/dist/esm/pointer/index.js +4 -5
- package/dist/esm/pointer/parseKeyDef.js +0 -1
- package/dist/esm/setup/setup.js +0 -1
- package/dist/esm/setup/wrapAsync.js +1 -2
- package/dist/esm/system/keyboard.js +0 -1
- package/dist/esm/system/pointer/index.js +12 -15
- package/dist/esm/system/pointer/mouse.js +0 -2
- package/dist/esm/system/pointer/pointer.js +0 -1
- package/dist/esm/utility/clear.js +0 -2
- package/dist/esm/utility/selectOptions.js +1 -4
- package/dist/esm/utility/type.js +0 -1
- package/dist/esm/utility/upload.js +1 -2
- package/dist/esm/utils/click/isClickableInput.js +8 -8
- package/dist/esm/utils/dataTransfer/Clipboard.js +2 -4
- package/dist/esm/utils/dataTransfer/DataTransfer.js +1 -2
- package/dist/esm/utils/edit/isEditable.js +12 -12
- package/dist/esm/utils/edit/maxLength.js +6 -6
- package/dist/esm/utils/edit/setFiles.js +2 -2
- package/dist/esm/utils/focus/getActiveElement.js +1 -2
- package/dist/esm/utils/keyDef/readNextDescriptor.js +2 -2
- package/dist/esm/utils/misc/getWindow.js +13 -4
- package/dist/esm/utils/misc/isVisible.js +1 -2
- package/dist/esm/utils/pointer/cssPointerEvents.js +7 -11
- package/dist/types/event/eventMap.d.ts +174 -333
- package/dist/types/event/types.d.ts +2 -1
- package/package.json +15 -4
- package/dist/cjs/_interop/dom-events.d.js +0 -2
- package/dist/cjs/_interop/dom-helpers.d.js +0 -2
- package/dist/cjs/_interop/dtl.js +0 -30
- package/dist/cjs/_interop/dtlEventMap.js +0 -30
- package/dist/cjs/_interop/dtlHelpers.js +0 -30
- package/dist/esm/_interop/dom-events.d.js +0 -1
- package/dist/esm/_interop/dom-helpers.d.js +0 -1
- package/dist/esm/_interop/dtl.js +0 -6
- package/dist/esm/_interop/dtlEventMap.js +0 -6
- package/dist/esm/_interop/dtlHelpers.js +0 -6
- package/dist/types/_interop/dtl.d.ts +0 -3
- package/dist/types/_interop/dtlEventMap.d.ts +0 -3
- package/dist/types/_interop/dtlHelpers.d.ts +0 -3
|
@@ -2,7 +2,6 @@ import '../utils/click/isClickableInput.js';
|
|
|
2
2
|
import { writeDataTransferToClipboard } from '../utils/dataTransfer/Clipboard.js';
|
|
3
3
|
import '../utils/edit/isEditable.js';
|
|
4
4
|
import '../utils/edit/maxLength.js';
|
|
5
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
6
5
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
7
6
|
import '../utils/misc/level.js';
|
|
8
7
|
import '../options.js';
|
|
@@ -2,7 +2,6 @@ import '../utils/click/isClickableInput.js';
|
|
|
2
2
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
3
|
import '../utils/edit/isEditable.js';
|
|
4
4
|
import '../utils/edit/maxLength.js';
|
|
5
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
6
5
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
7
6
|
import '../utils/misc/level.js';
|
|
8
7
|
import { assertPointerEvents } from '../utils/pointer/cssPointerEvents.js';
|
|
@@ -3,7 +3,6 @@ import '../utils/dataTransfer/Clipboard.js';
|
|
|
3
3
|
import { isContentEditable } from '../utils/edit/isContentEditable.js';
|
|
4
4
|
import '../utils/edit/isEditable.js';
|
|
5
5
|
import '../utils/edit/maxLength.js';
|
|
6
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
7
6
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
8
7
|
import '../utils/misc/level.js';
|
|
9
8
|
import '../options.js';
|
|
@@ -3,7 +3,6 @@ import '../utils/dataTransfer/Clipboard.js';
|
|
|
3
3
|
import '../utils/edit/isEditable.js';
|
|
4
4
|
import '../utils/edit/maxLength.js';
|
|
5
5
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
6
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
7
6
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
8
7
|
import '../utils/misc/level.js';
|
|
9
8
|
import '../options.js';
|
|
@@ -12,15 +11,13 @@ import { setUISelectionClean, setUISelectionRaw, getUIValue, setUIValueClean, is
|
|
|
12
11
|
|
|
13
12
|
const Interceptor = Symbol('Interceptor for programmatical calls');
|
|
14
13
|
function prepareInterceptor(element, propName, interceptorImpl) {
|
|
15
|
-
var _prototypeDescriptor, _prototypeDescriptor1;
|
|
16
14
|
const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
|
|
17
15
|
const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
|
|
18
|
-
const target = (
|
|
19
|
-
/* istanbul ignore if */ if (typeof (
|
|
16
|
+
const target = (prototypeDescriptor === null || prototypeDescriptor === void 0 ? void 0 : prototypeDescriptor.set) ? 'set' : 'value';
|
|
17
|
+
/* istanbul ignore if */ if (typeof (prototypeDescriptor === null || prototypeDescriptor === void 0 ? void 0 : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
|
|
20
18
|
throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`);
|
|
21
19
|
}
|
|
22
20
|
function intercept(...args) {
|
|
23
|
-
var _then;
|
|
24
21
|
const { applyNative = false, realArgs, then } = interceptorImpl.call(this, ...args);
|
|
25
22
|
const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];
|
|
26
23
|
if (target === 'set') {
|
|
@@ -28,7 +25,7 @@ function prepareInterceptor(element, propName, interceptorImpl) {
|
|
|
28
25
|
} else {
|
|
29
26
|
realFunc.call(this, ...realArgs);
|
|
30
27
|
}
|
|
31
|
-
|
|
28
|
+
then === null || then === void 0 ? void 0 : then();
|
|
32
29
|
}
|
|
33
30
|
intercept[Interceptor] = Interceptor;
|
|
34
31
|
Object.defineProperty(element, propName, {
|
|
@@ -4,7 +4,6 @@ import '../utils/dataTransfer/Clipboard.js';
|
|
|
4
4
|
import '../utils/edit/isEditable.js';
|
|
5
5
|
import '../utils/edit/maxLength.js';
|
|
6
6
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
7
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
8
7
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
9
8
|
import '../utils/misc/level.js';
|
|
10
9
|
import '../options.js';
|
|
@@ -39,10 +39,10 @@ function trackOrSetValue(element, v) {
|
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
function commitValueAfterInput(element, cursorOffset) {
|
|
42
|
-
var _changes_tracked
|
|
42
|
+
var _changes_tracked;
|
|
43
43
|
const changes = element[TrackChanges];
|
|
44
44
|
element[TrackChanges] = undefined;
|
|
45
|
-
if (!(
|
|
45
|
+
if (!(changes === null || changes === void 0 ? void 0 : (_changes_tracked = changes.tracked) === null || _changes_tracked === void 0 ? void 0 : _changes_tracked.length)) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
48
|
const isJustReactStateUpdate = changes.tracked.length === 2 && changes.tracked[0] === changes.previousValue && changes.tracked[1] === element.value;
|
|
@@ -2,7 +2,6 @@ import '../../utils/click/isClickableInput.js';
|
|
|
2
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
3
|
import { isEditable } from '../../utils/edit/isEditable.js';
|
|
4
4
|
import '../../utils/edit/maxLength.js';
|
|
5
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
6
5
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
7
6
|
import '../../utils/misc/level.js';
|
|
8
7
|
import '../../options.js';
|
|
@@ -9,7 +9,6 @@ import { isElementType } from '../../utils/misc/isElementType.js';
|
|
|
9
9
|
import { getTabDestination } from '../../utils/focus/getTabDestination.js';
|
|
10
10
|
import { hasOwnSelection } from '../../utils/focus/selection.js';
|
|
11
11
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
12
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
13
12
|
import '../../utils/misc/level.js';
|
|
14
13
|
import '../../options.js';
|
|
15
14
|
import { focusElement } from '../focus.js';
|
|
@@ -21,9 +20,9 @@ import { walkRadio } from '../radio.js';
|
|
|
21
20
|
import { behavior } from './registry.js';
|
|
22
21
|
|
|
23
22
|
behavior.keydown = (event, target, instance)=>{
|
|
24
|
-
var _keydownBehavior_event_key
|
|
23
|
+
var _keydownBehavior_event_key;
|
|
25
24
|
var _keydownBehavior_event_key1;
|
|
26
|
-
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key =
|
|
25
|
+
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = keydownBehavior[event.key]) === null || _keydownBehavior_event_key === void 0 ? void 0 : _keydownBehavior_event_key.call(keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== void 0 ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance);
|
|
27
26
|
};
|
|
28
27
|
const keydownBehavior = {
|
|
29
28
|
ArrowDown: (event, target, instance)=>{
|
|
@@ -4,7 +4,6 @@ import { isContentEditable } from '../../utils/edit/isContentEditable.js';
|
|
|
4
4
|
import { isEditable } from '../../utils/edit/isEditable.js';
|
|
5
5
|
import '../../utils/edit/maxLength.js';
|
|
6
6
|
import { isElementType } from '../../utils/misc/isElementType.js';
|
|
7
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
8
7
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
9
8
|
import '../../utils/misc/level.js';
|
|
10
9
|
import '../../options.js';
|
|
@@ -18,9 +17,8 @@ behavior.keypress = (event, target, instance)=>{
|
|
|
18
17
|
instance.dispatchUIEvent(target, 'click');
|
|
19
18
|
};
|
|
20
19
|
} else if (isElementType(target, 'input')) {
|
|
21
|
-
var _form;
|
|
22
20
|
const form = target.form;
|
|
23
|
-
const submit =
|
|
21
|
+
const submit = form === null || form === void 0 ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
|
|
24
22
|
if (submit) {
|
|
25
23
|
return ()=>instance.dispatchUIEvent(submit, 'click');
|
|
26
24
|
} else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll('input').length === 1) {
|
|
@@ -2,15 +2,14 @@ import { isClickableInput } from '../../utils/click/isClickableInput.js';
|
|
|
2
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
3
|
import '../../utils/edit/isEditable.js';
|
|
4
4
|
import '../../utils/edit/maxLength.js';
|
|
5
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
6
5
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
7
6
|
import '../../utils/misc/level.js';
|
|
8
7
|
import '../../options.js';
|
|
9
8
|
import { behavior } from './registry.js';
|
|
10
9
|
|
|
11
10
|
behavior.keyup = (event, target, instance)=>{
|
|
12
|
-
var _keyupBehavior_event_key
|
|
13
|
-
return (_keyupBehavior_event_key =
|
|
11
|
+
var _keyupBehavior_event_key;
|
|
12
|
+
return (_keyupBehavior_event_key = keyupBehavior[event.key]) === null || _keyupBehavior_event_key === void 0 ? void 0 : _keyupBehavior_event_key.call(keyupBehavior, event, target, instance);
|
|
14
13
|
};
|
|
15
14
|
const keyupBehavior = {
|
|
16
15
|
' ': (event, target, instance)=>{
|
|
@@ -2,7 +2,6 @@ import '../../utils/click/isClickableInput.js';
|
|
|
2
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
3
|
import { isEditable } from '../../utils/edit/isEditable.js';
|
|
4
4
|
import '../../utils/edit/maxLength.js';
|
|
5
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
6
5
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
7
6
|
import '../../utils/misc/level.js';
|
|
8
7
|
import '../../options.js';
|
|
@@ -6,12 +6,13 @@ import { getWindow } from '../utils/misc/getWindow.js';
|
|
|
6
6
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
7
7
|
import '../utils/misc/level.js';
|
|
8
8
|
import '../options.js';
|
|
9
|
-
import { eventMap
|
|
9
|
+
import { eventMap } from './eventMap.js';
|
|
10
10
|
|
|
11
11
|
const eventInitializer = {
|
|
12
12
|
ClipboardEvent: [
|
|
13
13
|
initClipboardEvent
|
|
14
14
|
],
|
|
15
|
+
Event: [],
|
|
15
16
|
InputEvent: [
|
|
16
17
|
initUIEvent,
|
|
17
18
|
initInputEvent
|
|
@@ -34,11 +35,10 @@ const eventInitializer = {
|
|
|
34
35
|
]
|
|
35
36
|
};
|
|
36
37
|
function createEvent(type, target, init) {
|
|
37
|
-
var _eventInitializer_EventType;
|
|
38
38
|
const window = getWindow(target);
|
|
39
|
-
const { EventType, defaultInit } = eventMap[
|
|
39
|
+
const { EventType, defaultInit } = eventMap[type];
|
|
40
40
|
const event = new (getEventConstructors(window))[EventType](type, defaultInit);
|
|
41
|
-
|
|
41
|
+
eventInitializer[EventType].forEach((f)=>f(event, init !== null && init !== void 0 ? init : {}));
|
|
42
42
|
return event;
|
|
43
43
|
}
|
|
44
44
|
/* istanbul ignore next */ function getEventConstructors(window) {
|
|
@@ -20,9 +20,9 @@ function dispatchUIEvent(target, type, init, preventDefault = false) {
|
|
|
20
20
|
return dispatchEvent.call(this, target, event, preventDefault);
|
|
21
21
|
}
|
|
22
22
|
function dispatchEvent(target, event, preventDefault = false) {
|
|
23
|
-
var _behavior_type
|
|
23
|
+
var _behavior_type;
|
|
24
24
|
const type = event.type;
|
|
25
|
-
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type =
|
|
25
|
+
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = behavior[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(behavior, event, target, this);
|
|
26
26
|
if (behaviorImplementation) {
|
|
27
27
|
event.preventDefault();
|
|
28
28
|
let defaultPrevented = false;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import dtlEvents from '../_interop/dtlEventMap.js';
|
|
2
|
-
|
|
3
1
|
const eventMap = {
|
|
4
|
-
|
|
5
|
-
click: {
|
|
2
|
+
auxclick: {
|
|
6
3
|
EventType: 'PointerEvent',
|
|
7
4
|
defaultInit: {
|
|
8
5
|
bubbles: true,
|
|
@@ -10,7 +7,15 @@ const eventMap = {
|
|
|
10
7
|
composed: true
|
|
11
8
|
}
|
|
12
9
|
},
|
|
13
|
-
|
|
10
|
+
beforeinput: {
|
|
11
|
+
EventType: 'InputEvent',
|
|
12
|
+
defaultInit: {
|
|
13
|
+
bubbles: true,
|
|
14
|
+
cancelable: true,
|
|
15
|
+
composed: true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
click: {
|
|
14
19
|
EventType: 'PointerEvent',
|
|
15
20
|
defaultInit: {
|
|
16
21
|
bubbles: true,
|
|
@@ -26,22 +31,205 @@ const eventMap = {
|
|
|
26
31
|
composed: true
|
|
27
32
|
}
|
|
28
33
|
},
|
|
29
|
-
|
|
34
|
+
copy: {
|
|
35
|
+
EventType: 'ClipboardEvent',
|
|
36
|
+
defaultInit: {
|
|
37
|
+
bubbles: true,
|
|
38
|
+
cancelable: true,
|
|
39
|
+
composed: true
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
change: {
|
|
43
|
+
EventType: 'Event',
|
|
44
|
+
defaultInit: {
|
|
45
|
+
bubbles: true,
|
|
46
|
+
cancelable: false
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
cut: {
|
|
50
|
+
EventType: 'ClipboardEvent',
|
|
51
|
+
defaultInit: {
|
|
52
|
+
bubbles: true,
|
|
53
|
+
cancelable: true,
|
|
54
|
+
composed: true
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
dblclick: {
|
|
58
|
+
EventType: 'MouseEvent',
|
|
59
|
+
defaultInit: {
|
|
60
|
+
bubbles: true,
|
|
61
|
+
cancelable: true,
|
|
62
|
+
composed: true
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
keydown: {
|
|
66
|
+
EventType: 'KeyboardEvent',
|
|
67
|
+
defaultInit: {
|
|
68
|
+
bubbles: true,
|
|
69
|
+
cancelable: true,
|
|
70
|
+
composed: true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
keypress: {
|
|
74
|
+
EventType: 'KeyboardEvent',
|
|
75
|
+
defaultInit: {
|
|
76
|
+
bubbles: true,
|
|
77
|
+
cancelable: true,
|
|
78
|
+
composed: true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
keyup: {
|
|
82
|
+
EventType: 'KeyboardEvent',
|
|
83
|
+
defaultInit: {
|
|
84
|
+
bubbles: true,
|
|
85
|
+
cancelable: true,
|
|
86
|
+
composed: true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
paste: {
|
|
90
|
+
EventType: 'ClipboardEvent',
|
|
91
|
+
defaultInit: {
|
|
92
|
+
bubbles: true,
|
|
93
|
+
cancelable: true,
|
|
94
|
+
composed: true
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
input: {
|
|
30
98
|
EventType: 'InputEvent',
|
|
99
|
+
defaultInit: {
|
|
100
|
+
bubbles: true,
|
|
101
|
+
cancelable: false,
|
|
102
|
+
composed: true
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
mousedown: {
|
|
106
|
+
EventType: 'MouseEvent',
|
|
107
|
+
defaultInit: {
|
|
108
|
+
bubbles: true,
|
|
109
|
+
cancelable: true,
|
|
110
|
+
composed: true
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
mouseenter: {
|
|
114
|
+
EventType: 'MouseEvent',
|
|
115
|
+
defaultInit: {
|
|
116
|
+
bubbles: false,
|
|
117
|
+
cancelable: false,
|
|
118
|
+
composed: true
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
mouseleave: {
|
|
122
|
+
EventType: 'MouseEvent',
|
|
123
|
+
defaultInit: {
|
|
124
|
+
bubbles: false,
|
|
125
|
+
cancelable: false,
|
|
126
|
+
composed: true
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
mousemove: {
|
|
130
|
+
EventType: 'MouseEvent',
|
|
131
|
+
defaultInit: {
|
|
132
|
+
bubbles: true,
|
|
133
|
+
cancelable: true,
|
|
134
|
+
composed: true
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
mouseout: {
|
|
138
|
+
EventType: 'MouseEvent',
|
|
139
|
+
defaultInit: {
|
|
140
|
+
bubbles: true,
|
|
141
|
+
cancelable: true,
|
|
142
|
+
composed: true
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
mouseover: {
|
|
146
|
+
EventType: 'MouseEvent',
|
|
147
|
+
defaultInit: {
|
|
148
|
+
bubbles: true,
|
|
149
|
+
cancelable: true,
|
|
150
|
+
composed: true
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
mouseup: {
|
|
154
|
+
EventType: 'MouseEvent',
|
|
155
|
+
defaultInit: {
|
|
156
|
+
bubbles: true,
|
|
157
|
+
cancelable: true,
|
|
158
|
+
composed: true
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
pointerover: {
|
|
162
|
+
EventType: 'PointerEvent',
|
|
163
|
+
defaultInit: {
|
|
164
|
+
bubbles: true,
|
|
165
|
+
cancelable: true,
|
|
166
|
+
composed: true
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
pointerenter: {
|
|
170
|
+
EventType: 'PointerEvent',
|
|
171
|
+
defaultInit: {
|
|
172
|
+
bubbles: false,
|
|
173
|
+
cancelable: false
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
pointerdown: {
|
|
177
|
+
EventType: 'PointerEvent',
|
|
178
|
+
defaultInit: {
|
|
179
|
+
bubbles: true,
|
|
180
|
+
cancelable: true,
|
|
181
|
+
composed: true
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
pointermove: {
|
|
185
|
+
EventType: 'PointerEvent',
|
|
31
186
|
defaultInit: {
|
|
32
187
|
bubbles: true,
|
|
33
188
|
cancelable: true,
|
|
34
189
|
composed: true
|
|
35
190
|
}
|
|
191
|
+
},
|
|
192
|
+
pointerup: {
|
|
193
|
+
EventType: 'PointerEvent',
|
|
194
|
+
defaultInit: {
|
|
195
|
+
bubbles: true,
|
|
196
|
+
cancelable: true,
|
|
197
|
+
composed: true
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
pointercancel: {
|
|
201
|
+
EventType: 'PointerEvent',
|
|
202
|
+
defaultInit: {
|
|
203
|
+
bubbles: true,
|
|
204
|
+
cancelable: false,
|
|
205
|
+
composed: true
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
pointerout: {
|
|
209
|
+
EventType: 'PointerEvent',
|
|
210
|
+
defaultInit: {
|
|
211
|
+
bubbles: true,
|
|
212
|
+
cancelable: true,
|
|
213
|
+
composed: true
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
pointerleave: {
|
|
217
|
+
EventType: 'PointerEvent',
|
|
218
|
+
defaultInit: {
|
|
219
|
+
bubbles: false,
|
|
220
|
+
cancelable: false
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
submit: {
|
|
224
|
+
EventType: 'Event',
|
|
225
|
+
defaultInit: {
|
|
226
|
+
bubbles: true,
|
|
227
|
+
cancelable: true
|
|
228
|
+
}
|
|
36
229
|
}
|
|
37
230
|
};
|
|
38
|
-
const eventMapKeys = Object.fromEntries(Object.keys(eventMap).map((k)=>[
|
|
39
|
-
k.toLowerCase(),
|
|
40
|
-
k
|
|
41
|
-
]));
|
|
42
231
|
function getEventClass(type) {
|
|
43
|
-
|
|
44
|
-
return k && eventMap[k].EventType;
|
|
232
|
+
return eventMap[type].EventType;
|
|
45
233
|
}
|
|
46
234
|
const mouseEvents = [
|
|
47
235
|
'MouseEvent',
|
|
@@ -54,4 +242,4 @@ function isKeyboardEvent(type) {
|
|
|
54
242
|
return getEventClass(type) === 'KeyboardEvent';
|
|
55
243
|
}
|
|
56
244
|
|
|
57
|
-
export { eventMap,
|
|
245
|
+
export { eventMap, isKeyboardEvent, isMouseEvent };
|
package/dist/esm/event/focus.js
CHANGED
|
@@ -3,7 +3,6 @@ import '../utils/dataTransfer/Clipboard.js';
|
|
|
3
3
|
import '../utils/edit/isEditable.js';
|
|
4
4
|
import '../utils/edit/maxLength.js';
|
|
5
5
|
import { getActiveElement } from '../utils/focus/getActiveElement.js';
|
|
6
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
7
6
|
import { isFocusable } from '../utils/focus/isFocusable.js';
|
|
8
7
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
9
8
|
import { findClosest } from '../utils/misc/findClosest.js';
|
|
@@ -22,10 +21,7 @@ import { wrapEvent } from './wrapEvent.js';
|
|
|
22
21
|
} else if (target) {
|
|
23
22
|
wrapEvent(()=>target.focus());
|
|
24
23
|
} else {
|
|
25
|
-
wrapEvent(()=>
|
|
26
|
-
var _activeElement;
|
|
27
|
-
return (_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.blur();
|
|
28
|
-
});
|
|
24
|
+
wrapEvent(()=>activeElement === null || activeElement === void 0 ? void 0 : activeElement.blur());
|
|
29
25
|
}
|
|
30
26
|
updateSelectionOnFocus(target !== null && target !== void 0 ? target : element.ownerDocument.body);
|
|
31
27
|
}
|
package/dist/esm/event/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import '../utils/click/isClickableInput.js';
|
|
|
5
5
|
import '../utils/dataTransfer/Clipboard.js';
|
|
6
6
|
import '../utils/edit/isEditable.js';
|
|
7
7
|
import '../utils/edit/maxLength.js';
|
|
8
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
9
8
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
10
9
|
import '../utils/misc/level.js';
|
|
11
10
|
import '../options.js';
|
package/dist/esm/event/input.js
CHANGED
|
@@ -6,7 +6,6 @@ import '../utils/edit/isEditable.js';
|
|
|
6
6
|
import { supportsMaxLength, getMaxLength } from '../utils/edit/maxLength.js';
|
|
7
7
|
import { getNextCursorPosition } from '../utils/focus/cursor.js';
|
|
8
8
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
9
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
10
9
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
11
10
|
import '../utils/misc/level.js';
|
|
12
11
|
import '../options.js';
|
|
@@ -4,7 +4,6 @@ import '../../utils/dataTransfer/Clipboard.js';
|
|
|
4
4
|
import { getContentEditable } from '../../utils/edit/isContentEditable.js';
|
|
5
5
|
import '../../utils/edit/isEditable.js';
|
|
6
6
|
import '../../utils/edit/maxLength.js';
|
|
7
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
8
7
|
import { hasOwnSelection } from '../../utils/focus/selection.js';
|
|
9
8
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
10
9
|
import '../../utils/misc/level.js';
|
|
@@ -13,7 +12,6 @@ import '../../options.js';
|
|
|
13
12
|
/**
|
|
14
13
|
* Determine which selection logic and selection ranges to consider.
|
|
15
14
|
*/ function getTargetTypeAndSelection(node) {
|
|
16
|
-
var _element, _selection;
|
|
17
15
|
const element = getElement(node);
|
|
18
16
|
if (element && hasOwnSelection(element)) {
|
|
19
17
|
return {
|
|
@@ -21,10 +19,10 @@ import '../../options.js';
|
|
|
21
19
|
selection: getUISelection(element)
|
|
22
20
|
};
|
|
23
21
|
}
|
|
24
|
-
const selection =
|
|
22
|
+
const selection = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection();
|
|
25
23
|
// It is possible to extend a single-range selection into a contenteditable.
|
|
26
24
|
// This results in the range acting like a range outside of contenteditable.
|
|
27
|
-
const isCE = getContentEditable(node) && (
|
|
25
|
+
const isCE = getContentEditable(node) && (selection === null || selection === void 0 ? void 0 : selection.anchorNode) && getContentEditable(selection.anchorNode);
|
|
28
26
|
return {
|
|
29
27
|
type: isCE ? 'contenteditable' : 'default',
|
|
30
28
|
selection
|
|
@@ -3,7 +3,6 @@ import '../../utils/click/isClickableInput.js';
|
|
|
3
3
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
4
|
import '../../utils/edit/isEditable.js';
|
|
5
5
|
import '../../utils/edit/maxLength.js';
|
|
6
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
7
6
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
8
7
|
import '../../utils/misc/level.js';
|
|
9
8
|
import '../../options.js';
|
|
@@ -3,7 +3,6 @@ import '../../utils/click/isClickableInput.js';
|
|
|
3
3
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
4
|
import '../../utils/edit/isEditable.js';
|
|
5
5
|
import '../../utils/edit/maxLength.js';
|
|
6
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
7
6
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
8
7
|
import '../../utils/misc/level.js';
|
|
9
8
|
import '../../options.js';
|
|
@@ -29,7 +28,6 @@ function modifySelectionPerMouseMove(selectionRange, { document, target, node, o
|
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
30
|
} else {
|
|
32
|
-
var _selection, _selection1;
|
|
33
31
|
const range = selectionRange.cloneRange();
|
|
34
32
|
const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);
|
|
35
33
|
if (cmp < 0) {
|
|
@@ -38,8 +36,8 @@ function modifySelectionPerMouseMove(selectionRange, { document, target, node, o
|
|
|
38
36
|
range.setEnd(selectionFocus.node, selectionFocus.offset);
|
|
39
37
|
}
|
|
40
38
|
const selection = document.getSelection();
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
|
|
40
|
+
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
|
|
43
41
|
}
|
|
44
42
|
}
|
|
45
43
|
|
|
@@ -4,7 +4,6 @@ import '../../utils/dataTransfer/Clipboard.js';
|
|
|
4
4
|
import '../../utils/edit/isEditable.js';
|
|
5
5
|
import '../../utils/edit/maxLength.js';
|
|
6
6
|
import { getNextCursorPosition } from '../../utils/focus/cursor.js';
|
|
7
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
8
7
|
import { hasOwnSelection } from '../../utils/focus/selection.js';
|
|
9
8
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
10
9
|
import '../../utils/misc/level.js';
|
|
@@ -22,9 +21,8 @@ import { setSelection } from './setSelection.js';
|
|
|
22
21
|
focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + direction : direction < 0 ? selection.startOffset : selection.endOffset
|
|
23
22
|
});
|
|
24
23
|
} else {
|
|
25
|
-
var _selection;
|
|
26
24
|
const selection = node.ownerDocument.getSelection();
|
|
27
|
-
if (!(
|
|
25
|
+
if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) {
|
|
28
26
|
return;
|
|
29
27
|
}
|
|
30
28
|
if (selection.isCollapsed) {
|
|
@@ -3,7 +3,6 @@ import '../../utils/click/isClickableInput.js';
|
|
|
3
3
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
4
|
import '../../utils/edit/isEditable.js';
|
|
5
5
|
import '../../utils/edit/maxLength.js';
|
|
6
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
7
6
|
import { hasOwnSelection } from '../../utils/focus/selection.js';
|
|
8
7
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
9
8
|
import '../../utils/misc/level.js';
|
|
@@ -4,7 +4,6 @@ import '../../utils/dataTransfer/Clipboard.js';
|
|
|
4
4
|
import { getContentEditable } from '../../utils/edit/isContentEditable.js';
|
|
5
5
|
import '../../utils/edit/isEditable.js';
|
|
6
6
|
import '../../utils/edit/maxLength.js';
|
|
7
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
8
7
|
import { hasOwnSelection } from '../../utils/focus/selection.js';
|
|
9
8
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
10
9
|
import '../../utils/misc/level.js';
|
|
@@ -30,14 +29,13 @@ import { setSelection } from './setSelection.js';
|
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
31
|
function isAllSelected(target) {
|
|
33
|
-
var _selection;
|
|
34
32
|
if (hasOwnSelection(target)) {
|
|
35
33
|
return getUISelection(target).startOffset === 0 && getUISelection(target).endOffset === getUIValue(target).length;
|
|
36
34
|
}
|
|
37
35
|
var _getContentEditable;
|
|
38
36
|
const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body;
|
|
39
37
|
const selection = target.ownerDocument.getSelection();
|
|
40
|
-
return (
|
|
38
|
+
return (selection === null || selection === void 0 ? void 0 : selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
export { isAllSelected, selectAll };
|
|
@@ -3,7 +3,6 @@ import '../../utils/click/isClickableInput.js';
|
|
|
3
3
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
4
|
import '../../utils/edit/isEditable.js';
|
|
5
5
|
import '../../utils/edit/maxLength.js';
|
|
6
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
7
6
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
8
7
|
import '../../utils/misc/level.js';
|
|
9
8
|
import '../../options.js';
|
|
@@ -3,7 +3,6 @@ import '../../utils/click/isClickableInput.js';
|
|
|
3
3
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
4
|
import '../../utils/edit/isEditable.js';
|
|
5
5
|
import '../../utils/edit/maxLength.js';
|
|
6
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
7
6
|
import { hasNoSelection, hasOwnSelection } from '../../utils/focus/selection.js';
|
|
8
7
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
9
8
|
import '../../utils/misc/level.js';
|
|
@@ -39,7 +38,6 @@ function setSelectionPerMouseDown({ document, target, clickCount, node, offset }
|
|
|
39
38
|
end: end !== null && end !== void 0 ? end : text.length
|
|
40
39
|
};
|
|
41
40
|
} else {
|
|
42
|
-
var _selection, _selection1;
|
|
43
41
|
const { node: startNode, offset: startOffset } = resolveCaretPosition({
|
|
44
42
|
target,
|
|
45
43
|
node,
|
|
@@ -58,8 +56,8 @@ function setSelectionPerMouseDown({ document, target, clickCount, node, offset }
|
|
|
58
56
|
throw new Error('The given offset is out of bounds.');
|
|
59
57
|
}
|
|
60
58
|
const selection = document.getSelection();
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
|
|
60
|
+
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
|
|
63
61
|
return range;
|
|
64
62
|
}
|
|
65
63
|
}
|