Socket
Socket
Sign inDemoInstall

@testing-library/user-event

Package Overview
Dependencies
Maintainers
15
Versions
199
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@testing-library/user-event - npm Package Compare versions

Comparing version 14.4.3 to 14.5.0

dist/cjs/_interop/dom-events.d.js

4

dist/cjs/clipboard/copy.js

@@ -17,4 +17,4 @@ 'use strict';

const doc = this.config.document;
var _activeElement;
const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body;
var _doc_activeElement;
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
const clipboardData = copySelection.copySelection(target);

@@ -21,0 +21,0 @@ if (clipboardData.items.length === 0) {

@@ -17,4 +17,4 @@ 'use strict';

const doc = this.config.document;
var _activeElement;
const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body;
var _doc_activeElement;
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
const clipboardData = copySelection.copySelection(target);

@@ -21,0 +21,0 @@ if (clipboardData.items.length === 0) {

@@ -17,6 +17,6 @@ 'use strict';

const doc = this.config.document;
var _activeElement;
const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body;
var ref;
const dataTransfer = (ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && ref !== void 0 ? ref : await Clipboard.readDataTransferFromClipboard(doc).catch(()=>{
var _doc_activeElement;
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
var _ref;
const dataTransfer = (_ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && _ref !== void 0 ? _ref : await Clipboard.readDataTransferFromClipboard(doc).catch(()=>{
throw new Error('`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.');

@@ -23,0 +23,0 @@ });

@@ -5,3 +5,3 @@ 'use strict';

async function tab({ shift } = {}) {
async function tab({ shift } = {}) {
return this.keyboard(shift === true ? '{Shift>}{Tab}{/Shift}' : shift === false ? '[/ShiftLeft][/ShiftRight]{Tab}' : '{Tab}');

@@ -8,0 +8,0 @@ }

@@ -19,10 +19,12 @@ 'use strict';

function prepareInterceptor(element, propName, interceptorImpl) {
var _prototypeDescriptor, _prototypeDescriptor1;
const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
const target = (prototypeDescriptor === null || prototypeDescriptor === void 0 ? void 0 : prototypeDescriptor.set) ? 'set' : 'value';
/* istanbul ignore if */ if (typeof (prototypeDescriptor === null || prototypeDescriptor === void 0 ? void 0 : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
const target = ((_prototypeDescriptor = prototypeDescriptor) === null || _prototypeDescriptor === void 0 ? void 0 : _prototypeDescriptor.set) ? 'set' : 'value';
/* istanbul ignore if */ if (typeof ((_prototypeDescriptor1 = prototypeDescriptor) === null || _prototypeDescriptor1 === void 0 ? void 0 : _prototypeDescriptor1[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`);
}
function intercept(...args) {
const { applyNative =false , realArgs , then , } = interceptorImpl.call(this, ...args);
var _then;
const { applyNative = false, realArgs, then } = interceptorImpl.call(this, ...args);
const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];

@@ -34,3 +36,3 @@ if (target === 'set') {

}
then === null || then === void 0 ? void 0 : then();
(_then = then) === null || _then === void 0 ? void 0 : _then();
}

@@ -37,0 +39,0 @@ intercept[Interceptor] = Interceptor;

@@ -36,4 +36,4 @@ 'use strict';

function trackOrSetValue(element, v) {
var ref, ref1;
(ref = element[TrackChanges]) === null || ref === void 0 ? void 0 : (ref1 = ref.tracked) === null || ref1 === void 0 ? void 0 : ref1.push(v);
var _element_TrackChanges_tracked, _element_TrackChanges;
(_element_TrackChanges = element[TrackChanges]) === null || _element_TrackChanges === void 0 ? void 0 : (_element_TrackChanges_tracked = _element_TrackChanges.tracked) === null || _element_TrackChanges_tracked === void 0 ? void 0 : _element_TrackChanges_tracked.push(v);
if (!element[TrackChanges]) {

@@ -47,6 +47,6 @@ UI.setUIValueClean(element);

function commitValueAfterInput(element, cursorOffset) {
var ref;
var _changes_tracked, _changes;
const changes = element[TrackChanges];
element[TrackChanges] = undefined;
if (!(changes === null || changes === void 0 ? void 0 : (ref = changes.tracked) === null || ref === void 0 ? void 0 : ref.length)) {
if (!((_changes = changes) === null || _changes === void 0 ? void 0 : (_changes_tracked = _changes.tracked) === null || _changes_tracked === void 0 ? void 0 : _changes_tracked.length)) {
return;

@@ -53,0 +53,0 @@ }

@@ -39,3 +39,3 @@ 'use strict';

}
function setUISelection(element, { focusOffset: focusOffsetParam , anchorOffset: anchorOffsetParam = focusOffsetParam }, mode = 'replace') {
function setUISelection(element, { focusOffset: focusOffsetParam, anchorOffset: anchorOffsetParam = focusOffsetParam }, mode = 'replace') {
const valueLength = getUIValue(element).length;

@@ -66,6 +66,6 @@ const sanitizeOffset = (o)=>Math.max(0, Math.min(valueLength, o));

function getUISelection(element) {
var _selectionStart, _selectionEnd, _UISelection;
const sel = (_UISelection = element[UISelection]) !== null && _UISelection !== void 0 ? _UISelection : {
anchorOffset: (_selectionStart = element.selectionStart) !== null && _selectionStart !== void 0 ? _selectionStart : 0,
focusOffset: (_selectionEnd = element.selectionEnd) !== null && _selectionEnd !== void 0 ? _selectionEnd : 0
var _element_selectionStart, _element_selectionEnd, _element_UISelection;
const sel = (_element_UISelection = element[UISelection]) !== null && _element_UISelection !== void 0 ? _element_UISelection : {
anchorOffset: (_element_selectionStart = element.selectionStart) !== null && _element_selectionStart !== void 0 ? _element_selectionStart : 0,
focusOffset: (_element_selectionEnd = element.selectionEnd) !== null && _element_selectionEnd !== void 0 ? _element_selectionEnd : 0
};

@@ -72,0 +72,0 @@ return {

@@ -26,5 +26,5 @@ 'use strict';

registry.behavior.keydown = (event, target, instance)=>{
var ref;
var ref1;
return (ref1 = (ref = keydownBehavior[event.key]) === null || ref === void 0 ? void 0 : ref.call(keydownBehavior, event, target, instance)) !== null && ref1 !== void 0 ? ref1 : combinationBehavior(event, target, instance);
var _keydownBehavior_event_key, _keydownBehavior;
var _keydownBehavior_event_key1;
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = (_keydownBehavior = keydownBehavior)[event.key]) === null || _keydownBehavior_event_key === void 0 ? void 0 : _keydownBehavior_event_key.call(_keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== void 0 ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance);
};

@@ -82,5 +82,5 @@ const keydownBehavior = {

return ()=>{
var ref;
var ref1;
const newPos = (ref1 = (ref = getValueOrTextContent.getValueOrTextContent(target)) === null || ref === void 0 ? void 0 : ref.length) !== null && ref1 !== void 0 ? ref1 : /* istanbul ignore next */ 0;
var _getValueOrTextContent;
var _getValueOrTextContent_length;
const newPos = (_getValueOrTextContent_length = (_getValueOrTextContent = getValueOrTextContent.getValueOrTextContent(target)) === null || _getValueOrTextContent === void 0 ? void 0 : _getValueOrTextContent.length) !== null && _getValueOrTextContent_length !== void 0 ? _getValueOrTextContent_length : /* istanbul ignore next */ 0;
setSelectionRange.setSelectionRange(target, newPos, newPos);

@@ -87,0 +87,0 @@ };

@@ -23,4 +23,5 @@ 'use strict';

} else if (isElementType.isElementType(target, 'input')) {
var _form;
const form = target.form;
const submit = form === null || form === void 0 ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
const submit = (_form = form) === null || _form === void 0 ? void 0 : _form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
if (submit) {

@@ -47,3 +48,3 @@ return ()=>instance.dispatchUIEvent(submit, 'click');

'reset',
'submit',
'submit'
];

@@ -58,3 +59,3 @@ const SubmitSingleInputOnEnter = [

'url',
'week',
'week'
];

@@ -14,4 +14,4 @@ 'use strict';

registry.behavior.keyup = (event, target, instance)=>{
var ref;
return (ref = keyupBehavior[event.key]) === null || ref === void 0 ? void 0 : ref.call(keyupBehavior, event, target, instance);
var _keyupBehavior_event_key, _keyupBehavior;
return (_keyupBehavior_event_key = (_keyupBehavior = keyupBehavior)[event.key]) === null || _keyupBehavior_event_key === void 0 ? void 0 : _keyupBehavior_event_key.call(_keyupBehavior, event, target, instance);
};

@@ -18,0 +18,0 @@ const keyupBehavior = {

@@ -17,4 +17,4 @@ 'use strict';

return ()=>{
var ref;
const insertData = (ref = event.clipboardData) === null || ref === void 0 ? void 0 : ref.getData('text');
var _event_clipboardData;
const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text');
if (insertData) {

@@ -21,0 +21,0 @@ input.input(instance, target, insertData, 'insertFromPaste');

@@ -32,3 +32,3 @@ 'use strict';

initMouseEvent,
initPointerEvent,
initPointerEvent
],

@@ -42,54 +42,54 @@ KeyboardEvent: [

function createEvent(type, target, init) {
var ref;
var _eventInitializer_EventType;
const window = getWindow.getWindow(target);
const { EventType , defaultInit } = eventMap.eventMap[eventMap.eventMapKeys[type]];
const { EventType, defaultInit } = eventMap.eventMap[eventMap.eventMapKeys[type]];
const event = new (getEventConstructors(window))[EventType](type, defaultInit);
(ref = eventInitializer[EventType]) === null || ref === void 0 ? void 0 : ref.forEach((f)=>f(event, init !== null && init !== void 0 ? init : {}));
(_eventInitializer_EventType = eventInitializer[EventType]) === null || _eventInitializer_EventType === void 0 ? void 0 : _eventInitializer_EventType.forEach((f)=>f(event, init !== null && init !== void 0 ? init : {}));
return event;
}
/* istanbul ignore next */ function getEventConstructors(window) {
var _Event;
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_Event = window.Event) !== null && _Event !== void 0 ? _Event : class Event {
var _window_Event;
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_window_Event = window.Event) !== null && _window_Event !== void 0 ? _window_Event : class Event {
};
var _AnimationEvent;
const AnimationEvent = (_AnimationEvent = window.AnimationEvent) !== null && _AnimationEvent !== void 0 ? _AnimationEvent : class AnimationEvent extends Event {
var _window_AnimationEvent;
const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !== void 0 ? _window_AnimationEvent : class AnimationEvent extends Event {
};
var _ClipboardEvent;
const ClipboardEvent = (_ClipboardEvent = window.ClipboardEvent) !== null && _ClipboardEvent !== void 0 ? _ClipboardEvent : class ClipboardEvent extends Event {
var _window_ClipboardEvent;
const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !== void 0 ? _window_ClipboardEvent : class ClipboardEvent extends Event {
};
var _PopStateEvent;
const PopStateEvent = (_PopStateEvent = window.PopStateEvent) !== null && _PopStateEvent !== void 0 ? _PopStateEvent : class PopStateEvent extends Event {
var _window_PopStateEvent;
const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !== void 0 ? _window_PopStateEvent : class PopStateEvent extends Event {
};
var _ProgressEvent;
const ProgressEvent = (_ProgressEvent = window.ProgressEvent) !== null && _ProgressEvent !== void 0 ? _ProgressEvent : class ProgressEvent extends Event {
var _window_ProgressEvent;
const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !== void 0 ? _window_ProgressEvent : class ProgressEvent extends Event {
};
var _TransitionEvent;
const TransitionEvent = (_TransitionEvent = window.TransitionEvent) !== null && _TransitionEvent !== void 0 ? _TransitionEvent : class TransitionEvent extends Event {
var _window_TransitionEvent;
const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !== void 0 ? _window_TransitionEvent : class TransitionEvent extends Event {
};
var _UIEvent;
const UIEvent = (_UIEvent = window.UIEvent) !== null && _UIEvent !== void 0 ? _UIEvent : class UIEvent extends Event {
var _window_UIEvent;
const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !== void 0 ? _window_UIEvent : class UIEvent extends Event {
};
var _CompositionEvent;
const CompositionEvent = (_CompositionEvent = window.CompositionEvent) !== null && _CompositionEvent !== void 0 ? _CompositionEvent : class CompositionEvent extends UIEvent {
var _window_CompositionEvent;
const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !== void 0 ? _window_CompositionEvent : class CompositionEvent extends UIEvent {
};
var _FocusEvent;
const FocusEvent = (_FocusEvent = window.FocusEvent) !== null && _FocusEvent !== void 0 ? _FocusEvent : class FocusEvent extends UIEvent {
var _window_FocusEvent;
const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !== void 0 ? _window_FocusEvent : class FocusEvent extends UIEvent {
};
var _InputEvent;
const InputEvent = (_InputEvent = window.InputEvent) !== null && _InputEvent !== void 0 ? _InputEvent : class InputEvent extends UIEvent {
var _window_InputEvent;
const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !== void 0 ? _window_InputEvent : class InputEvent extends UIEvent {
};
var _KeyboardEvent;
const KeyboardEvent = (_KeyboardEvent = window.KeyboardEvent) !== null && _KeyboardEvent !== void 0 ? _KeyboardEvent : class KeyboardEvent extends UIEvent {
var _window_KeyboardEvent;
const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !== void 0 ? _window_KeyboardEvent : class KeyboardEvent extends UIEvent {
};
var _MouseEvent;
const MouseEvent = (_MouseEvent = window.MouseEvent) !== null && _MouseEvent !== void 0 ? _MouseEvent : class MouseEvent extends UIEvent {
var _window_MouseEvent;
const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !== void 0 ? _window_MouseEvent : class MouseEvent extends UIEvent {
};
var _DragEvent;
const DragEvent = (_DragEvent = window.DragEvent) !== null && _DragEvent !== void 0 ? _DragEvent : class DragEvent extends MouseEvent {
var _window_DragEvent;
const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !== void 0 ? _window_DragEvent : class DragEvent extends MouseEvent {
};
var _PointerEvent;
const PointerEvent = (_PointerEvent = window.PointerEvent) !== null && _PointerEvent !== void 0 ? _PointerEvent : class PointerEvent extends MouseEvent {
var _window_PointerEvent;
const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !== void 0 ? _window_PointerEvent : class PointerEvent extends MouseEvent {
};
var _TouchEvent;
const TouchEvent = (_TouchEvent = window.TouchEvent) !== null && _TouchEvent !== void 0 ? _TouchEvent : class TouchEvent extends UIEvent {
var _window_TouchEvent;
const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !== void 0 ? _window_TouchEvent : class TouchEvent extends UIEvent {
};

@@ -124,3 +124,3 @@ /* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ return {

}
function initClipboardEvent(event, { clipboardData }) {
function initClipboardEvent(event, { clipboardData }) {
assignProps(event, {

@@ -130,3 +130,3 @@ clipboardData

}
function initInputEvent(event, { data , inputType , isComposing }) {
function initInputEvent(event, { data, inputType, isComposing }) {
assignProps(event, {

@@ -138,3 +138,3 @@ data,

}
function initUIEvent(event, { view , detail }) {
function initUIEvent(event, { view, detail }) {
assignProps(event, {

@@ -145,3 +145,3 @@ view,

}
function initUIEventModififiers(event, { altKey , ctrlKey , metaKey , shiftKey , modifierAltGraph , modifierCapsLock , modifierFn , modifierFnLock , modifierNumLock , modifierScrollLock , modifierSymbol , modifierSymbolLock }) {
function initUIEventModififiers(event, { altKey, ctrlKey, metaKey, shiftKey, modifierAltGraph, modifierCapsLock, modifierFn, modifierFnLock, modifierNumLock, modifierScrollLock, modifierSymbol, modifierSymbolLock }) {
assignProps(event, {

@@ -170,3 +170,3 @@ altKey: Boolean(altKey),

}
function initKeyboardEvent(event, { key , code , location , repeat , isComposing , charCode }) {
function initKeyboardEvent(event, { key, code, location, repeat, isComposing, charCode }) {
assignProps(event, {

@@ -181,3 +181,3 @@ key: String(key),

}
function initMouseEvent(event, { x , y , screenX , screenY , clientX =x , clientY =y , button , buttons , relatedTarget }) {
function initMouseEvent(event, { x, y, screenX, screenY, clientX = x, clientY = y, button, buttons, relatedTarget }) {
assignProps(event, {

@@ -195,3 +195,3 @@ screenX: sanitizeNumber(screenX),

}
function initPointerEvent(event, { pointerId , width , height , pressure , tangentialPressure , tiltX , tiltY , twist , pointerType , isPrimary }) {
function initPointerEvent(event, { pointerId, width, height, pressure, tangentialPressure, tiltX, tiltY, twist, pointerType, isPrimary }) {
assignProps(event, {

@@ -198,0 +198,0 @@ pointerId: sanitizeNumber(pointerId),

@@ -27,5 +27,5 @@ 'use strict';

function dispatchEvent(target, event, preventDefault = false) {
var ref;
var _behavior_type, _behavior;
const type = event.type;
const behaviorImplementation = preventDefault ? ()=>{} : (ref = registry.behavior[type]) === null || ref === void 0 ? void 0 : ref(event, target, this);
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = (_behavior = registry.behavior)[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(_behavior, event, target, this);
if (behaviorImplementation) {

@@ -32,0 +32,0 @@ event.preventDefault();

@@ -5,6 +5,6 @@ 'use strict';

var eventMap_js = require('@testing-library/dom/dist/event-map.js');
var dtlEventMap = require('../_interop/dtlEventMap.js');
const eventMap = {
...eventMap_js.eventMap,
...dtlEventMap.eventMap,
click: {

@@ -11,0 +11,0 @@ EventType: 'PointerEvent',

@@ -30,4 +30,4 @@ 'use strict';

wrapEvent.wrapEvent(()=>{
var ref;
return (ref = activeElement) === null || ref === void 0 ? void 0 : ref.blur();
var _activeElement;
return (_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.blur();
});

@@ -34,0 +34,0 @@ }

@@ -101,3 +101,3 @@ 'use strict';

}
const { newValue , newOffset , oldValue } = calculateNewValue(dataToInsert, element, inputRange, inputType);
const { newValue, newOffset, oldValue } = calculateNewValue(dataToInsert, element, inputRange, inputType);
if (newValue === oldValue && newOffset === inputRange.startOffset && newOffset === inputRange.endOffset) {

@@ -130,3 +130,3 @@ return;

}
function calculateNewValue(inputData, node, { startOffset , endOffset }, inputType) {
function calculateNewValue(inputData, node, { startOffset, endOffset }, inputType) {
const value = UI.getUIValue(node);

@@ -159,3 +159,3 @@ const prologEnd = Math.max(0, startOffset === endOffset && inputType === 'deleteContentBackward' ? startOffset - 1 : startOffset);

function isValidNumberInput(value) {
var ref, ref1;
var _value_match, _value_match1;
// the browser allows some invalid input but not others

@@ -165,5 +165,5 @@ // it allows up to two '-' at any place before any 'e' or one directly following 'e'

const valueParts = value.split('e', 2);
return !(/[^\d.\-e]/.test(value) || Number((ref = value.match(/-/g)) === null || ref === void 0 ? void 0 : ref.length) > 2 || Number((ref1 = value.match(/\./g)) === null || ref1 === void 0 ? void 0 : ref1.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
return !(/[^\d.\-e]/.test(value) || Number((_value_match = value.match(/-/g)) === null || _value_match === void 0 ? void 0 : _value_match.length) > 2 || Number((_value_match1 = value.match(/\./g)) === null || _value_match1 === void 0 ? void 0 : _value_match1.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
}
exports.input = input;

@@ -14,5 +14,5 @@ 'use strict';

} else if (typeAndSelection.type === 'contenteditable') {
var ref;
var _typeAndSelection_selection;
// Multi-range on contenteditable edits the first selection instead of the last
return (ref = typeAndSelection.selection) === null || ref === void 0 ? void 0 : ref.getRangeAt(0);
return (_typeAndSelection_selection = typeAndSelection.selection) === null || _typeAndSelection_selection === void 0 ? void 0 : _typeAndSelection_selection.getRangeAt(0);
}

@@ -19,0 +19,0 @@ }

@@ -20,2 +20,3 @@ 'use strict';

*/ function getTargetTypeAndSelection(node) {
var _element, _selection;
const element = getElement(node);

@@ -28,6 +29,6 @@ if (element && selection.hasOwnSelection(element)) {

}
const selection$1 = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection();
const selection$1 = (_element = element) === null || _element === void 0 ? void 0 : _element.ownerDocument.getSelection();
// It is possible to extend a single-range selection into a contenteditable.
// This results in the range acting like a range outside of contenteditable.
const isCE = isContentEditable.getContentEditable(node) && (selection$1 === null || selection$1 === void 0 ? void 0 : selection$1.anchorNode) && isContentEditable.getContentEditable(selection$1.anchorNode);
const isCE = isContentEditable.getContentEditable(node) && ((_selection = selection$1) === null || _selection === void 0 ? void 0 : _selection.anchorNode) && isContentEditable.getContentEditable(selection$1.anchorNode);
return {

@@ -34,0 +35,0 @@ type: isCE ? 'contenteditable' : 'default',

@@ -18,4 +18,4 @@ 'use strict';

* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
*/ function modifySelection({ focusNode , focusOffset }) {
var ref, ref1;
*/ function modifySelection({ focusNode, focusOffset }) {
var _focusNode_ownerDocument_getSelection, _focusNode_ownerDocument;
const typeAndSelection = getTargetTypeAndSelection.getTargetTypeAndSelection(focusNode);

@@ -28,5 +28,5 @@ if (typeAndSelection.type === 'input') {

}
(ref1 = (ref = focusNode.ownerDocument) === null || ref === void 0 ? void 0 : ref.getSelection()) === null || ref1 === void 0 ? void 0 : ref1.extend(focusNode, focusOffset);
(_focusNode_ownerDocument = focusNode.ownerDocument) === null || _focusNode_ownerDocument === void 0 ? void 0 : (_focusNode_ownerDocument_getSelection = _focusNode_ownerDocument.getSelection()) === null || _focusNode_ownerDocument_getSelection === void 0 ? void 0 : _focusNode_ownerDocument_getSelection.extend(focusNode, focusOffset);
}
exports.modifySelection = modifySelection;

@@ -16,3 +16,3 @@ 'use strict';

function modifySelectionPerMouseMove(selectionRange, { document , target , node , offset }) {
function modifySelectionPerMouseMove(selectionRange, { document, target, node, offset }) {
const selectionFocus = resolveCaretPosition.resolveCaretPosition({

@@ -37,2 +37,3 @@ target,

} else {
var _selection, _selection1;
const range = selectionRange.cloneRange();

@@ -46,4 +47,4 @@ const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);

const selection = document.getSelection();
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
(_selection = selection) === null || _selection === void 0 ? void 0 : _selection.removeAllRanges();
(_selection1 = selection) === null || _selection1 === void 0 ? void 0 : _selection1.addRange(range.cloneRange());
}

@@ -50,0 +51,0 @@ }

@@ -29,8 +29,9 @@ 'use strict';

} else {
const selection1 = node.ownerDocument.getSelection();
if (!(selection1 === null || selection1 === void 0 ? void 0 : selection1.focusNode)) {
var _selection;
const selection = node.ownerDocument.getSelection();
if (!((_selection = selection) === null || _selection === void 0 ? void 0 : _selection.focusNode)) {
return;
}
if (selection1.isCollapsed) {
const nextPosition = cursor.getNextCursorPosition(selection1.focusNode, selection1.focusOffset, direction);
if (selection.isCollapsed) {
const nextPosition = cursor.getNextCursorPosition(selection.focusNode, selection.focusOffset, direction);
if (nextPosition) {

@@ -43,3 +44,3 @@ setSelection.setSelection({

} else {
selection1[direction < 0 ? 'collapseToStart' : 'collapseToEnd']();
selection[direction < 0 ? 'collapseToStart' : 'collapseToEnd']();
}

@@ -46,0 +47,0 @@ }

@@ -16,3 +16,3 @@ 'use strict';

function resolveCaretPosition({ target , node , offset }) {
function resolveCaretPosition({ target, node, offset }) {
if (selection.hasOwnSelection(target)) {

@@ -19,0 +19,0 @@ return {

@@ -28,4 +28,4 @@ 'use strict';

}
var ref;
const focusNode = (ref = isContentEditable.getContentEditable(target)) !== null && ref !== void 0 ? ref : target.ownerDocument.body;
var _getContentEditable;
const focusNode = (_getContentEditable = isContentEditable.getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body;
setSelection.setSelection({

@@ -38,9 +38,10 @@ focusNode,

function isAllSelected(target) {
var _selection;
if (selection.hasOwnSelection(target)) {
return UI.getUISelection(target).startOffset === 0 && UI.getUISelection(target).endOffset === UI.getUIValue(target).length;
}
var ref;
const focusNode = (ref = isContentEditable.getContentEditable(target)) !== null && ref !== void 0 ? ref : target.ownerDocument.body;
var _getContentEditable;
const focusNode = (_getContentEditable = isContentEditable.getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body;
const selection$1 = target.ownerDocument.getSelection();
return (selection$1 === null || selection$1 === void 0 ? void 0 : selection$1.anchorNode) === focusNode && selection$1.focusNode === focusNode && selection$1.anchorOffset === 0 && selection$1.focusOffset === focusNode.childNodes.length;
return ((_selection = selection$1) === null || _selection === void 0 ? void 0 : _selection.anchorNode) === focusNode && selection$1.focusNode === focusNode && selection$1.anchorOffset === 0 && selection$1.focusOffset === focusNode.childNodes.length;
}

@@ -47,0 +48,0 @@

@@ -18,4 +18,4 @@ 'use strict';

* Set the selection
*/ function setSelection({ focusNode , focusOffset , anchorNode =focusNode , anchorOffset =focusOffset }) {
var ref, ref1;
*/ function setSelection({ focusNode, focusOffset, anchorNode = focusNode, anchorOffset = focusOffset }) {
var _anchorNode_ownerDocument_getSelection, _anchorNode_ownerDocument;
const typeAndSelection = getTargetTypeAndSelection.getTargetTypeAndSelection(focusNode);

@@ -28,5 +28,5 @@ if (typeAndSelection.type === 'input') {

}
(ref1 = (ref = anchorNode.ownerDocument) === null || ref === void 0 ? void 0 : ref.getSelection()) === null || ref1 === void 0 ? void 0 : ref1.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
(_anchorNode_ownerDocument = anchorNode.ownerDocument) === null || _anchorNode_ownerDocument === void 0 ? void 0 : (_anchorNode_ownerDocument_getSelection = _anchorNode_ownerDocument.getSelection()) === null || _anchorNode_ownerDocument_getSelection === void 0 ? void 0 : _anchorNode_ownerDocument_getSelection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
}
exports.setSelection = setSelection;

@@ -17,3 +17,3 @@ 'use strict';

function setSelectionPerMouseDown({ document , target , clickCount , node , offset }) {
function setSelectionPerMouseDown({ document, target, clickCount, node, offset }) {
if (selection.hasNoSelection(target)) {

@@ -47,3 +47,4 @@ return;

} else {
const { node: startNode , offset: startOffset } = resolveCaretPosition.resolveCaretPosition({
var _selection, _selection1;
const { node: startNode, offset: startOffset } = resolveCaretPosition.resolveCaretPosition({
target,

@@ -53,3 +54,3 @@ node,

});
const { node: endNode , offset: endOffset } = resolveCaretPosition.resolveCaretPosition({
const { node: endNode, offset: endOffset } = resolveCaretPosition.resolveCaretPosition({
target,

@@ -67,4 +68,4 @@ node,

const selection = document.getSelection();
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
(_selection = selection) === null || _selection === void 0 ? void 0 : _selection.removeAllRanges();
(_selection1 = selection) === null || _selection1 === void 0 ? void 0 : _selection1.addRange(range.cloneRange());
return range;

@@ -84,3 +85,3 @@ }

textPos - text.substr(0, pos).match(/(\w+|\s+|\W)?$/)[0].length,
pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length,
pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length
];

@@ -91,3 +92,3 @@ }

textPos - text.substr(0, pos).match(/[^\r\n]*$/)[0].length,
pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length,
pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length
];

@@ -94,0 +95,0 @@ }

@@ -22,3 +22,3 @@ 'use strict';

*/ function setSelectionRange(element, anchorOffset, focusOffset) {
var ref;
var _element_firstChild;
if (selection.hasOwnSelection(element)) {

@@ -31,3 +31,3 @@ return setSelection.setSelection({

}
/* istanbul ignore else */ if (isContentEditable.isContentEditable(element) && ((ref = element.firstChild) === null || ref === void 0 ? void 0 : ref.nodeType) === 3) {
/* istanbul ignore else */ if (isContentEditable.isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === void 0 ? void 0 : _element_firstChild.nodeType) === 3) {
return setSelection.setSelection({

@@ -34,0 +34,0 @@ focusNode: element.firstChild,

@@ -20,4 +20,5 @@ 'use strict';

*/ function updateSelectionOnFocus(element) {
var _selection;
const selection$1 = element.ownerDocument.getSelection();
/* istanbul ignore if */ if (!(selection$1 === null || selection$1 === void 0 ? void 0 : selection$1.focusNode)) {
/* istanbul ignore if */ if (!((_selection = selection$1) === null || _selection === void 0 ? void 0 : _selection.focusNode)) {
return;

@@ -36,4 +37,4 @@ }

if (!selection$1.isCollapsed) {
var ref;
const focusNode = ((ref = contenteditable.firstChild) === null || ref === void 0 ? void 0 : ref.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
var _contenteditable_firstChild;
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === void 0 ? void 0 : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
selection$1.setBaseAndExtent(focusNode, 0, focusNode, 0);

@@ -40,0 +41,0 @@ }

@@ -5,8 +5,9 @@ 'use strict';

var dom = require('@testing-library/dom');
var dtl = require('../_interop/dtl.js');
const { getConfig } = dtl;
function wrapEvent(cb, _element) {
return dom.getConfig().eventWrapper(cb);
return getConfig().eventWrapper(cb);
}
exports.wrapEvent = wrapEvent;

@@ -11,2 +11,3 @@ 'use strict';

exports["default"] = index.userEvent;
exports.userEvent = index.userEvent;
Object.defineProperty(exports, 'PointerEventsCheckLevel', {

@@ -13,0 +14,0 @@ enumerable: true,

@@ -23,4 +23,4 @@ 'use strict';

}
async function keyboardAction(instance, { keyDef , releasePrevious , releaseSelf , repeat }) {
const { system } = instance;
async function keyboardAction(instance, { keyDef, releasePrevious, releaseSelf, repeat }) {
const { system } = instance;
// Release the key automatically if it was pressed before.

@@ -27,0 +27,0 @@ if (system.keyboard.isKeyPressed(keyDef)) {

@@ -26,14 +26,14 @@ 'use strict';

do {
const { type , descriptor , consumedLength , releasePrevious , releaseSelf =true , repeat , } = readNextDescriptor.readNextDescriptor(text, 'keyboard');
var ref;
const keyDef = (ref = keyboardMap.find((def)=>{
const { type, descriptor, consumedLength, releasePrevious, releaseSelf = true, repeat } = readNextDescriptor.readNextDescriptor(text, 'keyboard');
var _keyboardMap_find;
const keyDef = (_keyboardMap_find = keyboardMap.find((def)=>{
if (type === '[') {
var ref;
return ((ref = def.code) === null || ref === void 0 ? void 0 : ref.toLowerCase()) === descriptor.toLowerCase();
var _def_code;
return ((_def_code = def.code) === null || _def_code === void 0 ? void 0 : _def_code.toLowerCase()) === descriptor.toLowerCase();
} else if (type === '{') {
var ref1;
return ((ref1 = def.key) === null || ref1 === void 0 ? void 0 : ref1.toLowerCase()) === descriptor.toLowerCase();
var _def_key;
return ((_def_key = def.key) === null || _def_key === void 0 ? void 0 : _def_key.toLowerCase()) === descriptor.toLowerCase();
}
return def.key === descriptor;
})) !== null && ref !== void 0 ? ref : {
})) !== null && _keyboardMap_find !== void 0 ? _keyboardMap_find : {
key: 'Unknown',

@@ -40,0 +40,0 @@ code: 'Unknown',

@@ -17,3 +17,3 @@ 'use strict';

async function pointer(input) {
const { pointerMap } = this.config;
const { pointerMap } = this.config;
const actions = [];

@@ -41,12 +41,12 @@ (Array.isArray(input) ? input : [

async function pointerAction(instance, action) {
var ref, ref1;
var _previousPosition, _previousPosition_caret, _previousPosition1, _previousPosition_caret1, _previousPosition2;
const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? instance.system.pointer.getPointerName(action.keyDef) : 'mouse';
const previousPosition = instance.system.pointer.getPreviousPosition(pointerName);
var _target, _coords, _node, _offset;
var _action_target, _action_coords, _action_node, _action_offset;
const position = {
target: (_target = action.target) !== null && _target !== void 0 ? _target : getPrevTarget(instance, previousPosition),
coords: (_coords = action.coords) !== null && _coords !== void 0 ? _coords : previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.coords,
target: (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : getPrevTarget(instance, previousPosition),
coords: (_action_coords = action.coords) !== null && _action_coords !== void 0 ? _action_coords : (_previousPosition = previousPosition) === null || _previousPosition === void 0 ? void 0 : _previousPosition.coords,
caret: {
node: (_node = action.node) !== null && _node !== void 0 ? _node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (ref = previousPosition.caret) === null || ref === void 0 ? void 0 : ref.node,
offset: (_offset = action.offset) !== null && _offset !== void 0 ? _offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (ref1 = previousPosition.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
node: (_action_node = action.node) !== null && _action_node !== void 0 ? _action_node : hasCaretPosition(action) ? undefined : (_previousPosition1 = previousPosition) === null || _previousPosition1 === void 0 ? void 0 : (_previousPosition_caret = _previousPosition1.caret) === null || _previousPosition_caret === void 0 ? void 0 : _previousPosition_caret.node,
offset: (_action_offset = action.offset) !== null && _action_offset !== void 0 ? _action_offset : hasCaretPosition(action) ? undefined : (_previousPosition2 = previousPosition) === null || _previousPosition2 === void 0 ? void 0 : (_previousPosition_caret1 = _previousPosition2.caret) === null || _previousPosition_caret1 === void 0 ? void 0 : _previousPosition_caret1.offset
}

@@ -73,4 +73,4 @@ };

function hasCaretPosition(action) {
var _target, ref;
return !!((ref = (_target = action.target) !== null && _target !== void 0 ? _target : action.node) !== null && ref !== void 0 ? ref : action.offset !== undefined);
var _action_target, _ref;
return !!((_ref = (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : action.node) !== null && _ref !== void 0 ? _ref : action.offset !== undefined);
}

@@ -81,6 +81,6 @@ function getPrevTarget(instance, position) {

}
var _target;
return (_target = position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
var _position_target;
return (_position_target = position.target) !== null && _position_target !== void 0 ? _position_target : instance.config.document.body;
}
exports.pointer = pointer;

@@ -32,5 +32,5 @@ 'use strict';

pointerType: 'touch'
},
}
];
exports.defaultKeyMap = defaultKeyMap;

@@ -17,3 +17,3 @@ 'use strict';

do {
const { descriptor , consumedLength , releasePrevious , releaseSelf =true , } = readNextDescriptor.readNextDescriptor(keys, 'pointer');
const { descriptor, consumedLength, releasePrevious, releaseSelf = true } = readNextDescriptor.readNextDescriptor(keys, 'pointer');
const keyDef = pointerMap.find((p)=>p.name === descriptor);

@@ -20,0 +20,0 @@ if (keyDef) {

@@ -18,19 +18,21 @@ 'use strict';

const userEventApi = {
click: click.click,
dblClick: click.dblClick,
tripleClick: click.tripleClick,
hover: hover.hover,
unhover: hover.unhover,
tab: tab.tab,
keyboard: index.keyboard,
copy: copy.copy,
cut: cut.cut,
paste: paste.paste,
pointer: index$1.pointer,
clear: clear.clear,
deselectOptions: selectOptions.deselectOptions,
selectOptions: selectOptions.selectOptions,
type: type.type,
upload: upload.upload
};
exports.click = click.click;
exports.dblClick = click.dblClick;
exports.tripleClick = click.tripleClick;
exports.hover = hover.hover;
exports.unhover = hover.unhover;
exports.tab = tab.tab;
exports.keyboard = index.keyboard;
exports.copy = copy.copy;
exports.cut = cut.cut;
exports.paste = paste.paste;
exports.pointer = index$1.pointer;
exports.clear = clear.clear;
exports.deselectOptions = selectOptions.deselectOptions;
exports.selectOptions = selectOptions.selectOptions;
exports.type = type.type;
exports.upload = upload.upload;
exports.userEventApi = userEventApi;

@@ -29,7 +29,7 @@ 'use strict';

async function keyboard(text, options = {}) {
const { api , system } = setup.setupDirect(options);
const { api, system } = setup.setupDirect(options);
return api.keyboard(text).then(()=>system);
}
async function pointer(input, options = {}) {
const { api , system } = setup.setupDirect(options);
const { api, system } = setup.setupDirect(options);
return api.pointer(input).then(()=>system);

@@ -50,3 +50,3 @@ }

function unhover(element, options = {}) {
const { api , system } = setup.setupDirect(options);
const { api, system } = setup.setupDirect(options);
system.pointer.setMousePosition({

@@ -53,0 +53,0 @@ target: element

@@ -60,4 +60,4 @@ 'use strict';

prepareDocument.prepareDocument(config.document);
var _defaultView;
const view = (_defaultView = config.document.defaultView) !== null && _defaultView !== void 0 ? _defaultView : /* istanbul ignore next */ globalThis.window;
var _config_document_defaultView;
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== void 0 ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window;
Clipboard.attachClipboardStubToView(view);

@@ -68,7 +68,7 @@ return createInstance(config).api;

* Setup in direct call per `userEvent.anyApi()`
*/ function setupDirect({ keyboardState , pointerState , ...options } = {}, node) {
*/ function setupDirect({ keyboardState, pointerState, ...options } = {}, node) {
const config = createConfig(options, defaultOptionsDirect, node);
prepareDocument.prepareDocument(config.document);
var ref;
const system = (ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && ref !== void 0 ? ref : new index.System();
var _ref;
const system = (_ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && _ref !== void 0 ? _ref : new index.System();
return {

@@ -108,3 +108,3 @@ api: createInstance(config, system).api,

levelRefs: {},
...api
...api.userEventApi
});

@@ -114,5 +114,5 @@ return {

api: {
...Object.fromEntries(Object.entries(api).map(([name, api])=>[
...Object.fromEntries(Object.entries(api.userEventApi).map(([name, api])=>[
name,
wrapAndBindImpl(instance, api),
wrapAndBindImpl(instance, api)
])),

@@ -124,4 +124,4 @@ setup: setupSub.bind(instance)

function getDocument(options, node, defaults) {
var _document, ref;
return (ref = (_document = options.document) !== null && _document !== void 0 ? _document : node && getDocumentFromNode.getDocumentFromNode(node)) !== null && ref !== void 0 ? ref : defaults.document;
var _options_document, _ref;
return (_ref = (_options_document = options.document) !== null && _options_document !== void 0 ? _options_document : node && getDocumentFromNode.getDocumentFromNode(node)) !== null && _ref !== void 0 ? _ref : defaults.document;
}

@@ -128,0 +128,0 @@

@@ -5,10 +5,11 @@ 'use strict';

var dom = require('@testing-library/dom');
var dtl = require('../_interop/dtl.js');
const { getConfig } = dtl;
/**
* Wrap an internal Promise
*/ function wrapAsync(implementation) {
return dom.getConfig().asyncWrapper(implementation);
return getConfig().asyncWrapper(implementation);
}
exports.wrapAsync = wrapAsync;

@@ -8,2 +8,15 @@ 'use strict';

function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
/**

@@ -29,4 +42,4 @@ * @internal Do not create/alter this by yourself as this type might be subject to changes.

constructor(){
this.keyboard = new keyboard.KeyboardHost(this);
this.pointer = new index.PointerHost(this);
_define_property(this, "keyboard", new keyboard.KeyboardHost(this));
_define_property(this, "pointer", new index.PointerHost(this));
}

@@ -33,0 +46,0 @@ }

@@ -15,3 +15,15 @@ 'use strict';

var _pressed, _code, _code1;
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
exports.DOM_KEY_LOCATION = void 0;

@@ -31,3 +43,3 @@ (function(DOM_KEY_LOCATION) {

'Shift',
'Symbol',
'Symbol'
];

@@ -42,3 +54,3 @@ function isModifierKey(key) {

'ScrollLock',
'SymbolLock',
'SymbolLock'
];

@@ -56,2 +68,4 @@ function isModifierLock(key) {

/** Press a key */ async keydown(instance, keyDef) {
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
_this_pressed, _code, _this_pressed_code;
const key = String(keyDef.key);

@@ -61,4 +75,4 @@ const code = String(keyDef.code);

this.setKeydownTarget(target);
var ref;
(ref = (_pressed = this.pressed)[_code = code]) !== null && ref !== void 0 ? ref : _pressed[_code] = {
var _;
(_ = (_this_pressed = this.pressed)[_code = code]) !== null && _ !== void 0 ? _ : _this_pressed[_code] = {
keyDef,

@@ -78,3 +92,3 @@ unpreventedDefault: false

}
(_code1 = this.pressed[code]).unpreventedDefault || (_code1.unpreventedDefault = unprevented);
(_this_pressed_code = this.pressed[code]).unpreventedDefault || (_this_pressed_code.unpreventedDefault = unprevented);
if (unprevented && this.hasKeyPress(key)) {

@@ -119,3 +133,4 @@ instance.dispatchUIEvent(getActiveElement.getActiveElementOrBody(instance.config.document), 'keypress', {

constructor(system){
this.modifiers = {
_define_property(this, "system", void 0);
_define_property(this, "modifiers", {
Alt: false,

@@ -133,7 +148,7 @@ AltGraph: false,

SymbolLock: false
};
this.pressed = {};
this.carryChar = '';
this.lastKeydownTarget = undefined;
this.modifierLockStart = {};
});
_define_property(this, "pressed", {});
_define_property(this, "carryChar", '');
_define_property(this, "lastKeydownTarget", undefined);
_define_property(this, "modifierLockStart", {});
this.system = system;

@@ -140,0 +155,0 @@ }

@@ -5,2 +5,15 @@ 'use strict';

function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Buttons {

@@ -39,3 +52,3 @@ getButtons() {

constructor(){
this.pressed = {};
_define_property(this, "pressed", {});
}

@@ -42,0 +55,0 @@ }

@@ -5,2 +5,15 @@ 'use strict';

function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Device {

@@ -20,3 +33,3 @@ get countPressed() {

constructor(){
this.pressedKeys = new Set();
_define_property(this, "pressedKeys", new Set());
}

@@ -23,0 +36,0 @@ }

@@ -10,3 +10,15 @@ 'use strict';

var _registry, _k;
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class PointerHost {

@@ -32,2 +44,3 @@ isKeyPressed(keyDef) {

async move(instance, pointerName, position) {
var _pointermove, _mousemove, _pointermove1, _mousemove1, _pointermove2, _mousemove2;
const pointer = this.pointers.get(pointerName);

@@ -40,8 +53,8 @@ // In (some?) browsers this order of events can be observed.

const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
pointermove === null || pointermove === void 0 ? void 0 : pointermove.leave();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
pointermove === null || pointermove === void 0 ? void 0 : pointermove.enter();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
pointermove === null || pointermove === void 0 ? void 0 : pointermove.move();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
(_pointermove = pointermove) === null || _pointermove === void 0 ? void 0 : _pointermove.leave();
(_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
(_pointermove1 = pointermove) === null || _pointermove1 === void 0 ? void 0 : _pointermove1.enter();
(_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
(_pointermove2 = pointermove) === null || _pointermove2 === void 0 ? void 0 : _pointermove2.move();
(_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
}

@@ -66,13 +79,15 @@ async release(instance, keyDef, position) {

if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
var _mousemove, _mousemove1, _mousemove2;
const mousemove = this.mouse.move(instance, pointer.position);
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
(_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
(_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
(_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
this.mouse.down(instance, keyDef, pointer);
}
if (!pointer.isMultitouch) {
const mousemove1 = this.mouse.move(instance, pointer.position);
mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.leave();
mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.enter();
mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.move();
var _mousemove3, _mousemove4, _mousemove5;
const mousemove = this.mouse.move(instance, pointer.position);
(_mousemove3 = mousemove) === null || _mousemove3 === void 0 ? void 0 : _mousemove3.leave();
(_mousemove4 = mousemove) === null || _mousemove4 === void 0 ? void 0 : _mousemove4.enter();
(_mousemove5 = mousemove) === null || _mousemove5 === void 0 ? void 0 : _mousemove5.move();
this.mouse.up(instance, keyDef, pointer);

@@ -92,4 +107,4 @@ }

getMouseTarget(instance) {
var _target;
return (_target = this.mouse.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
var _this_mouse_position_target;
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== void 0 ? _this_mouse_position_target : instance.config.document.body;
}

@@ -101,13 +116,18 @@ setMousePosition(position) {

constructor(system){
this.devices = new class {
_define_property(this, "system", void 0);
_define_property(this, "mouse", void 0);
_define_property(this, "buttons", void 0);
_define_property(this, "devices", new class {
get(k) {
var ref;
(ref = (_registry = this.registry)[_k = k]) !== null && ref !== void 0 ? ref : _registry[_k] = new device.Device();
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
_this_registry, _k;
var _;
(_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new device.Device();
return this.registry[k];
}
constructor(){
this.registry = {};
_define_property(this, "registry", {});
}
}();
this.pointers = new class {
}());
_define_property(this, "pointers", new class {
new(pointerName, keyDef) {

@@ -139,3 +159,3 @@ const isPrimary = keyDef.pointerType !== 'touch' || !Object.values(this.registry).some((p)=>p.pointerType === 'touch' && !p.isCancelled);

constructor(){
this.registry = {
_define_property(this, "registry", {
mouse: new pointer.Pointer({

@@ -146,6 +166,6 @@ pointerId: 1,

})
};
this.nextId = 2;
});
_define_property(this, "nextId", 2);
}
}();
}());
this.system = system;

@@ -152,0 +172,0 @@ this.buttons = new buttons.Buttons();

@@ -29,2 +29,15 @@ 'use strict';

function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
/**

@@ -127,7 +140,7 @@ * This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.

getTarget(instance) {
var _target;
return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
var _this_position_target;
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
}
startSelecting(instance, clickCount) {
var ref, ref1;
var _this_position_caret, _this_position_caret1;
// TODO: support extending range (shift)

@@ -137,4 +150,4 @@ this.selecting = setSelectionPerMouse.setSelectionPerMouseDown({

target: this.getTarget(instance),
node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset,
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset,
clickCount

@@ -144,3 +157,3 @@ });

modifySelecting(instance) {
var ref, ref1;
var _this_position_caret, _this_position_caret1;
if (!this.selecting) {

@@ -152,4 +165,4 @@ return;

target: this.getTarget(instance),
node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset
});

@@ -161,5 +174,6 @@ }

constructor(){
this.position = {};
this.buttons = new buttons.Buttons();
this.buttonDownTarget = {};
_define_property(this, "position", {});
_define_property(this, "buttons", new buttons.Buttons());
_define_property(this, "selecting", void 0);
_define_property(this, "buttonDownTarget", {});
// According to spec the `detail` on click events should be the number

@@ -175,3 +189,3 @@ // of *consecutive* clicks with a specific button.

// We'll follow the minimal implementation of Webkit.
this.clickCount = new class {
_define_property(this, "clickCount", new class {
incOnClick(button) {

@@ -185,9 +199,9 @@ const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;

getOnDown(button) {
var _button;
var _this_count_button;
this.down = {
[button]: (_button = this.count[button]) !== null && _button !== void 0 ? _button : 0
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0
};
var _button1;
var _this_count_button1;
this.count = {
[button]: (_button1 = this.count[button]) !== null && _button1 !== void 0 ? _button1 : 0
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0
};

@@ -203,6 +217,6 @@ return Number(this.count[button]) + 1;

constructor(){
this.down = {};
this.count = {};
_define_property(this, "down", {});
_define_property(this, "count", {});
}
}();
}());
}

@@ -209,0 +223,0 @@ }

@@ -16,2 +16,15 @@ 'use strict';

function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Pointer {

@@ -90,4 +103,4 @@ init(instance, position) {

getTarget(instance) {
var _target;
return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
var _this_position_target;
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
}

@@ -102,8 +115,11 @@ getEventInit() {

}
constructor({ pointerId , pointerType , isPrimary }){
this.isMultitouch = false;
this.isCancelled = false;
this.isDown = false;
this.isPrevented = false;
this.position = {};
constructor({ pointerId, pointerType, isPrimary }){
_define_property(this, "pointerId", void 0);
_define_property(this, "pointerType", void 0);
_define_property(this, "isPrimary", void 0);
_define_property(this, "isMultitouch", false);
_define_property(this, "isCancelled", false);
_define_property(this, "isDown", false);
_define_property(this, "isPrevented", false);
_define_property(this, "position", {});
this.pointerId = pointerId;

@@ -110,0 +126,0 @@ this.pointerType = pointerType;

@@ -6,6 +6,6 @@ 'use strict';

function isDifferentPointerPosition(positionA, positionB) {
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
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);
var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
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.y) || ((_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_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);
}
exports.isDifferentPointerPosition = isDifferentPointerPosition;

@@ -5,3 +5,3 @@ 'use strict';

var dom = require('@testing-library/dom');
var dtl = require('../_interop/dtl.js');
require('../utils/click/isClickableInput.js');

@@ -27,2 +27,3 @@ require('../utils/dataTransfer/Clipboard.js');

const { getConfig } = dtl;
async function selectOptions(select, values) {

@@ -36,3 +37,3 @@ return selectOptionsBase.call(this, true, select, values);

if (!newValue && !select.multiple) {
throw dom.getConfig().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
throw getConfig().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
}

@@ -51,3 +52,3 @@ const valArray = Array.isArray(values) ? values : [

} else {
throw dom.getConfig().getElementError(`Value "${String(val)}" not found in options`, select);
throw getConfig().getElementError(`Value "${String(val)}" not found in options`, select);
}

@@ -93,5 +94,5 @@ }

} else if (selectedOptions.length === 1) {
const withPointerEvents1 = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, select);
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, select);
// the click to open the select options
if (withPointerEvents1) {
if (withPointerEvents) {
await this.click(select);

@@ -102,3 +103,3 @@ } else {

selectOption(selectedOptions[0]);
if (withPointerEvents1) {
if (withPointerEvents) {
// the browser triggers another click event on the select for the click on the option

@@ -116,11 +117,11 @@ // this second click has no 'down' phase

} else {
throw dom.getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
throw getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
}
} else if (select.getAttribute('role') === 'listbox') {
for (const option1 of selectedOptions){
await this.click(option1);
await this.unhover(option1);
for (const option of selectedOptions){
await this.click(option);
await this.unhover(option);
}
} else {
throw dom.getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
throw getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
}

@@ -127,0 +128,0 @@ }

@@ -16,3 +16,3 @@ 'use strict';

async function type(element, text, { skipClick =this.config.skipClick , skipAutoClose =this.config.skipAutoClose , initialSelectionStart , initialSelectionEnd } = {}) {
async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
// TODO: properly type guard

@@ -19,0 +19,0 @@ // we use this workaround for now to prevent changing behavior

@@ -23,3 +23,4 @@ 'use strict';

})) {
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
var _input;
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${(_input = input) === null || _input === void 0 ? void 0 : _input.tagName} element does not accept file uploads`);
}

@@ -31,7 +32,7 @@ if (isDisabled.isDisabled(element)) return;

const fileDialog = ()=>{
var ref;
var _input_files;
// do not fire an input event if the file selection does not change
if (files.length === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.length) && files.every((f, i)=>{
var ref;
return f === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.item(i));
if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{
var _input_files;
return f === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.item(i));
})) {

@@ -38,0 +39,0 @@ return;

@@ -10,2 +10,15 @@ 'use strict';

// Clipboard is not available in jsdom
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
// MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData

@@ -17,3 +30,3 @@ // lib.dom.d.ts lists only Promise<Blob|string>

typeof b === 'string' ? 'text/plain' : b.type,
Promise.resolve(b),
Promise.resolve(b)
]));

@@ -40,2 +53,3 @@ // use real ClipboardItem if available

constructor(d){
_define_property(this, "data", void 0);
this.data = d;

@@ -71,3 +85,3 @@ }

super(...args);
this.items = [];
_define_property(this, "items", []);
}

@@ -79,4 +93,4 @@ }(), {

function isClipboardStub(clipboard) {
var ref;
return !!((ref = clipboard) === null || ref === void 0 ? void 0 : ref[ClipboardStubControl]);
var _clipboard;
return !!((_clipboard = clipboard) === null || _clipboard === void 0 ? void 0 : _clipboard[ClipboardStubControl]);
}

@@ -122,4 +136,5 @@ function attachClipboardStubToView(window) {

async function readDataTransferFromClipboard(document) {
var _window;
const window = document.defaultView;
const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard;
const clipboard = (_window = window) === null || _window === void 0 ? void 0 : _window.navigator.clipboard;
const items = clipboard && await clipboard.read();

@@ -152,7 +167,8 @@ if (!items) {

}
/* istanbul ignore else */ if (typeof globalThis.afterEach === 'function') {
globalThis.afterEach(()=>resetClipboardStubOnView(globalThis.window));
const g = globalThis;
/* istanbul ignore else */ if (typeof g.afterEach === 'function') {
g.afterEach(()=>resetClipboardStubOnView(globalThis.window));
}
/* istanbul ignore else */ if (typeof globalThis.afterAll === 'function') {
globalThis.afterAll(()=>detachClipboardStubFromView(globalThis.window));
/* istanbul ignore else */ if (typeof g.afterAll === 'function') {
g.afterAll(()=>detachClipboardStubFromView(globalThis.window));
}

@@ -159,0 +175,0 @@

@@ -7,2 +7,15 @@ 'use strict';

function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
// DataTransfer is not implemented in jsdom.

@@ -23,4 +36,6 @@ // DataTransfer with FileList is being created by the browser on certain events.

constructor(dataOrFile, type){
this.file = null;
this.data = undefined;
_define_property(this, "kind", void 0);
_define_property(this, "type", void 0);
_define_property(this, "file", null);
_define_property(this, "data", undefined);
if (typeof dataOrFile === 'string') {

@@ -60,6 +75,7 @@ this.kind = 'string';

getData(format) {
var ref;
const match = (ref = this.items.find(getTypeMatcher(format, true))) !== null && ref !== void 0 ? ref : this.items.find(getTypeMatcher(format, false));
var _match;
var _this_items_find;
const match = (_this_items_find = this.items.find(getTypeMatcher(format, true))) !== null && _this_items_find !== void 0 ? _this_items_find : this.items.find(getTypeMatcher(format, false));
let text = '';
match === null || match === void 0 ? void 0 : match.getAsString((t)=>{
(_match = match) === null || _match === void 0 ? void 0 : _match.getAsString((t)=>{
text = t;

@@ -99,6 +115,6 @@ });

constructor(){
this.dropEffect = 'none';
this.effectAllowed = 'uninitialized';
this.items = new DataTransferItemListStub();
this.files = FileList.createFileList(window, []);
_define_property(this, "dropEffect", 'none');
_define_property(this, "effectAllowed", 'uninitialized');
_define_property(this, "items", new DataTransferItemListStub());
_define_property(this, "files", FileList.createFileList(window, []));
}

@@ -105,0 +121,0 @@ }();

@@ -19,4 +19,4 @@ 'use strict';

function getMaxLength(element) {
var ref;
const attr = (ref = element.getAttribute('maxlength')) !== null && ref !== void 0 ? ref : '';
var _element_getAttribute;
const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== void 0 ? _element_getAttribute : '';
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;

@@ -23,0 +23,0 @@ }

@@ -18,4 +18,4 @@ 'use strict';

function setFiles(el, files) {
var ref;
(ref = el[fakeFiles]) === null || ref === void 0 ? void 0 : ref.restore();
var _el_fakeFiles;
(_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === void 0 ? void 0 : _el_fakeFiles.restore();
const typeDescr = Object.getOwnPropertyDescriptor(el, 'type');

@@ -44,4 +44,4 @@ const valueDescr = Object.getOwnPropertyDescriptor(el, 'value');

} else {
var ref;
valueDescr === null || valueDescr === void 0 ? void 0 : (ref = valueDescr.set) === null || ref === void 0 ? void 0 : ref.call(el, v);
var _valueDescr_set, _valueDescr;
(_valueDescr = valueDescr) === null || _valueDescr === void 0 ? void 0 : (_valueDescr_set = _valueDescr.set) === null || _valueDescr_set === void 0 ? void 0 : _valueDescr_set.call(el, v);
}

@@ -48,0 +48,0 @@ }

@@ -107,3 +107,3 @@ 'use strict';

for(;;){
var ref;
var _node_ownerDocument;
const sibling = node[`${direction}Sibling`];

@@ -115,3 +115,3 @@ if (sibling) {

}
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable.isContentEditable(node.parentNode) && node.parentNode !== ((ref = node.ownerDocument) === null || ref === void 0 ? void 0 : ref.body))) {
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable.isContentEditable(node.parentNode) && node.parentNode !== ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === void 0 ? void 0 : _node_ownerDocument.body))) {
node = node.parentNode;

@@ -118,0 +118,0 @@ } else {

@@ -8,4 +8,5 @@ 'use strict';

function getActiveElement(document) {
var _activeElement;
const activeElement = document.activeElement;
if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.shadowRoot) {
if ((_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.shadowRoot) {
return getActiveElement(activeElement.shadowRoot);

@@ -21,4 +22,4 @@ } else {

function getActiveElementOrBody(document) {
var ref;
return (ref = getActiveElement(document)) !== null && ref !== void 0 ? ref : /* istanbul ignore next */ document.body;
var _getActiveElement;
return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== void 0 ? _getActiveElement : /* istanbul ignore next */ document.body;
}

@@ -25,0 +26,0 @@

@@ -13,5 +13,5 @@ 'use strict';

'a[href]',
'[tabindex]:not([disabled])',
'[tabindex]:not([disabled])'
].join(', ');
exports.FOCUSABLE_SELECTOR = FOCUSABLE_SELECTOR;

@@ -44,3 +44,3 @@ 'use strict';

function readTag(text, pos, startBracket, context) {
var ref, ref1;
var _text_slice_match, _text_slice_match1;
const releasePreviousModifier = text[pos] === '/' ? '/' : '';

@@ -50,7 +50,7 @@ pos += releasePreviousModifier.length;

pos += Number(escapedDescriptor);
const descriptor = escapedDescriptor ? text[pos] : (ref = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || ref === void 0 ? void 0 : ref[0];
const descriptor = escapedDescriptor ? text[pos] : (_text_slice_match = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || _text_slice_match === void 0 ? void 0 : _text_slice_match[0];
assertDescriptor(descriptor, text, pos, context);
pos += descriptor.length;
var ref2;
const repeatModifier = (ref2 = (ref1 = text.slice(pos).match(/^>\d+/)) === null || ref1 === void 0 ? void 0 : ref1[0]) !== null && ref2 !== void 0 ? ref2 : '';
var _text_slice_match_;
const repeatModifier = (_text_slice_match_ = (_text_slice_match1 = text.slice(pos).match(/^>\d+/)) === null || _text_slice_match1 === void 0 ? void 0 : _text_slice_match1[0]) !== null && _text_slice_match_ !== void 0 ? _text_slice_match_ : '';
pos += repeatModifier.length;

@@ -65,3 +65,3 @@ const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : '';

!releaseSelfModifier && 'release modifier',
`"${expectedEndBracket}"`,
`"${expectedEndBracket}"`
].filter(Boolean).join(' or '), text[pos], text, context));

@@ -68,0 +68,0 @@ }

@@ -11,4 +11,4 @@ 'use strict';

const treeB = [];
for(let el1 = b; el1; el1 = el1.parentElement){
treeB.push(el1);
for(let el = b; el; el = el.parentElement){
treeB.push(el);
}

@@ -24,3 +24,3 @@ let i = 0;

treeB.slice(0, treeB.length - i),
treeB.slice(treeB.length - i),
treeB.slice(treeB.length - i)
];

@@ -27,0 +27,0 @@ }

@@ -5,8 +5,9 @@ 'use strict';

var helpers_js = require('@testing-library/dom/dist/helpers.js');
var dtlHelpers = require('../../_interop/dtlHelpers.js');
const { getWindowFromNode } = dtlHelpers;
function getWindow(node) {
return helpers_js.getWindowFromNode(node);
return getWindowFromNode(node);
}
exports.getWindow = getWindow;

@@ -16,3 +16,3 @@ 'use strict';

'optgroup',
'option',
'option'
])) {

@@ -23,4 +23,4 @@ if (el.hasAttribute('disabled')) {

} else if (isElementType.isElementType(el, 'fieldset')) {
var ref;
if (el.hasAttribute('disabled') && !((ref = el.querySelector(':scope > legend')) === null || ref === void 0 ? void 0 : ref.contains(element))) {
var _el_querySelector;
if (el.hasAttribute('disabled') && !((_el_querySelector = el.querySelector(':scope > legend')) === null || _el_querySelector === void 0 ? void 0 : _el_querySelector.contains(element))) {
return true;

@@ -27,0 +27,0 @@ }

@@ -8,5 +8,6 @@ 'use strict';

function isVisible(element) {
var _el;
const window = getWindow.getWindow(element);
for(let el = element; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
const { display , visibility } = window.getComputedStyle(el);
for(let el = element; (_el = el) === null || _el === void 0 ? void 0 : _el.ownerDocument; el = el.parentElement){
const { display, visibility } = window.getComputedStyle(el);
if (display === 'none') {

@@ -13,0 +14,0 @@ return false;

@@ -12,3 +12,3 @@ 'use strict';

new Promise((resolve)=>globalThis.setTimeout(()=>resolve(), delay)),
config.advanceTimers(delay),
config.advanceTimers(delay)
]);

@@ -15,0 +15,0 @@ }

@@ -11,8 +11,9 @@ 'use strict';

function hasPointerEvents(instance, element) {
var ref;
return ((ref = checkPointerEvents(instance, element)) === null || ref === void 0 ? void 0 : ref.pointerEvents) !== 'none';
var _checkPointerEvents;
return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === void 0 ? void 0 : _checkPointerEvents.pointerEvents) !== 'none';
}
function closestPointerEventsDeclaration(element) {
var _el;
const window = getWindow.getWindow(element);
for(let el = element, tree = []; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
for(let el = element, tree = []; (_el = el) === null || _el === void 0 ? void 0 : _el.ownerDocument; el = el.parentElement){
tree.push(el);

@@ -37,3 +38,4 @@ const pointerEvents = window.getComputedStyle(el).pointerEvents;

if (!needsCheck) {
return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result;
var _lastCheck;
return (_lastCheck = lastCheck) === null || _lastCheck === void 0 ? void 0 : _lastCheck.result;
}

@@ -49,8 +51,9 @@ const declaration = closestPointerEventsDeclaration(element);

function assertPointerEvents(instance, element) {
var _declaration;
const declaration = checkPointerEvents(instance, element);
if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') {
if (((_declaration = declaration) === null || _declaration === void 0 ? void 0 : _declaration.pointerEvents) === 'none') {
throw new Error([
`Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`,
'',
printTree(declaration.tree),
printTree(declaration.tree)
].join('\n'));

@@ -67,7 +70,7 @@ }

tree.length > 1 && i === 0 && ' <-- This element declared `pointer-events: none`',
tree.length > 1 && i === tree.length - 1 && ' <-- Asserted pointer events here',
tree.length > 1 && i === tree.length - 1 && ' <-- Asserted pointer events here'
].filter(Boolean).join('')).join('\n');
}
function getLabelDescr(element) {
var ref;
var _element_labels, _label, _label1;
let label;

@@ -77,4 +80,4 @@ if (element.hasAttribute('aria-label')) {

} else if (element.hasAttribute('aria-labelledby')) {
var ref1, ref2;
label = (ref1 = element.ownerDocument.getElementById(element.getAttribute('aria-labelledby'))) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.textContent) === null || ref2 === void 0 ? void 0 : ref2.trim();
var _element_ownerDocument_getElementById_textContent, _element_ownerDocument_getElementById;
label = (_element_ownerDocument_getElementById = element.ownerDocument.getElementById(element.getAttribute('aria-labelledby'))) === null || _element_ownerDocument_getElementById === void 0 ? void 0 : (_element_ownerDocument_getElementById_textContent = _element_ownerDocument_getElementById.textContent) === null || _element_ownerDocument_getElementById_textContent === void 0 ? void 0 : _element_ownerDocument_getElementById_textContent.trim();
} else if (isElementType.isElementType(element, [

@@ -87,15 +90,16 @@ 'button',

'select',
'textarea',
]) && ((ref = element.labels) === null || ref === void 0 ? void 0 : ref.length)) {
'textarea'
]) && ((_element_labels = element.labels) === null || _element_labels === void 0 ? void 0 : _element_labels.length)) {
label = Array.from(element.labels).map((el)=>{
var ref;
return (ref = el.textContent) === null || ref === void 0 ? void 0 : ref.trim();
var _el_textContent;
return (_el_textContent = el.textContent) === null || _el_textContent === void 0 ? void 0 : _el_textContent.trim();
}).join('|');
} else if (isElementType.isElementType(element, 'button')) {
var ref3;
label = (ref3 = element.textContent) === null || ref3 === void 0 ? void 0 : ref3.trim();
var _element_textContent;
label = (_element_textContent = element.textContent) === null || _element_textContent === void 0 ? void 0 : _element_textContent.trim();
}
label = label === null || label === void 0 ? void 0 : label.replace(/\n/g, ' ');
if (Number(label === null || label === void 0 ? void 0 : label.length) > 30) {
label = `${label === null || label === void 0 ? void 0 : label.substring(0, 29)}…`;
label = (_label = label) === null || _label === void 0 ? void 0 : _label.replace(/\n/g, ' ');
if (Number((_label1 = label) === null || _label1 === void 0 ? void 0 : _label1.length) > 30) {
var _label2;
label = `${(_label2 = label) === null || _label2 === void 0 ? void 0 : _label2.substring(0, 29)}…`;
}

@@ -102,0 +106,0 @@ return label ? `(label=${label})` : '';

@@ -13,4 +13,4 @@ import '../utils/click/isClickableInput.js';

const doc = this.config.document;
var _activeElement;
const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body;
var _doc_activeElement;
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
const clipboardData = copySelection(target);

@@ -17,0 +17,0 @@ if (clipboardData.items.length === 0) {

@@ -13,4 +13,4 @@ import '../utils/click/isClickableInput.js';

const doc = this.config.document;
var _activeElement;
const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body;
var _doc_activeElement;
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
const clipboardData = copySelection(target);

@@ -17,0 +17,0 @@ if (clipboardData.items.length === 0) {

@@ -13,6 +13,6 @@ import '../utils/click/isClickableInput.js';

const doc = this.config.document;
var _activeElement;
const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body;
var ref;
const dataTransfer = (ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && ref !== void 0 ? ref : await readDataTransferFromClipboard(doc).catch(()=>{
var _doc_activeElement;
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body;
var _ref;
const dataTransfer = (_ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && _ref !== void 0 ? _ref : await readDataTransferFromClipboard(doc).catch(()=>{
throw new Error('`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.');

@@ -19,0 +19,0 @@ });

@@ -1,2 +0,2 @@

async function tab({ shift } = {}) {
async function tab({ shift } = {}) {
return this.keyboard(shift === true ? '{Shift>}{Tab}{/Shift}' : shift === false ? '[/ShiftLeft][/ShiftRight]{Tab}' : '{Tab}');

@@ -3,0 +3,0 @@ }

@@ -15,10 +15,12 @@ import '../utils/click/isClickableInput.js';

function prepareInterceptor(element, propName, interceptorImpl) {
var _prototypeDescriptor, _prototypeDescriptor1;
const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
const target = (prototypeDescriptor === null || prototypeDescriptor === void 0 ? void 0 : prototypeDescriptor.set) ? 'set' : 'value';
/* istanbul ignore if */ if (typeof (prototypeDescriptor === null || prototypeDescriptor === void 0 ? void 0 : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
const target = ((_prototypeDescriptor = prototypeDescriptor) === null || _prototypeDescriptor === void 0 ? void 0 : _prototypeDescriptor.set) ? 'set' : 'value';
/* istanbul ignore if */ if (typeof ((_prototypeDescriptor1 = prototypeDescriptor) === null || _prototypeDescriptor1 === void 0 ? void 0 : _prototypeDescriptor1[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`);
}
function intercept(...args) {
const { applyNative =false , realArgs , then , } = interceptorImpl.call(this, ...args);
var _then;
const { applyNative = false, realArgs, then } = interceptorImpl.call(this, ...args);
const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];

@@ -30,3 +32,3 @@ if (target === 'set') {

}
then === null || then === void 0 ? void 0 : then();
(_then = then) === null || _then === void 0 ? void 0 : _then();
}

@@ -33,0 +35,0 @@ intercept[Interceptor] = Interceptor;

@@ -32,4 +32,4 @@ import '../utils/click/isClickableInput.js';

function trackOrSetValue(element, v) {
var ref, ref1;
(ref = element[TrackChanges]) === null || ref === void 0 ? void 0 : (ref1 = ref.tracked) === null || ref1 === void 0 ? void 0 : ref1.push(v);
var _element_TrackChanges_tracked, _element_TrackChanges;
(_element_TrackChanges = element[TrackChanges]) === null || _element_TrackChanges === void 0 ? void 0 : (_element_TrackChanges_tracked = _element_TrackChanges.tracked) === null || _element_TrackChanges_tracked === void 0 ? void 0 : _element_TrackChanges_tracked.push(v);
if (!element[TrackChanges]) {

@@ -43,6 +43,6 @@ setUIValueClean(element);

function commitValueAfterInput(element, cursorOffset) {
var ref;
var _changes_tracked, _changes;
const changes = element[TrackChanges];
element[TrackChanges] = undefined;
if (!(changes === null || changes === void 0 ? void 0 : (ref = changes.tracked) === null || ref === void 0 ? void 0 : ref.length)) {
if (!((_changes = changes) === null || _changes === void 0 ? void 0 : (_changes_tracked = _changes.tracked) === null || _changes_tracked === void 0 ? void 0 : _changes_tracked.length)) {
return;

@@ -49,0 +49,0 @@ }

@@ -35,3 +35,3 @@ const UIValue = Symbol('Displayed value in UI');

}
function setUISelection(element, { focusOffset: focusOffsetParam , anchorOffset: anchorOffsetParam = focusOffsetParam }, mode = 'replace') {
function setUISelection(element, { focusOffset: focusOffsetParam, anchorOffset: anchorOffsetParam = focusOffsetParam }, mode = 'replace') {
const valueLength = getUIValue(element).length;

@@ -62,6 +62,6 @@ const sanitizeOffset = (o)=>Math.max(0, Math.min(valueLength, o));

function getUISelection(element) {
var _selectionStart, _selectionEnd, _UISelection;
const sel = (_UISelection = element[UISelection]) !== null && _UISelection !== void 0 ? _UISelection : {
anchorOffset: (_selectionStart = element.selectionStart) !== null && _selectionStart !== void 0 ? _selectionStart : 0,
focusOffset: (_selectionEnd = element.selectionEnd) !== null && _selectionEnd !== void 0 ? _selectionEnd : 0
var _element_selectionStart, _element_selectionEnd, _element_UISelection;
const sel = (_element_UISelection = element[UISelection]) !== null && _element_UISelection !== void 0 ? _element_UISelection : {
anchorOffset: (_element_selectionStart = element.selectionStart) !== null && _element_selectionStart !== void 0 ? _element_selectionStart : 0,
focusOffset: (_element_selectionEnd = element.selectionEnd) !== null && _element_selectionEnd !== void 0 ? _element_selectionEnd : 0
};

@@ -68,0 +68,0 @@ return {

@@ -24,5 +24,5 @@ import { getUIValue, setUISelection } from '../../document/UI.js';

behavior.keydown = (event, target, instance)=>{
var ref;
var ref1;
return (ref1 = (ref = keydownBehavior[event.key]) === null || ref === void 0 ? void 0 : ref.call(keydownBehavior, event, target, instance)) !== null && ref1 !== void 0 ? ref1 : combinationBehavior(event, target, instance);
var _keydownBehavior_event_key, _keydownBehavior;
var _keydownBehavior_event_key1;
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = (_keydownBehavior = keydownBehavior)[event.key]) === null || _keydownBehavior_event_key === void 0 ? void 0 : _keydownBehavior_event_key.call(_keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== void 0 ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance);
};

@@ -80,5 +80,5 @@ const keydownBehavior = {

return ()=>{
var ref;
var ref1;
const newPos = (ref1 = (ref = getValueOrTextContent(target)) === null || ref === void 0 ? void 0 : ref.length) !== null && ref1 !== void 0 ? ref1 : /* istanbul ignore next */ 0;
var _getValueOrTextContent;
var _getValueOrTextContent_length;
const newPos = (_getValueOrTextContent_length = (_getValueOrTextContent = getValueOrTextContent(target)) === null || _getValueOrTextContent === void 0 ? void 0 : _getValueOrTextContent.length) !== null && _getValueOrTextContent_length !== void 0 ? _getValueOrTextContent_length : /* istanbul ignore next */ 0;
setSelectionRange(target, newPos, newPos);

@@ -85,0 +85,0 @@ };

@@ -21,4 +21,5 @@ import '../../utils/click/isClickableInput.js';

} else if (isElementType(target, 'input')) {
var _form;
const form = target.form;
const submit = form === null || form === void 0 ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
const submit = (_form = form) === null || _form === void 0 ? void 0 : _form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
if (submit) {

@@ -45,3 +46,3 @@ return ()=>instance.dispatchUIEvent(submit, 'click');

'reset',
'submit',
'submit'
];

@@ -56,3 +57,3 @@ const SubmitSingleInputOnEnter = [

'url',
'week',
'week'
];

@@ -12,4 +12,4 @@ import { isClickableInput } from '../../utils/click/isClickableInput.js';

behavior.keyup = (event, target, instance)=>{
var ref;
return (ref = keyupBehavior[event.key]) === null || ref === void 0 ? void 0 : ref.call(keyupBehavior, event, target, instance);
var _keyupBehavior_event_key, _keyupBehavior;
return (_keyupBehavior_event_key = (_keyupBehavior = keyupBehavior)[event.key]) === null || _keyupBehavior_event_key === void 0 ? void 0 : _keyupBehavior_event_key.call(_keyupBehavior, event, target, instance);
};

@@ -16,0 +16,0 @@ const keyupBehavior = {

@@ -15,4 +15,4 @@ import '../../utils/click/isClickableInput.js';

return ()=>{
var ref;
const insertData = (ref = event.clipboardData) === null || ref === void 0 ? void 0 : ref.getData('text');
var _event_clipboardData;
const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text');
if (insertData) {

@@ -19,0 +19,0 @@ input(instance, target, insertData, 'insertFromPaste');

@@ -28,3 +28,3 @@ import '../utils/click/isClickableInput.js';

initMouseEvent,
initPointerEvent,
initPointerEvent
],

@@ -38,54 +38,54 @@ KeyboardEvent: [

function createEvent(type, target, init) {
var ref;
var _eventInitializer_EventType;
const window = getWindow(target);
const { EventType , defaultInit } = eventMap[eventMapKeys[type]];
const { EventType, defaultInit } = eventMap[eventMapKeys[type]];
const event = new (getEventConstructors(window))[EventType](type, defaultInit);
(ref = eventInitializer[EventType]) === null || ref === void 0 ? void 0 : ref.forEach((f)=>f(event, init !== null && init !== void 0 ? init : {}));
(_eventInitializer_EventType = eventInitializer[EventType]) === null || _eventInitializer_EventType === void 0 ? void 0 : _eventInitializer_EventType.forEach((f)=>f(event, init !== null && init !== void 0 ? init : {}));
return event;
}
/* istanbul ignore next */ function getEventConstructors(window) {
var _Event;
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_Event = window.Event) !== null && _Event !== void 0 ? _Event : class Event {
var _window_Event;
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_window_Event = window.Event) !== null && _window_Event !== void 0 ? _window_Event : class Event {
};
var _AnimationEvent;
const AnimationEvent = (_AnimationEvent = window.AnimationEvent) !== null && _AnimationEvent !== void 0 ? _AnimationEvent : class AnimationEvent extends Event {
var _window_AnimationEvent;
const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !== void 0 ? _window_AnimationEvent : class AnimationEvent extends Event {
};
var _ClipboardEvent;
const ClipboardEvent = (_ClipboardEvent = window.ClipboardEvent) !== null && _ClipboardEvent !== void 0 ? _ClipboardEvent : class ClipboardEvent extends Event {
var _window_ClipboardEvent;
const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !== void 0 ? _window_ClipboardEvent : class ClipboardEvent extends Event {
};
var _PopStateEvent;
const PopStateEvent = (_PopStateEvent = window.PopStateEvent) !== null && _PopStateEvent !== void 0 ? _PopStateEvent : class PopStateEvent extends Event {
var _window_PopStateEvent;
const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !== void 0 ? _window_PopStateEvent : class PopStateEvent extends Event {
};
var _ProgressEvent;
const ProgressEvent = (_ProgressEvent = window.ProgressEvent) !== null && _ProgressEvent !== void 0 ? _ProgressEvent : class ProgressEvent extends Event {
var _window_ProgressEvent;
const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !== void 0 ? _window_ProgressEvent : class ProgressEvent extends Event {
};
var _TransitionEvent;
const TransitionEvent = (_TransitionEvent = window.TransitionEvent) !== null && _TransitionEvent !== void 0 ? _TransitionEvent : class TransitionEvent extends Event {
var _window_TransitionEvent;
const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !== void 0 ? _window_TransitionEvent : class TransitionEvent extends Event {
};
var _UIEvent;
const UIEvent = (_UIEvent = window.UIEvent) !== null && _UIEvent !== void 0 ? _UIEvent : class UIEvent extends Event {
var _window_UIEvent;
const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !== void 0 ? _window_UIEvent : class UIEvent extends Event {
};
var _CompositionEvent;
const CompositionEvent = (_CompositionEvent = window.CompositionEvent) !== null && _CompositionEvent !== void 0 ? _CompositionEvent : class CompositionEvent extends UIEvent {
var _window_CompositionEvent;
const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !== void 0 ? _window_CompositionEvent : class CompositionEvent extends UIEvent {
};
var _FocusEvent;
const FocusEvent = (_FocusEvent = window.FocusEvent) !== null && _FocusEvent !== void 0 ? _FocusEvent : class FocusEvent extends UIEvent {
var _window_FocusEvent;
const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !== void 0 ? _window_FocusEvent : class FocusEvent extends UIEvent {
};
var _InputEvent;
const InputEvent = (_InputEvent = window.InputEvent) !== null && _InputEvent !== void 0 ? _InputEvent : class InputEvent extends UIEvent {
var _window_InputEvent;
const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !== void 0 ? _window_InputEvent : class InputEvent extends UIEvent {
};
var _KeyboardEvent;
const KeyboardEvent = (_KeyboardEvent = window.KeyboardEvent) !== null && _KeyboardEvent !== void 0 ? _KeyboardEvent : class KeyboardEvent extends UIEvent {
var _window_KeyboardEvent;
const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !== void 0 ? _window_KeyboardEvent : class KeyboardEvent extends UIEvent {
};
var _MouseEvent;
const MouseEvent = (_MouseEvent = window.MouseEvent) !== null && _MouseEvent !== void 0 ? _MouseEvent : class MouseEvent extends UIEvent {
var _window_MouseEvent;
const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !== void 0 ? _window_MouseEvent : class MouseEvent extends UIEvent {
};
var _DragEvent;
const DragEvent = (_DragEvent = window.DragEvent) !== null && _DragEvent !== void 0 ? _DragEvent : class DragEvent extends MouseEvent {
var _window_DragEvent;
const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !== void 0 ? _window_DragEvent : class DragEvent extends MouseEvent {
};
var _PointerEvent;
const PointerEvent = (_PointerEvent = window.PointerEvent) !== null && _PointerEvent !== void 0 ? _PointerEvent : class PointerEvent extends MouseEvent {
var _window_PointerEvent;
const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !== void 0 ? _window_PointerEvent : class PointerEvent extends MouseEvent {
};
var _TouchEvent;
const TouchEvent = (_TouchEvent = window.TouchEvent) !== null && _TouchEvent !== void 0 ? _TouchEvent : class TouchEvent extends UIEvent {
var _window_TouchEvent;
const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !== void 0 ? _window_TouchEvent : class TouchEvent extends UIEvent {
};

@@ -120,3 +120,3 @@ /* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ return {

}
function initClipboardEvent(event, { clipboardData }) {
function initClipboardEvent(event, { clipboardData }) {
assignProps(event, {

@@ -126,3 +126,3 @@ clipboardData

}
function initInputEvent(event, { data , inputType , isComposing }) {
function initInputEvent(event, { data, inputType, isComposing }) {
assignProps(event, {

@@ -134,3 +134,3 @@ data,

}
function initUIEvent(event, { view , detail }) {
function initUIEvent(event, { view, detail }) {
assignProps(event, {

@@ -141,3 +141,3 @@ view,

}
function initUIEventModififiers(event, { altKey , ctrlKey , metaKey , shiftKey , modifierAltGraph , modifierCapsLock , modifierFn , modifierFnLock , modifierNumLock , modifierScrollLock , modifierSymbol , modifierSymbolLock }) {
function initUIEventModififiers(event, { altKey, ctrlKey, metaKey, shiftKey, modifierAltGraph, modifierCapsLock, modifierFn, modifierFnLock, modifierNumLock, modifierScrollLock, modifierSymbol, modifierSymbolLock }) {
assignProps(event, {

@@ -166,3 +166,3 @@ altKey: Boolean(altKey),

}
function initKeyboardEvent(event, { key , code , location , repeat , isComposing , charCode }) {
function initKeyboardEvent(event, { key, code, location, repeat, isComposing, charCode }) {
assignProps(event, {

@@ -177,3 +177,3 @@ key: String(key),

}
function initMouseEvent(event, { x , y , screenX , screenY , clientX =x , clientY =y , button , buttons , relatedTarget }) {
function initMouseEvent(event, { x, y, screenX, screenY, clientX = x, clientY = y, button, buttons, relatedTarget }) {
assignProps(event, {

@@ -191,3 +191,3 @@ screenX: sanitizeNumber(screenX),

}
function initPointerEvent(event, { pointerId , width , height , pressure , tangentialPressure , tiltX , tiltY , twist , pointerType , isPrimary }) {
function initPointerEvent(event, { pointerId, width, height, pressure, tangentialPressure, tiltX, tiltY, twist, pointerType, isPrimary }) {
assignProps(event, {

@@ -194,0 +194,0 @@ pointerId: sanitizeNumber(pointerId),

@@ -23,5 +23,5 @@ import './behavior/click.js';

function dispatchEvent(target, event, preventDefault = false) {
var ref;
var _behavior_type, _behavior;
const type = event.type;
const behaviorImplementation = preventDefault ? ()=>{} : (ref = behavior[type]) === null || ref === void 0 ? void 0 : ref(event, target, this);
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = (_behavior = behavior)[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(_behavior, event, target, this);
if (behaviorImplementation) {

@@ -28,0 +28,0 @@ event.preventDefault();

@@ -1,5 +0,5 @@

import { eventMap as eventMap$1 } from '@testing-library/dom/dist/event-map.js';
import dtlEvents from '../_interop/dtlEventMap.js';
const eventMap = {
...eventMap$1,
...dtlEvents.eventMap,
click: {

@@ -6,0 +6,0 @@ EventType: 'PointerEvent',

@@ -26,4 +26,4 @@ import '../utils/click/isClickableInput.js';

wrapEvent(()=>{
var ref;
return (ref = activeElement) === null || ref === void 0 ? void 0 : ref.blur();
var _activeElement;
return (_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.blur();
});

@@ -30,0 +30,0 @@ }

@@ -97,3 +97,3 @@ import { setUIValue, clearInitialValue, getUIValue } from '../document/UI.js';

}
const { newValue , newOffset , oldValue } = calculateNewValue(dataToInsert, element, inputRange, inputType);
const { newValue, newOffset, oldValue } = calculateNewValue(dataToInsert, element, inputRange, inputType);
if (newValue === oldValue && newOffset === inputRange.startOffset && newOffset === inputRange.endOffset) {

@@ -126,3 +126,3 @@ return;

}
function calculateNewValue(inputData, node, { startOffset , endOffset }, inputType) {
function calculateNewValue(inputData, node, { startOffset, endOffset }, inputType) {
const value = getUIValue(node);

@@ -155,3 +155,3 @@ const prologEnd = Math.max(0, startOffset === endOffset && inputType === 'deleteContentBackward' ? startOffset - 1 : startOffset);

function isValidNumberInput(value) {
var ref, ref1;
var _value_match, _value_match1;
// the browser allows some invalid input but not others

@@ -161,5 +161,5 @@ // it allows up to two '-' at any place before any 'e' or one directly following 'e'

const valueParts = value.split('e', 2);
return !(/[^\d.\-e]/.test(value) || Number((ref = value.match(/-/g)) === null || ref === void 0 ? void 0 : ref.length) > 2 || Number((ref1 = value.match(/\./g)) === null || ref1 === void 0 ? void 0 : ref1.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
return !(/[^\d.\-e]/.test(value) || Number((_value_match = value.match(/-/g)) === null || _value_match === void 0 ? void 0 : _value_match.length) > 2 || Number((_value_match1 = value.match(/\./g)) === null || _value_match1 === void 0 ? void 0 : _value_match1.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
}
export { input };

@@ -10,5 +10,5 @@ import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js';

} else if (typeAndSelection.type === 'contenteditable') {
var ref;
var _typeAndSelection_selection;
// Multi-range on contenteditable edits the first selection instead of the last
return (ref = typeAndSelection.selection) === null || ref === void 0 ? void 0 : ref.getRangeAt(0);
return (_typeAndSelection_selection = typeAndSelection.selection) === null || _typeAndSelection_selection === void 0 ? void 0 : _typeAndSelection_selection.getRangeAt(0);
}

@@ -15,0 +15,0 @@ }

@@ -16,2 +16,3 @@ import { getUISelection } from '../../document/UI.js';

*/ function getTargetTypeAndSelection(node) {
var _element, _selection;
const element = getElement(node);

@@ -24,6 +25,6 @@ if (element && hasOwnSelection(element)) {

}
const selection = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection();
const selection = (_element = element) === null || _element === void 0 ? void 0 : _element.ownerDocument.getSelection();
// It is possible to extend a single-range selection into a contenteditable.
// This results in the range acting like a range outside of contenteditable.
const isCE = getContentEditable(node) && (selection === null || selection === void 0 ? void 0 : selection.anchorNode) && getContentEditable(selection.anchorNode);
const isCE = getContentEditable(node) && ((_selection = selection) === null || _selection === void 0 ? void 0 : _selection.anchorNode) && getContentEditable(selection.anchorNode);
return {

@@ -30,0 +31,0 @@ type: isCE ? 'contenteditable' : 'default',

@@ -14,4 +14,4 @@ import { setUISelection } from '../../document/UI.js';

* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
*/ function modifySelection({ focusNode , focusOffset }) {
var ref, ref1;
*/ function modifySelection({ focusNode, focusOffset }) {
var _focusNode_ownerDocument_getSelection, _focusNode_ownerDocument;
const typeAndSelection = getTargetTypeAndSelection(focusNode);

@@ -24,5 +24,5 @@ if (typeAndSelection.type === 'input') {

}
(ref1 = (ref = focusNode.ownerDocument) === null || ref === void 0 ? void 0 : ref.getSelection()) === null || ref1 === void 0 ? void 0 : ref1.extend(focusNode, focusOffset);
(_focusNode_ownerDocument = focusNode.ownerDocument) === null || _focusNode_ownerDocument === void 0 ? void 0 : (_focusNode_ownerDocument_getSelection = _focusNode_ownerDocument.getSelection()) === null || _focusNode_ownerDocument_getSelection === void 0 ? void 0 : _focusNode_ownerDocument_getSelection.extend(focusNode, focusOffset);
}
export { modifySelection };

@@ -12,3 +12,3 @@ import { setUISelection } from '../../document/UI.js';

function modifySelectionPerMouseMove(selectionRange, { document , target , node , offset }) {
function modifySelectionPerMouseMove(selectionRange, { document, target, node, offset }) {
const selectionFocus = resolveCaretPosition({

@@ -33,2 +33,3 @@ target,

} else {
var _selection, _selection1;
const range = selectionRange.cloneRange();

@@ -42,4 +43,4 @@ const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);

const selection = document.getSelection();
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
(_selection = selection) === null || _selection === void 0 ? void 0 : _selection.removeAllRanges();
(_selection1 = selection) === null || _selection1 === void 0 ? void 0 : _selection1.addRange(range.cloneRange());
}

@@ -46,0 +47,0 @@ }

@@ -25,8 +25,9 @@ import { getUISelection } from '../../document/UI.js';

} else {
const selection1 = node.ownerDocument.getSelection();
if (!(selection1 === null || selection1 === void 0 ? void 0 : selection1.focusNode)) {
var _selection;
const selection = node.ownerDocument.getSelection();
if (!((_selection = selection) === null || _selection === void 0 ? void 0 : _selection.focusNode)) {
return;
}
if (selection1.isCollapsed) {
const nextPosition = getNextCursorPosition(selection1.focusNode, selection1.focusOffset, direction);
if (selection.isCollapsed) {
const nextPosition = getNextCursorPosition(selection.focusNode, selection.focusOffset, direction);
if (nextPosition) {

@@ -39,3 +40,3 @@ setSelection({

} else {
selection1[direction < 0 ? 'collapseToStart' : 'collapseToEnd']();
selection[direction < 0 ? 'collapseToStart' : 'collapseToEnd']();
}

@@ -42,0 +43,0 @@ }

@@ -12,3 +12,3 @@ import { getUIValue } from '../../document/UI.js';

function resolveCaretPosition({ target , node , offset }) {
function resolveCaretPosition({ target, node, offset }) {
if (hasOwnSelection(target)) {

@@ -15,0 +15,0 @@ return {

@@ -24,4 +24,4 @@ import { getUIValue, getUISelection } from '../../document/UI.js';

}
var ref;
const focusNode = (ref = getContentEditable(target)) !== null && ref !== void 0 ? ref : target.ownerDocument.body;
var _getContentEditable;
const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body;
setSelection({

@@ -34,11 +34,12 @@ focusNode,

function isAllSelected(target) {
var _selection;
if (hasOwnSelection(target)) {
return getUISelection(target).startOffset === 0 && getUISelection(target).endOffset === getUIValue(target).length;
}
var ref;
const focusNode = (ref = getContentEditable(target)) !== null && ref !== void 0 ? ref : target.ownerDocument.body;
var _getContentEditable;
const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body;
const selection = target.ownerDocument.getSelection();
return (selection === null || selection === void 0 ? void 0 : selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
return ((_selection = selection) === null || _selection === void 0 ? void 0 : _selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
}
export { isAllSelected, selectAll };

@@ -14,4 +14,4 @@ import { setUISelection } from '../../document/UI.js';

* Set the selection
*/ function setSelection({ focusNode , focusOffset , anchorNode =focusNode , anchorOffset =focusOffset }) {
var ref, ref1;
*/ function setSelection({ focusNode, focusOffset, anchorNode = focusNode, anchorOffset = focusOffset }) {
var _anchorNode_ownerDocument_getSelection, _anchorNode_ownerDocument;
const typeAndSelection = getTargetTypeAndSelection(focusNode);

@@ -24,5 +24,5 @@ if (typeAndSelection.type === 'input') {

}
(ref1 = (ref = anchorNode.ownerDocument) === null || ref === void 0 ? void 0 : ref.getSelection()) === null || ref1 === void 0 ? void 0 : ref1.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
(_anchorNode_ownerDocument = anchorNode.ownerDocument) === null || _anchorNode_ownerDocument === void 0 ? void 0 : (_anchorNode_ownerDocument_getSelection = _anchorNode_ownerDocument.getSelection()) === null || _anchorNode_ownerDocument_getSelection === void 0 ? void 0 : _anchorNode_ownerDocument_getSelection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
}
export { setSelection };

@@ -13,3 +13,3 @@ import { getUIValue, setUISelection } from '../../document/UI.js';

function setSelectionPerMouseDown({ document , target , clickCount , node , offset }) {
function setSelectionPerMouseDown({ document, target, clickCount, node, offset }) {
if (hasNoSelection(target)) {

@@ -43,3 +43,4 @@ return;

} else {
const { node: startNode , offset: startOffset } = resolveCaretPosition({
var _selection, _selection1;
const { node: startNode, offset: startOffset } = resolveCaretPosition({
target,

@@ -49,3 +50,3 @@ node,

});
const { node: endNode , offset: endOffset } = resolveCaretPosition({
const { node: endNode, offset: endOffset } = resolveCaretPosition({
target,

@@ -63,4 +64,4 @@ node,

const selection = document.getSelection();
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
(_selection = selection) === null || _selection === void 0 ? void 0 : _selection.removeAllRanges();
(_selection1 = selection) === null || _selection1 === void 0 ? void 0 : _selection1.addRange(range.cloneRange());
return range;

@@ -80,3 +81,3 @@ }

textPos - text.substr(0, pos).match(/(\w+|\s+|\W)?$/)[0].length,
pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length,
pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length
];

@@ -87,3 +88,3 @@ }

textPos - text.substr(0, pos).match(/[^\r\n]*$/)[0].length,
pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length,
pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length
];

@@ -90,0 +91,0 @@ }

@@ -18,3 +18,3 @@ import '../../utils/click/isClickableInput.js';

*/ function setSelectionRange(element, anchorOffset, focusOffset) {
var ref;
var _element_firstChild;
if (hasOwnSelection(element)) {

@@ -27,3 +27,3 @@ return setSelection({

}
/* istanbul ignore else */ if (isContentEditable(element) && ((ref = element.firstChild) === null || ref === void 0 ? void 0 : ref.nodeType) === 3) {
/* istanbul ignore else */ if (isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === void 0 ? void 0 : _element_firstChild.nodeType) === 3) {
return setSelection({

@@ -30,0 +30,0 @@ focusNode: element.firstChild,

@@ -16,4 +16,5 @@ import '../../utils/click/isClickableInput.js';

*/ function updateSelectionOnFocus(element) {
var _selection;
const selection = element.ownerDocument.getSelection();
/* istanbul ignore if */ if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) {
/* istanbul ignore if */ if (!((_selection = selection) === null || _selection === void 0 ? void 0 : _selection.focusNode)) {
return;

@@ -32,4 +33,4 @@ }

if (!selection.isCollapsed) {
var ref;
const focusNode = ((ref = contenteditable.firstChild) === null || ref === void 0 ? void 0 : ref.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
var _contenteditable_firstChild;
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === void 0 ? void 0 : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
selection.setBaseAndExtent(focusNode, 0, focusNode, 0);

@@ -36,0 +37,0 @@ }

@@ -1,3 +0,4 @@

import { getConfig } from '@testing-library/dom';
import dtl from '../_interop/dtl.js';
const { getConfig } = dtl;
function wrapEvent(cb, _element) {

@@ -4,0 +5,0 @@ return getConfig().eventWrapper(cb);

@@ -1,2 +0,2 @@

export { userEvent as default } from './setup/index.js';
export { userEvent as default, userEvent } from './setup/index.js';
export { PointerEventsCheckLevel } from './options.js';

@@ -19,4 +19,4 @@ import '../utils/click/isClickableInput.js';

}
async function keyboardAction(instance, { keyDef , releasePrevious , releaseSelf , repeat }) {
const { system } = instance;
async function keyboardAction(instance, { keyDef, releasePrevious, releaseSelf, repeat }) {
const { system } = instance;
// Release the key automatically if it was pressed before.

@@ -23,0 +23,0 @@ if (system.keyboard.isKeyPressed(keyDef)) {

@@ -22,14 +22,14 @@ import '../utils/click/isClickableInput.js';

do {
const { type , descriptor , consumedLength , releasePrevious , releaseSelf =true , repeat , } = readNextDescriptor(text, 'keyboard');
var ref;
const keyDef = (ref = keyboardMap.find((def)=>{
const { type, descriptor, consumedLength, releasePrevious, releaseSelf = true, repeat } = readNextDescriptor(text, 'keyboard');
var _keyboardMap_find;
const keyDef = (_keyboardMap_find = keyboardMap.find((def)=>{
if (type === '[') {
var ref;
return ((ref = def.code) === null || ref === void 0 ? void 0 : ref.toLowerCase()) === descriptor.toLowerCase();
var _def_code;
return ((_def_code = def.code) === null || _def_code === void 0 ? void 0 : _def_code.toLowerCase()) === descriptor.toLowerCase();
} else if (type === '{') {
var ref1;
return ((ref1 = def.key) === null || ref1 === void 0 ? void 0 : ref1.toLowerCase()) === descriptor.toLowerCase();
var _def_key;
return ((_def_key = def.key) === null || _def_key === void 0 ? void 0 : _def_key.toLowerCase()) === descriptor.toLowerCase();
}
return def.key === descriptor;
})) !== null && ref !== void 0 ? ref : {
})) !== null && _keyboardMap_find !== void 0 ? _keyboardMap_find : {
key: 'Unknown',

@@ -36,0 +36,0 @@ code: 'Unknown',

@@ -13,3 +13,3 @@ import '../utils/click/isClickableInput.js';

async function pointer(input) {
const { pointerMap } = this.config;
const { pointerMap } = this.config;
const actions = [];

@@ -37,12 +37,12 @@ (Array.isArray(input) ? input : [

async function pointerAction(instance, action) {
var ref, ref1;
var _previousPosition, _previousPosition_caret, _previousPosition1, _previousPosition_caret1, _previousPosition2;
const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? instance.system.pointer.getPointerName(action.keyDef) : 'mouse';
const previousPosition = instance.system.pointer.getPreviousPosition(pointerName);
var _target, _coords, _node, _offset;
var _action_target, _action_coords, _action_node, _action_offset;
const position = {
target: (_target = action.target) !== null && _target !== void 0 ? _target : getPrevTarget(instance, previousPosition),
coords: (_coords = action.coords) !== null && _coords !== void 0 ? _coords : previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.coords,
target: (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : getPrevTarget(instance, previousPosition),
coords: (_action_coords = action.coords) !== null && _action_coords !== void 0 ? _action_coords : (_previousPosition = previousPosition) === null || _previousPosition === void 0 ? void 0 : _previousPosition.coords,
caret: {
node: (_node = action.node) !== null && _node !== void 0 ? _node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (ref = previousPosition.caret) === null || ref === void 0 ? void 0 : ref.node,
offset: (_offset = action.offset) !== null && _offset !== void 0 ? _offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (ref1 = previousPosition.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
node: (_action_node = action.node) !== null && _action_node !== void 0 ? _action_node : hasCaretPosition(action) ? undefined : (_previousPosition1 = previousPosition) === null || _previousPosition1 === void 0 ? void 0 : (_previousPosition_caret = _previousPosition1.caret) === null || _previousPosition_caret === void 0 ? void 0 : _previousPosition_caret.node,
offset: (_action_offset = action.offset) !== null && _action_offset !== void 0 ? _action_offset : hasCaretPosition(action) ? undefined : (_previousPosition2 = previousPosition) === null || _previousPosition2 === void 0 ? void 0 : (_previousPosition_caret1 = _previousPosition2.caret) === null || _previousPosition_caret1 === void 0 ? void 0 : _previousPosition_caret1.offset
}

@@ -69,4 +69,4 @@ };

function hasCaretPosition(action) {
var _target, ref;
return !!((ref = (_target = action.target) !== null && _target !== void 0 ? _target : action.node) !== null && ref !== void 0 ? ref : action.offset !== undefined);
var _action_target, _ref;
return !!((_ref = (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : action.node) !== null && _ref !== void 0 ? _ref : action.offset !== undefined);
}

@@ -77,6 +77,6 @@ function getPrevTarget(instance, position) {

}
var _target;
return (_target = position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
var _position_target;
return (_position_target = position.target) !== null && _position_target !== void 0 ? _position_target : instance.config.document.body;
}
export { pointer };

@@ -28,5 +28,5 @@ const defaultKeyMap = [

pointerType: 'touch'
},
}
];
export { defaultKeyMap };

@@ -13,3 +13,3 @@ import '../utils/click/isClickableInput.js';

do {
const { descriptor , consumedLength , releasePrevious , releaseSelf =true , } = readNextDescriptor(keys, 'pointer');
const { descriptor, consumedLength, releasePrevious, releaseSelf = true } = readNextDescriptor(keys, 'pointer');
const keyDef = pointerMap.find((p)=>p.name === descriptor);

@@ -16,0 +16,0 @@ if (keyDef) {

@@ -1,12 +0,33 @@

export { click, dblClick, tripleClick } from '../convenience/click.js';
export { hover, unhover } from '../convenience/hover.js';
export { tab } from '../convenience/tab.js';
export { keyboard } from '../keyboard/index.js';
export { copy } from '../clipboard/copy.js';
export { cut } from '../clipboard/cut.js';
export { paste } from '../clipboard/paste.js';
export { pointer } from '../pointer/index.js';
export { clear } from '../utility/clear.js';
export { deselectOptions, selectOptions } from '../utility/selectOptions.js';
export { type } from '../utility/type.js';
export { upload } from '../utility/upload.js';
import { click, dblClick, tripleClick } from '../convenience/click.js';
import { hover, unhover } from '../convenience/hover.js';
import { tab } from '../convenience/tab.js';
import { keyboard } from '../keyboard/index.js';
import { copy } from '../clipboard/copy.js';
import { cut } from '../clipboard/cut.js';
import { paste } from '../clipboard/paste.js';
import { pointer } from '../pointer/index.js';
import { clear } from '../utility/clear.js';
import { deselectOptions, selectOptions } from '../utility/selectOptions.js';
import { type } from '../utility/type.js';
import { upload } from '../utility/upload.js';
const userEventApi = {
click,
dblClick,
tripleClick,
hover,
unhover,
tab,
keyboard,
copy,
cut,
paste,
pointer,
clear,
deselectOptions,
selectOptions,
type,
upload
};
export { userEventApi };

@@ -25,7 +25,7 @@ import { setupDirect } from './setup.js';

async function keyboard(text, options = {}) {
const { api , system } = setupDirect(options);
const { api, system } = setupDirect(options);
return api.keyboard(text).then(()=>system);
}
async function pointer(input, options = {}) {
const { api , system } = setupDirect(options);
const { api, system } = setupDirect(options);
return api.pointer(input).then(()=>system);

@@ -46,3 +46,3 @@ }

function unhover(element, options = {}) {
const { api , system } = setupDirect(options);
const { api, system } = setupDirect(options);
system.pointer.setMousePosition({

@@ -49,0 +49,0 @@ target: element

@@ -17,3 +17,3 @@ import { prepareDocument } from '../document/prepareDocument.js';

import { System } from '../system/index.js';
import * as api from './api.js';
import { userEventApi } from './api.js';
import { wrapAsync } from './wrapAsync.js';

@@ -57,4 +57,4 @@

prepareDocument(config.document);
var _defaultView;
const view = (_defaultView = config.document.defaultView) !== null && _defaultView !== void 0 ? _defaultView : /* istanbul ignore next */ globalThis.window;
var _config_document_defaultView;
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== void 0 ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window;
attachClipboardStubToView(view);

@@ -65,7 +65,7 @@ return createInstance(config).api;

* Setup in direct call per `userEvent.anyApi()`
*/ function setupDirect({ keyboardState , pointerState , ...options } = {}, node) {
*/ function setupDirect({ keyboardState, pointerState, ...options } = {}, node) {
const config = createConfig(options, defaultOptionsDirect, node);
prepareDocument(config.document);
var ref;
const system = (ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && ref !== void 0 ? ref : new System();
var _ref;
const system = (_ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && _ref !== void 0 ? _ref : new System();
return {

@@ -105,3 +105,3 @@ api: createInstance(config, system).api,

levelRefs: {},
...api
...userEventApi
});

@@ -111,5 +111,5 @@ return {

api: {
...Object.fromEntries(Object.entries(api).map(([name, api])=>[
...Object.fromEntries(Object.entries(userEventApi).map(([name, api])=>[
name,
wrapAndBindImpl(instance, api),
wrapAndBindImpl(instance, api)
])),

@@ -121,6 +121,6 @@ setup: setupSub.bind(instance)

function getDocument(options, node, defaults) {
var _document, ref;
return (ref = (_document = options.document) !== null && _document !== void 0 ? _document : node && getDocumentFromNode(node)) !== null && ref !== void 0 ? ref : defaults.document;
var _options_document, _ref;
return (_ref = (_options_document = options.document) !== null && _options_document !== void 0 ? _options_document : node && getDocumentFromNode(node)) !== null && _ref !== void 0 ? _ref : defaults.document;
}
export { createConfig, createInstance, setupDirect, setupMain, setupSub };

@@ -1,3 +0,4 @@

import { getConfig } from '@testing-library/dom';
import dtl from '../_interop/dtl.js';
const { getConfig } = dtl;
/**

@@ -4,0 +5,0 @@ * Wrap an internal Promise

import { KeyboardHost } from './keyboard.js';
import { PointerHost } from './pointer/index.js';
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
/**

@@ -24,4 +37,4 @@ * @internal Do not create/alter this by yourself as this type might be subject to changes.

constructor(){
this.keyboard = new KeyboardHost(this);
this.pointer = new PointerHost(this);
_define_property(this, "keyboard", new KeyboardHost(this));
_define_property(this, "pointer", new PointerHost(this));
}

@@ -28,0 +41,0 @@ }

@@ -11,3 +11,15 @@ import '../utils/click/isClickableInput.js';

var _pressed, _code, _code1;
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
var DOM_KEY_LOCATION;

@@ -27,3 +39,3 @@ (function(DOM_KEY_LOCATION) {

'Shift',
'Symbol',
'Symbol'
];

@@ -38,3 +50,3 @@ function isModifierKey(key) {

'ScrollLock',
'SymbolLock',
'SymbolLock'
];

@@ -52,2 +64,4 @@ function isModifierLock(key) {

/** Press a key */ async keydown(instance, keyDef) {
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
_this_pressed, _code, _this_pressed_code;
const key = String(keyDef.key);

@@ -57,4 +71,4 @@ const code = String(keyDef.code);

this.setKeydownTarget(target);
var ref;
(ref = (_pressed = this.pressed)[_code = code]) !== null && ref !== void 0 ? ref : _pressed[_code] = {
var _;
(_ = (_this_pressed = this.pressed)[_code = code]) !== null && _ !== void 0 ? _ : _this_pressed[_code] = {
keyDef,

@@ -74,3 +88,3 @@ unpreventedDefault: false

}
(_code1 = this.pressed[code]).unpreventedDefault || (_code1.unpreventedDefault = unprevented);
(_this_pressed_code = this.pressed[code]).unpreventedDefault || (_this_pressed_code.unpreventedDefault = unprevented);
if (unprevented && this.hasKeyPress(key)) {

@@ -115,3 +129,4 @@ instance.dispatchUIEvent(getActiveElementOrBody(instance.config.document), 'keypress', {

constructor(system){
this.modifiers = {
_define_property(this, "system", void 0);
_define_property(this, "modifiers", {
Alt: false,

@@ -129,7 +144,7 @@ AltGraph: false,

SymbolLock: false
};
this.pressed = {};
this.carryChar = '';
this.lastKeydownTarget = undefined;
this.modifierLockStart = {};
});
_define_property(this, "pressed", {});
_define_property(this, "carryChar", '');
_define_property(this, "lastKeydownTarget", undefined);
_define_property(this, "modifierLockStart", {});
this.system = system;

@@ -136,0 +151,0 @@ }

@@ -0,1 +1,14 @@

function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Buttons {

@@ -34,3 +47,3 @@ getButtons() {

constructor(){
this.pressed = {};
_define_property(this, "pressed", {});
}

@@ -37,0 +50,0 @@ }

@@ -0,1 +1,14 @@

function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Device {

@@ -15,3 +28,3 @@ get countPressed() {

constructor(){
this.pressedKeys = new Set();
_define_property(this, "pressedKeys", new Set());
}

@@ -18,0 +31,0 @@ }

@@ -6,3 +6,15 @@ import { Buttons } from './buttons.js';

var _registry, _k;
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class PointerHost {

@@ -28,2 +40,3 @@ isKeyPressed(keyDef) {

async move(instance, pointerName, position) {
var _pointermove, _mousemove, _pointermove1, _mousemove1, _pointermove2, _mousemove2;
const pointer = this.pointers.get(pointerName);

@@ -36,8 +49,8 @@ // In (some?) browsers this order of events can be observed.

const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
pointermove === null || pointermove === void 0 ? void 0 : pointermove.leave();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
pointermove === null || pointermove === void 0 ? void 0 : pointermove.enter();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
pointermove === null || pointermove === void 0 ? void 0 : pointermove.move();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
(_pointermove = pointermove) === null || _pointermove === void 0 ? void 0 : _pointermove.leave();
(_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
(_pointermove1 = pointermove) === null || _pointermove1 === void 0 ? void 0 : _pointermove1.enter();
(_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
(_pointermove2 = pointermove) === null || _pointermove2 === void 0 ? void 0 : _pointermove2.move();
(_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
}

@@ -62,13 +75,15 @@ async release(instance, keyDef, position) {

if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
var _mousemove, _mousemove1, _mousemove2;
const mousemove = this.mouse.move(instance, pointer.position);
mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
(_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
(_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
(_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
this.mouse.down(instance, keyDef, pointer);
}
if (!pointer.isMultitouch) {
const mousemove1 = this.mouse.move(instance, pointer.position);
mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.leave();
mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.enter();
mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.move();
var _mousemove3, _mousemove4, _mousemove5;
const mousemove = this.mouse.move(instance, pointer.position);
(_mousemove3 = mousemove) === null || _mousemove3 === void 0 ? void 0 : _mousemove3.leave();
(_mousemove4 = mousemove) === null || _mousemove4 === void 0 ? void 0 : _mousemove4.enter();
(_mousemove5 = mousemove) === null || _mousemove5 === void 0 ? void 0 : _mousemove5.move();
this.mouse.up(instance, keyDef, pointer);

@@ -88,4 +103,4 @@ }

getMouseTarget(instance) {
var _target;
return (_target = this.mouse.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
var _this_mouse_position_target;
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== void 0 ? _this_mouse_position_target : instance.config.document.body;
}

@@ -97,13 +112,18 @@ setMousePosition(position) {

constructor(system){
this.devices = new class {
_define_property(this, "system", void 0);
_define_property(this, "mouse", void 0);
_define_property(this, "buttons", void 0);
_define_property(this, "devices", new class {
get(k) {
var ref;
(ref = (_registry = this.registry)[_k = k]) !== null && ref !== void 0 ? ref : _registry[_k] = new Device();
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
_this_registry, _k;
var _;
(_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new Device();
return this.registry[k];
}
constructor(){
this.registry = {};
_define_property(this, "registry", {});
}
}();
this.pointers = new class {
}());
_define_property(this, "pointers", new class {
new(pointerName, keyDef) {

@@ -135,3 +155,3 @@ const isPrimary = keyDef.pointerType !== 'touch' || !Object.values(this.registry).some((p)=>p.pointerType === 'touch' && !p.isCancelled);

constructor(){
this.registry = {
_define_property(this, "registry", {
mouse: new Pointer({

@@ -142,6 +162,6 @@ pointerId: 1,

})
};
this.nextId = 2;
});
_define_property(this, "nextId", 2);
}
}();
}());
this.system = system;

@@ -148,0 +168,0 @@ this.buttons = new Buttons();

@@ -25,2 +25,15 @@ import '../../event/behavior/click.js';

function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
/**

@@ -123,7 +136,7 @@ * This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.

getTarget(instance) {
var _target;
return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
var _this_position_target;
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
}
startSelecting(instance, clickCount) {
var ref, ref1;
var _this_position_caret, _this_position_caret1;
// TODO: support extending range (shift)

@@ -133,4 +146,4 @@ this.selecting = setSelectionPerMouseDown({

target: this.getTarget(instance),
node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset,
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset,
clickCount

@@ -140,3 +153,3 @@ });

modifySelecting(instance) {
var ref, ref1;
var _this_position_caret, _this_position_caret1;
if (!this.selecting) {

@@ -148,4 +161,4 @@ return;

target: this.getTarget(instance),
node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset
});

@@ -157,5 +170,6 @@ }

constructor(){
this.position = {};
this.buttons = new Buttons();
this.buttonDownTarget = {};
_define_property(this, "position", {});
_define_property(this, "buttons", new Buttons());
_define_property(this, "selecting", void 0);
_define_property(this, "buttonDownTarget", {});
// According to spec the `detail` on click events should be the number

@@ -171,3 +185,3 @@ // of *consecutive* clicks with a specific button.

// We'll follow the minimal implementation of Webkit.
this.clickCount = new class {
_define_property(this, "clickCount", new class {
incOnClick(button) {

@@ -181,9 +195,9 @@ const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;

getOnDown(button) {
var _button;
var _this_count_button;
this.down = {
[button]: (_button = this.count[button]) !== null && _button !== void 0 ? _button : 0
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0
};
var _button1;
var _this_count_button1;
this.count = {
[button]: (_button1 = this.count[button]) !== null && _button1 !== void 0 ? _button1 : 0
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0
};

@@ -199,6 +213,6 @@ return Number(this.count[button]) + 1;

constructor(){
this.down = {};
this.count = {};
_define_property(this, "down", {});
_define_property(this, "count", {});
}
}();
}());
}

@@ -205,0 +219,0 @@ }

@@ -12,2 +12,15 @@ import '../../utils/click/isClickableInput.js';

function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
class Pointer {

@@ -86,4 +99,4 @@ init(instance, position) {

getTarget(instance) {
var _target;
return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
var _this_position_target;
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
}

@@ -98,8 +111,11 @@ getEventInit() {

}
constructor({ pointerId , pointerType , isPrimary }){
this.isMultitouch = false;
this.isCancelled = false;
this.isDown = false;
this.isPrevented = false;
this.position = {};
constructor({ pointerId, pointerType, isPrimary }){
_define_property(this, "pointerId", void 0);
_define_property(this, "pointerType", void 0);
_define_property(this, "isPrimary", void 0);
_define_property(this, "isMultitouch", false);
_define_property(this, "isCancelled", false);
_define_property(this, "isDown", false);
_define_property(this, "isPrevented", false);
_define_property(this, "position", {});
this.pointerId = pointerId;

@@ -106,0 +122,0 @@ this.pointerType = pointerType;

function isDifferentPointerPosition(positionA, positionB) {
var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
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);
var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
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.y) || ((_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_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);
}
export { isDifferentPointerPosition };

@@ -1,2 +0,2 @@

import { getConfig } from '@testing-library/dom';
import dtl from '../_interop/dtl.js';
import '../utils/click/isClickableInput.js';

@@ -22,2 +22,3 @@ import '../utils/dataTransfer/Clipboard.js';

const { getConfig } = dtl;
async function selectOptions(select, values) {

@@ -86,5 +87,5 @@ return selectOptionsBase.call(this, true, select, values);

} else if (selectedOptions.length === 1) {
const withPointerEvents1 = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, select);
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, select);
// the click to open the select options
if (withPointerEvents1) {
if (withPointerEvents) {
await this.click(select);

@@ -95,3 +96,3 @@ } else {

selectOption(selectedOptions[0]);
if (withPointerEvents1) {
if (withPointerEvents) {
// the browser triggers another click event on the select for the click on the option

@@ -112,5 +113,5 @@ // this second click has no 'down' phase

} else if (select.getAttribute('role') === 'listbox') {
for (const option1 of selectedOptions){
await this.click(option1);
await this.unhover(option1);
for (const option of selectedOptions){
await this.click(option);
await this.unhover(option);
}

@@ -117,0 +118,0 @@ } else {

@@ -12,3 +12,3 @@ import { releaseAllKeys } from '../keyboard/index.js';

async function type(element, text, { skipClick =this.config.skipClick , skipAutoClose =this.config.skipAutoClose , initialSelectionStart , initialSelectionEnd } = {}) {
async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
// TODO: properly type guard

@@ -15,0 +15,0 @@ // we use this workaround for now to prevent changing behavior

@@ -19,3 +19,4 @@ import '../utils/click/isClickableInput.js';

})) {
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
var _input;
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${(_input = input) === null || _input === void 0 ? void 0 : _input.tagName} element does not accept file uploads`);
}

@@ -27,7 +28,7 @@ if (isDisabled(element)) return;

const fileDialog = ()=>{
var ref;
var _input_files;
// do not fire an input event if the file selection does not change
if (files.length === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.length) && files.every((f, i)=>{
var ref;
return f === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.item(i));
if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{
var _input_files;
return f === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.item(i));
})) {

@@ -34,0 +35,0 @@ return;

@@ -6,2 +6,15 @@ import { getWindow } from '../misc/getWindow.js';

// Clipboard is not available in jsdom
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
// MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData

@@ -13,3 +26,3 @@ // lib.dom.d.ts lists only Promise<Blob|string>

typeof b === 'string' ? 'text/plain' : b.type,
Promise.resolve(b),
Promise.resolve(b)
]));

@@ -36,2 +49,3 @@ // use real ClipboardItem if available

constructor(d){
_define_property(this, "data", void 0);
this.data = d;

@@ -67,3 +81,3 @@ }

super(...args);
this.items = [];
_define_property(this, "items", []);
}

@@ -75,4 +89,4 @@ }(), {

function isClipboardStub(clipboard) {
var ref;
return !!((ref = clipboard) === null || ref === void 0 ? void 0 : ref[ClipboardStubControl]);
var _clipboard;
return !!((_clipboard = clipboard) === null || _clipboard === void 0 ? void 0 : _clipboard[ClipboardStubControl]);
}

@@ -118,4 +132,5 @@ function attachClipboardStubToView(window) {

async function readDataTransferFromClipboard(document) {
var _window;
const window = document.defaultView;
const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard;
const clipboard = (_window = window) === null || _window === void 0 ? void 0 : _window.navigator.clipboard;
const items = clipboard && await clipboard.read();

@@ -148,9 +163,10 @@ if (!items) {

}
/* istanbul ignore else */ if (typeof globalThis.afterEach === 'function') {
globalThis.afterEach(()=>resetClipboardStubOnView(globalThis.window));
const g = globalThis;
/* istanbul ignore else */ if (typeof g.afterEach === 'function') {
g.afterEach(()=>resetClipboardStubOnView(globalThis.window));
}
/* istanbul ignore else */ if (typeof globalThis.afterAll === 'function') {
globalThis.afterAll(()=>detachClipboardStubFromView(globalThis.window));
/* istanbul ignore else */ if (typeof g.afterAll === 'function') {
g.afterAll(()=>detachClipboardStubFromView(globalThis.window));
}
export { attachClipboardStubToView, createClipboardItem, detachClipboardStubFromView, readDataTransferFromClipboard, resetClipboardStubOnView, writeDataTransferToClipboard };
import { createFileList } from './FileList.js';
function _define_property(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
// DataTransfer is not implemented in jsdom.

@@ -18,4 +31,6 @@ // DataTransfer with FileList is being created by the browser on certain events.

constructor(dataOrFile, type){
this.file = null;
this.data = undefined;
_define_property(this, "kind", void 0);
_define_property(this, "type", void 0);
_define_property(this, "file", null);
_define_property(this, "data", undefined);
if (typeof dataOrFile === 'string') {

@@ -55,6 +70,7 @@ this.kind = 'string';

getData(format) {
var ref;
const match = (ref = this.items.find(getTypeMatcher(format, true))) !== null && ref !== void 0 ? ref : this.items.find(getTypeMatcher(format, false));
var _match;
var _this_items_find;
const match = (_this_items_find = this.items.find(getTypeMatcher(format, true))) !== null && _this_items_find !== void 0 ? _this_items_find : this.items.find(getTypeMatcher(format, false));
let text = '';
match === null || match === void 0 ? void 0 : match.getAsString((t)=>{
(_match = match) === null || _match === void 0 ? void 0 : _match.getAsString((t)=>{
text = t;

@@ -94,6 +110,6 @@ });

constructor(){
this.dropEffect = 'none';
this.effectAllowed = 'uninitialized';
this.items = new DataTransferItemListStub();
this.files = createFileList(window, []);
_define_property(this, "dropEffect", 'none');
_define_property(this, "effectAllowed", 'uninitialized');
_define_property(this, "items", new DataTransferItemListStub());
_define_property(this, "files", createFileList(window, []));
}

@@ -100,0 +116,0 @@ }();

@@ -15,4 +15,4 @@ import { isElementType } from '../misc/isElementType.js';

function getMaxLength(element) {
var ref;
const attr = (ref = element.getAttribute('maxlength')) !== null && ref !== void 0 ? ref : '';
var _element_getAttribute;
const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== void 0 ? _element_getAttribute : '';
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;

@@ -19,0 +19,0 @@ }

@@ -14,4 +14,4 @@ // It is not possible to create a real FileList programmatically.

function setFiles(el, files) {
var ref;
(ref = el[fakeFiles]) === null || ref === void 0 ? void 0 : ref.restore();
var _el_fakeFiles;
(_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === void 0 ? void 0 : _el_fakeFiles.restore();
const typeDescr = Object.getOwnPropertyDescriptor(el, 'type');

@@ -40,4 +40,4 @@ const valueDescr = Object.getOwnPropertyDescriptor(el, 'value');

} else {
var ref;
valueDescr === null || valueDescr === void 0 ? void 0 : (ref = valueDescr.set) === null || ref === void 0 ? void 0 : ref.call(el, v);
var _valueDescr_set, _valueDescr;
(_valueDescr = valueDescr) === null || _valueDescr === void 0 ? void 0 : (_valueDescr_set = _valueDescr.set) === null || _valueDescr_set === void 0 ? void 0 : _valueDescr_set.call(el, v);
}

@@ -44,0 +44,0 @@ }

@@ -103,3 +103,3 @@ import { isContentEditable } from '../edit/isContentEditable.js';

for(;;){
var ref;
var _node_ownerDocument;
const sibling = node[`${direction}Sibling`];

@@ -111,3 +111,3 @@ if (sibling) {

}
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((ref = node.ownerDocument) === null || ref === void 0 ? void 0 : ref.body))) {
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === void 0 ? void 0 : _node_ownerDocument.body))) {
node = node.parentNode;

@@ -114,0 +114,0 @@ } else {

import { isDisabled } from '../misc/isDisabled.js';
function getActiveElement(document) {
var _activeElement;
const activeElement = document.activeElement;
if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.shadowRoot) {
if ((_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.shadowRoot) {
return getActiveElement(activeElement.shadowRoot);

@@ -16,6 +17,6 @@ } else {

function getActiveElementOrBody(document) {
var ref;
return (ref = getActiveElement(document)) !== null && ref !== void 0 ? ref : /* istanbul ignore next */ document.body;
var _getActiveElement;
return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== void 0 ? _getActiveElement : /* istanbul ignore next */ document.body;
}
export { getActiveElement, getActiveElementOrBody };

@@ -9,5 +9,5 @@ const FOCUSABLE_SELECTOR = [

'a[href]',
'[tabindex]:not([disabled])',
'[tabindex]:not([disabled])'
].join(', ');
export { FOCUSABLE_SELECTOR };

@@ -40,3 +40,3 @@ var bracketDict;

function readTag(text, pos, startBracket, context) {
var ref, ref1;
var _text_slice_match, _text_slice_match1;
const releasePreviousModifier = text[pos] === '/' ? '/' : '';

@@ -46,7 +46,7 @@ pos += releasePreviousModifier.length;

pos += Number(escapedDescriptor);
const descriptor = escapedDescriptor ? text[pos] : (ref = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || ref === void 0 ? void 0 : ref[0];
const descriptor = escapedDescriptor ? text[pos] : (_text_slice_match = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || _text_slice_match === void 0 ? void 0 : _text_slice_match[0];
assertDescriptor(descriptor, text, pos, context);
pos += descriptor.length;
var ref2;
const repeatModifier = (ref2 = (ref1 = text.slice(pos).match(/^>\d+/)) === null || ref1 === void 0 ? void 0 : ref1[0]) !== null && ref2 !== void 0 ? ref2 : '';
var _text_slice_match_;
const repeatModifier = (_text_slice_match_ = (_text_slice_match1 = text.slice(pos).match(/^>\d+/)) === null || _text_slice_match1 === void 0 ? void 0 : _text_slice_match1[0]) !== null && _text_slice_match_ !== void 0 ? _text_slice_match_ : '';
pos += repeatModifier.length;

@@ -61,3 +61,3 @@ const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : '';

!releaseSelfModifier && 'release modifier',
`"${expectedEndBracket}"`,
`"${expectedEndBracket}"`
].filter(Boolean).join(' or '), text[pos], text, context));

@@ -64,0 +64,0 @@ }

@@ -7,4 +7,4 @@ function getTreeDiff(a, b) {

const treeB = [];
for(let el1 = b; el1; el1 = el1.parentElement){
treeB.push(el1);
for(let el = b; el; el = el.parentElement){
treeB.push(el);
}

@@ -20,3 +20,3 @@ let i = 0;

treeB.slice(0, treeB.length - i),
treeB.slice(treeB.length - i),
treeB.slice(treeB.length - i)
];

@@ -23,0 +23,0 @@ }

@@ -1,3 +0,4 @@

import { getWindowFromNode } from '@testing-library/dom/dist/helpers.js';
import dtlHelpers from '../../_interop/dtlHelpers.js';
const { getWindowFromNode } = dtlHelpers;
function getWindow(node) {

@@ -4,0 +5,0 @@ return getWindowFromNode(node);

@@ -12,3 +12,3 @@ import { isElementType } from './isElementType.js';

'optgroup',
'option',
'option'
])) {

@@ -19,4 +19,4 @@ if (el.hasAttribute('disabled')) {

} else if (isElementType(el, 'fieldset')) {
var ref;
if (el.hasAttribute('disabled') && !((ref = el.querySelector(':scope > legend')) === null || ref === void 0 ? void 0 : ref.contains(element))) {
var _el_querySelector;
if (el.hasAttribute('disabled') && !((_el_querySelector = el.querySelector(':scope > legend')) === null || _el_querySelector === void 0 ? void 0 : _el_querySelector.contains(element))) {
return true;

@@ -23,0 +23,0 @@ }

import { getWindow } from './getWindow.js';
function isVisible(element) {
var _el;
const window = getWindow(element);
for(let el = element; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
const { display , visibility } = window.getComputedStyle(el);
for(let el = element; (_el = el) === null || _el === void 0 ? void 0 : _el.ownerDocument; el = el.parentElement){
const { display, visibility } = window.getComputedStyle(el);
if (display === 'none') {

@@ -8,0 +9,0 @@ return false;

@@ -8,3 +8,3 @@ function wait(config) {

new Promise((resolve)=>globalThis.setTimeout(()=>resolve(), delay)),
config.advanceTimers(delay),
config.advanceTimers(delay)
]);

@@ -11,0 +11,0 @@ }

@@ -7,8 +7,9 @@ import { PointerEventsCheckLevel } from '../../options.js';

function hasPointerEvents(instance, element) {
var ref;
return ((ref = checkPointerEvents(instance, element)) === null || ref === void 0 ? void 0 : ref.pointerEvents) !== 'none';
var _checkPointerEvents;
return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === void 0 ? void 0 : _checkPointerEvents.pointerEvents) !== 'none';
}
function closestPointerEventsDeclaration(element) {
var _el;
const window = getWindow(element);
for(let el = element, tree = []; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
for(let el = element, tree = []; (_el = el) === null || _el === void 0 ? void 0 : _el.ownerDocument; el = el.parentElement){
tree.push(el);

@@ -33,3 +34,4 @@ const pointerEvents = window.getComputedStyle(el).pointerEvents;

if (!needsCheck) {
return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result;
var _lastCheck;
return (_lastCheck = lastCheck) === null || _lastCheck === void 0 ? void 0 : _lastCheck.result;
}

@@ -45,8 +47,9 @@ const declaration = closestPointerEventsDeclaration(element);

function assertPointerEvents(instance, element) {
var _declaration;
const declaration = checkPointerEvents(instance, element);
if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') {
if (((_declaration = declaration) === null || _declaration === void 0 ? void 0 : _declaration.pointerEvents) === 'none') {
throw new Error([
`Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`,
'',
printTree(declaration.tree),
printTree(declaration.tree)
].join('\n'));

@@ -63,7 +66,7 @@ }

tree.length > 1 && i === 0 && ' <-- This element declared `pointer-events: none`',
tree.length > 1 && i === tree.length - 1 && ' <-- Asserted pointer events here',
tree.length > 1 && i === tree.length - 1 && ' <-- Asserted pointer events here'
].filter(Boolean).join('')).join('\n');
}
function getLabelDescr(element) {
var ref;
var _element_labels, _label, _label1;
let label;

@@ -73,4 +76,4 @@ if (element.hasAttribute('aria-label')) {

} else if (element.hasAttribute('aria-labelledby')) {
var ref1, ref2;
label = (ref1 = element.ownerDocument.getElementById(element.getAttribute('aria-labelledby'))) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.textContent) === null || ref2 === void 0 ? void 0 : ref2.trim();
var _element_ownerDocument_getElementById_textContent, _element_ownerDocument_getElementById;
label = (_element_ownerDocument_getElementById = element.ownerDocument.getElementById(element.getAttribute('aria-labelledby'))) === null || _element_ownerDocument_getElementById === void 0 ? void 0 : (_element_ownerDocument_getElementById_textContent = _element_ownerDocument_getElementById.textContent) === null || _element_ownerDocument_getElementById_textContent === void 0 ? void 0 : _element_ownerDocument_getElementById_textContent.trim();
} else if (isElementType(element, [

@@ -83,15 +86,16 @@ 'button',

'select',
'textarea',
]) && ((ref = element.labels) === null || ref === void 0 ? void 0 : ref.length)) {
'textarea'
]) && ((_element_labels = element.labels) === null || _element_labels === void 0 ? void 0 : _element_labels.length)) {
label = Array.from(element.labels).map((el)=>{
var ref;
return (ref = el.textContent) === null || ref === void 0 ? void 0 : ref.trim();
var _el_textContent;
return (_el_textContent = el.textContent) === null || _el_textContent === void 0 ? void 0 : _el_textContent.trim();
}).join('|');
} else if (isElementType(element, 'button')) {
var ref3;
label = (ref3 = element.textContent) === null || ref3 === void 0 ? void 0 : ref3.trim();
var _element_textContent;
label = (_element_textContent = element.textContent) === null || _element_textContent === void 0 ? void 0 : _element_textContent.trim();
}
label = label === null || label === void 0 ? void 0 : label.replace(/\n/g, ' ');
if (Number(label === null || label === void 0 ? void 0 : label.length) > 30) {
label = `${label === null || label === void 0 ? void 0 : label.substring(0, 29)}…`;
label = (_label = label) === null || _label === void 0 ? void 0 : _label.replace(/\n/g, ' ');
if (Number((_label1 = label) === null || _label1 === void 0 ? void 0 : _label1.length) > 30) {
var _label2;
label = `${(_label2 = label) === null || _label2 === void 0 ? void 0 : _label2.substring(0, 29)}…`;
}

@@ -98,0 +102,0 @@ return label ? `(label=${label})` : '';

@@ -1,2 +0,2 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function copy(this: Instance): Promise<DataTransfer | undefined>;

@@ -1,2 +0,2 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function cut(this: Instance): Promise<DataTransfer | undefined>;

@@ -1,2 +0,2 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function paste(this: Instance, clipboardData?: DataTransfer | string): Promise<void>;

@@ -1,4 +0,4 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function click(this: Instance, element: Element): Promise<void>;
export declare function dblClick(this: Instance, element: Element): Promise<void>;
export declare function tripleClick(this: Instance, element: Element): Promise<void>;

@@ -1,3 +0,3 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function hover(this: Instance, element: Element): Promise<void>;
export declare function unhover(this: Instance, element: Element): Promise<void>;

@@ -1,4 +0,4 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function tab(this: Instance, { shift, }?: {
shift?: boolean;
}): Promise<void>;

@@ -1,4 +0,4 @@

declare type anyFunc = (...a: any[]) => any;
declare type Params<Prop> = Prop extends anyFunc ? Parameters<Prop> : [Prop];
declare type ImplReturn<Prop> = Prop extends anyFunc ? Parameters<Prop> : Prop;
type anyFunc = (...a: any[]) => any;
type Params<Prop> = Prop extends anyFunc ? Parameters<Prop> : [Prop];
type ImplReturn<Prop> = Prop extends anyFunc ? Parameters<Prop> : Prop;
export declare function prepareInterceptor<ElementType extends Element, PropName extends keyof ElementType>(element: ElementType, propName: PropName, interceptorImpl: (this: ElementType, ...args: Params<ElementType[PropName]>) => {

@@ -5,0 +5,0 @@ /**

@@ -15,6 +15,6 @@ declare const UIValue: unique symbol;

}
export declare type UIValueString = String & {
export type UIValueString = String & {
[UIValue]: true;
};
export declare type UISelectionStart = Number & {
export type UISelectionStart = Number & {
[UISelection]: true;

@@ -35,3 +35,3 @@ };

}, mode?: 'replace' | 'modify'): void;
export declare type UISelectionRange = UISelection & {
export type UISelectionRange = UISelection & {
startOffset: number;

@@ -38,0 +38,0 @@ endOffset: number;

@@ -1,2 +0,2 @@

import type { Instance } from '../../setup';
import { type Instance } from '../../setup';
import { EventType } from '../types';

@@ -3,0 +3,0 @@ export interface BehaviorPlugin<Type extends EventType> {

@@ -1,2 +0,2 @@

import type { EventType, EventTypeInit, FixedDocumentEventMap } from './types';
import { type EventType, type EventTypeInit, type FixedDocumentEventMap } from './types';
export declare function createEvent<K extends EventType>(type: K, target: Element, init?: EventTypeInit<K>): FixedDocumentEventMap[K];

@@ -1,2 +0,2 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
import { EventType, EventTypeInit } from './types';

@@ -3,0 +3,0 @@ export declare function dispatchUIEvent<K extends EventType>(this: Instance, target: Element, type: K, init?: EventTypeInit<K>, preventDefault?: boolean): boolean;

@@ -379,2 +379,10 @@ import { EventType } from './types';

};
readonly offline: {
EventType: EventInterface;
defaultInit: EventInit;
};
readonly online: {
EventType: EventInterface;
defaultInit: EventInit;
};
};

@@ -381,0 +389,0 @@ export declare const eventMapKeys: {

@@ -1,2 +0,2 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function input(instance: Instance, element: Element, data: string, inputType?: string): void;

@@ -1,4 +0,4 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function walkRadio(instance: Instance, el: HTMLInputElement & {
type: 'radio';
}, direction: -1 | 1): void;

@@ -1,2 +0,2 @@

import type { EditableInputOrTextarea } from '../../utils';
import { type EditableInputOrTextarea } from '../../utils';
export { getInputRange } from './getInputRange';

@@ -11,3 +11,3 @@ export { modifySelection } from './modifySelection';

export { updateSelectionOnFocus } from './updateSelectionOnFocus';
export declare type SelectionRange = {
export type SelectionRange = {
node: EditableInputOrTextarea;

@@ -14,0 +14,0 @@ start: number;

@@ -1,2 +0,2 @@

import type { SelectionRange } from '.';
import { type SelectionRange } from '.';
export declare function modifySelectionPerMouseMove(selectionRange: Range | SelectionRange, { document, target, node, offset, }: {

@@ -3,0 +3,0 @@ document: Document;

@@ -1,2 +0,2 @@

import type { SelectionRange } from '.';
import { type SelectionRange } from '.';
export declare function setSelectionPerMouseDown({ document, target, clickCount, node, offset, }: {

@@ -3,0 +3,0 @@ document: Document;

@@ -1,7 +0,7 @@

export declare type EventType = keyof DocumentEventMap;
export declare type EventTypeInit<K extends EventType> = SpecificEventInit<FixedDocumentEventMap[K]>;
export type EventType = keyof DocumentEventMap;
export type EventTypeInit<K extends EventType> = SpecificEventInit<FixedDocumentEventMap[K]>;
export interface FixedDocumentEventMap extends DocumentEventMap {
input: InputEvent;
}
declare type SpecificEventInit<E extends Event> = E extends InputEvent ? InputEventInit : E extends ClipboardEvent ? ClipboardEventInit : E extends KeyboardEvent ? KeyboardEventInit : E extends PointerEvent ? PointerEventInit : E extends MouseEvent ? MouseEventInit : E extends UIEvent ? UIEventInit : EventInit;
type SpecificEventInit<E extends Event> = E extends InputEvent ? InputEventInit : E extends ClipboardEvent ? ClipboardEventInit : E extends KeyboardEvent ? KeyboardEventInit : E extends PointerEvent ? PointerEventInit : E extends MouseEvent ? MouseEventInit : E extends UIEvent ? UIEventInit : EventInit;
export interface PointerCoords {

@@ -8,0 +8,0 @@ x?: number;

export { userEvent as default } from './setup';
export { userEvent } from './setup';
export type { UserEvent } from './setup/setup';
export type { keyboardKey } from './system/keyboard';
export type { pointerKey } from './system/pointer';
export { PointerEventsCheckLevel } from './options';
export { PointerEventsCheckLevel, type Options } from './options';

@@ -1,3 +0,3 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function keyboard(this: Instance, text: string): Promise<void>;
export declare function releaseAllKeys(instance: Instance): Promise<void>;

@@ -1,3 +0,3 @@

import type { keyboardKey } from './system/keyboard';
import type { pointerKey } from './system/pointer';
import { type keyboardKey } from './system/keyboard';
import { type pointerKey } from './system/pointer';
export declare enum PointerEventsCheckLevel {

@@ -4,0 +4,0 @@ /**

@@ -1,10 +0,10 @@

import type { PointerCoords } from '../event';
import type { Instance } from '../setup';
import type { pointerKey } from '../system/pointer';
declare type PointerActionInput = string | ({
import { type PointerCoords } from '../event';
import { type Instance } from '../setup';
import { type pointerKey } from '../system/pointer';
type PointerActionInput = string | ({
keys: string;
} & PointerActionPosition) | PointerAction;
export declare type PointerInput = PointerActionInput | Array<PointerActionInput>;
declare type PointerAction = PointerPressAction | PointerMoveAction;
declare type PointerActionPosition = {
export type PointerInput = PointerActionInput | Array<PointerActionInput>;
type PointerAction = PointerPressAction | PointerMoveAction;
type PointerActionPosition = {
target?: Element;

@@ -11,0 +11,0 @@ coords?: PointerCoords;

@@ -1,5 +0,23 @@

export { click, dblClick, tripleClick, hover, unhover, tab } from '../convenience';
export { keyboard } from '../keyboard';
export { copy, cut, paste } from '../clipboard';
export { pointer } from '../pointer';
export { clear, deselectOptions, selectOptions, type, upload } from '../utility';
import { click, dblClick, tripleClick, hover, unhover, tab } from '../convenience';
import { keyboard } from '../keyboard';
import { copy, cut, paste } from '../clipboard';
import { pointer } from '../pointer';
import { clear, deselectOptions, selectOptions, type, upload } from '../utility';
export declare const userEventApi: {
click: typeof click;
dblClick: typeof dblClick;
tripleClick: typeof tripleClick;
hover: typeof hover;
unhover: typeof unhover;
tab: typeof tab;
keyboard: typeof keyboard;
copy: typeof copy;
cut: typeof cut;
paste: typeof paste;
pointer: typeof pointer;
clear: typeof clear;
deselectOptions: typeof deselectOptions;
selectOptions: typeof selectOptions;
type: typeof type;
upload: typeof upload;
};

@@ -1,6 +0,6 @@

import type { Options } from '../options';
import type { PointerInput } from '../pointer';
import type { System } from '../system';
import type { UserEventApi } from './setup';
export declare type DirectOptions = Options & {
import { type Options } from '../options';
import { type PointerInput } from '../pointer';
import { type System } from '../system';
import { type UserEventApi } from './setup';
export type DirectOptions = Options & {
keyboardState?: System;

@@ -7,0 +7,0 @@ pointerState?: System;

import { dispatchEvent, dispatchUIEvent } from '../event';
import { Options } from '../options';
import { System } from '../system';
import * as userEventApi from './api';
import { userEventApi } from './api';
import { DirectOptions } from './directApi';
export declare type UserEventApi = typeof userEventApi;
export declare type UserEvent = {
export type UserEventApi = typeof userEventApi;
export type UserEvent = {
readonly setup: (...args: Parameters<typeof setupSub>) => UserEvent;

@@ -12,3 +12,3 @@ } & {

};
export declare type Instance = UserEventApi & {
export type Instance = UserEventApi & {
config: Config;

@@ -20,3 +20,3 @@ dispatchEvent: OmitThisParameter<typeof dispatchEvent>;

};
export declare type Config = Required<Options>;
export type Config = Required<Options>;
export declare function createConfig(options?: Options, defaults?: Required<Options>, node?: Node): Config;

@@ -23,0 +23,0 @@ /**

@@ -1,3 +0,3 @@

import type { Instance } from '../setup';
import type { System } from '.';
import { type Instance } from '../setup';
import { type System } from '.';
export declare enum DOM_KEY_LOCATION {

@@ -4,0 +4,0 @@ STANDARD = 0,

@@ -1,2 +0,2 @@

import type { pointerKey } from './shared';
import { type pointerKey } from './shared';
export declare class Buttons {

@@ -17,3 +17,3 @@ private readonly pressed;

};
export declare type MouseButton = keyof typeof MouseButton | number;
export type MouseButton = keyof typeof MouseButton | number;
export declare function getMouseButtonId(button?: MouseButton): number;

@@ -20,0 +20,0 @@ export declare const MouseButtonFlip: {

@@ -1,2 +0,2 @@

import type { pointerKey } from '.';
import { type pointerKey } from '.';
export declare class Device {

@@ -3,0 +3,0 @@ private pressedKeys;

@@ -1,3 +0,3 @@

import type { Instance } from '../../setup';
import type { Pointer } from './pointer';
import { type Instance } from '../../setup';
import { type Pointer } from './pointer';
import { pointerKey, PointerPosition } from './shared';

@@ -4,0 +4,0 @@ /**

@@ -1,4 +0,4 @@

import type { Instance } from '../../setup';
import { type Instance } from '../../setup';
import { pointerKey, PointerPosition } from './shared';
declare type PointerInit = {
type PointerInit = {
pointerId: number;

@@ -5,0 +5,0 @@ pointerType: string;

@@ -1,2 +0,2 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function clear(this: Instance, element: Element): Promise<void>;

@@ -1,3 +0,3 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export declare function selectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
export declare function deselectOptions(this: Instance, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;

@@ -1,3 +0,3 @@

import type { Instance } from '../setup';
import type { Options } from '../options';
import { type Instance } from '../setup';
import { type Options } from '../options';
export interface typeOptions {

@@ -4,0 +4,0 @@ skipClick?: Options['skipClick'];

@@ -1,2 +0,2 @@

import type { Instance } from '../setup';
import { type Instance } from '../setup';
export interface uploadInit {

@@ -3,0 +3,0 @@ changeInit?: EventInit;

@@ -11,3 +11,3 @@ declare enum clickableInputTypes {

}
export declare type ClickableInputOrButton = HTMLButtonElement | (HTMLInputElement & {
export type ClickableInputOrButton = HTMLButtonElement | (HTMLInputElement & {
type: clickableInputTypes;

@@ -14,0 +14,0 @@ });

export declare function createClipboardItem(window: Window & typeof globalThis, ...blobs: Array<Blob | string>): ClipboardItem;
declare type ClipboardStubControlInstance = {
type ClipboardStubControlInstance = {
resetClipboardStub: () => void;

@@ -4,0 +4,0 @@ detachClipboardStub: () => void;

import { isContentEditable } from './isContentEditable';
declare type GuardedType<T> = T extends (x: any) => x is infer R ? R : never;
type GuardedType<T> = T extends (x: any) => x is infer R ? R : never;
export declare function isEditable(element: Element): element is GuardedType<typeof isContentEditable> | (EditableInputOrTextarea & {

@@ -20,3 +20,3 @@ readOnly: false;

}
export declare type EditableInputOrTextarea = HTMLTextAreaElement | (HTMLInputElement & {
export type EditableInputOrTextarea = HTMLTextAreaElement | (HTMLInputElement & {
type: editableInputTypes;

@@ -23,0 +23,0 @@ });

@@ -9,3 +9,3 @@ declare enum maxLengthSupportedTypes {

}
declare type ElementWithMaxLengthSupport = HTMLTextAreaElement | (HTMLInputElement & {
type ElementWithMaxLengthSupport = HTMLTextAreaElement | (HTMLInputElement & {
type: maxLengthSupportedTypes;

@@ -12,0 +12,0 @@ });

@@ -1,2 +0,2 @@

declare type Context = 'pointer' | 'keyboard';
type Context = 'pointer' | 'keyboard';
/**

@@ -3,0 +3,0 @@ * Read the next key definition from user input

@@ -1,2 +0,2 @@

declare type tag = keyof HTMLElementTagNameMap;
type tag = keyof HTMLElementTagNameMap;
export declare function isElementType<T extends tag, P extends {

@@ -3,0 +3,0 @@ [k: string]: unknown;

@@ -1,2 +0,2 @@

import type { Instance } from '../../setup';
import { type Instance } from '../../setup';
export declare enum ApiLevel {

@@ -6,4 +6,4 @@ Trigger = 2,

}
export declare type LevelRefs = Record<ApiLevel, object | undefined>;
export type LevelRefs = Record<ApiLevel, object | undefined>;
export declare function setLevelRef(instance: Instance, level: ApiLevel): void;
export declare function getLevelRef(instance: Instance, level: ApiLevel): object | undefined;

@@ -1,2 +0,2 @@

import type { Instance } from '../../setup';
import { type Instance } from '../../setup';
export declare function wait(config: Instance['config']): Promise<[void, void]> | undefined;

@@ -1,2 +0,2 @@

import type { Instance } from '../../setup';
import { type Instance } from '../../setup';
import { ApiLevel } from '../misc/level';

@@ -3,0 +3,0 @@ export declare function hasPointerEvents(instance: Instance, element: Element): boolean;

{
"name": "@testing-library/user-event",
"version": "14.4.3",
"version": "14.5.0",
"description": "Fire events the same way the user does",

@@ -32,3 +32,6 @@ "keywords": [

"setup": "npm install && npm run validate -s",
"setup:env": "node --experimental-import-meta-resolve scripts/setup.js",
"test": "kcd-scripts test",
"test:jest": "kcd-scripts test",
"test:toolbox": "NODE_OPTIONS='--experimental-vm-modules --experimental-modules --experimental-import-meta-resolve' node scripts/test.js",
"test:debug": "kcd-scripts --inspect-brk test --runInBand",

@@ -40,21 +43,28 @@ "test:update": "npm test -- --updateSnapshot --coverage",

"@ph.fritsche/scripts-config": "^2.4.0",
"@testing-library/dom": "^8.11.4",
"@ph.fritsche/toolbox": "^1.0.0-alpha.1",
"@testing-library/dom": "^8.19.0",
"@testing-library/jest-dom": "^5.16.3",
"@testing-library/react": "^13.0.0",
"@testing-library/react": "^13.4.0",
"@types/jest-in-case": "^1.0.3",
"@types/react": "^17.0.42",
"eslint-import-resolver-typescript": "^2.7.0",
"eslint-plugin-local-rules": "^1.1.0",
"@types/react": "^18.0.25",
"@types/sinonjs__fake-timers": "^8.1.2",
"css.escape": "^1.5.1",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-local-rules": "^1.3.2",
"expect": "^28.1.3",
"is-ci": "^3.0.1",
"istanbul-lib-coverage": "^3.2.0",
"istanbul-lib-report": "^3.0.0",
"istanbul-lib-source-maps": "^4.0.1",
"istanbul-reports": "^3.1.5",
"jest-in-case": "^1.0.2",
"jest-mock": "^28.1.3",
"jest-serializer-ansi": "^1.0.3",
"jsdom": "^20.0.3",
"kcd-scripts": "^12.1.0",
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react17": "npm:react@^17.0.2",
"reactDom17": "npm:react-dom@^17.0.2",
"reactIs17": "npm:react-is@^17.0.2",
"reactTesting17": "npm:@testing-library/react@^12.1.3",
"shared-scripts": "^1.5.1",
"typescript": "^4.1.2"
"ts-node": "^10.9.1",
"typescript": "^4.9.3"
},

@@ -64,2 +74,3 @@ "peerDependencies": {

},
"dependencies": {},
"main": "./dist/cjs/index.js",

@@ -66,0 +77,0 @@ "module": "./dist/esm/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc