@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
package/dist/esm/setup/setup.js
CHANGED
|
@@ -1,29 +1,50 @@
|
|
|
1
|
-
import { prepareDocument } from '../document/
|
|
2
|
-
import {
|
|
3
|
-
import { defaultOptionsSetup, defaultOptionsDirect } from '../options.js';
|
|
1
|
+
import { prepareDocument } from '../document/prepareDocument.js';
|
|
2
|
+
import { dispatchEvent, dispatchUIEvent } from '../event/dispatchEvent.js';
|
|
4
3
|
import '../utils/click/isClickableInput.js';
|
|
5
4
|
import { attachClipboardStubToView } from '../utils/dataTransfer/Clipboard.js';
|
|
6
|
-
import '../utils/edit/maxLength.js';
|
|
7
5
|
import '../utils/edit/isEditable.js';
|
|
8
|
-
import '
|
|
6
|
+
import '../utils/edit/maxLength.js';
|
|
9
7
|
import '@testing-library/dom/dist/helpers.js';
|
|
10
8
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
11
9
|
import { getDocumentFromNode } from '../utils/misc/getDocumentFromNode.js';
|
|
12
10
|
import { setLevelRef, ApiLevel } from '../utils/misc/level.js';
|
|
13
11
|
import { wait } from '../utils/misc/wait.js';
|
|
12
|
+
import { PointerEventsCheckLevel } from '../options.js';
|
|
13
|
+
import '@testing-library/dom';
|
|
14
|
+
import { defaultKeyMap } from '../keyboard/keyMap.js';
|
|
15
|
+
import { defaultKeyMap as defaultKeyMap$1 } from '../pointer/keyMap.js';
|
|
14
16
|
import { System } from '../system/index.js';
|
|
15
|
-
import { Config } from './config.js';
|
|
16
17
|
import * as api from './api.js';
|
|
17
18
|
import { wrapAsync } from './wrapAsync.js';
|
|
18
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Default options applied when API is called per `userEvent.anyApi()`
|
|
22
|
+
*/ const defaultOptionsDirect = {
|
|
23
|
+
applyAccept: true,
|
|
24
|
+
autoModify: true,
|
|
25
|
+
delay: 0,
|
|
26
|
+
document: globalThis.document,
|
|
27
|
+
keyboardMap: defaultKeyMap,
|
|
28
|
+
pointerMap: defaultKeyMap$1,
|
|
29
|
+
pointerEventsCheck: PointerEventsCheckLevel.EachApiCall,
|
|
30
|
+
skipAutoClose: false,
|
|
31
|
+
skipClick: false,
|
|
32
|
+
skipHover: false,
|
|
33
|
+
writeToClipboard: false,
|
|
34
|
+
advanceTimers: ()=>Promise.resolve()
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Default options applied when API is called per `userEvent().anyApi()`
|
|
38
|
+
*/ const defaultOptionsSetup = {
|
|
39
|
+
...defaultOptionsDirect,
|
|
40
|
+
writeToClipboard: true
|
|
41
|
+
};
|
|
19
42
|
function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
|
|
20
43
|
const document = getDocument(options, node, defaults);
|
|
21
|
-
var _system;
|
|
22
44
|
return {
|
|
23
45
|
...defaults,
|
|
24
46
|
...options,
|
|
25
|
-
document
|
|
26
|
-
system: (_system = options.system) !== null && _system !== void 0 ? _system : new System()
|
|
47
|
+
document
|
|
27
48
|
};
|
|
28
49
|
}
|
|
29
50
|
/**
|
|
@@ -35,34 +56,33 @@ function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
|
|
|
35
56
|
var _defaultView;
|
|
36
57
|
const view = (_defaultView = config.document.defaultView) !== null && _defaultView !== void 0 ? _defaultView : /* istanbul ignore next */ globalThis.window;
|
|
37
58
|
attachClipboardStubToView(view);
|
|
38
|
-
return
|
|
59
|
+
return createInstance(config).api;
|
|
39
60
|
}
|
|
40
61
|
/**
|
|
41
62
|
* Setup in direct call per `userEvent.anyApi()`
|
|
42
63
|
*/ function setupDirect({ keyboardState , pointerState , ...options } = {}, node) {
|
|
43
|
-
const config = createConfig(
|
|
44
|
-
...options,
|
|
45
|
-
system: pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState
|
|
46
|
-
}, defaultOptionsDirect, node);
|
|
64
|
+
const config = createConfig(options, defaultOptionsDirect, node);
|
|
47
65
|
prepareDocument(config.document);
|
|
66
|
+
var ref;
|
|
67
|
+
const system = (ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && ref !== void 0 ? ref : new System();
|
|
48
68
|
return {
|
|
49
|
-
config,
|
|
50
|
-
|
|
69
|
+
api: createInstance(config, system).api,
|
|
70
|
+
system
|
|
51
71
|
};
|
|
52
72
|
}
|
|
53
73
|
/**
|
|
54
74
|
* Create a set of callbacks with different default settings but the same state.
|
|
55
75
|
*/ function setupSub(options) {
|
|
56
|
-
return
|
|
57
|
-
...this
|
|
76
|
+
return createInstance({
|
|
77
|
+
...this.config,
|
|
58
78
|
...options
|
|
59
|
-
});
|
|
79
|
+
}, this.system).api;
|
|
60
80
|
}
|
|
61
81
|
function wrapAndBindImpl(instance, impl) {
|
|
62
82
|
function method(...args) {
|
|
63
|
-
setLevelRef(instance
|
|
83
|
+
setLevelRef(instance, ApiLevel.Call);
|
|
64
84
|
return wrapAsync(()=>impl.apply(instance, args).then(async (ret)=>{
|
|
65
|
-
await wait(instance
|
|
85
|
+
await wait(instance.config);
|
|
66
86
|
return ret;
|
|
67
87
|
}));
|
|
68
88
|
}
|
|
@@ -71,18 +91,25 @@ function wrapAndBindImpl(instance, impl) {
|
|
|
71
91
|
});
|
|
72
92
|
return method;
|
|
73
93
|
}
|
|
74
|
-
function
|
|
75
|
-
const instance = {
|
|
76
|
-
|
|
77
|
-
|
|
94
|
+
function createInstance(config, system = new System()) {
|
|
95
|
+
const instance = {};
|
|
96
|
+
Object.assign(instance, {
|
|
97
|
+
config,
|
|
98
|
+
dispatchEvent: dispatchEvent.bind(instance),
|
|
99
|
+
dispatchUIEvent: dispatchUIEvent.bind(instance),
|
|
100
|
+
system,
|
|
101
|
+
levelRefs: {},
|
|
78
102
|
...api
|
|
79
|
-
};
|
|
103
|
+
});
|
|
80
104
|
return {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
105
|
+
instance,
|
|
106
|
+
api: {
|
|
107
|
+
...Object.fromEntries(Object.entries(api).map(([name, api])=>[
|
|
108
|
+
name,
|
|
109
|
+
wrapAndBindImpl(instance, api),
|
|
110
|
+
])),
|
|
111
|
+
setup: setupSub.bind(instance)
|
|
112
|
+
}
|
|
86
113
|
};
|
|
87
114
|
}
|
|
88
115
|
function getDocument(options, node, defaults) {
|
|
@@ -90,4 +117,4 @@ function getDocument(options, node, defaults) {
|
|
|
90
117
|
return (ref = (_document = options.document) !== null && _document !== void 0 ? _document : node && getDocumentFromNode(node)) !== null && ref !== void 0 ? ref : defaults.document;
|
|
91
118
|
}
|
|
92
119
|
|
|
93
|
-
export { createConfig, setupDirect, setupMain, setupSub };
|
|
120
|
+
export { createConfig, createInstance, setupDirect, setupMain, setupSub };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { dispatchUIEvent } from '../event/index.js';
|
|
2
1
|
import '../utils/click/isClickableInput.js';
|
|
3
2
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
3
|
import '../utils/edit/isEditable.js';
|
|
6
|
-
import '
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
7
5
|
import { getActiveElementOrBody } from '../utils/focus/getActiveElement.js';
|
|
8
6
|
import '@testing-library/dom/dist/helpers.js';
|
|
9
7
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
@@ -47,10 +45,10 @@ class KeyboardHost {
|
|
|
47
45
|
getPressedKeys() {
|
|
48
46
|
return Object.values(this.pressed).map((p)=>p.keyDef);
|
|
49
47
|
}
|
|
50
|
-
/** Press a key */ async keydown(
|
|
48
|
+
/** Press a key */ async keydown(instance, keyDef) {
|
|
51
49
|
const key = String(keyDef.key);
|
|
52
50
|
const code = String(keyDef.code);
|
|
53
|
-
const target = getActiveElementOrBody(config.document);
|
|
51
|
+
const target = getActiveElementOrBody(instance.config.document);
|
|
54
52
|
this.setKeydownTarget(target);
|
|
55
53
|
var ref;
|
|
56
54
|
(ref = (_pressed = this.pressed)[_code = code]) !== null && ref !== void 0 ? ref : _pressed[_code] = {
|
|
@@ -60,7 +58,7 @@ class KeyboardHost {
|
|
|
60
58
|
if (isModifierKey(key)) {
|
|
61
59
|
this.modifiers[key] = true;
|
|
62
60
|
}
|
|
63
|
-
const unprevented = dispatchUIEvent(
|
|
61
|
+
const unprevented = instance.dispatchUIEvent(target, 'keydown', {
|
|
64
62
|
key,
|
|
65
63
|
code
|
|
66
64
|
});
|
|
@@ -70,14 +68,14 @@ class KeyboardHost {
|
|
|
70
68
|
}
|
|
71
69
|
(_code1 = this.pressed[code]).unpreventedDefault || (_code1.unpreventedDefault = unprevented);
|
|
72
70
|
if (unprevented && this.hasKeyPress(key)) {
|
|
73
|
-
dispatchUIEvent(
|
|
71
|
+
instance.dispatchUIEvent(getActiveElementOrBody(instance.config.document), 'keypress', {
|
|
74
72
|
key,
|
|
75
73
|
code,
|
|
76
74
|
charCode: keyDef.key === 'Enter' ? 13 : String(keyDef.key).charCodeAt(0)
|
|
77
75
|
});
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
|
-
/** Release a key */ async keyup(
|
|
78
|
+
/** Release a key */ async keyup(instance, keyDef) {
|
|
81
79
|
const key = String(keyDef.key);
|
|
82
80
|
const code = String(keyDef.code);
|
|
83
81
|
const unprevented = this.pressed[code].unpreventedDefault;
|
|
@@ -86,7 +84,7 @@ class KeyboardHost {
|
|
|
86
84
|
if (isModifierKey(key) && !Object.values(this.pressed).find((p)=>p.keyDef.key === key)) {
|
|
87
85
|
this.modifiers[key] = false;
|
|
88
86
|
}
|
|
89
|
-
dispatchUIEvent(
|
|
87
|
+
instance.dispatchUIEvent(getActiveElementOrBody(instance.config.document), 'keyup', {
|
|
90
88
|
key,
|
|
91
89
|
code
|
|
92
90
|
}, !unprevented);
|
|
@@ -8,9 +8,9 @@ class PointerHost {
|
|
|
8
8
|
isKeyPressed(keyDef) {
|
|
9
9
|
return this.devices.get(keyDef.pointerType).isPressed(keyDef);
|
|
10
10
|
}
|
|
11
|
-
async press(
|
|
11
|
+
async press(instance, keyDef, position) {
|
|
12
12
|
const pointerName = this.getPointerName(keyDef);
|
|
13
|
-
const pointer = keyDef.pointerType === 'touch' ? this.pointers.new(pointerName, keyDef).init(
|
|
13
|
+
const pointer = keyDef.pointerType === 'touch' ? this.pointers.new(pointerName, keyDef).init(instance, position) : this.pointers.get(pointerName);
|
|
14
14
|
// TODO: deprecate the following implicit setting of position
|
|
15
15
|
pointer.position = position;
|
|
16
16
|
if (pointer.pointerType !== 'touch') {
|
|
@@ -18,19 +18,19 @@ class PointerHost {
|
|
|
18
18
|
}
|
|
19
19
|
this.devices.get(keyDef.pointerType).addPressed(keyDef);
|
|
20
20
|
this.buttons.down(keyDef);
|
|
21
|
-
pointer.down(
|
|
21
|
+
pointer.down(instance, keyDef);
|
|
22
22
|
if (pointer.pointerType !== 'touch' && !pointer.isPrevented) {
|
|
23
|
-
this.mouse.down(
|
|
23
|
+
this.mouse.down(instance, keyDef, pointer);
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
async move(
|
|
26
|
+
async move(instance, pointerName, position) {
|
|
27
27
|
const pointer = this.pointers.get(pointerName);
|
|
28
28
|
// In (some?) browsers this order of events can be observed.
|
|
29
29
|
// This interweaving of events is probably unnecessary.
|
|
30
30
|
// While the order of mouse (or pointer) events is defined per spec,
|
|
31
31
|
// the order in which they interweave/follow on a user interaction depends on the implementation.
|
|
32
|
-
const pointermove = pointer.move(
|
|
33
|
-
const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(
|
|
32
|
+
const pointermove = pointer.move(instance, position);
|
|
33
|
+
const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
|
|
34
34
|
pointermove === null || pointermove === void 0 ? void 0 : pointermove.leave();
|
|
35
35
|
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
|
|
36
36
|
pointermove === null || pointermove === void 0 ? void 0 : pointermove.enter();
|
|
@@ -38,7 +38,7 @@ class PointerHost {
|
|
|
38
38
|
pointermove === null || pointermove === void 0 ? void 0 : pointermove.move();
|
|
39
39
|
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
|
|
40
40
|
}
|
|
41
|
-
async release(
|
|
41
|
+
async release(instance, keyDef, position) {
|
|
42
42
|
const device = this.devices.get(keyDef.pointerType);
|
|
43
43
|
device.removePressed(keyDef);
|
|
44
44
|
this.buttons.up(keyDef);
|
|
@@ -49,25 +49,25 @@ class PointerHost {
|
|
|
49
49
|
this.mouse.position = position;
|
|
50
50
|
}
|
|
51
51
|
if (device.countPressed === 0) {
|
|
52
|
-
pointer.up(
|
|
52
|
+
pointer.up(instance, keyDef);
|
|
53
53
|
}
|
|
54
54
|
if (pointer.pointerType === 'touch') {
|
|
55
|
-
pointer.release(
|
|
55
|
+
pointer.release(instance);
|
|
56
56
|
}
|
|
57
57
|
if (!pointer.isPrevented) {
|
|
58
58
|
if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
|
|
59
|
-
const mousemove = this.mouse.move(
|
|
59
|
+
const mousemove = this.mouse.move(instance, pointer.position);
|
|
60
60
|
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
|
|
61
61
|
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
|
|
62
62
|
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
|
|
63
|
-
this.mouse.down(
|
|
63
|
+
this.mouse.down(instance, keyDef, pointer);
|
|
64
64
|
}
|
|
65
65
|
if (!pointer.isMultitouch) {
|
|
66
|
-
const mousemove1 = this.mouse.move(
|
|
66
|
+
const mousemove1 = this.mouse.move(instance, pointer.position);
|
|
67
67
|
mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.leave();
|
|
68
68
|
mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.enter();
|
|
69
69
|
mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.move();
|
|
70
|
-
this.mouse.up(
|
|
70
|
+
this.mouse.up(instance, keyDef, pointer);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -80,9 +80,9 @@ class PointerHost {
|
|
|
80
80
|
resetClickCount() {
|
|
81
81
|
this.mouse.resetClickCount();
|
|
82
82
|
}
|
|
83
|
-
getMouseTarget(
|
|
83
|
+
getMouseTarget(instance) {
|
|
84
84
|
var _target;
|
|
85
|
-
return (_target = this.mouse.position.target) !== null && _target !== void 0 ? _target : config.document.body;
|
|
85
|
+
return (_target = this.mouse.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
|
|
86
86
|
}
|
|
87
87
|
setMousePosition(position) {
|
|
88
88
|
this.mouse.position = position;
|
|
@@ -141,9 +141,5 @@ class PointerHost {
|
|
|
141
141
|
this.mouse = new Mouse();
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
|
-
function isDifferentPointerPosition(positionA, positionB) {
|
|
145
|
-
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
|
|
146
|
-
return positionA.target !== positionB.target || ((ref = positionA.coords) === null || ref === void 0 ? void 0 : ref.x) !== ((ref1 = positionB.coords) === null || ref1 === void 0 ? void 0 : ref1.y) || ((ref2 = positionA.coords) === null || ref2 === void 0 ? void 0 : ref2.y) !== ((ref3 = positionB.coords) === null || ref3 === void 0 ? void 0 : ref3.y) || ((ref4 = positionA.caret) === null || ref4 === void 0 ? void 0 : ref4.node) !== ((ref5 = positionB.caret) === null || ref5 === void 0 ? void 0 : ref5.node) || ((ref6 = positionA.caret) === null || ref6 === void 0 ? void 0 : ref6.offset) !== ((ref7 = positionB.caret) === null || ref7 === void 0 ? void 0 : ref7.offset);
|
|
147
|
-
}
|
|
148
144
|
|
|
149
|
-
export { PointerHost
|
|
145
|
+
export { PointerHost };
|
|
@@ -1,85 +1,92 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../../event/behavior/click.js';
|
|
2
|
+
import '../../event/behavior/cut.js';
|
|
3
|
+
import '../../event/behavior/keydown.js';
|
|
4
|
+
import '../../event/behavior/keypress.js';
|
|
5
|
+
import '../../event/behavior/keyup.js';
|
|
6
|
+
import '../../event/behavior/paste.js';
|
|
7
|
+
import '@testing-library/dom';
|
|
8
|
+
import '../../event/eventMap.js';
|
|
2
9
|
import '../../utils/click/isClickableInput.js';
|
|
3
10
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
11
|
import '../../utils/edit/isEditable.js';
|
|
6
|
-
import
|
|
7
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
12
|
+
import '../../utils/edit/maxLength.js';
|
|
8
13
|
import { isDisabled } from '../../utils/misc/isDisabled.js';
|
|
9
|
-
import '@testing-library/dom';
|
|
10
|
-
import { setSelectionPerMouseDown, modifySelectionPerMouseMove } from '../../utils/focus/selection.js';
|
|
14
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
11
15
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
12
16
|
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js';
|
|
13
17
|
import '../../utils/misc/level.js';
|
|
14
18
|
import '../../options.js';
|
|
15
|
-
import {
|
|
19
|
+
import { focusElement } from '../../event/focus.js';
|
|
20
|
+
import { setSelectionPerMouseDown } from '../../event/selection/setSelectionPerMouse.js';
|
|
21
|
+
import { modifySelectionPerMouseMove } from '../../event/selection/modifySelectionPerMouse.js';
|
|
16
22
|
import { getMouseEventButton, Buttons } from './buttons.js';
|
|
23
|
+
import { isDifferentPointerPosition } from './shared.js';
|
|
17
24
|
|
|
18
25
|
/**
|
|
19
26
|
* This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
|
|
20
27
|
*/ class Mouse {
|
|
21
|
-
move(
|
|
28
|
+
move(instance, position) {
|
|
22
29
|
const prevPosition = this.position;
|
|
23
|
-
const prevTarget = this.getTarget(
|
|
30
|
+
const prevTarget = this.getTarget(instance);
|
|
24
31
|
this.position = position;
|
|
25
32
|
if (!isDifferentPointerPosition(prevPosition, position)) {
|
|
26
33
|
return;
|
|
27
34
|
}
|
|
28
|
-
const nextTarget = this.getTarget(
|
|
35
|
+
const nextTarget = this.getTarget(instance);
|
|
29
36
|
const init = this.getEventInit('mousemove');
|
|
30
37
|
const [leave, enter] = getTreeDiff(prevTarget, nextTarget);
|
|
31
38
|
return {
|
|
32
39
|
leave: ()=>{
|
|
33
40
|
if (prevTarget !== nextTarget) {
|
|
34
|
-
dispatchUIEvent(
|
|
35
|
-
leave.forEach((el)=>dispatchUIEvent(
|
|
41
|
+
instance.dispatchUIEvent(prevTarget, 'mouseout', init);
|
|
42
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'mouseleave', init));
|
|
36
43
|
}
|
|
37
44
|
},
|
|
38
45
|
enter: ()=>{
|
|
39
46
|
if (prevTarget !== nextTarget) {
|
|
40
|
-
dispatchUIEvent(
|
|
41
|
-
enter.forEach((el)=>dispatchUIEvent(
|
|
47
|
+
instance.dispatchUIEvent(nextTarget, 'mouseover', init);
|
|
48
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'mouseenter', init));
|
|
42
49
|
}
|
|
43
50
|
},
|
|
44
51
|
move: ()=>{
|
|
45
|
-
dispatchUIEvent(
|
|
46
|
-
this.modifySelecting(
|
|
52
|
+
instance.dispatchUIEvent(nextTarget, 'mousemove', init);
|
|
53
|
+
this.modifySelecting(instance);
|
|
47
54
|
}
|
|
48
55
|
};
|
|
49
56
|
}
|
|
50
|
-
down(
|
|
57
|
+
down(instance, keyDef, pointer) {
|
|
51
58
|
const button = this.buttons.down(keyDef);
|
|
52
59
|
if (button === undefined) {
|
|
53
60
|
return;
|
|
54
61
|
}
|
|
55
|
-
const target = this.getTarget(
|
|
62
|
+
const target = this.getTarget(instance);
|
|
56
63
|
this.buttonDownTarget[button] = target;
|
|
57
64
|
const disabled = isDisabled(target);
|
|
58
65
|
const init = this.getEventInit('mousedown', keyDef.button);
|
|
59
|
-
if (disabled || dispatchUIEvent(
|
|
60
|
-
this.startSelecting(
|
|
61
|
-
|
|
66
|
+
if (disabled || instance.dispatchUIEvent(target, 'mousedown', init)) {
|
|
67
|
+
this.startSelecting(instance, init.detail);
|
|
68
|
+
focusElement(target);
|
|
62
69
|
}
|
|
63
70
|
if (!disabled && getMouseEventButton(keyDef.button) === 2) {
|
|
64
|
-
dispatchUIEvent(
|
|
71
|
+
instance.dispatchUIEvent(target, 'contextmenu', this.getEventInit('contextmenu', keyDef.button, pointer));
|
|
65
72
|
}
|
|
66
73
|
}
|
|
67
|
-
up(
|
|
74
|
+
up(instance, keyDef, pointer) {
|
|
68
75
|
const button = this.buttons.up(keyDef);
|
|
69
76
|
if (button === undefined) {
|
|
70
77
|
return;
|
|
71
78
|
}
|
|
72
|
-
const target = this.getTarget(
|
|
79
|
+
const target = this.getTarget(instance);
|
|
73
80
|
if (!isDisabled(target)) {
|
|
74
|
-
dispatchUIEvent(
|
|
81
|
+
instance.dispatchUIEvent(target, 'mouseup', this.getEventInit('mouseup', keyDef.button));
|
|
75
82
|
this.endSelecting();
|
|
76
83
|
const clickTarget = getTreeDiff(this.buttonDownTarget[button], target)[2][0];
|
|
77
84
|
if (clickTarget) {
|
|
78
85
|
const init = this.getEventInit('click', keyDef.button, pointer);
|
|
79
86
|
if (init.detail) {
|
|
80
|
-
dispatchUIEvent(
|
|
87
|
+
instance.dispatchUIEvent(clickTarget, init.button === 0 ? 'click' : 'auxclick', init);
|
|
81
88
|
if (init.button === 0 && init.detail === 2) {
|
|
82
|
-
dispatchUIEvent(
|
|
89
|
+
instance.dispatchUIEvent(clickTarget, 'dblclick', {
|
|
83
90
|
...this.getEventInit('dblclick', keyDef.button),
|
|
84
91
|
detail: init.detail
|
|
85
92
|
});
|
|
@@ -111,29 +118,29 @@ import { getMouseEventButton, Buttons } from './buttons.js';
|
|
|
111
118
|
}
|
|
112
119
|
return init;
|
|
113
120
|
}
|
|
114
|
-
getTarget(
|
|
121
|
+
getTarget(instance) {
|
|
115
122
|
var _target;
|
|
116
|
-
return (_target = this.position.target) !== null && _target !== void 0 ? _target : config.document.body;
|
|
123
|
+
return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
|
|
117
124
|
}
|
|
118
|
-
startSelecting(
|
|
125
|
+
startSelecting(instance, clickCount) {
|
|
119
126
|
var ref, ref1;
|
|
120
127
|
// TODO: support extending range (shift)
|
|
121
128
|
this.selecting = setSelectionPerMouseDown({
|
|
122
|
-
document: config.document,
|
|
123
|
-
target: this.getTarget(
|
|
129
|
+
document: instance.config.document,
|
|
130
|
+
target: this.getTarget(instance),
|
|
124
131
|
node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
|
|
125
132
|
offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset,
|
|
126
133
|
clickCount
|
|
127
134
|
});
|
|
128
135
|
}
|
|
129
|
-
modifySelecting(
|
|
136
|
+
modifySelecting(instance) {
|
|
130
137
|
var ref, ref1;
|
|
131
138
|
if (!this.selecting) {
|
|
132
139
|
return;
|
|
133
140
|
}
|
|
134
141
|
modifySelectionPerMouseMove(this.selecting, {
|
|
135
|
-
document: config.document,
|
|
136
|
-
target: this.getTarget(
|
|
142
|
+
document: instance.config.document,
|
|
143
|
+
target: this.getTarget(instance),
|
|
137
144
|
node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
|
|
138
145
|
offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
|
|
139
146
|
});
|
|
@@ -1,91 +1,89 @@
|
|
|
1
|
-
import { dispatchUIEvent } from '../../event/index.js';
|
|
2
1
|
import '../../utils/click/isClickableInput.js';
|
|
3
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
3
|
import '../../utils/edit/isEditable.js';
|
|
6
|
-
import '
|
|
4
|
+
import '../../utils/edit/maxLength.js';
|
|
7
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
8
6
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
9
7
|
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js';
|
|
10
8
|
import '../../utils/misc/level.js';
|
|
11
9
|
import { assertPointerEvents, hasPointerEvents } from '../../utils/pointer/cssPointerEvents.js';
|
|
12
|
-
import { isDifferentPointerPosition } from './
|
|
10
|
+
import { isDifferentPointerPosition } from './shared.js';
|
|
13
11
|
|
|
14
12
|
class Pointer {
|
|
15
|
-
init(
|
|
13
|
+
init(instance, position) {
|
|
16
14
|
this.position = position;
|
|
17
|
-
const target = this.getTarget(
|
|
15
|
+
const target = this.getTarget(instance);
|
|
18
16
|
const [, enter] = getTreeDiff(null, target);
|
|
19
17
|
const init = this.getEventInit();
|
|
20
|
-
assertPointerEvents(
|
|
21
|
-
dispatchUIEvent(
|
|
22
|
-
enter.forEach((el)=>dispatchUIEvent(
|
|
18
|
+
assertPointerEvents(instance, target);
|
|
19
|
+
instance.dispatchUIEvent(target, 'pointerover', init);
|
|
20
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
|
|
23
21
|
return this;
|
|
24
22
|
}
|
|
25
|
-
move(
|
|
23
|
+
move(instance, position) {
|
|
26
24
|
const prevPosition = this.position;
|
|
27
|
-
const prevTarget = this.getTarget(
|
|
25
|
+
const prevTarget = this.getTarget(instance);
|
|
28
26
|
this.position = position;
|
|
29
27
|
if (!isDifferentPointerPosition(prevPosition, position)) {
|
|
30
28
|
return;
|
|
31
29
|
}
|
|
32
|
-
const nextTarget = this.getTarget(
|
|
30
|
+
const nextTarget = this.getTarget(instance);
|
|
33
31
|
const init = this.getEventInit();
|
|
34
32
|
const [leave, enter] = getTreeDiff(prevTarget, nextTarget);
|
|
35
33
|
return {
|
|
36
34
|
leave: ()=>{
|
|
37
|
-
if (hasPointerEvents(
|
|
35
|
+
if (hasPointerEvents(instance, prevTarget)) {
|
|
38
36
|
if (prevTarget !== nextTarget) {
|
|
39
|
-
dispatchUIEvent(
|
|
40
|
-
leave.forEach((el)=>dispatchUIEvent(
|
|
37
|
+
instance.dispatchUIEvent(prevTarget, 'pointerout', init);
|
|
38
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
},
|
|
44
42
|
enter: ()=>{
|
|
45
|
-
assertPointerEvents(
|
|
43
|
+
assertPointerEvents(instance, nextTarget);
|
|
46
44
|
if (prevTarget !== nextTarget) {
|
|
47
|
-
dispatchUIEvent(
|
|
48
|
-
enter.forEach((el)=>dispatchUIEvent(
|
|
45
|
+
instance.dispatchUIEvent(nextTarget, 'pointerover', init);
|
|
46
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
|
|
49
47
|
}
|
|
50
48
|
},
|
|
51
49
|
move: ()=>{
|
|
52
|
-
dispatchUIEvent(
|
|
50
|
+
instance.dispatchUIEvent(nextTarget, 'pointermove', init);
|
|
53
51
|
}
|
|
54
52
|
};
|
|
55
53
|
}
|
|
56
|
-
down(
|
|
54
|
+
down(instance, _keyDef) {
|
|
57
55
|
if (this.isDown) {
|
|
58
56
|
return;
|
|
59
57
|
}
|
|
60
|
-
const target = this.getTarget(
|
|
61
|
-
assertPointerEvents(
|
|
58
|
+
const target = this.getTarget(instance);
|
|
59
|
+
assertPointerEvents(instance, target);
|
|
62
60
|
this.isDown = true;
|
|
63
|
-
this.isPrevented = !dispatchUIEvent(
|
|
61
|
+
this.isPrevented = !instance.dispatchUIEvent(target, 'pointerdown', this.getEventInit());
|
|
64
62
|
}
|
|
65
|
-
up(
|
|
63
|
+
up(instance, _keyDef) {
|
|
66
64
|
if (!this.isDown) {
|
|
67
65
|
return;
|
|
68
66
|
}
|
|
69
|
-
const target = this.getTarget(
|
|
70
|
-
assertPointerEvents(
|
|
67
|
+
const target = this.getTarget(instance);
|
|
68
|
+
assertPointerEvents(instance, target);
|
|
71
69
|
this.isDown = false;
|
|
72
|
-
dispatchUIEvent(
|
|
70
|
+
instance.dispatchUIEvent(target, 'pointerup', this.getEventInit());
|
|
73
71
|
}
|
|
74
|
-
release(
|
|
75
|
-
const target = this.getTarget(
|
|
72
|
+
release(instance) {
|
|
73
|
+
const target = this.getTarget(instance);
|
|
76
74
|
const [leave] = getTreeDiff(target, null);
|
|
77
75
|
const init = this.getEventInit();
|
|
78
76
|
// Currently there is no PointerEventsCheckLevel that would
|
|
79
77
|
// make this check not use the *asserted* cached value from `up`.
|
|
80
|
-
/* istanbul ignore else */ if (hasPointerEvents(
|
|
81
|
-
dispatchUIEvent(
|
|
82
|
-
leave.forEach((el)=>dispatchUIEvent(
|
|
78
|
+
/* istanbul ignore else */ if (hasPointerEvents(instance, target)) {
|
|
79
|
+
instance.dispatchUIEvent(target, 'pointerout', init);
|
|
80
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
|
|
83
81
|
}
|
|
84
82
|
this.isCancelled = true;
|
|
85
83
|
}
|
|
86
|
-
getTarget(
|
|
84
|
+
getTarget(instance) {
|
|
87
85
|
var _target;
|
|
88
|
-
return (_target = this.position.target) !== null && _target !== void 0 ? _target : config.document.body;
|
|
86
|
+
return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
|
|
89
87
|
}
|
|
90
88
|
getEventInit() {
|
|
91
89
|
return {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
function isDifferentPointerPosition(positionA, positionB) {
|
|
2
|
+
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
|
|
3
|
+
return positionA.target !== positionB.target || ((ref = positionA.coords) === null || ref === void 0 ? void 0 : ref.x) !== ((ref1 = positionB.coords) === null || ref1 === void 0 ? void 0 : ref1.y) || ((ref2 = positionA.coords) === null || ref2 === void 0 ? void 0 : ref2.y) !== ((ref3 = positionB.coords) === null || ref3 === void 0 ? void 0 : ref3.y) || ((ref4 = positionA.caret) === null || ref4 === void 0 ? void 0 : ref4.node) !== ((ref5 = positionB.caret) === null || ref5 === void 0 ? void 0 : ref5.node) || ((ref6 = positionA.caret) === null || ref6 === void 0 ? void 0 : ref6.offset) !== ((ref7 = positionB.caret) === null || ref7 === void 0 ? void 0 : ref7.offset);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export { isDifferentPointerPosition };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import '../setup/index.js';
|
|
2
|
-
import '../utils/click/isClickableInput.js';
|
|
3
|
-
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../event/eventMap.js';
|
|
5
1
|
import '../event/behavior/click.js';
|
|
6
2
|
import '../event/behavior/cut.js';
|
|
7
3
|
import '../event/behavior/keydown.js';
|
|
@@ -9,22 +5,25 @@ import '../event/behavior/keypress.js';
|
|
|
9
5
|
import '../event/behavior/keyup.js';
|
|
10
6
|
import '../event/behavior/paste.js';
|
|
11
7
|
import '@testing-library/dom';
|
|
12
|
-
import
|
|
8
|
+
import '../event/eventMap.js';
|
|
9
|
+
import '../utils/click/isClickableInput.js';
|
|
10
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
13
11
|
import { isEditable } from '../utils/edit/isEditable.js';
|
|
14
|
-
import
|
|
15
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
12
|
+
import '../utils/edit/maxLength.js';
|
|
16
13
|
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
17
|
-
import
|
|
14
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
18
15
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
19
16
|
import '../utils/misc/level.js';
|
|
20
17
|
import '../options.js';
|
|
21
|
-
import {
|
|
18
|
+
import { focusElement } from '../event/focus.js';
|
|
19
|
+
import { input } from '../event/input.js';
|
|
20
|
+
import { selectAll, isAllSelected } from '../event/selection/selectAll.js';
|
|
22
21
|
|
|
23
22
|
async function clear(element) {
|
|
24
23
|
if (!isEditable(element) || isDisabled(element)) {
|
|
25
24
|
throw new Error('clear()` is only supported on editable elements.');
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
focusElement(element);
|
|
28
27
|
if (element.ownerDocument.activeElement !== element) {
|
|
29
28
|
throw new Error('The element to be cleared could not be focused.');
|
|
30
29
|
}
|
|
@@ -32,7 +31,7 @@ async function clear(element) {
|
|
|
32
31
|
if (!isAllSelected(element)) {
|
|
33
32
|
throw new Error('The element content to be cleared could not be selected.');
|
|
34
33
|
}
|
|
35
|
-
input(this
|
|
34
|
+
input(this, element, '', 'deleteContentBackward');
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
export { clear };
|