@testing-library/user-event 14.5.2 → 14.6.0
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 +1 -7
- package/dist/cjs/clipboard/cut.js +1 -7
- package/dist/cjs/clipboard/paste.js +2 -8
- package/dist/cjs/convenience/hover.js +0 -5
- package/dist/cjs/document/UI.js +3 -3
- package/dist/cjs/document/copySelection.js +0 -6
- package/dist/cjs/document/getValueOrTextContent.js +0 -6
- package/dist/cjs/document/interceptor.js +5 -11
- package/dist/cjs/document/patchFocus.js +104 -0
- package/dist/cjs/document/prepareDocument.js +1 -7
- package/dist/cjs/document/trackValue.js +2 -8
- package/dist/cjs/event/behavior/click.js +1 -7
- package/dist/cjs/event/behavior/cut.js +0 -5
- package/dist/cjs/event/behavior/keydown.js +3 -8
- package/dist/cjs/event/behavior/keypress.js +2 -7
- package/dist/cjs/event/behavior/keyup.js +1 -6
- package/dist/cjs/event/behavior/paste.js +1 -6
- package/dist/cjs/event/createEvent.js +34 -27
- package/dist/cjs/event/dispatchEvent.js +1 -1
- package/dist/cjs/event/eventMap.js +32 -0
- package/dist/cjs/event/focus.js +5 -9
- package/dist/cjs/event/index.js +0 -6
- package/dist/cjs/event/input.js +2 -7
- package/dist/cjs/event/radio.js +0 -6
- package/dist/cjs/event/selection/getInputRange.js +1 -1
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +2 -8
- package/dist/cjs/event/selection/modifySelection.js +1 -7
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +2 -8
- package/dist/cjs/event/selection/moveSelection.js +1 -7
- package/dist/cjs/event/selection/resolveCaretPosition.js +4 -10
- package/dist/cjs/event/selection/selectAll.js +3 -9
- package/dist/cjs/event/selection/setSelection.js +1 -7
- package/dist/cjs/event/selection/setSelectionPerMouse.js +7 -13
- package/dist/cjs/event/selection/setSelectionRange.js +1 -7
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +6 -8
- package/dist/cjs/index.js +1 -4
- package/dist/cjs/keyboard/index.js +0 -6
- package/dist/cjs/keyboard/parseKeyDef.js +3 -8
- package/dist/cjs/options.js +5 -3
- package/dist/cjs/pointer/index.js +6 -11
- package/dist/cjs/pointer/parseKeyDef.js +0 -5
- package/dist/cjs/setup/setup.js +7 -7
- package/dist/cjs/system/keyboard.js +47 -25
- package/dist/cjs/system/pointer/index.js +18 -20
- package/dist/cjs/system/pointer/mouse.js +8 -14
- package/dist/cjs/system/pointer/pointer.js +4 -9
- package/dist/cjs/system/pointer/shared.js +2 -2
- package/dist/cjs/utility/clear.js +0 -5
- package/dist/cjs/utility/selectOptions.js +1 -6
- package/dist/cjs/utility/type.js +1 -7
- package/dist/cjs/utility/upload.js +4 -10
- package/dist/cjs/utils/click/isClickableInput.js +3 -3
- package/dist/cjs/utils/dataTransfer/Clipboard.js +5 -6
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +6 -10
- package/dist/cjs/utils/edit/isEditable.js +3 -3
- package/dist/cjs/utils/edit/maxLength.js +4 -4
- package/dist/cjs/utils/edit/setFiles.js +2 -2
- package/dist/cjs/utils/focus/cursor.js +1 -1
- package/dist/cjs/utils/focus/getActiveElement.js +2 -2
- package/dist/cjs/utils/index.js +1 -4
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +6 -6
- package/dist/cjs/utils/misc/getWindow.js +1 -1
- package/dist/cjs/utils/misc/isDisabled.js +1 -1
- package/dist/cjs/utils/misc/isVisible.js +1 -1
- package/dist/cjs/utils/misc/level.js +4 -3
- package/dist/cjs/utils/pointer/cssPointerEvents.js +11 -11
- package/dist/esm/clipboard/copy.js +1 -7
- package/dist/esm/clipboard/cut.js +1 -7
- package/dist/esm/clipboard/paste.js +2 -8
- package/dist/esm/convenience/hover.js +0 -5
- package/dist/esm/document/UI.js +3 -3
- package/dist/esm/document/copySelection.js +0 -6
- package/dist/esm/document/getValueOrTextContent.js +0 -6
- package/dist/esm/document/interceptor.js +5 -11
- package/dist/esm/document/patchFocus.js +101 -0
- package/dist/esm/document/prepareDocument.js +1 -7
- package/dist/esm/document/trackValue.js +2 -8
- package/dist/esm/event/behavior/click.js +1 -7
- package/dist/esm/event/behavior/cut.js +0 -5
- package/dist/esm/event/behavior/keydown.js +3 -8
- package/dist/esm/event/behavior/keypress.js +2 -7
- package/dist/esm/event/behavior/keyup.js +1 -6
- package/dist/esm/event/behavior/paste.js +1 -6
- package/dist/esm/event/createEvent.js +34 -27
- package/dist/esm/event/dispatchEvent.js +1 -1
- package/dist/esm/event/eventMap.js +32 -0
- package/dist/esm/event/focus.js +5 -9
- package/dist/esm/event/index.js +0 -6
- package/dist/esm/event/input.js +2 -7
- package/dist/esm/event/radio.js +0 -6
- package/dist/esm/event/selection/getInputRange.js +1 -1
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +2 -8
- package/dist/esm/event/selection/modifySelection.js +1 -7
- package/dist/esm/event/selection/modifySelectionPerMouse.js +2 -8
- package/dist/esm/event/selection/moveSelection.js +1 -7
- package/dist/esm/event/selection/resolveCaretPosition.js +4 -10
- package/dist/esm/event/selection/selectAll.js +3 -9
- package/dist/esm/event/selection/setSelection.js +1 -7
- package/dist/esm/event/selection/setSelectionPerMouse.js +7 -13
- package/dist/esm/event/selection/setSelectionRange.js +1 -7
- package/dist/esm/event/selection/updateSelectionOnFocus.js +6 -8
- package/dist/esm/keyboard/index.js +0 -6
- package/dist/esm/keyboard/parseKeyDef.js +3 -8
- package/dist/esm/options.js +3 -3
- package/dist/esm/pointer/index.js +6 -11
- package/dist/esm/pointer/parseKeyDef.js +0 -5
- package/dist/esm/setup/setup.js +7 -7
- package/dist/esm/system/keyboard.js +46 -25
- package/dist/esm/system/pointer/index.js +18 -20
- package/dist/esm/system/pointer/mouse.js +8 -14
- package/dist/esm/system/pointer/pointer.js +4 -9
- package/dist/esm/system/pointer/shared.js +2 -2
- package/dist/esm/utility/clear.js +0 -5
- package/dist/esm/utility/selectOptions.js +1 -6
- package/dist/esm/utility/type.js +1 -7
- package/dist/esm/utility/upload.js +4 -10
- package/dist/esm/utils/click/isClickableInput.js +3 -3
- package/dist/esm/utils/dataTransfer/Clipboard.js +5 -6
- package/dist/esm/utils/dataTransfer/DataTransfer.js +6 -10
- package/dist/esm/utils/edit/isEditable.js +3 -3
- package/dist/esm/utils/edit/maxLength.js +4 -4
- package/dist/esm/utils/edit/setFiles.js +2 -2
- package/dist/esm/utils/focus/cursor.js +1 -1
- package/dist/esm/utils/focus/getActiveElement.js +2 -2
- package/dist/esm/utils/keyDef/readNextDescriptor.js +6 -6
- package/dist/esm/utils/misc/getWindow.js +1 -1
- package/dist/esm/utils/misc/isDisabled.js +1 -1
- package/dist/esm/utils/misc/isVisible.js +1 -1
- package/dist/esm/utils/misc/level.js +3 -3
- package/dist/esm/utils/pointer/cssPointerEvents.js +11 -11
- package/dist/types/document/patchFocus.d.ts +9 -0
- package/dist/types/event/eventMap.d.ts +32 -0
- package/dist/types/event/types.d.ts +1 -1
- package/dist/types/system/keyboard.d.ts +1 -4
- package/dist/types/utils/dataTransfer/DataTransfer.d.ts +1 -1
- package/package.json +3 -3
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import '../../utils/click/isClickableInput.js';
|
|
2
1
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
2
|
import { getContentEditable } from '../../utils/edit/isContentEditable.js';
|
|
4
|
-
import '../../utils/edit/isEditable.js';
|
|
5
|
-
import '../../utils/edit/maxLength.js';
|
|
6
3
|
import { hasOwnSelection } from '../../utils/focus/selection.js';
|
|
7
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
8
|
-
import '../../utils/misc/level.js';
|
|
9
|
-
import '../../options.js';
|
|
10
4
|
|
|
5
|
+
// The browser implementation seems to have changed.
|
|
6
|
+
// When focus is inside <input type="text"/>,
|
|
7
|
+
// Chrome updates Selection to be collapsed at the position of the input element.
|
|
8
|
+
// TODO: update implementation to match that of current browsers
|
|
11
9
|
/**
|
|
12
10
|
* Reset the Document Selection when moving focus into an element
|
|
13
11
|
* with own selection implementation.
|
|
14
12
|
*/ function updateSelectionOnFocus(element) {
|
|
15
13
|
const selection = element.ownerDocument.getSelection();
|
|
16
|
-
/* istanbul ignore if */ if (!(selection === null || selection ===
|
|
14
|
+
/* istanbul ignore if */ if (!(selection === null || selection === undefined ? undefined : selection.focusNode)) {
|
|
17
15
|
return;
|
|
18
16
|
}
|
|
19
17
|
// If the focus moves inside an element with own selection implementation,
|
|
@@ -28,7 +26,7 @@ import '../../options.js';
|
|
|
28
26
|
if (contenteditable) {
|
|
29
27
|
if (!selection.isCollapsed) {
|
|
30
28
|
var _contenteditable_firstChild;
|
|
31
|
-
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild ===
|
|
29
|
+
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === undefined ? undefined : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
|
|
32
30
|
selection.setBaseAndExtent(focusNode, 0, focusNode, 0);
|
|
33
31
|
}
|
|
34
32
|
} else {
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../utils/edit/isEditable.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
6
|
-
import '../utils/misc/level.js';
|
|
7
2
|
import { wait } from '../utils/misc/wait.js';
|
|
8
|
-
import '../options.js';
|
|
9
3
|
import { parseKeyDef } from './parseKeyDef.js';
|
|
10
4
|
|
|
11
5
|
async function keyboard(text) {
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../utils/edit/isEditable.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
2
|
import { readNextDescriptor } from '../utils/keyDef/readNextDescriptor.js';
|
|
6
|
-
import '../utils/misc/level.js';
|
|
7
|
-
import '../options.js';
|
|
8
3
|
|
|
9
4
|
/**
|
|
10
5
|
* Parse key defintions per `keyboardMap`
|
|
@@ -23,13 +18,13 @@ import '../options.js';
|
|
|
23
18
|
const keyDef = (_keyboardMap_find = keyboardMap.find((def)=>{
|
|
24
19
|
if (type === '[') {
|
|
25
20
|
var _def_code;
|
|
26
|
-
return ((_def_code = def.code) === null || _def_code ===
|
|
21
|
+
return ((_def_code = def.code) === null || _def_code === undefined ? undefined : _def_code.toLowerCase()) === descriptor.toLowerCase();
|
|
27
22
|
} else if (type === '{') {
|
|
28
23
|
var _def_key;
|
|
29
|
-
return ((_def_key = def.key) === null || _def_key ===
|
|
24
|
+
return ((_def_key = def.key) === null || _def_key === undefined ? undefined : _def_key.toLowerCase()) === descriptor.toLowerCase();
|
|
30
25
|
}
|
|
31
26
|
return def.key === descriptor;
|
|
32
|
-
})) !== null && _keyboardMap_find !==
|
|
27
|
+
})) !== null && _keyboardMap_find !== undefined ? _keyboardMap_find : {
|
|
33
28
|
key: 'Unknown',
|
|
34
29
|
code: 'Unknown',
|
|
35
30
|
[type === '[' ? 'code' : 'key']: descriptor
|
package/dist/esm/options.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var PointerEventsCheckLevel
|
|
2
|
-
(function(PointerEventsCheckLevel) {
|
|
1
|
+
var PointerEventsCheckLevel = /*#__PURE__*/ function(PointerEventsCheckLevel) {
|
|
3
2
|
/**
|
|
4
3
|
* Check pointer events on every user interaction that triggers a bunch of events.
|
|
5
4
|
* E.g. once for releasing a mouse button even though this triggers `pointerup`, `mouseup`, `click`, etc...
|
|
@@ -7,6 +6,7 @@ var PointerEventsCheckLevel;
|
|
|
7
6
|
/** Check each target once per call to pointer (related) API */ PointerEventsCheckLevel[PointerEventsCheckLevel["EachApiCall"] = 2] = "EachApiCall";
|
|
8
7
|
/** Check each event target once */ PointerEventsCheckLevel[PointerEventsCheckLevel["EachTarget"] = 1] = "EachTarget";
|
|
9
8
|
/** No pointer events check */ PointerEventsCheckLevel[PointerEventsCheckLevel["Never"] = 0] = "Never";
|
|
10
|
-
|
|
9
|
+
return PointerEventsCheckLevel;
|
|
10
|
+
}({});
|
|
11
11
|
|
|
12
12
|
export { PointerEventsCheckLevel };
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../utils/edit/isEditable.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
6
2
|
import { setLevelRef, ApiLevel } from '../utils/misc/level.js';
|
|
7
3
|
import { wait } from '../utils/misc/wait.js';
|
|
8
|
-
import '../options.js';
|
|
9
4
|
import { parseKeyDef } from './parseKeyDef.js';
|
|
10
5
|
|
|
11
6
|
async function pointer(input) {
|
|
@@ -37,11 +32,11 @@ async function pointerAction(instance, action) {
|
|
|
37
32
|
const previousPosition = instance.system.pointer.getPreviousPosition(pointerName);
|
|
38
33
|
var _action_target, _action_coords, _action_node, _action_offset;
|
|
39
34
|
const position = {
|
|
40
|
-
target: (_action_target = action.target) !== null && _action_target !==
|
|
41
|
-
coords: (_action_coords = action.coords) !== null && _action_coords !==
|
|
35
|
+
target: (_action_target = action.target) !== null && _action_target !== undefined ? _action_target : getPrevTarget(instance, previousPosition),
|
|
36
|
+
coords: (_action_coords = action.coords) !== null && _action_coords !== undefined ? _action_coords : previousPosition === null || previousPosition === undefined ? undefined : previousPosition.coords,
|
|
42
37
|
caret: {
|
|
43
|
-
node: (_action_node = action.node) !== null && _action_node !==
|
|
44
|
-
offset: (_action_offset = action.offset) !== null && _action_offset !==
|
|
38
|
+
node: (_action_node = action.node) !== null && _action_node !== undefined ? _action_node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === undefined ? undefined : (_previousPosition_caret = previousPosition.caret) === null || _previousPosition_caret === undefined ? undefined : _previousPosition_caret.node,
|
|
39
|
+
offset: (_action_offset = action.offset) !== null && _action_offset !== undefined ? _action_offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === undefined ? undefined : (_previousPosition_caret1 = previousPosition.caret) === null || _previousPosition_caret1 === undefined ? undefined : _previousPosition_caret1.offset
|
|
45
40
|
}
|
|
46
41
|
};
|
|
47
42
|
if ('keyDef' in action) {
|
|
@@ -64,14 +59,14 @@ async function pointerAction(instance, action) {
|
|
|
64
59
|
}
|
|
65
60
|
function hasCaretPosition(action) {
|
|
66
61
|
var _action_target, _ref;
|
|
67
|
-
return !!((_ref = (_action_target = action.target) !== null && _action_target !==
|
|
62
|
+
return !!((_ref = (_action_target = action.target) !== null && _action_target !== undefined ? _action_target : action.node) !== null && _ref !== undefined ? _ref : action.offset !== undefined);
|
|
68
63
|
}
|
|
69
64
|
function getPrevTarget(instance, position) {
|
|
70
65
|
if (!position) {
|
|
71
66
|
throw new Error('This pointer has no previous position. Provide a target property!');
|
|
72
67
|
}
|
|
73
68
|
var _position_target;
|
|
74
|
-
return (_position_target = position.target) !== null && _position_target !==
|
|
69
|
+
return (_position_target = position.target) !== null && _position_target !== undefined ? _position_target : instance.config.document.body;
|
|
75
70
|
}
|
|
76
71
|
|
|
77
72
|
export { pointer };
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../utils/edit/isEditable.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
2
|
import { readNextDescriptor } from '../utils/keyDef/readNextDescriptor.js';
|
|
6
|
-
import '../utils/misc/level.js';
|
|
7
|
-
import '../options.js';
|
|
8
3
|
|
|
9
4
|
function parseKeyDef(pointerMap, keys) {
|
|
10
5
|
const defs = [];
|
package/dist/esm/setup/setup.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { patchFocus } from '../document/patchFocus.js';
|
|
1
2
|
import { prepareDocument } from '../document/prepareDocument.js';
|
|
2
3
|
import { dispatchEvent, dispatchUIEvent } from '../event/dispatchEvent.js';
|
|
3
|
-
import '../utils/click/isClickableInput.js';
|
|
4
4
|
import { attachClipboardStubToView } from '../utils/dataTransfer/Clipboard.js';
|
|
5
|
-
import '../utils/
|
|
6
|
-
import '../utils/edit/maxLength.js';
|
|
7
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
5
|
+
import { getWindow } from '../utils/misc/getWindow.js';
|
|
8
6
|
import { getDocumentFromNode } from '../utils/misc/getDocumentFromNode.js';
|
|
9
7
|
import { setLevelRef, ApiLevel } from '../utils/misc/level.js';
|
|
10
8
|
import { wait } from '../utils/misc/wait.js';
|
|
@@ -52,8 +50,9 @@ function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
|
|
|
52
50
|
*/ function setupMain(options = {}) {
|
|
53
51
|
const config = createConfig(options);
|
|
54
52
|
prepareDocument(config.document);
|
|
53
|
+
patchFocus(getWindow(config.document).HTMLElement);
|
|
55
54
|
var _config_document_defaultView;
|
|
56
|
-
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !==
|
|
55
|
+
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== undefined ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window;
|
|
57
56
|
attachClipboardStubToView(view);
|
|
58
57
|
return createInstance(config).api;
|
|
59
58
|
}
|
|
@@ -62,8 +61,9 @@ function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
|
|
|
62
61
|
*/ function setupDirect({ keyboardState, pointerState, ...options } = {}, node) {
|
|
63
62
|
const config = createConfig(options, defaultOptionsDirect, node);
|
|
64
63
|
prepareDocument(config.document);
|
|
64
|
+
patchFocus(getWindow(config.document).HTMLElement);
|
|
65
65
|
var _ref;
|
|
66
|
-
const system = (_ref = pointerState !== null && pointerState !==
|
|
66
|
+
const system = (_ref = pointerState !== null && pointerState !== undefined ? pointerState : keyboardState) !== null && _ref !== undefined ? _ref : new System();
|
|
67
67
|
return {
|
|
68
68
|
api: createInstance(config, system).api,
|
|
69
69
|
system
|
|
@@ -113,7 +113,7 @@ function createInstance(config, system = new System()) {
|
|
|
113
113
|
}
|
|
114
114
|
function getDocument(options, node, defaults) {
|
|
115
115
|
var _options_document, _ref;
|
|
116
|
-
return (_ref = (_options_document = options.document) !== null && _options_document !==
|
|
116
|
+
return (_ref = (_options_document = options.document) !== null && _options_document !== undefined ? _options_document : node && getDocumentFromNode(node)) !== null && _ref !== undefined ? _ref : defaults.document;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
export { createConfig, createInstance, setupDirect, setupMain, setupSub };
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import '../utils/click/isClickableInput.js';
|
|
2
1
|
import '../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../utils/edit/isEditable.js';
|
|
4
|
-
import '../utils/edit/maxLength.js';
|
|
5
2
|
import { getActiveElementOrBody } from '../utils/focus/getActiveElement.js';
|
|
6
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
7
|
-
import '../utils/misc/level.js';
|
|
8
|
-
import '../options.js';
|
|
9
3
|
|
|
10
4
|
function _define_property(obj, key, value) {
|
|
11
5
|
if (key in obj) {
|
|
@@ -20,13 +14,13 @@ function _define_property(obj, key, value) {
|
|
|
20
14
|
}
|
|
21
15
|
return obj;
|
|
22
16
|
}
|
|
23
|
-
var DOM_KEY_LOCATION
|
|
24
|
-
(function(DOM_KEY_LOCATION) {
|
|
17
|
+
var DOM_KEY_LOCATION = /*#__PURE__*/ function(DOM_KEY_LOCATION) {
|
|
25
18
|
DOM_KEY_LOCATION[DOM_KEY_LOCATION["STANDARD"] = 0] = "STANDARD";
|
|
26
19
|
DOM_KEY_LOCATION[DOM_KEY_LOCATION["LEFT"] = 1] = "LEFT";
|
|
27
20
|
DOM_KEY_LOCATION[DOM_KEY_LOCATION["RIGHT"] = 2] = "RIGHT";
|
|
28
21
|
DOM_KEY_LOCATION[DOM_KEY_LOCATION["NUMPAD"] = 3] = "NUMPAD";
|
|
29
|
-
|
|
22
|
+
return DOM_KEY_LOCATION;
|
|
23
|
+
}({});
|
|
30
24
|
const modifierKeys = [
|
|
31
25
|
'Alt',
|
|
32
26
|
'AltGraph',
|
|
@@ -51,23 +45,17 @@ function isModifierLock(key) {
|
|
|
51
45
|
}
|
|
52
46
|
class KeyboardHost {
|
|
53
47
|
isKeyPressed(keyDef) {
|
|
54
|
-
return
|
|
48
|
+
return this.pressed.has(String(keyDef.code));
|
|
55
49
|
}
|
|
56
50
|
getPressedKeys() {
|
|
57
|
-
return
|
|
51
|
+
return this.pressed.values().map((p)=>p.keyDef);
|
|
58
52
|
}
|
|
59
53
|
/** Press a key */ async keydown(instance, keyDef) {
|
|
60
|
-
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
61
|
-
_this_pressed, _code, _this_pressed_code;
|
|
62
54
|
const key = String(keyDef.key);
|
|
63
55
|
const code = String(keyDef.code);
|
|
64
56
|
const target = getActiveElementOrBody(instance.config.document);
|
|
65
57
|
this.setKeydownTarget(target);
|
|
66
|
-
|
|
67
|
-
(_ = (_this_pressed = this.pressed)[_code = code]) !== null && _ !== void 0 ? _ : _this_pressed[_code] = {
|
|
68
|
-
keyDef,
|
|
69
|
-
unpreventedDefault: false
|
|
70
|
-
};
|
|
58
|
+
this.pressed.add(code, keyDef);
|
|
71
59
|
if (isModifierKey(key)) {
|
|
72
60
|
this.modifiers[key] = true;
|
|
73
61
|
}
|
|
@@ -79,7 +67,9 @@ class KeyboardHost {
|
|
|
79
67
|
this.modifiers[key] = true;
|
|
80
68
|
this.modifierLockStart[key] = true;
|
|
81
69
|
}
|
|
82
|
-
|
|
70
|
+
if (unprevented) {
|
|
71
|
+
this.pressed.setUnprevented(code);
|
|
72
|
+
}
|
|
83
73
|
if (unprevented && this.hasKeyPress(key)) {
|
|
84
74
|
instance.dispatchUIEvent(getActiveElementOrBody(instance.config.document), 'keypress', {
|
|
85
75
|
key,
|
|
@@ -91,10 +81,9 @@ class KeyboardHost {
|
|
|
91
81
|
/** Release a key */ async keyup(instance, keyDef) {
|
|
92
82
|
const key = String(keyDef.key);
|
|
93
83
|
const code = String(keyDef.code);
|
|
94
|
-
const unprevented = this.pressed
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
if (isModifierKey(key) && !Object.values(this.pressed).find((p)=>p.keyDef.key === key)) {
|
|
84
|
+
const unprevented = this.pressed.isUnprevented(code);
|
|
85
|
+
this.pressed.delete(code);
|
|
86
|
+
if (isModifierKey(key) && !this.pressed.values().find((p)=>p.keyDef.key === key)) {
|
|
98
87
|
this.modifiers[key] = false;
|
|
99
88
|
}
|
|
100
89
|
instance.dispatchUIEvent(getActiveElementOrBody(instance.config.document), 'keyup', {
|
|
@@ -119,7 +108,7 @@ class KeyboardHost {
|
|
|
119
108
|
return (key.length === 1 || key === 'Enter') && !this.modifiers.Control && !this.modifiers.Alt;
|
|
120
109
|
}
|
|
121
110
|
constructor(system){
|
|
122
|
-
_define_property(this, "system",
|
|
111
|
+
_define_property(this, "system", undefined);
|
|
123
112
|
_define_property(this, "modifiers", {
|
|
124
113
|
Alt: false,
|
|
125
114
|
AltGraph: false,
|
|
@@ -134,7 +123,39 @@ class KeyboardHost {
|
|
|
134
123
|
Symbol: false,
|
|
135
124
|
SymbolLock: false
|
|
136
125
|
});
|
|
137
|
-
_define_property(this, "pressed", {
|
|
126
|
+
_define_property(this, "pressed", new class {
|
|
127
|
+
add(code, keyDef) {
|
|
128
|
+
var _this_registry, _code;
|
|
129
|
+
var _;
|
|
130
|
+
(_ = (_this_registry = this.registry)[_code = code]) !== null && _ !== undefined ? _ : _this_registry[_code] = {
|
|
131
|
+
keyDef,
|
|
132
|
+
unpreventedDefault: false
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
has(code) {
|
|
136
|
+
return !!this.registry[code];
|
|
137
|
+
}
|
|
138
|
+
setUnprevented(code) {
|
|
139
|
+
const o = this.registry[code];
|
|
140
|
+
if (o) {
|
|
141
|
+
o.unpreventedDefault = true;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
isUnprevented(code) {
|
|
145
|
+
var _this_registry_code;
|
|
146
|
+
return !!((_this_registry_code = this.registry[code]) === null || _this_registry_code === undefined ? undefined : _this_registry_code.unpreventedDefault);
|
|
147
|
+
}
|
|
148
|
+
delete(code) {
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
150
|
+
delete this.registry[code];
|
|
151
|
+
}
|
|
152
|
+
values() {
|
|
153
|
+
return Object.values(this.registry);
|
|
154
|
+
}
|
|
155
|
+
constructor(){
|
|
156
|
+
_define_property(this, "registry", {});
|
|
157
|
+
}
|
|
158
|
+
}());
|
|
138
159
|
_define_property(this, "carryChar", '');
|
|
139
160
|
_define_property(this, "lastKeydownTarget", undefined);
|
|
140
161
|
_define_property(this, "modifierLockStart", {});
|
|
@@ -43,12 +43,12 @@ class PointerHost {
|
|
|
43
43
|
// the order in which they interweave/follow on a user interaction depends on the implementation.
|
|
44
44
|
const pointermove = pointer.move(instance, position);
|
|
45
45
|
const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
|
|
46
|
-
pointermove === null || pointermove ===
|
|
47
|
-
mousemove === null || mousemove ===
|
|
48
|
-
pointermove === null || pointermove ===
|
|
49
|
-
mousemove === null || mousemove ===
|
|
50
|
-
pointermove === null || pointermove ===
|
|
51
|
-
mousemove === null || mousemove ===
|
|
46
|
+
pointermove === null || pointermove === undefined ? undefined : pointermove.leave();
|
|
47
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
|
|
48
|
+
pointermove === null || pointermove === undefined ? undefined : pointermove.enter();
|
|
49
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
|
|
50
|
+
pointermove === null || pointermove === undefined ? undefined : pointermove.move();
|
|
51
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.move();
|
|
52
52
|
}
|
|
53
53
|
async release(instance, keyDef, position) {
|
|
54
54
|
const device = this.devices.get(keyDef.pointerType);
|
|
@@ -69,16 +69,16 @@ class PointerHost {
|
|
|
69
69
|
if (!pointer.isPrevented) {
|
|
70
70
|
if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
|
|
71
71
|
const mousemove = this.mouse.move(instance, pointer.position);
|
|
72
|
-
mousemove === null || mousemove ===
|
|
73
|
-
mousemove === null || mousemove ===
|
|
74
|
-
mousemove === null || mousemove ===
|
|
72
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
|
|
73
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
|
|
74
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.move();
|
|
75
75
|
this.mouse.down(instance, keyDef, pointer);
|
|
76
76
|
}
|
|
77
77
|
if (!pointer.isMultitouch) {
|
|
78
78
|
const mousemove = this.mouse.move(instance, pointer.position);
|
|
79
|
-
mousemove === null || mousemove ===
|
|
80
|
-
mousemove === null || mousemove ===
|
|
81
|
-
mousemove === null || mousemove ===
|
|
79
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.leave();
|
|
80
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.enter();
|
|
81
|
+
mousemove === null || mousemove === undefined ? undefined : mousemove.move();
|
|
82
82
|
this.mouse.up(instance, keyDef, pointer);
|
|
83
83
|
}
|
|
84
84
|
}
|
|
@@ -94,23 +94,21 @@ class PointerHost {
|
|
|
94
94
|
}
|
|
95
95
|
getMouseTarget(instance) {
|
|
96
96
|
var _this_mouse_position_target;
|
|
97
|
-
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !==
|
|
97
|
+
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== undefined ? _this_mouse_position_target : instance.config.document.body;
|
|
98
98
|
}
|
|
99
99
|
setMousePosition(position) {
|
|
100
100
|
this.mouse.position = position;
|
|
101
101
|
this.pointers.get('mouse').position = position;
|
|
102
102
|
}
|
|
103
103
|
constructor(system){
|
|
104
|
-
_define_property(this, "system",
|
|
105
|
-
_define_property(this, "mouse",
|
|
106
|
-
_define_property(this, "buttons",
|
|
104
|
+
_define_property(this, "system", undefined);
|
|
105
|
+
_define_property(this, "mouse", undefined);
|
|
106
|
+
_define_property(this, "buttons", undefined);
|
|
107
107
|
_define_property(this, "devices", new class {
|
|
108
108
|
get(k) {
|
|
109
|
-
var
|
|
110
|
-
_this_registry, _k;
|
|
109
|
+
var _this_registry, _k;
|
|
111
110
|
var _;
|
|
112
|
-
(_ = (_this_registry = this.registry)[_k = k]) !== null && _ !==
|
|
113
|
-
return this.registry[k];
|
|
111
|
+
return (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== undefined ? _ : _this_registry[_k] = new Device();
|
|
114
112
|
}
|
|
115
113
|
constructor(){
|
|
116
114
|
_define_property(this, "registry", {});
|
|
@@ -5,15 +5,9 @@ import '../../event/behavior/keypress.js';
|
|
|
5
5
|
import '../../event/behavior/keyup.js';
|
|
6
6
|
import '../../event/behavior/paste.js';
|
|
7
7
|
import '@testing-library/dom';
|
|
8
|
-
import '../../utils/click/isClickableInput.js';
|
|
9
8
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
10
|
-
import '../../utils/edit/isEditable.js';
|
|
11
|
-
import '../../utils/edit/maxLength.js';
|
|
12
9
|
import { isDisabled } from '../../utils/misc/isDisabled.js';
|
|
13
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
14
10
|
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js';
|
|
15
|
-
import '../../utils/misc/level.js';
|
|
16
|
-
import '../../options.js';
|
|
17
11
|
import { focusElement } from '../../event/focus.js';
|
|
18
12
|
import { setSelectionPerMouseDown } from '../../event/selection/setSelectionPerMouse.js';
|
|
19
13
|
import { modifySelectionPerMouseMove } from '../../event/selection/modifySelectionPerMouse.js';
|
|
@@ -131,7 +125,7 @@ function _define_property(obj, key, value) {
|
|
|
131
125
|
}
|
|
132
126
|
getTarget(instance) {
|
|
133
127
|
var _this_position_target;
|
|
134
|
-
return (_this_position_target = this.position.target) !== null && _this_position_target !==
|
|
128
|
+
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body;
|
|
135
129
|
}
|
|
136
130
|
startSelecting(instance, clickCount) {
|
|
137
131
|
var _this_position_caret, _this_position_caret1;
|
|
@@ -139,8 +133,8 @@ function _define_property(obj, key, value) {
|
|
|
139
133
|
this.selecting = setSelectionPerMouseDown({
|
|
140
134
|
document: instance.config.document,
|
|
141
135
|
target: this.getTarget(instance),
|
|
142
|
-
node: (_this_position_caret = this.position.caret) === null || _this_position_caret ===
|
|
143
|
-
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 ===
|
|
136
|
+
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node,
|
|
137
|
+
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset,
|
|
144
138
|
clickCount
|
|
145
139
|
});
|
|
146
140
|
}
|
|
@@ -152,8 +146,8 @@ function _define_property(obj, key, value) {
|
|
|
152
146
|
modifySelectionPerMouseMove(this.selecting, {
|
|
153
147
|
document: instance.config.document,
|
|
154
148
|
target: this.getTarget(instance),
|
|
155
|
-
node: (_this_position_caret = this.position.caret) === null || _this_position_caret ===
|
|
156
|
-
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 ===
|
|
149
|
+
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node,
|
|
150
|
+
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset
|
|
157
151
|
});
|
|
158
152
|
}
|
|
159
153
|
endSelecting() {
|
|
@@ -162,7 +156,7 @@ function _define_property(obj, key, value) {
|
|
|
162
156
|
constructor(){
|
|
163
157
|
_define_property(this, "position", {});
|
|
164
158
|
_define_property(this, "buttons", new Buttons());
|
|
165
|
-
_define_property(this, "selecting",
|
|
159
|
+
_define_property(this, "selecting", undefined);
|
|
166
160
|
_define_property(this, "buttonDownTarget", {});
|
|
167
161
|
// According to spec the `detail` on click events should be the number
|
|
168
162
|
// of *consecutive* clicks with a specific button.
|
|
@@ -185,11 +179,11 @@ function _define_property(obj, key, value) {
|
|
|
185
179
|
getOnDown(button) {
|
|
186
180
|
var _this_count_button;
|
|
187
181
|
this.down = {
|
|
188
|
-
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !==
|
|
182
|
+
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== undefined ? _this_count_button : 0
|
|
189
183
|
};
|
|
190
184
|
var _this_count_button1;
|
|
191
185
|
this.count = {
|
|
192
|
-
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !==
|
|
186
|
+
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== undefined ? _this_count_button1 : 0
|
|
193
187
|
};
|
|
194
188
|
return Number(this.count[button]) + 1;
|
|
195
189
|
}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import '../../utils/click/isClickableInput.js';
|
|
2
1
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
3
|
-
import '../../utils/edit/isEditable.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
|
-
import '../../utils/keyDef/readNextDescriptor.js';
|
|
6
2
|
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js';
|
|
7
|
-
import '../../utils/misc/level.js';
|
|
8
3
|
import { assertPointerEvents, hasPointerEvents } from '../../utils/pointer/cssPointerEvents.js';
|
|
9
4
|
import { isDifferentPointerPosition } from './shared.js';
|
|
10
5
|
|
|
@@ -95,7 +90,7 @@ class Pointer {
|
|
|
95
90
|
}
|
|
96
91
|
getTarget(instance) {
|
|
97
92
|
var _this_position_target;
|
|
98
|
-
return (_this_position_target = this.position.target) !== null && _this_position_target !==
|
|
93
|
+
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body;
|
|
99
94
|
}
|
|
100
95
|
getEventInit() {
|
|
101
96
|
return {
|
|
@@ -106,9 +101,9 @@ class Pointer {
|
|
|
106
101
|
};
|
|
107
102
|
}
|
|
108
103
|
constructor({ pointerId, pointerType, isPrimary }){
|
|
109
|
-
_define_property(this, "pointerId",
|
|
110
|
-
_define_property(this, "pointerType",
|
|
111
|
-
_define_property(this, "isPrimary",
|
|
104
|
+
_define_property(this, "pointerId", undefined);
|
|
105
|
+
_define_property(this, "pointerType", undefined);
|
|
106
|
+
_define_property(this, "isPrimary", undefined);
|
|
112
107
|
_define_property(this, "isMultitouch", false);
|
|
113
108
|
_define_property(this, "isCancelled", false);
|
|
114
109
|
_define_property(this, "isDown", false);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
function isDifferentPointerPosition(positionA, positionB) {
|
|
2
|
-
var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
|
|
3
|
-
return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords ===
|
|
2
|
+
var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_coords2, _positionB_coords2, _positionA_coords3, _positionB_coords3, _positionA_coords4, _positionB_coords4, _positionA_coords5, _positionB_coords5, _positionA_coords6, _positionB_coords6, _positionA_coords7, _positionB_coords7, _positionA_coords8, _positionB_coords8, _positionA_coords9, _positionB_coords9, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
|
|
3
|
+
return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords === undefined ? undefined : _positionA_coords.x) !== ((_positionB_coords = positionB.coords) === null || _positionB_coords === undefined ? undefined : _positionB_coords.x) || ((_positionA_coords1 = positionA.coords) === null || _positionA_coords1 === undefined ? undefined : _positionA_coords1.y) !== ((_positionB_coords1 = positionB.coords) === null || _positionB_coords1 === undefined ? undefined : _positionB_coords1.y) || ((_positionA_coords2 = positionA.coords) === null || _positionA_coords2 === undefined ? undefined : _positionA_coords2.clientX) !== ((_positionB_coords2 = positionB.coords) === null || _positionB_coords2 === undefined ? undefined : _positionB_coords2.clientX) || ((_positionA_coords3 = positionA.coords) === null || _positionA_coords3 === undefined ? undefined : _positionA_coords3.clientY) !== ((_positionB_coords3 = positionB.coords) === null || _positionB_coords3 === undefined ? undefined : _positionB_coords3.clientY) || ((_positionA_coords4 = positionA.coords) === null || _positionA_coords4 === undefined ? undefined : _positionA_coords4.offsetX) !== ((_positionB_coords4 = positionB.coords) === null || _positionB_coords4 === undefined ? undefined : _positionB_coords4.offsetX) || ((_positionA_coords5 = positionA.coords) === null || _positionA_coords5 === undefined ? undefined : _positionA_coords5.offsetY) !== ((_positionB_coords5 = positionB.coords) === null || _positionB_coords5 === undefined ? undefined : _positionB_coords5.offsetY) || ((_positionA_coords6 = positionA.coords) === null || _positionA_coords6 === undefined ? undefined : _positionA_coords6.pageX) !== ((_positionB_coords6 = positionB.coords) === null || _positionB_coords6 === undefined ? undefined : _positionB_coords6.pageX) || ((_positionA_coords7 = positionA.coords) === null || _positionA_coords7 === undefined ? undefined : _positionA_coords7.pageY) !== ((_positionB_coords7 = positionB.coords) === null || _positionB_coords7 === undefined ? undefined : _positionB_coords7.pageY) || ((_positionA_coords8 = positionA.coords) === null || _positionA_coords8 === undefined ? undefined : _positionA_coords8.screenX) !== ((_positionB_coords8 = positionB.coords) === null || _positionB_coords8 === undefined ? undefined : _positionB_coords8.screenX) || ((_positionA_coords9 = positionA.coords) === null || _positionA_coords9 === undefined ? undefined : _positionA_coords9.screenY) !== ((_positionB_coords9 = positionB.coords) === null || _positionB_coords9 === undefined ? undefined : _positionB_coords9.screenY) || ((_positionA_caret = positionA.caret) === null || _positionA_caret === undefined ? undefined : _positionA_caret.node) !== ((_positionB_caret = positionB.caret) === null || _positionB_caret === undefined ? undefined : _positionB_caret.node) || ((_positionA_caret1 = positionA.caret) === null || _positionA_caret1 === undefined ? undefined : _positionA_caret1.offset) !== ((_positionB_caret1 = positionB.caret) === null || _positionB_caret1 === undefined ? undefined : _positionB_caret1.offset);
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export { isDifferentPointerPosition };
|
|
@@ -5,14 +5,9 @@ import '../event/behavior/keypress.js';
|
|
|
5
5
|
import '../event/behavior/keyup.js';
|
|
6
6
|
import '../event/behavior/paste.js';
|
|
7
7
|
import '@testing-library/dom';
|
|
8
|
-
import '../utils/click/isClickableInput.js';
|
|
9
8
|
import '../utils/dataTransfer/Clipboard.js';
|
|
10
9
|
import { isEditable } from '../utils/edit/isEditable.js';
|
|
11
|
-
import '../utils/edit/maxLength.js';
|
|
12
10
|
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
13
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
14
|
-
import '../utils/misc/level.js';
|
|
15
|
-
import '../options.js';
|
|
16
11
|
import { focusElement } from '../event/focus.js';
|
|
17
12
|
import { input } from '../event/input.js';
|
|
18
13
|
import { selectAll, isAllSelected } from '../event/selection/selectAll.js';
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { getConfig } from '@testing-library/dom';
|
|
2
|
-
import '../utils/click/isClickableInput.js';
|
|
3
|
-
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../utils/edit/isEditable.js';
|
|
5
|
-
import '../utils/edit/maxLength.js';
|
|
6
2
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
3
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
7
4
|
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
8
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
9
|
-
import '../utils/misc/level.js';
|
|
10
5
|
import { wait } from '../utils/misc/wait.js';
|
|
11
6
|
import { hasPointerEvents } from '../utils/pointer/cssPointerEvents.js';
|
|
12
7
|
import '../event/behavior/click.js';
|
package/dist/esm/utility/type.js
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { releaseAllKeys } from '../keyboard/index.js';
|
|
2
|
-
import '../utils/click/isClickableInput.js';
|
|
3
2
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../utils/edit/isEditable.js';
|
|
5
|
-
import '../utils/edit/maxLength.js';
|
|
6
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
7
|
-
import '../utils/misc/level.js';
|
|
8
|
-
import '../options.js';
|
|
9
3
|
import { setSelectionRange } from '../event/selection/setSelectionRange.js';
|
|
10
4
|
|
|
11
5
|
async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
|
|
@@ -16,7 +10,7 @@ async function type(element, text, { skipClick = this.config.skipClick, skipAuto
|
|
|
16
10
|
await this.click(element);
|
|
17
11
|
}
|
|
18
12
|
if (initialSelectionStart !== undefined) {
|
|
19
|
-
setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !==
|
|
13
|
+
setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== undefined ? initialSelectionEnd : initialSelectionStart);
|
|
20
14
|
}
|
|
21
15
|
await this.keyboard(text);
|
|
22
16
|
if (!skipAutoClose) {
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import '../utils/
|
|
1
|
+
import { isElementType } from '../utils/misc/isElementType.js';
|
|
2
2
|
import { createFileList } from '../utils/dataTransfer/FileList.js';
|
|
3
3
|
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../utils/edit/isEditable.js';
|
|
5
|
-
import '../utils/edit/maxLength.js';
|
|
6
4
|
import { setFiles } from '../utils/edit/setFiles.js';
|
|
7
|
-
import { isElementType } from '../utils/misc/isElementType.js';
|
|
8
5
|
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
9
6
|
import { getWindow } from '../utils/misc/getWindow.js';
|
|
10
|
-
import '../utils/keyDef/readNextDescriptor.js';
|
|
11
|
-
import '../utils/misc/level.js';
|
|
12
|
-
import '../options.js';
|
|
13
7
|
|
|
14
8
|
async function upload(element, fileOrFiles) {
|
|
15
9
|
const input = isElementType(element, 'label') ? element.control : element;
|
|
16
10
|
if (!input || !isElementType(input, 'input', {
|
|
17
11
|
type: 'file'
|
|
18
12
|
})) {
|
|
19
|
-
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input ===
|
|
13
|
+
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === undefined ? undefined : input.tagName} element does not accept file uploads`);
|
|
20
14
|
}
|
|
21
15
|
if (isDisabled(element)) return;
|
|
22
16
|
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
|
|
@@ -25,9 +19,9 @@ async function upload(element, fileOrFiles) {
|
|
|
25
19
|
const fileDialog = ()=>{
|
|
26
20
|
var _input_files;
|
|
27
21
|
// do not fire an input event if the file selection does not change
|
|
28
|
-
if (files.length === ((_input_files = input.files) === null || _input_files ===
|
|
22
|
+
if (files.length === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _input_files.length) && files.every((f, i)=>{
|
|
29
23
|
var _input_files;
|
|
30
|
-
return f === ((_input_files = input.files) === null || _input_files ===
|
|
24
|
+
return f === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _input_files.item(i));
|
|
31
25
|
})) {
|
|
32
26
|
return;
|
|
33
27
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { isElementType } from '../misc/isElementType.js';
|
|
2
2
|
|
|
3
|
-
var clickableInputTypes
|
|
4
|
-
(function(clickableInputTypes) {
|
|
3
|
+
var clickableInputTypes = /*#__PURE__*/ function(clickableInputTypes) {
|
|
5
4
|
clickableInputTypes["button"] = "button";
|
|
6
5
|
clickableInputTypes["color"] = "color";
|
|
7
6
|
clickableInputTypes["file"] = "file";
|
|
@@ -10,7 +9,8 @@ var clickableInputTypes;
|
|
|
10
9
|
clickableInputTypes["submit"] = "submit";
|
|
11
10
|
clickableInputTypes["checkbox"] = "checkbox";
|
|
12
11
|
clickableInputTypes["radio"] = "radio";
|
|
13
|
-
|
|
12
|
+
return clickableInputTypes;
|
|
13
|
+
}(clickableInputTypes || {});
|
|
14
14
|
function isClickableInput(element) {
|
|
15
15
|
return isElementType(element, 'button') || isElementType(element, 'input') && element.type in clickableInputTypes;
|
|
16
16
|
}
|