@testing-library/user-event 14.6.1 → 14.6.4
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/README.md +19 -16
- package/dist/cjs/clipboard/copy.js +2 -2
- package/dist/cjs/clipboard/cut.js +2 -2
- package/dist/cjs/clipboard/paste.js +3 -4
- package/dist/cjs/document/UI.js +5 -7
- package/dist/cjs/document/interceptor.js +4 -4
- package/dist/cjs/document/patchFocus.js +5 -3
- package/dist/cjs/document/trackValue.js +2 -2
- package/dist/cjs/event/behavior/keydown.js +4 -4
- package/dist/cjs/event/behavior/keypress.js +1 -1
- package/dist/cjs/event/behavior/keyup.js +1 -1
- package/dist/cjs/event/behavior/paste.js +1 -1
- package/dist/cjs/event/createEvent.js +25 -39
- package/dist/cjs/event/dispatchEvent.js +1 -1
- package/dist/cjs/event/focus.js +3 -3
- package/dist/cjs/event/input.js +3 -2
- package/dist/cjs/event/selection/getInputRange.js +1 -1
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +2 -2
- package/dist/cjs/event/selection/modifySelection.js +1 -1
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +2 -2
- package/dist/cjs/event/selection/moveSelection.js +1 -1
- package/dist/cjs/event/selection/resolveCaretPosition.js +4 -5
- package/dist/cjs/event/selection/selectAll.js +5 -5
- package/dist/cjs/event/selection/setSelection.js +1 -1
- package/dist/cjs/event/selection/setSelectionPerMouse.js +9 -11
- package/dist/cjs/event/selection/setSelectionRange.js +1 -1
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +2 -2
- package/dist/cjs/event/wrapEvent.js +2 -1
- package/dist/cjs/keyboard/index.js +1 -1
- package/dist/cjs/keyboard/parseKeyDef.js +4 -4
- package/dist/cjs/pointer/index.js +9 -9
- package/dist/cjs/setup/api.js +4 -4
- package/dist/cjs/setup/setup.js +10 -10
- package/dist/cjs/system/index.js +1 -3
- package/dist/cjs/system/keyboard.js +8 -11
- package/dist/cjs/system/pointer/buttons.js +1 -5
- package/dist/cjs/system/pointer/device.js +1 -3
- package/dist/cjs/system/pointer/index.js +19 -22
- package/dist/cjs/system/pointer/mouse.js +10 -13
- package/dist/cjs/system/pointer/pointer.js +6 -8
- package/dist/cjs/system/pointer/shared.js +1 -1
- package/dist/cjs/utility/type.js +1 -1
- package/dist/cjs/utility/upload.js +3 -3
- package/dist/cjs/utils/dataTransfer/Clipboard.js +14 -9
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +5 -7
- package/dist/cjs/utils/edit/isContentEditable.js +1 -1
- package/dist/cjs/utils/edit/maxLength.js +1 -1
- package/dist/cjs/utils/edit/setFiles.js +2 -3
- package/dist/cjs/utils/focus/cursor.js +1 -1
- package/dist/cjs/utils/focus/getActiveElement.js +10 -8
- package/dist/cjs/utils/focus/selector.js +2 -1
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +8 -9
- 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/pointer/cssPointerEvents.js +11 -12
- package/dist/esm/clipboard/copy.js +2 -2
- package/dist/esm/clipboard/cut.js +2 -2
- package/dist/esm/clipboard/paste.js +3 -4
- package/dist/esm/document/UI.js +5 -7
- package/dist/esm/document/interceptor.js +5 -5
- package/dist/esm/document/patchFocus.js +5 -3
- package/dist/esm/document/trackValue.js +3 -3
- package/dist/esm/event/behavior/keydown.js +5 -5
- package/dist/esm/event/behavior/keypress.js +1 -1
- package/dist/esm/event/behavior/keyup.js +1 -1
- package/dist/esm/event/behavior/paste.js +1 -1
- package/dist/esm/event/createEvent.js +25 -39
- package/dist/esm/event/dispatchEvent.js +1 -1
- package/dist/esm/event/focus.js +3 -3
- package/dist/esm/event/input.js +3 -2
- package/dist/esm/event/selection/getInputRange.js +1 -1
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +2 -2
- package/dist/esm/event/selection/modifySelection.js +1 -1
- package/dist/esm/event/selection/modifySelectionPerMouse.js +2 -2
- package/dist/esm/event/selection/moveSelection.js +1 -1
- package/dist/esm/event/selection/resolveCaretPosition.js +4 -5
- package/dist/esm/event/selection/selectAll.js +6 -6
- package/dist/esm/event/selection/setSelection.js +1 -1
- package/dist/esm/event/selection/setSelectionPerMouse.js +9 -11
- package/dist/esm/event/selection/setSelectionRange.js +1 -1
- package/dist/esm/event/selection/updateSelectionOnFocus.js +2 -2
- package/dist/esm/event/wrapEvent.js +2 -1
- package/dist/esm/keyboard/index.js +1 -1
- package/dist/esm/keyboard/parseKeyDef.js +4 -4
- package/dist/esm/pointer/index.js +9 -9
- package/dist/esm/setup/api.js +3 -3
- package/dist/esm/setup/setup.js +11 -11
- package/dist/esm/system/index.js +1 -3
- package/dist/esm/system/keyboard.js +8 -11
- package/dist/esm/system/pointer/buttons.js +1 -5
- package/dist/esm/system/pointer/device.js +1 -3
- package/dist/esm/system/pointer/index.js +19 -22
- package/dist/esm/system/pointer/mouse.js +10 -13
- package/dist/esm/system/pointer/pointer.js +6 -8
- package/dist/esm/system/pointer/shared.js +1 -1
- package/dist/esm/utility/type.js +1 -1
- package/dist/esm/utility/upload.js +3 -3
- package/dist/esm/utils/dataTransfer/Clipboard.js +14 -9
- package/dist/esm/utils/dataTransfer/DataTransfer.js +5 -7
- package/dist/esm/utils/edit/isContentEditable.js +1 -1
- package/dist/esm/utils/edit/maxLength.js +1 -1
- package/dist/esm/utils/edit/setFiles.js +2 -3
- package/dist/esm/utils/focus/cursor.js +1 -1
- package/dist/esm/utils/focus/getActiveElement.js +10 -8
- package/dist/esm/utils/focus/selector.js +2 -1
- package/dist/esm/utils/keyDef/readNextDescriptor.js +8 -9
- 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/pointer/cssPointerEvents.js +11 -12
- package/dist/types/document/UI.d.ts +3 -3
- package/dist/types/event/behavior/registry.d.ts +1 -2
- package/dist/types/options.d.ts +1 -1
- package/dist/types/system/keyboard.d.ts +1 -1
- package/package.json +6 -3
|
@@ -16,22 +16,20 @@ function setSelectionPerMouseDown({ document, target, clickCount, node, offset }
|
|
|
16
16
|
// Looks it might be every inline element.
|
|
17
17
|
// TODO: Check what might be considered part of the same line of text.
|
|
18
18
|
const text = String(targetHasOwnSelection ? UI.getUIValue(target) : target.textContent);
|
|
19
|
-
const [start, end] = node ?
|
|
20
|
-
// TODO: support expanding initial range on multiple clicks if node is given
|
|
21
|
-
[
|
|
19
|
+
const [start, end] = node ? [
|
|
22
20
|
offset,
|
|
23
21
|
offset
|
|
24
22
|
] : getTextRange(text, offset, clickCount);
|
|
25
23
|
// TODO: implement modifying selection per shift/ctrl+mouse
|
|
26
24
|
if (targetHasOwnSelection) {
|
|
27
25
|
UI.setUISelection(target, {
|
|
28
|
-
anchorOffset: start !== null && start !==
|
|
29
|
-
focusOffset: end !== null && end !==
|
|
26
|
+
anchorOffset: start !== null && start !== void 0 ? start : text.length,
|
|
27
|
+
focusOffset: end !== null && end !== void 0 ? end : text.length
|
|
30
28
|
});
|
|
31
29
|
return {
|
|
32
30
|
node: target,
|
|
33
|
-
start: start !== null && start !==
|
|
34
|
-
end: end !== null && end !==
|
|
31
|
+
start: start !== null && start !== void 0 ? start : 0,
|
|
32
|
+
end: end !== null && end !== void 0 ? end : text.length
|
|
35
33
|
};
|
|
36
34
|
} else {
|
|
37
35
|
const { node: startNode, offset: startOffset } = resolveCaretPosition.resolveCaretPosition({
|
|
@@ -48,12 +46,12 @@ function setSelectionPerMouseDown({ document, target, clickCount, node, offset }
|
|
|
48
46
|
try {
|
|
49
47
|
range.setStart(startNode, startOffset);
|
|
50
48
|
range.setEnd(endNode, endOffset);
|
|
51
|
-
} catch
|
|
49
|
+
} catch {
|
|
52
50
|
throw new Error('The given offset is out of bounds.');
|
|
53
51
|
}
|
|
54
52
|
const selection = document.getSelection();
|
|
55
|
-
selection === null || selection ===
|
|
56
|
-
selection === null || selection ===
|
|
53
|
+
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
|
|
54
|
+
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
|
|
57
55
|
return range;
|
|
58
56
|
}
|
|
59
57
|
}
|
|
@@ -64,7 +62,7 @@ function getTextRange(text, pos, clickCount) {
|
|
|
64
62
|
pos
|
|
65
63
|
];
|
|
66
64
|
}
|
|
67
|
-
const textPos = pos !== null && pos !==
|
|
65
|
+
const textPos = pos !== null && pos !== void 0 ? pos : text.length;
|
|
68
66
|
if (clickCount % 3 === 2) {
|
|
69
67
|
return [
|
|
70
68
|
textPos - text.substr(0, pos).match(/(\w+|\s+|\W)?$/)[0].length,
|
|
@@ -18,7 +18,7 @@ var setSelection = require('./setSelection.js');
|
|
|
18
18
|
focusOffset
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
/* istanbul ignore else */ if (isContentEditable.isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild ===
|
|
21
|
+
/* istanbul ignore else */ if (isContentEditable.isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === void 0 ? void 0 : _element_firstChild.nodeType) === 3) {
|
|
22
22
|
return setSelection.setSelection({
|
|
23
23
|
focusNode: element.firstChild,
|
|
24
24
|
anchorOffset,
|
|
@@ -13,7 +13,7 @@ var selection = require('../../utils/focus/selection.js');
|
|
|
13
13
|
* with own selection implementation.
|
|
14
14
|
*/ function updateSelectionOnFocus(element) {
|
|
15
15
|
const selection$1 = element.ownerDocument.getSelection();
|
|
16
|
-
/* istanbul ignore if */ if (!(selection$1 === null || selection$1 ===
|
|
16
|
+
/* istanbul ignore if */ if (!(selection$1 === null || selection$1 === void 0 ? void 0 : selection$1.focusNode)) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
// If the focus moves inside an element with own selection implementation,
|
|
@@ -28,7 +28,7 @@ var selection = require('../../utils/focus/selection.js');
|
|
|
28
28
|
if (contenteditable) {
|
|
29
29
|
if (!selection$1.isCollapsed) {
|
|
30
30
|
var _contenteditable_firstChild;
|
|
31
|
-
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild ===
|
|
31
|
+
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === void 0 ? void 0 : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
|
|
32
32
|
selection$1.setBaseAndExtent(focusNode, 0, focusNode, 0);
|
|
33
33
|
}
|
|
34
34
|
} else {
|
|
@@ -19,7 +19,7 @@ async function keyboardAction(instance, { keyDef, releasePrevious, releaseSelf,
|
|
|
19
19
|
}
|
|
20
20
|
if (!releasePrevious) {
|
|
21
21
|
for(let i = 1; i <= repeat; i++){
|
|
22
|
-
await system.keyboard.keydown(instance, keyDef);
|
|
22
|
+
await system.keyboard.keydown(instance, keyDef, i > 1);
|
|
23
23
|
if (i < repeat) {
|
|
24
24
|
await wait.wait(instance.config);
|
|
25
25
|
}
|
|
@@ -15,18 +15,18 @@ var readNextDescriptor = require('../utils/keyDef/readNextDescriptor.js');
|
|
|
15
15
|
*/ function parseKeyDef(keyboardMap, text) {
|
|
16
16
|
const defs = [];
|
|
17
17
|
do {
|
|
18
|
-
const { type, descriptor, consumedLength, releasePrevious, releaseSelf = true, repeat } = readNextDescriptor.readNextDescriptor(text, 'keyboard');
|
|
19
18
|
var _keyboardMap_find;
|
|
19
|
+
const { type, descriptor, consumedLength, releasePrevious, releaseSelf = true, repeat } = readNextDescriptor.readNextDescriptor(text, 'keyboard');
|
|
20
20
|
const keyDef = (_keyboardMap_find = keyboardMap.find((def)=>{
|
|
21
21
|
if (type === '[') {
|
|
22
22
|
var _def_code;
|
|
23
|
-
return ((_def_code = def.code) === null || _def_code ===
|
|
23
|
+
return ((_def_code = def.code) === null || _def_code === void 0 ? void 0 : _def_code.toLowerCase()) === descriptor.toLowerCase();
|
|
24
24
|
} else if (type === '{') {
|
|
25
25
|
var _def_key;
|
|
26
|
-
return ((_def_key = def.key) === null || _def_key ===
|
|
26
|
+
return ((_def_key = def.key) === null || _def_key === void 0 ? void 0 : _def_key.toLowerCase()) === descriptor.toLowerCase();
|
|
27
27
|
}
|
|
28
28
|
return def.key === descriptor;
|
|
29
|
-
})) !== null && _keyboardMap_find !==
|
|
29
|
+
})) !== null && _keyboardMap_find !== void 0 ? _keyboardMap_find : {
|
|
30
30
|
key: 'Unknown',
|
|
31
31
|
code: 'Unknown',
|
|
32
32
|
[type === '[' ? 'code' : 'key']: descriptor
|
|
@@ -29,16 +29,16 @@ async function pointer(input) {
|
|
|
29
29
|
this.system.pointer.resetClickCount();
|
|
30
30
|
}
|
|
31
31
|
async function pointerAction(instance, action) {
|
|
32
|
+
var _action_target, _action_coords, _action_node, _action_offset;
|
|
32
33
|
var _previousPosition_caret, _previousPosition_caret1;
|
|
33
34
|
const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? instance.system.pointer.getPointerName(action.keyDef) : 'mouse';
|
|
34
35
|
const previousPosition = instance.system.pointer.getPreviousPosition(pointerName);
|
|
35
|
-
var _action_target, _action_coords, _action_node, _action_offset;
|
|
36
36
|
const position = {
|
|
37
|
-
target: (_action_target = action.target) !== null && _action_target !==
|
|
38
|
-
coords: (_action_coords = action.coords) !== null && _action_coords !==
|
|
37
|
+
target: (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : getPrevTarget(instance, previousPosition),
|
|
38
|
+
coords: (_action_coords = action.coords) !== null && _action_coords !== void 0 ? _action_coords : previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.coords,
|
|
39
39
|
caret: {
|
|
40
|
-
node: (_action_node = action.node) !== null && _action_node !==
|
|
41
|
-
offset: (_action_offset = action.offset) !== null && _action_offset !==
|
|
40
|
+
node: (_action_node = action.node) !== null && _action_node !== void 0 ? _action_node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (_previousPosition_caret = previousPosition.caret) === null || _previousPosition_caret === void 0 ? void 0 : _previousPosition_caret.node,
|
|
41
|
+
offset: (_action_offset = action.offset) !== null && _action_offset !== void 0 ? _action_offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (_previousPosition_caret1 = previousPosition.caret) === null || _previousPosition_caret1 === void 0 ? void 0 : _previousPosition_caret1.offset
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
if ('keyDef' in action) {
|
|
@@ -60,15 +60,15 @@ async function pointerAction(instance, action) {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
function hasCaretPosition(action) {
|
|
63
|
-
var
|
|
64
|
-
return !!((_ref = (_action_target = action.target) !== null && _action_target !==
|
|
63
|
+
var _ref, _action_target;
|
|
64
|
+
return !!((_ref = (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : action.node) !== null && _ref !== void 0 ? _ref : action.offset !== undefined);
|
|
65
65
|
}
|
|
66
66
|
function getPrevTarget(instance, position) {
|
|
67
|
+
var _position_target;
|
|
67
68
|
if (!position) {
|
|
68
69
|
throw new Error('This pointer has no previous position. Provide a target property!');
|
|
69
70
|
}
|
|
70
|
-
|
|
71
|
-
return (_position_target = position.target) !== null && _position_target !== undefined ? _position_target : instance.config.document.body;
|
|
71
|
+
return (_position_target = position.target) !== null && _position_target !== void 0 ? _position_target : instance.config.document.body;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
exports.pointer = pointer;
|
package/dist/cjs/setup/api.js
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
var click = require('../convenience/click.js');
|
|
4
4
|
var hover = require('../convenience/hover.js');
|
|
5
5
|
var tab = require('../convenience/tab.js');
|
|
6
|
-
var index = require('../keyboard/index.js');
|
|
6
|
+
var index$1 = require('../keyboard/index.js');
|
|
7
7
|
var copy = require('../clipboard/copy.js');
|
|
8
8
|
var cut = require('../clipboard/cut.js');
|
|
9
9
|
var paste = require('../clipboard/paste.js');
|
|
10
|
-
var index
|
|
10
|
+
var index = require('../pointer/index.js');
|
|
11
11
|
var clear = require('../utility/clear.js');
|
|
12
12
|
var selectOptions = require('../utility/selectOptions.js');
|
|
13
13
|
var type = require('../utility/type.js');
|
|
@@ -20,11 +20,11 @@ const userEventApi = {
|
|
|
20
20
|
hover: hover.hover,
|
|
21
21
|
unhover: hover.unhover,
|
|
22
22
|
tab: tab.tab,
|
|
23
|
-
keyboard: index.keyboard,
|
|
23
|
+
keyboard: index$1.keyboard,
|
|
24
24
|
copy: copy.copy,
|
|
25
25
|
cut: cut.cut,
|
|
26
26
|
paste: paste.paste,
|
|
27
|
-
pointer: index
|
|
27
|
+
pointer: index.pointer,
|
|
28
28
|
clear: clear.clear,
|
|
29
29
|
deselectOptions: selectOptions.deselectOptions,
|
|
30
30
|
selectOptions: selectOptions.selectOptions,
|
package/dist/cjs/setup/setup.js
CHANGED
|
@@ -10,8 +10,8 @@ var level = require('../utils/misc/level.js');
|
|
|
10
10
|
var wait = require('../utils/misc/wait.js');
|
|
11
11
|
var options = require('../options.js');
|
|
12
12
|
require('@testing-library/dom');
|
|
13
|
-
var keyMap = require('../keyboard/keyMap.js');
|
|
14
|
-
var keyMap
|
|
13
|
+
var keyMap$1 = require('../keyboard/keyMap.js');
|
|
14
|
+
var keyMap = require('../pointer/keyMap.js');
|
|
15
15
|
var index = require('../system/index.js');
|
|
16
16
|
var api = require('./api.js');
|
|
17
17
|
var wrapAsync = require('./wrapAsync.js');
|
|
@@ -23,8 +23,8 @@ var wrapAsync = require('./wrapAsync.js');
|
|
|
23
23
|
autoModify: true,
|
|
24
24
|
delay: 0,
|
|
25
25
|
document: globalThis.document,
|
|
26
|
-
keyboardMap: keyMap.defaultKeyMap,
|
|
27
|
-
pointerMap: keyMap
|
|
26
|
+
keyboardMap: keyMap$1.defaultKeyMap,
|
|
27
|
+
pointerMap: keyMap.defaultKeyMap,
|
|
28
28
|
pointerEventsCheck: options.PointerEventsCheckLevel.EachApiCall,
|
|
29
29
|
skipAutoClose: false,
|
|
30
30
|
skipClick: false,
|
|
@@ -50,22 +50,22 @@ function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
|
|
|
50
50
|
* Start a "session" with userEvent.
|
|
51
51
|
* All APIs returned by this function share an input device state and a default configuration.
|
|
52
52
|
*/ function setupMain(options = {}) {
|
|
53
|
+
var _config_document_defaultView;
|
|
53
54
|
const config = createConfig(options);
|
|
54
55
|
prepareDocument.prepareDocument(config.document);
|
|
55
56
|
patchFocus.patchFocus(getWindow.getWindow(config.document).HTMLElement);
|
|
56
|
-
|
|
57
|
-
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== undefined ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window;
|
|
57
|
+
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== void 0 ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window;
|
|
58
58
|
Clipboard.attachClipboardStubToView(view);
|
|
59
59
|
return createInstance(config).api;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
62
|
* Setup in direct call per `userEvent.anyApi()`
|
|
63
63
|
*/ function setupDirect({ keyboardState, pointerState, ...options } = {}, node) {
|
|
64
|
+
var _ref;
|
|
64
65
|
const config = createConfig(options, defaultOptionsDirect, node);
|
|
65
66
|
prepareDocument.prepareDocument(config.document);
|
|
66
67
|
patchFocus.patchFocus(getWindow.getWindow(config.document).HTMLElement);
|
|
67
|
-
|
|
68
|
-
const system = (_ref = pointerState !== null && pointerState !== undefined ? pointerState : keyboardState) !== null && _ref !== undefined ? _ref : new index.System();
|
|
68
|
+
const system = (_ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && _ref !== void 0 ? _ref : new index.System();
|
|
69
69
|
return {
|
|
70
70
|
api: createInstance(config, system).api,
|
|
71
71
|
system
|
|
@@ -114,8 +114,8 @@ function createInstance(config, system = new index.System()) {
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
function getDocument(options, node, defaults) {
|
|
117
|
-
var
|
|
118
|
-
return (_ref = (_options_document = options.document) !== null && _options_document !==
|
|
117
|
+
var _ref, _options_document;
|
|
118
|
+
return (_ref = (_options_document = options.document) !== null && _options_document !== void 0 ? _options_document : node && getDocumentFromNode.getDocumentFromNode(node)) !== null && _ref !== void 0 ? _ref : defaults.document;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
exports.createConfig = createConfig;
|
package/dist/cjs/system/index.js
CHANGED
|
@@ -11,9 +11,7 @@ function _define_property(obj, key, value) {
|
|
|
11
11
|
configurable: true,
|
|
12
12
|
writable: true
|
|
13
13
|
});
|
|
14
|
-
} else
|
|
15
|
-
obj[key] = value;
|
|
16
|
-
}
|
|
14
|
+
} else obj[key] = value;
|
|
17
15
|
return obj;
|
|
18
16
|
}
|
|
19
17
|
var DOM_KEY_LOCATION = /*#__PURE__*/ function(DOM_KEY_LOCATION) {
|
|
@@ -52,7 +50,7 @@ class KeyboardHost {
|
|
|
52
50
|
getPressedKeys() {
|
|
53
51
|
return this.pressed.values().map((p)=>p.keyDef);
|
|
54
52
|
}
|
|
55
|
-
/** Press a key */ async keydown(instance, keyDef) {
|
|
53
|
+
/** Press a key */ async keydown(instance, keyDef, repeat = false) {
|
|
56
54
|
const key = String(keyDef.key);
|
|
57
55
|
const code = String(keyDef.code);
|
|
58
56
|
const target = getActiveElement.getActiveElementOrBody(instance.config.document);
|
|
@@ -63,7 +61,8 @@ class KeyboardHost {
|
|
|
63
61
|
}
|
|
64
62
|
const unprevented = instance.dispatchUIEvent(target, 'keydown', {
|
|
65
63
|
key,
|
|
66
|
-
code
|
|
64
|
+
code,
|
|
65
|
+
repeat
|
|
67
66
|
});
|
|
68
67
|
if (isModifierLock(key) && !this.modifiers[key]) {
|
|
69
68
|
this.modifiers[key] = true;
|
|
@@ -110,7 +109,7 @@ class KeyboardHost {
|
|
|
110
109
|
return (key.length === 1 || key === 'Enter') && !this.modifiers.Control && !this.modifiers.Alt;
|
|
111
110
|
}
|
|
112
111
|
constructor(system){
|
|
113
|
-
_define_property(this, "system",
|
|
112
|
+
_define_property(this, "system", void 0);
|
|
114
113
|
_define_property(this, "modifiers", {
|
|
115
114
|
Alt: false,
|
|
116
115
|
AltGraph: false,
|
|
@@ -127,9 +126,8 @@ class KeyboardHost {
|
|
|
127
126
|
});
|
|
128
127
|
_define_property(this, "pressed", new class {
|
|
129
128
|
add(code, keyDef) {
|
|
130
|
-
var _this_registry, _code;
|
|
131
|
-
|
|
132
|
-
(_ = (_this_registry = this.registry)[_code = code]) !== null && _ !== undefined ? _ : _this_registry[_code] = {
|
|
129
|
+
var _this_registry, _code, _;
|
|
130
|
+
(_ = (_this_registry = this.registry)[_code = code]) !== null && _ !== void 0 ? _ : _this_registry[_code] = {
|
|
133
131
|
keyDef,
|
|
134
132
|
unpreventedDefault: false
|
|
135
133
|
};
|
|
@@ -145,10 +143,9 @@ class KeyboardHost {
|
|
|
145
143
|
}
|
|
146
144
|
isUnprevented(code) {
|
|
147
145
|
var _this_registry_code;
|
|
148
|
-
return !!((_this_registry_code = this.registry[code]) === null || _this_registry_code ===
|
|
146
|
+
return !!((_this_registry_code = this.registry[code]) === null || _this_registry_code === void 0 ? void 0 : _this_registry_code.unpreventedDefault);
|
|
149
147
|
}
|
|
150
148
|
delete(code) {
|
|
151
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
152
149
|
delete this.registry[code];
|
|
153
150
|
}
|
|
154
151
|
values() {
|
|
@@ -8,16 +8,13 @@ function _define_property(obj, key, value) {
|
|
|
8
8
|
configurable: true,
|
|
9
9
|
writable: true
|
|
10
10
|
});
|
|
11
|
-
} else
|
|
12
|
-
obj[key] = value;
|
|
13
|
-
}
|
|
11
|
+
} else obj[key] = value;
|
|
14
12
|
return obj;
|
|
15
13
|
}
|
|
16
14
|
class Buttons {
|
|
17
15
|
getButtons() {
|
|
18
16
|
let v = 0;
|
|
19
17
|
for (const button of Object.keys(this.pressed)){
|
|
20
|
-
// eslint-disable-next-line no-bitwise
|
|
21
18
|
v |= 2 ** Number(button);
|
|
22
19
|
}
|
|
23
20
|
return v;
|
|
@@ -38,7 +35,6 @@ class Buttons {
|
|
|
38
35
|
if (button in this.pressed) {
|
|
39
36
|
this.pressed[button] = this.pressed[button].filter((k)=>k.name !== keyDef.name);
|
|
40
37
|
if (this.pressed[button].length === 0) {
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
|
42
38
|
delete this.pressed[button];
|
|
43
39
|
return button;
|
|
44
40
|
}
|
|
@@ -13,9 +13,7 @@ function _define_property(obj, key, value) {
|
|
|
13
13
|
configurable: true,
|
|
14
14
|
writable: true
|
|
15
15
|
});
|
|
16
|
-
} else
|
|
17
|
-
obj[key] = value;
|
|
18
|
-
}
|
|
16
|
+
} else obj[key] = value;
|
|
19
17
|
return obj;
|
|
20
18
|
}
|
|
21
19
|
class PointerHost {
|
|
@@ -48,12 +46,12 @@ class PointerHost {
|
|
|
48
46
|
// the order in which they interweave/follow on a user interaction depends on the implementation.
|
|
49
47
|
const pointermove = pointer.move(instance, position);
|
|
50
48
|
const mousemove = pointer.pointerType === 'touch' ? undefined : this.mouse.move(instance, position, pointer.isPrevented);
|
|
51
|
-
pointermove === null || pointermove ===
|
|
52
|
-
mousemove === null || mousemove ===
|
|
53
|
-
pointermove === null || pointermove ===
|
|
54
|
-
mousemove === null || mousemove ===
|
|
55
|
-
pointermove === null || pointermove ===
|
|
56
|
-
mousemove === null || mousemove ===
|
|
49
|
+
pointermove === null || pointermove === void 0 ? void 0 : pointermove.leave();
|
|
50
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
|
|
51
|
+
pointermove === null || pointermove === void 0 ? void 0 : pointermove.enter();
|
|
52
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
|
|
53
|
+
pointermove === null || pointermove === void 0 ? void 0 : pointermove.move();
|
|
54
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
|
|
57
55
|
}
|
|
58
56
|
async release(instance, keyDef, position) {
|
|
59
57
|
const device = this.devices.get(keyDef.pointerType);
|
|
@@ -74,16 +72,16 @@ class PointerHost {
|
|
|
74
72
|
}
|
|
75
73
|
if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
|
|
76
74
|
const mousemove = this.mouse.move(instance, position, isPrevented);
|
|
77
|
-
mousemove === null || mousemove ===
|
|
78
|
-
mousemove === null || mousemove ===
|
|
79
|
-
mousemove === null || mousemove ===
|
|
75
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
|
|
76
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
|
|
77
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
|
|
80
78
|
this.mouse.down(instance, keyDef, isPrevented);
|
|
81
79
|
}
|
|
82
80
|
if (!pointer.isMultitouch) {
|
|
83
81
|
const mousemove = this.mouse.move(instance, position, isPrevented);
|
|
84
|
-
mousemove === null || mousemove ===
|
|
85
|
-
mousemove === null || mousemove ===
|
|
86
|
-
mousemove === null || mousemove ===
|
|
82
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
|
|
83
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
|
|
84
|
+
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
|
|
87
85
|
this.mouse.up(instance, keyDef, isPrevented);
|
|
88
86
|
}
|
|
89
87
|
}
|
|
@@ -98,21 +96,20 @@ class PointerHost {
|
|
|
98
96
|
}
|
|
99
97
|
getMouseTarget(instance) {
|
|
100
98
|
var _this_mouse_position_target;
|
|
101
|
-
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !==
|
|
99
|
+
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== void 0 ? _this_mouse_position_target : instance.config.document.body;
|
|
102
100
|
}
|
|
103
101
|
setMousePosition(position) {
|
|
104
102
|
this.mouse.position = position;
|
|
105
103
|
this.pointers.get('mouse').position = position;
|
|
106
104
|
}
|
|
107
105
|
constructor(system){
|
|
108
|
-
_define_property(this, "system",
|
|
109
|
-
_define_property(this, "mouse",
|
|
110
|
-
_define_property(this, "buttons",
|
|
106
|
+
_define_property(this, "system", void 0);
|
|
107
|
+
_define_property(this, "mouse", void 0);
|
|
108
|
+
_define_property(this, "buttons", void 0);
|
|
111
109
|
_define_property(this, "devices", new class {
|
|
112
110
|
get(k) {
|
|
113
|
-
var _this_registry, _k;
|
|
114
|
-
|
|
115
|
-
return (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== undefined ? _ : _this_registry[_k] = new device.Device();
|
|
111
|
+
var _this_registry, _k, _;
|
|
112
|
+
return (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new device.Device();
|
|
116
113
|
}
|
|
117
114
|
constructor(){
|
|
118
115
|
_define_property(this, "registry", {});
|
|
@@ -24,9 +24,7 @@ function _define_property(obj, key, value) {
|
|
|
24
24
|
configurable: true,
|
|
25
25
|
writable: true
|
|
26
26
|
});
|
|
27
|
-
} else
|
|
28
|
-
obj[key] = value;
|
|
29
|
-
}
|
|
27
|
+
} else obj[key] = value;
|
|
30
28
|
return obj;
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
@@ -128,7 +126,7 @@ function _define_property(obj, key, value) {
|
|
|
128
126
|
}
|
|
129
127
|
getTarget(instance) {
|
|
130
128
|
var _this_position_target;
|
|
131
|
-
return (_this_position_target = this.position.target) !== null && _this_position_target !==
|
|
129
|
+
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
|
|
132
130
|
}
|
|
133
131
|
startSelecting(instance, clickCount) {
|
|
134
132
|
var _this_position_caret, _this_position_caret1;
|
|
@@ -136,8 +134,8 @@ function _define_property(obj, key, value) {
|
|
|
136
134
|
this.selecting = setSelectionPerMouse.setSelectionPerMouseDown({
|
|
137
135
|
document: instance.config.document,
|
|
138
136
|
target: this.getTarget(instance),
|
|
139
|
-
node: (_this_position_caret = this.position.caret) === null || _this_position_caret ===
|
|
140
|
-
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 ===
|
|
137
|
+
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
|
|
138
|
+
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset,
|
|
141
139
|
clickCount
|
|
142
140
|
});
|
|
143
141
|
}
|
|
@@ -149,8 +147,8 @@ function _define_property(obj, key, value) {
|
|
|
149
147
|
modifySelectionPerMouse.modifySelectionPerMouseMove(this.selecting, {
|
|
150
148
|
document: instance.config.document,
|
|
151
149
|
target: this.getTarget(instance),
|
|
152
|
-
node: (_this_position_caret = this.position.caret) === null || _this_position_caret ===
|
|
153
|
-
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 ===
|
|
150
|
+
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
|
|
151
|
+
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset
|
|
154
152
|
});
|
|
155
153
|
}
|
|
156
154
|
endSelecting() {
|
|
@@ -159,7 +157,7 @@ function _define_property(obj, key, value) {
|
|
|
159
157
|
constructor(){
|
|
160
158
|
_define_property(this, "position", {});
|
|
161
159
|
_define_property(this, "buttons", new buttons.Buttons());
|
|
162
|
-
_define_property(this, "selecting",
|
|
160
|
+
_define_property(this, "selecting", void 0);
|
|
163
161
|
_define_property(this, "buttonDownTarget", {});
|
|
164
162
|
// According to spec the `detail` on click events should be the number
|
|
165
163
|
// of *consecutive* clicks with a specific button.
|
|
@@ -180,13 +178,12 @@ function _define_property(obj, key, value) {
|
|
|
180
178
|
return current;
|
|
181
179
|
}
|
|
182
180
|
getOnDown(button) {
|
|
183
|
-
var _this_count_button;
|
|
181
|
+
var _this_count_button, _this_count_button1;
|
|
184
182
|
this.down = {
|
|
185
|
-
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !==
|
|
183
|
+
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0
|
|
186
184
|
};
|
|
187
|
-
var _this_count_button1;
|
|
188
185
|
this.count = {
|
|
189
|
-
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !==
|
|
186
|
+
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0
|
|
190
187
|
};
|
|
191
188
|
return Number(this.count[button]) + 1;
|
|
192
189
|
}
|
|
@@ -14,9 +14,7 @@ function _define_property(obj, key, value) {
|
|
|
14
14
|
configurable: true,
|
|
15
15
|
writable: true
|
|
16
16
|
});
|
|
17
|
-
} else
|
|
18
|
-
obj[key] = value;
|
|
19
|
-
}
|
|
17
|
+
} else obj[key] = value;
|
|
20
18
|
return obj;
|
|
21
19
|
}
|
|
22
20
|
class Pointer {
|
|
@@ -93,7 +91,7 @@ class Pointer {
|
|
|
93
91
|
}
|
|
94
92
|
getTarget(instance) {
|
|
95
93
|
var _this_position_target;
|
|
96
|
-
return (_this_position_target = this.position.target) !== null && _this_position_target !==
|
|
94
|
+
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
|
|
97
95
|
}
|
|
98
96
|
getEventInit(/**
|
|
99
97
|
* The `button` that caused the event.
|
|
@@ -111,10 +109,10 @@ class Pointer {
|
|
|
111
109
|
};
|
|
112
110
|
}
|
|
113
111
|
constructor({ pointerId, pointerType, isPrimary }, buttons){
|
|
114
|
-
_define_property(this, "pointerId",
|
|
115
|
-
_define_property(this, "pointerType",
|
|
116
|
-
_define_property(this, "isPrimary",
|
|
117
|
-
_define_property(this, "buttons",
|
|
112
|
+
_define_property(this, "pointerId", void 0);
|
|
113
|
+
_define_property(this, "pointerType", void 0);
|
|
114
|
+
_define_property(this, "isPrimary", void 0);
|
|
115
|
+
_define_property(this, "buttons", void 0);
|
|
118
116
|
_define_property(this, "isMultitouch", false);
|
|
119
117
|
_define_property(this, "isCancelled", false);
|
|
120
118
|
_define_property(this, "isDown", false);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
function isDifferentPointerPosition(positionA, positionB) {
|
|
4
4
|
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;
|
|
5
|
-
return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords ===
|
|
5
|
+
return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords === void 0 ? void 0 : _positionA_coords.x) !== ((_positionB_coords = positionB.coords) === null || _positionB_coords === void 0 ? void 0 : _positionB_coords.x) || ((_positionA_coords1 = positionA.coords) === null || _positionA_coords1 === void 0 ? void 0 : _positionA_coords1.y) !== ((_positionB_coords1 = positionB.coords) === null || _positionB_coords1 === void 0 ? void 0 : _positionB_coords1.y) || ((_positionA_coords2 = positionA.coords) === null || _positionA_coords2 === void 0 ? void 0 : _positionA_coords2.clientX) !== ((_positionB_coords2 = positionB.coords) === null || _positionB_coords2 === void 0 ? void 0 : _positionB_coords2.clientX) || ((_positionA_coords3 = positionA.coords) === null || _positionA_coords3 === void 0 ? void 0 : _positionA_coords3.clientY) !== ((_positionB_coords3 = positionB.coords) === null || _positionB_coords3 === void 0 ? void 0 : _positionB_coords3.clientY) || ((_positionA_coords4 = positionA.coords) === null || _positionA_coords4 === void 0 ? void 0 : _positionA_coords4.offsetX) !== ((_positionB_coords4 = positionB.coords) === null || _positionB_coords4 === void 0 ? void 0 : _positionB_coords4.offsetX) || ((_positionA_coords5 = positionA.coords) === null || _positionA_coords5 === void 0 ? void 0 : _positionA_coords5.offsetY) !== ((_positionB_coords5 = positionB.coords) === null || _positionB_coords5 === void 0 ? void 0 : _positionB_coords5.offsetY) || ((_positionA_coords6 = positionA.coords) === null || _positionA_coords6 === void 0 ? void 0 : _positionA_coords6.pageX) !== ((_positionB_coords6 = positionB.coords) === null || _positionB_coords6 === void 0 ? void 0 : _positionB_coords6.pageX) || ((_positionA_coords7 = positionA.coords) === null || _positionA_coords7 === void 0 ? void 0 : _positionA_coords7.pageY) !== ((_positionB_coords7 = positionB.coords) === null || _positionB_coords7 === void 0 ? void 0 : _positionB_coords7.pageY) || ((_positionA_coords8 = positionA.coords) === null || _positionA_coords8 === void 0 ? void 0 : _positionA_coords8.screenX) !== ((_positionB_coords8 = positionB.coords) === null || _positionB_coords8 === void 0 ? void 0 : _positionB_coords8.screenX) || ((_positionA_coords9 = positionA.coords) === null || _positionA_coords9 === void 0 ? void 0 : _positionA_coords9.screenY) !== ((_positionB_coords9 = positionB.coords) === null || _positionB_coords9 === void 0 ? void 0 : _positionB_coords9.screenY) || ((_positionA_caret = positionA.caret) === null || _positionA_caret === void 0 ? void 0 : _positionA_caret.node) !== ((_positionB_caret = positionB.caret) === null || _positionB_caret === void 0 ? void 0 : _positionB_caret.node) || ((_positionA_caret1 = positionA.caret) === null || _positionA_caret1 === void 0 ? void 0 : _positionA_caret1.offset) !== ((_positionB_caret1 = positionB.caret) === null || _positionB_caret1 === void 0 ? void 0 : _positionB_caret1.offset);
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
exports.isDifferentPointerPosition = isDifferentPointerPosition;
|
package/dist/cjs/utility/type.js
CHANGED
|
@@ -12,7 +12,7 @@ async function type(element, text, { skipClick = this.config.skipClick, skipAuto
|
|
|
12
12
|
await this.click(element);
|
|
13
13
|
}
|
|
14
14
|
if (initialSelectionStart !== undefined) {
|
|
15
|
-
setSelectionRange.setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !==
|
|
15
|
+
setSelectionRange.setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== void 0 ? initialSelectionEnd : initialSelectionStart);
|
|
16
16
|
}
|
|
17
17
|
await this.keyboard(text);
|
|
18
18
|
if (!skipAutoClose) {
|
|
@@ -12,7 +12,7 @@ async function upload(element, fileOrFiles) {
|
|
|
12
12
|
if (!input || !isElementType.isElementType(input, 'input', {
|
|
13
13
|
type: 'file'
|
|
14
14
|
})) {
|
|
15
|
-
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input ===
|
|
15
|
+
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
|
|
16
16
|
}
|
|
17
17
|
if (isDisabled.isDisabled(element)) return;
|
|
18
18
|
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
|
|
@@ -21,9 +21,9 @@ async function upload(element, fileOrFiles) {
|
|
|
21
21
|
const fileDialog = ()=>{
|
|
22
22
|
var _input_files;
|
|
23
23
|
// do not fire an input event if the file selection does not change
|
|
24
|
-
if (files.length === ((_input_files = input.files) === null || _input_files ===
|
|
24
|
+
if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{
|
|
25
25
|
var _input_files;
|
|
26
|
-
return f === ((_input_files = input.files) === null || _input_files ===
|
|
26
|
+
return f === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.item(i));
|
|
27
27
|
})) {
|
|
28
28
|
return;
|
|
29
29
|
}
|