@testing-library/user-event
Advanced tools
Comparing version 14.5.2 to 14.6.0
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
var Clipboard = require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var copySelection = require('../document/copySelection.js'); | ||
@@ -15,3 +9,3 @@ | ||
var _doc_activeElement; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== undefined ? _doc_activeElement : /* istanbul ignore next */ doc.body; | ||
const clipboardData = copySelection.copySelection(target); | ||
@@ -18,0 +12,0 @@ if (clipboardData.items.length === 0) { |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
var Clipboard = require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var copySelection = require('../document/copySelection.js'); | ||
@@ -15,3 +9,3 @@ | ||
var _doc_activeElement; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== undefined ? _doc_activeElement : /* istanbul ignore next */ doc.body; | ||
const clipboardData = copySelection.copySelection(target); | ||
@@ -18,0 +12,0 @@ if (clipboardData.items.length === 0) { |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
var DataTransfer = require('../utils/dataTransfer/DataTransfer.js'); | ||
var Clipboard = require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var getWindow = require('../utils/misc/getWindow.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
@@ -16,5 +10,5 @@ async function paste(clipboardData) { | ||
var _doc_activeElement; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== undefined ? _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(()=>{ | ||
const dataTransfer = (_ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && _ref !== undefined ? _ref : await Clipboard.readDataTransferFromClipboard(doc).catch(()=>{ | ||
throw new Error('`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.'); | ||
@@ -21,0 +15,0 @@ }); |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
var cssPointerEvents = require('../utils/pointer/cssPointerEvents.js'); | ||
@@ -10,0 +5,0 @@ |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
var DataTransfer = require('../utils/dataTransfer/DataTransfer.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var getWindow = require('../utils/misc/getWindow.js'); | ||
var selection = require('../utils/focus/selection.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var UI = require('./UI.js'); | ||
@@ -14,0 +8,0 @@ |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
var isContentEditable = require('../utils/edit/isContentEditable.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var UI = require('./UI.js'); | ||
@@ -12,0 +6,0 @@ |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
var isElementType = require('../utils/misc/isElementType.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var isElementType = require('../utils/misc/isElementType.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var trackValue = require('./trackValue.js'); | ||
@@ -18,4 +12,4 @@ var UI = require('./UI.js'); | ||
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 === null || prototypeDescriptor === undefined ? undefined : prototypeDescriptor.set) ? 'set' : 'value'; | ||
/* istanbul ignore if */ if (typeof (prototypeDescriptor === null || prototypeDescriptor === undefined ? undefined : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) { | ||
throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`); | ||
@@ -31,7 +25,7 @@ } | ||
} | ||
then === null || then === void 0 ? void 0 : then(); | ||
then === null || then === undefined ? undefined : then(); | ||
} | ||
intercept[Interceptor] = Interceptor; | ||
Object.defineProperty(element, propName, { | ||
...objectDescriptor !== null && objectDescriptor !== void 0 ? objectDescriptor : prototypeDescriptor, | ||
...objectDescriptor !== null && objectDescriptor !== undefined ? objectDescriptor : prototypeDescriptor, | ||
[target]: intercept | ||
@@ -38,0 +32,0 @@ }); |
'use strict'; | ||
var dispatchEvent = require('../event/dispatchEvent.js'); | ||
require('../utils/click/isClickableInput.js'); | ||
var isElementType = require('../utils/misc/isElementType.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var isElementType = require('../utils/misc/isElementType.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var UI = require('./UI.js'); | ||
@@ -13,0 +7,0 @@ require('@testing-library/dom'); |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var getWindow = require('../utils/misc/getWindow.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var UI = require('./UI.js'); | ||
@@ -35,3 +29,3 @@ | ||
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); | ||
(_element_TrackChanges = element[TrackChanges]) === null || _element_TrackChanges === undefined ? undefined : (_element_TrackChanges_tracked = _element_TrackChanges.tracked) === null || _element_TrackChanges_tracked === undefined ? undefined : _element_TrackChanges_tracked.push(v); | ||
if (!element[TrackChanges]) { | ||
@@ -48,3 +42,3 @@ UI.setUIValueClean(element); | ||
element[TrackChanges] = undefined; | ||
if (!(changes === null || changes === void 0 ? void 0 : (_changes_tracked = changes.tracked) === null || _changes_tracked === void 0 ? void 0 : _changes_tracked.length)) { | ||
if (!(changes === null || changes === undefined ? undefined : (_changes_tracked = changes.tracked) === null || _changes_tracked === undefined ? undefined : _changes_tracked.length)) { | ||
return; | ||
@@ -51,0 +45,0 @@ } |
@@ -64,5 +64,5 @@ 'use strict'; | ||
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 | ||
const sel = (_element_UISelection = element[UISelection]) !== null && _element_UISelection !== undefined ? _element_UISelection : { | ||
anchorOffset: (_element_selectionStart = element.selectionStart) !== null && _element_selectionStart !== undefined ? _element_selectionStart : 0, | ||
focusOffset: (_element_selectionEnd = element.selectionEnd) !== null && _element_selectionEnd !== undefined ? _element_selectionEnd : 0 | ||
}; | ||
@@ -69,0 +69,0 @@ return { |
'use strict'; | ||
require('../../utils/click/isClickableInput.js'); | ||
var isElementType = require('../../utils/misc/isElementType.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var isElementType = require('../../utils/misc/isElementType.js'); | ||
var getWindow = require('../../utils/misc/getWindow.js'); | ||
var isFocusable = require('../../utils/focus/isFocusable.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
var cloneEvent = require('../../utils/misc/cloneEvent.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var focus = require('../focus.js'); | ||
@@ -15,0 +9,0 @@ var registry = require('./registry.js'); |
'use strict'; | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
var isEditable = require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var input = require('../input.js'); | ||
@@ -11,0 +6,0 @@ var registry = require('./registry.js'); |
@@ -5,13 +5,8 @@ 'use strict'; | ||
var getValueOrTextContent = require('../../document/getValueOrTextContent.js'); | ||
require('../../utils/click/isClickableInput.js'); | ||
var isElementType = require('../../utils/misc/isElementType.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
var isContentEditable = require('../../utils/edit/isContentEditable.js'); | ||
var isEditable = require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var isElementType = require('../../utils/misc/isElementType.js'); | ||
var getTabDestination = require('../../utils/focus/getTabDestination.js'); | ||
var selection = require('../../utils/focus/selection.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var focus = require('../focus.js'); | ||
@@ -28,3 +23,3 @@ var input = require('../input.js'); | ||
var _keydownBehavior_event_key1; | ||
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = keydownBehavior[event.key]) === null || _keydownBehavior_event_key === void 0 ? void 0 : _keydownBehavior_event_key.call(keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== void 0 ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance); | ||
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = keydownBehavior[event.key]) === null || _keydownBehavior_event_key === undefined ? undefined : _keydownBehavior_event_key.call(keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== undefined ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance); | ||
}; | ||
@@ -84,3 +79,3 @@ const keydownBehavior = { | ||
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; | ||
const newPos = (_getValueOrTextContent_length = (_getValueOrTextContent = getValueOrTextContent.getValueOrTextContent(target)) === null || _getValueOrTextContent === undefined ? undefined : _getValueOrTextContent.length) !== null && _getValueOrTextContent_length !== undefined ? _getValueOrTextContent_length : /* istanbul ignore next */ 0; | ||
setSelectionRange.setSelectionRange(target, newPos, newPos); | ||
@@ -87,0 +82,0 @@ }; |
'use strict'; | ||
require('../../utils/click/isClickableInput.js'); | ||
var isElementType = require('../../utils/misc/isElementType.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
var isContentEditable = require('../../utils/edit/isContentEditable.js'); | ||
var isEditable = require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var isElementType = require('../../utils/misc/isElementType.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var input = require('../input.js'); | ||
@@ -23,3 +18,3 @@ var registry = require('./registry.js'); | ||
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 === null || form === undefined ? undefined : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]'); | ||
if (submit) { | ||
@@ -26,0 +21,0 @@ return ()=>instance.dispatchUIEvent(submit, 'click'); |
@@ -5,7 +5,2 @@ 'use strict'; | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var registry = require('./registry.js'); | ||
@@ -15,3 +10,3 @@ | ||
var _keyupBehavior_event_key; | ||
return (_keyupBehavior_event_key = keyupBehavior[event.key]) === null || _keyupBehavior_event_key === void 0 ? void 0 : _keyupBehavior_event_key.call(keyupBehavior, event, target, instance); | ||
return (_keyupBehavior_event_key = keyupBehavior[event.key]) === null || _keyupBehavior_event_key === undefined ? undefined : _keyupBehavior_event_key.call(keyupBehavior, event, target, instance); | ||
}; | ||
@@ -18,0 +13,0 @@ const keyupBehavior = { |
'use strict'; | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
var isEditable = require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var input = require('../input.js'); | ||
@@ -17,3 +12,3 @@ var registry = require('./registry.js'); | ||
var _event_clipboardData; | ||
const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text'); | ||
const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === undefined ? undefined : _event_clipboardData.getData('text'); | ||
if (insertData) { | ||
@@ -20,0 +15,0 @@ input.input(instance, target, insertData, 'insertFromPaste'); |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var getWindow = require('../utils/misc/getWindow.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var eventMap = require('./eventMap.js'); | ||
@@ -18,2 +12,6 @@ | ||
Event: [], | ||
FocusEvent: [ | ||
initUIEvent, | ||
initFocusEvent | ||
], | ||
InputEvent: [ | ||
@@ -44,3 +42,3 @@ initUIEvent, | ||
const event = new (getEventConstructors(window))[EventType](type, defaultInit); | ||
eventInitializer[EventType].forEach((f)=>f(event, init !== null && init !== void 0 ? init : {})); | ||
eventInitializer[EventType].forEach((f)=>f(event, init !== null && init !== undefined ? init : {})); | ||
return event; | ||
@@ -50,45 +48,45 @@ } | ||
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 { | ||
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_window_Event = window.Event) !== null && _window_Event !== undefined ? _window_Event : class Event { | ||
}; | ||
var _window_AnimationEvent; | ||
const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !== void 0 ? _window_AnimationEvent : class AnimationEvent extends Event { | ||
const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !== undefined ? _window_AnimationEvent : class AnimationEvent extends Event { | ||
}; | ||
var _window_ClipboardEvent; | ||
const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !== void 0 ? _window_ClipboardEvent : class ClipboardEvent extends Event { | ||
const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !== undefined ? _window_ClipboardEvent : class ClipboardEvent extends Event { | ||
}; | ||
var _window_PopStateEvent; | ||
const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !== void 0 ? _window_PopStateEvent : class PopStateEvent extends Event { | ||
const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !== undefined ? _window_PopStateEvent : class PopStateEvent extends Event { | ||
}; | ||
var _window_ProgressEvent; | ||
const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !== void 0 ? _window_ProgressEvent : class ProgressEvent extends Event { | ||
const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !== undefined ? _window_ProgressEvent : class ProgressEvent extends Event { | ||
}; | ||
var _window_TransitionEvent; | ||
const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !== void 0 ? _window_TransitionEvent : class TransitionEvent extends Event { | ||
const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !== undefined ? _window_TransitionEvent : class TransitionEvent extends Event { | ||
}; | ||
var _window_UIEvent; | ||
const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !== void 0 ? _window_UIEvent : class UIEvent extends Event { | ||
const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !== undefined ? _window_UIEvent : class UIEvent extends Event { | ||
}; | ||
var _window_CompositionEvent; | ||
const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !== void 0 ? _window_CompositionEvent : class CompositionEvent extends UIEvent { | ||
const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !== undefined ? _window_CompositionEvent : class CompositionEvent extends UIEvent { | ||
}; | ||
var _window_FocusEvent; | ||
const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !== void 0 ? _window_FocusEvent : class FocusEvent extends UIEvent { | ||
const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !== undefined ? _window_FocusEvent : class FocusEvent extends UIEvent { | ||
}; | ||
var _window_InputEvent; | ||
const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !== void 0 ? _window_InputEvent : class InputEvent extends UIEvent { | ||
const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !== undefined ? _window_InputEvent : class InputEvent extends UIEvent { | ||
}; | ||
var _window_KeyboardEvent; | ||
const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !== void 0 ? _window_KeyboardEvent : class KeyboardEvent extends UIEvent { | ||
const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !== undefined ? _window_KeyboardEvent : class KeyboardEvent extends UIEvent { | ||
}; | ||
var _window_MouseEvent; | ||
const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !== void 0 ? _window_MouseEvent : class MouseEvent extends UIEvent { | ||
const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !== undefined ? _window_MouseEvent : class MouseEvent extends UIEvent { | ||
}; | ||
var _window_DragEvent; | ||
const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !== void 0 ? _window_DragEvent : class DragEvent extends MouseEvent { | ||
const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !== undefined ? _window_DragEvent : class DragEvent extends MouseEvent { | ||
}; | ||
var _window_PointerEvent; | ||
const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !== void 0 ? _window_PointerEvent : class PointerEvent extends MouseEvent { | ||
const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !== undefined ? _window_PointerEvent : class PointerEvent extends MouseEvent { | ||
}; | ||
var _window_TouchEvent; | ||
const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !== void 0 ? _window_TouchEvent : class TouchEvent extends UIEvent { | ||
const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !== undefined ? _window_TouchEvent : class TouchEvent extends UIEvent { | ||
}; | ||
@@ -116,3 +114,3 @@ /* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ return { | ||
Object.defineProperty(obj, key, { | ||
get: ()=>value !== null && value !== void 0 ? value : null | ||
get: ()=>value !== null && value !== undefined ? value : null | ||
}); | ||
@@ -122,3 +120,3 @@ } | ||
function sanitizeNumber(n) { | ||
return Number(n !== null && n !== void 0 ? n : 0); | ||
return Number(n !== null && n !== undefined ? n : 0); | ||
} | ||
@@ -130,2 +128,7 @@ function initClipboardEvent(event, { clipboardData }) { | ||
} | ||
function initFocusEvent(event, { relatedTarget }) { | ||
assignProps(event, { | ||
relatedTarget | ||
}); | ||
} | ||
function initInputEvent(event, { data, inputType, isComposing }) { | ||
@@ -141,3 +144,3 @@ assignProps(event, { | ||
view, | ||
detail: sanitizeNumber(detail !== null && detail !== void 0 ? detail : 0) | ||
detail: sanitizeNumber(detail !== null && detail !== undefined ? detail : 0) | ||
}); | ||
@@ -179,3 +182,3 @@ } | ||
} | ||
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, offsetX, offsetY, pageX, pageY }) { | ||
assignProps(event, { | ||
@@ -190,3 +193,7 @@ screenX: sanitizeNumber(screenX), | ||
buttons: sanitizeNumber(buttons), | ||
relatedTarget | ||
relatedTarget, | ||
offsetX: sanitizeNumber(offsetX), | ||
offsetY: sanitizeNumber(offsetY), | ||
pageX: sanitizeNumber(pageX), | ||
pageY: sanitizeNumber(pageY) | ||
}); | ||
@@ -193,0 +200,0 @@ } |
@@ -27,3 +27,3 @@ 'use strict'; | ||
const type = event.type; | ||
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = registry.behavior[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(registry.behavior, event, target, this); | ||
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = registry.behavior[type]) === null || _behavior_type === undefined ? undefined : _behavior_type.call(registry.behavior, event, target, this); | ||
if (behaviorImplementation) { | ||
@@ -30,0 +30,0 @@ event.preventDefault(); |
@@ -20,2 +20,10 @@ 'use strict'; | ||
}, | ||
blur: { | ||
EventType: 'FocusEvent', | ||
defaultInit: { | ||
bubbles: false, | ||
cancelable: false, | ||
composed: true | ||
} | ||
}, | ||
click: { | ||
@@ -68,2 +76,26 @@ EventType: 'PointerEvent', | ||
}, | ||
focus: { | ||
EventType: 'FocusEvent', | ||
defaultInit: { | ||
bubbles: false, | ||
cancelable: false, | ||
composed: true | ||
} | ||
}, | ||
focusin: { | ||
EventType: 'FocusEvent', | ||
defaultInit: { | ||
bubbles: true, | ||
cancelable: false, | ||
composed: true | ||
} | ||
}, | ||
focusout: { | ||
EventType: 'FocusEvent', | ||
defaultInit: { | ||
bubbles: true, | ||
cancelable: false, | ||
composed: true | ||
} | ||
}, | ||
keydown: { | ||
@@ -70,0 +102,0 @@ EventType: 'KeyboardEvent', |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var getActiveElement = require('../utils/focus/getActiveElement.js'); | ||
var isFocusable = require('../utils/focus/isFocusable.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
var findClosest = require('../utils/misc/findClosest.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var updateSelectionOnFocus = require('./selection/updateSelectionOnFocus.js'); | ||
var wrapEvent = require('./wrapEvent.js'); | ||
// Browsers do not dispatch FocusEvent if the document does not have focus. | ||
// TODO: simulate FocusEvent in browsers | ||
/** | ||
@@ -21,3 +17,3 @@ * Focus closest focusable element. | ||
const activeElement = getActiveElement.getActiveElement(element.ownerDocument); | ||
if ((target !== null && target !== void 0 ? target : element.ownerDocument.body) === activeElement) { | ||
if ((target !== null && target !== undefined ? target : element.ownerDocument.body) === activeElement) { | ||
return; | ||
@@ -27,5 +23,5 @@ } else if (target) { | ||
} else { | ||
wrapEvent.wrapEvent(()=>activeElement === null || activeElement === void 0 ? void 0 : activeElement.blur()); | ||
wrapEvent.wrapEvent(()=>activeElement === null || activeElement === undefined ? undefined : activeElement.blur()); | ||
} | ||
updateSelectionOnFocus.updateSelectionOnFocus(target !== null && target !== void 0 ? target : element.ownerDocument.body); | ||
updateSelectionOnFocus.updateSelectionOnFocus(target !== null && target !== undefined ? target : element.ownerDocument.body); | ||
} | ||
@@ -32,0 +28,0 @@ function blurElement(element) { |
@@ -6,9 +6,3 @@ 'use strict'; | ||
var input = require('./input.js'); | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var setSelectionPerMouse = require('./selection/setSelectionPerMouse.js'); | ||
@@ -15,0 +9,0 @@ var modifySelectionPerMouse = require('./selection/modifySelectionPerMouse.js'); |
'use strict'; | ||
var UI = require('../document/UI.js'); | ||
require('../utils/click/isClickableInput.js'); | ||
var isElementType = require('../utils/misc/isElementType.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
var timeValue = require('../utils/edit/timeValue.js'); | ||
require('../utils/edit/isEditable.js'); | ||
var maxLength = require('../utils/edit/maxLength.js'); | ||
var cursor = require('../utils/focus/cursor.js'); | ||
var isElementType = require('../utils/misc/isElementType.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var trackValue = require('../document/trackValue.js'); | ||
@@ -159,5 +154,5 @@ var getInputRange = require('./selection/getInputRange.js'); | ||
const valueParts = value.split('e', 2); | ||
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])); | ||
return !(/[^\d.\-e]/.test(value) || Number((_value_match = value.match(/-/g)) === null || _value_match === undefined ? undefined : _value_match.length) > 2 || Number((_value_match1 = value.match(/\./g)) === null || _value_match1 === undefined ? undefined : _value_match1.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1])); | ||
} | ||
exports.input = input; |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var isDisabled = require('../utils/misc/isDisabled.js'); | ||
var getWindow = require('../utils/misc/getWindow.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var focus = require('./focus.js'); | ||
@@ -13,0 +7,0 @@ |
@@ -14,3 +14,3 @@ 'use strict'; | ||
// Multi-range on contenteditable edits the first selection instead of the last | ||
return (_typeAndSelection_selection = typeAndSelection.selection) === null || _typeAndSelection_selection === void 0 ? void 0 : _typeAndSelection_selection.getRangeAt(0); | ||
return (_typeAndSelection_selection = typeAndSelection.selection) === null || _typeAndSelection_selection === undefined ? undefined : _typeAndSelection_selection.getRangeAt(0); | ||
} | ||
@@ -17,0 +17,0 @@ } |
'use strict'; | ||
var UI = require('../../document/UI.js'); | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
var isContentEditable = require('../../utils/edit/isContentEditable.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var selection = require('../../utils/focus/selection.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
@@ -24,6 +18,6 @@ /** | ||
} | ||
const selection$1 = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection(); | ||
const selection$1 = element === null || element === undefined ? undefined : 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$1 === null || selection$1 === undefined ? undefined : selection$1.anchorNode) && isContentEditable.getContentEditable(selection$1.anchorNode); | ||
return { | ||
@@ -30,0 +24,0 @@ type: isCE ? 'contenteditable' : 'default', |
'use strict'; | ||
var UI = require('../../document/UI.js'); | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var getTargetTypeAndSelection = require('./getTargetTypeAndSelection.js'); | ||
@@ -24,5 +18,5 @@ | ||
} | ||
(_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); | ||
(_focusNode_ownerDocument = focusNode.ownerDocument) === null || _focusNode_ownerDocument === undefined ? undefined : (_focusNode_ownerDocument_getSelection = _focusNode_ownerDocument.getSelection()) === null || _focusNode_ownerDocument_getSelection === undefined ? undefined : _focusNode_ownerDocument_getSelection.extend(focusNode, focusOffset); | ||
} | ||
exports.modifySelection = modifySelection; |
'use strict'; | ||
var UI = require('../../document/UI.js'); | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var resolveCaretPosition = require('./resolveCaretPosition.js'); | ||
@@ -41,4 +35,4 @@ | ||
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 === null || selection === undefined ? undefined : selection.removeAllRanges(); | ||
selection === null || selection === undefined ? undefined : selection.addRange(range.cloneRange()); | ||
} | ||
@@ -45,0 +39,0 @@ } |
'use strict'; | ||
var UI = require('../../document/UI.js'); | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var cursor = require('../../utils/focus/cursor.js'); | ||
var selection = require('../../utils/focus/selection.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var setSelection = require('./setSelection.js'); | ||
@@ -27,3 +21,3 @@ | ||
const selection = node.ownerDocument.getSelection(); | ||
if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) { | ||
if (!(selection === null || selection === undefined ? undefined : selection.focusNode)) { | ||
return; | ||
@@ -30,0 +24,0 @@ } |
'use strict'; | ||
var UI = require('../../document/UI.js'); | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var selection = require('../../utils/focus/selection.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
@@ -17,3 +11,3 @@ function resolveCaretPosition({ target, node, offset }) { | ||
node: target, | ||
offset: offset !== null && offset !== void 0 ? offset : UI.getUIValue(target).length | ||
offset: offset !== null && offset !== undefined ? offset : UI.getUIValue(target).length | ||
}; | ||
@@ -23,3 +17,3 @@ } else if (node) { | ||
node, | ||
offset: offset !== null && offset !== void 0 ? offset : node.nodeType === 3 ? node.nodeValue.length : node.childNodes.length | ||
offset: offset !== null && offset !== undefined ? offset : node.nodeType === 3 ? node.nodeValue.length : node.childNodes.length | ||
}; | ||
@@ -37,3 +31,3 @@ } | ||
let i = offset === undefined ? node.childNodes.length - 1 : 0; | ||
const step = offset === undefined ? -1 : +1; | ||
const step = offset === undefined ? -1 : 1; | ||
while(offset === undefined ? i >= (isRoot ? Math.max(node.childNodes.length - 1, 0) : 0) : i <= node.childNodes.length){ | ||
@@ -57,3 +51,3 @@ if (offset && i === node.childNodes.length) { | ||
node: c, | ||
offset: offset !== null && offset !== void 0 ? offset : c.nodeValue.length | ||
offset: offset !== null && offset !== undefined ? offset : c.nodeValue.length | ||
}; | ||
@@ -60,0 +54,0 @@ } |
'use strict'; | ||
var UI = require('../../document/UI.js'); | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
var isContentEditable = require('../../utils/edit/isContentEditable.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var selection = require('../../utils/focus/selection.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var setSelection = require('./setSelection.js'); | ||
@@ -26,3 +20,3 @@ | ||
var _getContentEditable; | ||
const focusNode = (_getContentEditable = isContentEditable.getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body; | ||
const focusNode = (_getContentEditable = isContentEditable.getContentEditable(target)) !== null && _getContentEditable !== undefined ? _getContentEditable : target.ownerDocument.body; | ||
setSelection.setSelection({ | ||
@@ -39,5 +33,5 @@ focusNode, | ||
var _getContentEditable; | ||
const focusNode = (_getContentEditable = isContentEditable.getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body; | ||
const focusNode = (_getContentEditable = isContentEditable.getContentEditable(target)) !== null && _getContentEditable !== undefined ? _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$1 === null || selection$1 === undefined ? undefined : selection$1.anchorNode) === focusNode && selection$1.focusNode === focusNode && selection$1.anchorOffset === 0 && selection$1.focusOffset === focusNode.childNodes.length; | ||
} | ||
@@ -44,0 +38,0 @@ |
'use strict'; | ||
var UI = require('../../document/UI.js'); | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var getTargetTypeAndSelection = require('./getTargetTypeAndSelection.js'); | ||
@@ -24,5 +18,5 @@ | ||
} | ||
(_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); | ||
(_anchorNode_ownerDocument = anchorNode.ownerDocument) === null || _anchorNode_ownerDocument === undefined ? undefined : (_anchorNode_ownerDocument_getSelection = _anchorNode_ownerDocument.getSelection()) === null || _anchorNode_ownerDocument_getSelection === undefined ? undefined : _anchorNode_ownerDocument_getSelection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset); | ||
} | ||
exports.setSelection = setSelection; |
'use strict'; | ||
var UI = require('../../document/UI.js'); | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var selection = require('../../utils/focus/selection.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var resolveCaretPosition = require('./resolveCaretPosition.js'); | ||
@@ -34,9 +28,9 @@ | ||
UI.setUISelection(target, { | ||
anchorOffset: start !== null && start !== void 0 ? start : text.length, | ||
focusOffset: end !== null && end !== void 0 ? end : text.length | ||
anchorOffset: start !== null && start !== undefined ? start : text.length, | ||
focusOffset: end !== null && end !== undefined ? end : text.length | ||
}); | ||
return { | ||
node: target, | ||
start: start !== null && start !== void 0 ? start : 0, | ||
end: end !== null && end !== void 0 ? end : text.length | ||
start: start !== null && start !== undefined ? start : 0, | ||
end: end !== null && end !== undefined ? end : text.length | ||
}; | ||
@@ -62,4 +56,4 @@ } else { | ||
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 === null || selection === undefined ? undefined : selection.removeAllRanges(); | ||
selection === null || selection === undefined ? undefined : selection.addRange(range.cloneRange()); | ||
return range; | ||
@@ -75,3 +69,3 @@ } | ||
} | ||
const textPos = pos !== null && pos !== void 0 ? pos : text.length; | ||
const textPos = pos !== null && pos !== undefined ? pos : text.length; | ||
if (clickCount % 3 === 2) { | ||
@@ -78,0 +72,0 @@ return [ |
'use strict'; | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
var isContentEditable = require('../../utils/edit/isContentEditable.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var selection = require('../../utils/focus/selection.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var setSelection = require('./setSelection.js'); | ||
@@ -27,3 +21,3 @@ | ||
} | ||
/* istanbul ignore else */ if (isContentEditable.isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === void 0 ? void 0 : _element_firstChild.nodeType) === 3) { | ||
/* istanbul ignore else */ if (isContentEditable.isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === undefined ? undefined : _element_firstChild.nodeType) === 3) { | ||
return setSelection.setSelection({ | ||
@@ -30,0 +24,0 @@ focusNode: element.firstChild, |
'use strict'; | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
var isContentEditable = require('../../utils/edit/isContentEditable.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var selection = require('../../utils/focus/selection.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
// The browser implementation seems to have changed. | ||
// When focus is inside <input type="text"/>, | ||
// Chrome updates Selection to be collapsed at the position of the input element. | ||
// TODO: update implementation to match that of current browsers | ||
/** | ||
@@ -18,3 +16,3 @@ * Reset the Document Selection when moving focus into an element | ||
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$1 === null || selection$1 === undefined ? undefined : selection$1.focusNode)) { | ||
return; | ||
@@ -34,3 +32,3 @@ } | ||
var _contenteditable_firstChild; | ||
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === void 0 ? void 0 : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable; | ||
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === undefined ? undefined : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable; | ||
selection$1.setBaseAndExtent(focusNode, 0, focusNode, 0); | ||
@@ -37,0 +35,0 @@ } |
@@ -12,5 +12,2 @@ 'use strict'; | ||
exports.userEvent = index.userEvent; | ||
Object.defineProperty(exports, "PointerEventsCheckLevel", { | ||
enumerable: true, | ||
get: function () { return options.PointerEventsCheckLevel; } | ||
}); | ||
exports.PointerEventsCheckLevel = options.PointerEventsCheckLevel; |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
var wait = require('../utils/misc/wait.js'); | ||
require('../options.js'); | ||
var parseKeyDef = require('./parseKeyDef.js'); | ||
@@ -12,0 +6,0 @@ |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var readNextDescriptor = require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
@@ -28,9 +23,9 @@ /** | ||
var _def_code; | ||
return ((_def_code = def.code) === null || _def_code === void 0 ? void 0 : _def_code.toLowerCase()) === descriptor.toLowerCase(); | ||
return ((_def_code = def.code) === null || _def_code === undefined ? undefined : _def_code.toLowerCase()) === descriptor.toLowerCase(); | ||
} else if (type === '{') { | ||
var _def_key; | ||
return ((_def_key = def.key) === null || _def_key === void 0 ? void 0 : _def_key.toLowerCase()) === descriptor.toLowerCase(); | ||
return ((_def_key = def.key) === null || _def_key === undefined ? undefined : _def_key.toLowerCase()) === descriptor.toLowerCase(); | ||
} | ||
return def.key === descriptor; | ||
})) !== null && _keyboardMap_find !== void 0 ? _keyboardMap_find : { | ||
})) !== null && _keyboardMap_find !== undefined ? _keyboardMap_find : { | ||
key: 'Unknown', | ||
@@ -37,0 +32,0 @@ code: 'Unknown', |
'use strict'; | ||
exports.PointerEventsCheckLevel = void 0; | ||
(function(PointerEventsCheckLevel) { | ||
var PointerEventsCheckLevel = /*#__PURE__*/ function(PointerEventsCheckLevel) { | ||
/** | ||
@@ -12,2 +11,5 @@ * Check pointer events on every user interaction that triggers a bunch of events. | ||
/** No pointer events check */ PointerEventsCheckLevel[PointerEventsCheckLevel["Never"] = 0] = "Never"; | ||
})(exports.PointerEventsCheckLevel || (exports.PointerEventsCheckLevel = {})); | ||
return PointerEventsCheckLevel; | ||
}({}); | ||
exports.PointerEventsCheckLevel = PointerEventsCheckLevel; |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
var level = require('../utils/misc/level.js'); | ||
var wait = require('../utils/misc/wait.js'); | ||
require('../options.js'); | ||
var parseKeyDef = require('./parseKeyDef.js'); | ||
@@ -42,7 +37,7 @@ | ||
const position = { | ||
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 === null || previousPosition === void 0 ? void 0 : previousPosition.coords, | ||
target: (_action_target = action.target) !== null && _action_target !== undefined ? _action_target : getPrevTarget(instance, previousPosition), | ||
coords: (_action_coords = action.coords) !== null && _action_coords !== undefined ? _action_coords : previousPosition === null || previousPosition === undefined ? undefined : previousPosition.coords, | ||
caret: { | ||
node: (_action_node = action.node) !== null && _action_node !== void 0 ? _action_node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (_previousPosition_caret = previousPosition.caret) === null || _previousPosition_caret === void 0 ? void 0 : _previousPosition_caret.node, | ||
offset: (_action_offset = action.offset) !== null && _action_offset !== void 0 ? _action_offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (_previousPosition_caret1 = previousPosition.caret) === null || _previousPosition_caret1 === void 0 ? void 0 : _previousPosition_caret1.offset | ||
node: (_action_node = action.node) !== null && _action_node !== undefined ? _action_node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === undefined ? undefined : (_previousPosition_caret = previousPosition.caret) === null || _previousPosition_caret === undefined ? undefined : _previousPosition_caret.node, | ||
offset: (_action_offset = action.offset) !== null && _action_offset !== undefined ? _action_offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === undefined ? undefined : (_previousPosition_caret1 = previousPosition.caret) === null || _previousPosition_caret1 === undefined ? undefined : _previousPosition_caret1.offset | ||
} | ||
@@ -70,3 +65,3 @@ }; | ||
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); | ||
return !!((_ref = (_action_target = action.target) !== null && _action_target !== undefined ? _action_target : action.node) !== null && _ref !== undefined ? _ref : action.offset !== undefined); | ||
} | ||
@@ -78,5 +73,5 @@ function getPrevTarget(instance, position) { | ||
var _position_target; | ||
return (_position_target = position.target) !== null && _position_target !== void 0 ? _position_target : instance.config.document.body; | ||
return (_position_target = position.target) !== null && _position_target !== undefined ? _position_target : instance.config.document.body; | ||
} | ||
exports.pointer = pointer; |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var readNextDescriptor = require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
@@ -11,0 +6,0 @@ function parseKeyDef(pointerMap, keys) { |
'use strict'; | ||
var patchFocus = require('../document/patchFocus.js'); | ||
var prepareDocument = require('../document/prepareDocument.js'); | ||
var dispatchEvent = require('../event/dispatchEvent.js'); | ||
require('../utils/click/isClickableInput.js'); | ||
var Clipboard = require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
var getWindow = require('../utils/misc/getWindow.js'); | ||
var getDocumentFromNode = require('../utils/misc/getDocumentFromNode.js'); | ||
@@ -57,4 +55,5 @@ var level = require('../utils/misc/level.js'); | ||
prepareDocument.prepareDocument(config.document); | ||
patchFocus.patchFocus(getWindow.getWindow(config.document).HTMLElement); | ||
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; | ||
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== undefined ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window; | ||
Clipboard.attachClipboardStubToView(view); | ||
@@ -68,4 +67,5 @@ return createInstance(config).api; | ||
prepareDocument.prepareDocument(config.document); | ||
patchFocus.patchFocus(getWindow.getWindow(config.document).HTMLElement); | ||
var _ref; | ||
const system = (_ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && _ref !== void 0 ? _ref : new index.System(); | ||
const system = (_ref = pointerState !== null && pointerState !== undefined ? pointerState : keyboardState) !== null && _ref !== undefined ? _ref : new index.System(); | ||
return { | ||
@@ -120,3 +120,3 @@ api: createInstance(config, system).api, | ||
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; | ||
return (_ref = (_options_document = options.document) !== null && _options_document !== undefined ? _options_document : node && getDocumentFromNode.getDocumentFromNode(node)) !== null && _ref !== undefined ? _ref : defaults.document; | ||
} | ||
@@ -123,0 +123,0 @@ |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var getActiveElement = require('../utils/focus/getActiveElement.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
@@ -25,4 +19,3 @@ function _define_property(obj, key, value) { | ||
} | ||
exports.DOM_KEY_LOCATION = void 0; | ||
(function(DOM_KEY_LOCATION) { | ||
var DOM_KEY_LOCATION = /*#__PURE__*/ function(DOM_KEY_LOCATION) { | ||
DOM_KEY_LOCATION[DOM_KEY_LOCATION["STANDARD"] = 0] = "STANDARD"; | ||
@@ -32,3 +25,4 @@ DOM_KEY_LOCATION[DOM_KEY_LOCATION["LEFT"] = 1] = "LEFT"; | ||
DOM_KEY_LOCATION[DOM_KEY_LOCATION["NUMPAD"] = 3] = "NUMPAD"; | ||
})(exports.DOM_KEY_LOCATION || (exports.DOM_KEY_LOCATION = {})); | ||
return DOM_KEY_LOCATION; | ||
}({}); | ||
const modifierKeys = [ | ||
@@ -58,10 +52,8 @@ 'Alt', | ||
isKeyPressed(keyDef) { | ||
return !!this.pressed[String(keyDef.code)]; | ||
return this.pressed.has(String(keyDef.code)); | ||
} | ||
getPressedKeys() { | ||
return Object.values(this.pressed).map((p)=>p.keyDef); | ||
return this.pressed.values().map((p)=>p.keyDef); | ||
} | ||
/** 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); | ||
@@ -71,7 +63,3 @@ const code = String(keyDef.code); | ||
this.setKeydownTarget(target); | ||
var _; | ||
(_ = (_this_pressed = this.pressed)[_code = code]) !== null && _ !== void 0 ? _ : _this_pressed[_code] = { | ||
keyDef, | ||
unpreventedDefault: false | ||
}; | ||
this.pressed.add(code, keyDef); | ||
if (isModifierKey(key)) { | ||
@@ -88,3 +76,5 @@ this.modifiers[key] = true; | ||
} | ||
(_this_pressed_code = this.pressed[code]).unpreventedDefault || (_this_pressed_code.unpreventedDefault = unprevented); | ||
if (unprevented) { | ||
this.pressed.setUnprevented(code); | ||
} | ||
if (unprevented && this.hasKeyPress(key)) { | ||
@@ -101,6 +91,5 @@ instance.dispatchUIEvent(getActiveElement.getActiveElementOrBody(instance.config.document), 'keypress', { | ||
const code = String(keyDef.code); | ||
const unprevented = this.pressed[code].unpreventedDefault; | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
delete this.pressed[code]; | ||
if (isModifierKey(key) && !Object.values(this.pressed).find((p)=>p.keyDef.key === key)) { | ||
const unprevented = this.pressed.isUnprevented(code); | ||
this.pressed.delete(code); | ||
if (isModifierKey(key) && !this.pressed.values().find((p)=>p.keyDef.key === key)) { | ||
this.modifiers[key] = false; | ||
@@ -130,3 +119,3 @@ } | ||
constructor(system){ | ||
_define_property(this, "system", void 0); | ||
_define_property(this, "system", undefined); | ||
_define_property(this, "modifiers", { | ||
@@ -146,3 +135,35 @@ Alt: false, | ||
}); | ||
_define_property(this, "pressed", {}); | ||
_define_property(this, "pressed", new class { | ||
add(code, keyDef) { | ||
var _this_registry, _code; | ||
var _; | ||
(_ = (_this_registry = this.registry)[_code = code]) !== null && _ !== undefined ? _ : _this_registry[_code] = { | ||
keyDef, | ||
unpreventedDefault: false | ||
}; | ||
} | ||
has(code) { | ||
return !!this.registry[code]; | ||
} | ||
setUnprevented(code) { | ||
const o = this.registry[code]; | ||
if (o) { | ||
o.unpreventedDefault = true; | ||
} | ||
} | ||
isUnprevented(code) { | ||
var _this_registry_code; | ||
return !!((_this_registry_code = this.registry[code]) === null || _this_registry_code === undefined ? undefined : _this_registry_code.unpreventedDefault); | ||
} | ||
delete(code) { | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
delete this.registry[code]; | ||
} | ||
values() { | ||
return Object.values(this.registry); | ||
} | ||
constructor(){ | ||
_define_property(this, "registry", {}); | ||
} | ||
}()); | ||
_define_property(this, "carryChar", ''); | ||
@@ -155,2 +176,3 @@ _define_property(this, "lastKeydownTarget", undefined); | ||
exports.DOM_KEY_LOCATION = DOM_KEY_LOCATION; | ||
exports.KeyboardHost = KeyboardHost; |
@@ -48,8 +48,8 @@ 'use strict'; | ||
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 === null || pointermove === undefined ? undefined : pointermove.leave(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.leave(); | ||
pointermove === null || pointermove === undefined ? undefined : pointermove.enter(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.enter(); | ||
pointermove === null || pointermove === undefined ? undefined : pointermove.move(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.move(); | ||
} | ||
@@ -75,5 +75,5 @@ async release(instance, keyDef, position) { | ||
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 === null || mousemove === undefined ? undefined : mousemove.leave(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.enter(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.move(); | ||
this.mouse.down(instance, keyDef, pointer); | ||
@@ -83,5 +83,5 @@ } | ||
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 === null || mousemove === undefined ? undefined : mousemove.leave(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.enter(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.move(); | ||
this.mouse.up(instance, keyDef, pointer); | ||
@@ -102,3 +102,3 @@ } | ||
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; | ||
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== undefined ? _this_mouse_position_target : instance.config.document.body; | ||
} | ||
@@ -110,12 +110,10 @@ setMousePosition(position) { | ||
constructor(system){ | ||
_define_property(this, "system", void 0); | ||
_define_property(this, "mouse", void 0); | ||
_define_property(this, "buttons", void 0); | ||
_define_property(this, "system", undefined); | ||
_define_property(this, "mouse", undefined); | ||
_define_property(this, "buttons", undefined); | ||
_define_property(this, "devices", new class { | ||
get(k) { | ||
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
_this_registry, _k; | ||
var _this_registry, _k; | ||
var _; | ||
(_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new device.Device(); | ||
return this.registry[k]; | ||
return (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== undefined ? _ : _this_registry[_k] = new device.Device(); | ||
} | ||
@@ -122,0 +120,0 @@ constructor(){ |
@@ -10,11 +10,5 @@ 'use strict'; | ||
require('@testing-library/dom'); | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
var isDisabled = require('../../utils/misc/isDisabled.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
var getTreeDiff = require('../../utils/misc/getTreeDiff.js'); | ||
require('../../utils/misc/level.js'); | ||
require('../../options.js'); | ||
var focus = require('../../event/focus.js'); | ||
@@ -137,3 +131,3 @@ var setSelectionPerMouse = require('../../event/selection/setSelectionPerMouse.js'); | ||
var _this_position_target; | ||
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body; | ||
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body; | ||
} | ||
@@ -146,4 +140,4 @@ startSelecting(instance, clickCount) { | ||
target: this.getTarget(instance), | ||
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, | ||
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node, | ||
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset, | ||
clickCount | ||
@@ -160,4 +154,4 @@ }); | ||
target: this.getTarget(instance), | ||
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 | ||
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node, | ||
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset | ||
}); | ||
@@ -171,3 +165,3 @@ } | ||
_define_property(this, "buttons", new buttons.Buttons()); | ||
_define_property(this, "selecting", void 0); | ||
_define_property(this, "selecting", undefined); | ||
_define_property(this, "buttonDownTarget", {}); | ||
@@ -195,7 +189,7 @@ // According to spec the `detail` on click events should be the number | ||
this.down = { | ||
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0 | ||
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== undefined ? _this_count_button : 0 | ||
}; | ||
var _this_count_button1; | ||
this.count = { | ||
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0 | ||
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== undefined ? _this_count_button1 : 0 | ||
}; | ||
@@ -202,0 +196,0 @@ return Number(this.count[button]) + 1; |
'use strict'; | ||
require('../../utils/click/isClickableInput.js'); | ||
require('../../utils/dataTransfer/Clipboard.js'); | ||
require('../../utils/edit/isEditable.js'); | ||
require('../../utils/edit/maxLength.js'); | ||
require('../../utils/keyDef/readNextDescriptor.js'); | ||
var getTreeDiff = require('../../utils/misc/getTreeDiff.js'); | ||
require('../../utils/misc/level.js'); | ||
var cssPointerEvents = require('../../utils/pointer/cssPointerEvents.js'); | ||
@@ -100,3 +95,3 @@ var shared = require('./shared.js'); | ||
var _this_position_target; | ||
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body; | ||
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body; | ||
} | ||
@@ -112,5 +107,5 @@ getEventInit() { | ||
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, "pointerId", undefined); | ||
_define_property(this, "pointerType", undefined); | ||
_define_property(this, "isPrimary", undefined); | ||
_define_property(this, "isMultitouch", false); | ||
@@ -117,0 +112,0 @@ _define_property(this, "isCancelled", false); |
'use strict'; | ||
function isDifferentPointerPosition(positionA, positionB) { | ||
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); | ||
var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_coords2, _positionB_coords2, _positionA_coords3, _positionB_coords3, _positionA_coords4, _positionB_coords4, _positionA_coords5, _positionB_coords5, _positionA_coords6, _positionB_coords6, _positionA_coords7, _positionB_coords7, _positionA_coords8, _positionB_coords8, _positionA_coords9, _positionB_coords9, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1; | ||
return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords === undefined ? undefined : _positionA_coords.x) !== ((_positionB_coords = positionB.coords) === null || _positionB_coords === undefined ? undefined : _positionB_coords.x) || ((_positionA_coords1 = positionA.coords) === null || _positionA_coords1 === undefined ? undefined : _positionA_coords1.y) !== ((_positionB_coords1 = positionB.coords) === null || _positionB_coords1 === undefined ? undefined : _positionB_coords1.y) || ((_positionA_coords2 = positionA.coords) === null || _positionA_coords2 === undefined ? undefined : _positionA_coords2.clientX) !== ((_positionB_coords2 = positionB.coords) === null || _positionB_coords2 === undefined ? undefined : _positionB_coords2.clientX) || ((_positionA_coords3 = positionA.coords) === null || _positionA_coords3 === undefined ? undefined : _positionA_coords3.clientY) !== ((_positionB_coords3 = positionB.coords) === null || _positionB_coords3 === undefined ? undefined : _positionB_coords3.clientY) || ((_positionA_coords4 = positionA.coords) === null || _positionA_coords4 === undefined ? undefined : _positionA_coords4.offsetX) !== ((_positionB_coords4 = positionB.coords) === null || _positionB_coords4 === undefined ? undefined : _positionB_coords4.offsetX) || ((_positionA_coords5 = positionA.coords) === null || _positionA_coords5 === undefined ? undefined : _positionA_coords5.offsetY) !== ((_positionB_coords5 = positionB.coords) === null || _positionB_coords5 === undefined ? undefined : _positionB_coords5.offsetY) || ((_positionA_coords6 = positionA.coords) === null || _positionA_coords6 === undefined ? undefined : _positionA_coords6.pageX) !== ((_positionB_coords6 = positionB.coords) === null || _positionB_coords6 === undefined ? undefined : _positionB_coords6.pageX) || ((_positionA_coords7 = positionA.coords) === null || _positionA_coords7 === undefined ? undefined : _positionA_coords7.pageY) !== ((_positionB_coords7 = positionB.coords) === null || _positionB_coords7 === undefined ? undefined : _positionB_coords7.pageY) || ((_positionA_coords8 = positionA.coords) === null || _positionA_coords8 === undefined ? undefined : _positionA_coords8.screenX) !== ((_positionB_coords8 = positionB.coords) === null || _positionB_coords8 === undefined ? undefined : _positionB_coords8.screenX) || ((_positionA_coords9 = positionA.coords) === null || _positionA_coords9 === undefined ? undefined : _positionA_coords9.screenY) !== ((_positionB_coords9 = positionB.coords) === null || _positionB_coords9 === undefined ? undefined : _positionB_coords9.screenY) || ((_positionA_caret = positionA.caret) === null || _positionA_caret === undefined ? undefined : _positionA_caret.node) !== ((_positionB_caret = positionB.caret) === null || _positionB_caret === undefined ? undefined : _positionB_caret.node) || ((_positionA_caret1 = positionA.caret) === null || _positionA_caret1 === undefined ? undefined : _positionA_caret1.offset) !== ((_positionB_caret1 = positionB.caret) === null || _positionB_caret1 === undefined ? undefined : _positionB_caret1.offset); | ||
} | ||
exports.isDifferentPointerPosition = isDifferentPointerPosition; |
@@ -10,10 +10,5 @@ 'use strict'; | ||
require('@testing-library/dom'); | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
var isEditable = require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var isDisabled = require('../utils/misc/isDisabled.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var focus = require('../event/focus.js'); | ||
@@ -20,0 +15,0 @@ var input = require('../event/input.js'); |
'use strict'; | ||
var dom = require('@testing-library/dom'); | ||
require('../utils/click/isClickableInput.js'); | ||
var isElementType = require('../utils/misc/isElementType.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var isElementType = require('../utils/misc/isElementType.js'); | ||
var isDisabled = require('../utils/misc/isDisabled.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
var wait = require('../utils/misc/wait.js'); | ||
@@ -13,0 +8,0 @@ var cssPointerEvents = require('../utils/pointer/cssPointerEvents.js'); |
'use strict'; | ||
var index = require('../keyboard/index.js'); | ||
require('../utils/click/isClickableInput.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
var setSelectionRange = require('../event/selection/setSelectionRange.js'); | ||
@@ -21,3 +15,3 @@ | ||
if (initialSelectionStart !== undefined) { | ||
setSelectionRange.setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== void 0 ? initialSelectionEnd : initialSelectionStart); | ||
setSelectionRange.setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== undefined ? initialSelectionEnd : initialSelectionStart); | ||
} | ||
@@ -24,0 +18,0 @@ await this.keyboard(text); |
'use strict'; | ||
require('../utils/click/isClickableInput.js'); | ||
var isElementType = require('../utils/misc/isElementType.js'); | ||
var FileList = require('../utils/dataTransfer/FileList.js'); | ||
require('../utils/dataTransfer/Clipboard.js'); | ||
require('../utils/edit/isEditable.js'); | ||
require('../utils/edit/maxLength.js'); | ||
var setFiles = require('../utils/edit/setFiles.js'); | ||
var isElementType = require('../utils/misc/isElementType.js'); | ||
var isDisabled = require('../utils/misc/isDisabled.js'); | ||
var getWindow = require('../utils/misc/getWindow.js'); | ||
require('../utils/keyDef/readNextDescriptor.js'); | ||
require('../utils/misc/level.js'); | ||
require('../options.js'); | ||
@@ -21,3 +15,3 @@ async function upload(element, fileOrFiles) { | ||
})) { | ||
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`); | ||
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === undefined ? undefined : input.tagName} element does not accept file uploads`); | ||
} | ||
@@ -31,5 +25,5 @@ if (isDisabled.isDisabled(element)) return; | ||
// do not fire an input event if the file selection does not change | ||
if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{ | ||
if (files.length === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _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)); | ||
return f === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _input_files.item(i)); | ||
})) { | ||
@@ -36,0 +30,0 @@ return; |
@@ -5,4 +5,3 @@ 'use strict'; | ||
var clickableInputTypes; | ||
(function(clickableInputTypes) { | ||
var clickableInputTypes = /*#__PURE__*/ function(clickableInputTypes) { | ||
clickableInputTypes["button"] = "button"; | ||
@@ -16,3 +15,4 @@ clickableInputTypes["color"] = "color"; | ||
clickableInputTypes["radio"] = "radio"; | ||
})(clickableInputTypes || (clickableInputTypes = {})); | ||
return clickableInputTypes; | ||
}(clickableInputTypes || {}); | ||
function isClickableInput(element) { | ||
@@ -19,0 +19,0 @@ return isElementType.isElementType(element, 'button') || isElementType.isElementType(element, 'input') && element.type in clickableInputTypes; |
@@ -49,3 +49,3 @@ 'use strict'; | ||
constructor(d){ | ||
_define_property(this, "data", void 0); | ||
_define_property(this, "data", undefined); | ||
this.data = d; | ||
@@ -80,4 +80,3 @@ } | ||
constructor(...args){ | ||
super(...args); | ||
_define_property(this, "items", []); | ||
super(...args), _define_property(this, "items", []); | ||
} | ||
@@ -89,3 +88,3 @@ }(), { | ||
function isClipboardStub(clipboard) { | ||
return !!(clipboard === null || clipboard === void 0 ? void 0 : clipboard[ClipboardStubControl]); | ||
return !!(clipboard === null || clipboard === undefined ? undefined : clipboard[ClipboardStubControl]); | ||
} | ||
@@ -132,3 +131,3 @@ function attachClipboardStubToView(window) { | ||
const window = document.defaultView; | ||
const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard; | ||
const clipboard = window === null || window === undefined ? undefined : window.navigator.clipboard; | ||
const items = clipboard && await clipboard.read(); | ||
@@ -152,3 +151,3 @@ if (!items) { | ||
const dtItem = clipboardData.items[i]; | ||
const blob = DataTransfer.getBlobFromDataTransferItem(window, dtItem); | ||
const blob = await DataTransfer.getBlobFromDataTransferItem(window, dtItem); | ||
items.push(createClipboardItem(window, blob)); | ||
@@ -155,0 +154,0 @@ } |
@@ -33,4 +33,4 @@ 'use strict'; | ||
constructor(dataOrFile, type){ | ||
_define_property(this, "kind", void 0); | ||
_define_property(this, "type", void 0); | ||
_define_property(this, "kind", undefined); | ||
_define_property(this, "type", undefined); | ||
_define_property(this, "file", null); | ||
@@ -73,5 +73,5 @@ _define_property(this, "data", undefined); | ||
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)); | ||
const match = (_this_items_find = this.items.find(getTypeMatcher(format, true))) !== null && _this_items_find !== undefined ? _this_items_find : this.items.find(getTypeMatcher(format, false)); | ||
let text = ''; | ||
match === null || match === void 0 ? void 0 : match.getAsString((t)=>{ | ||
match === null || match === undefined ? undefined : match.getAsString((t)=>{ | ||
text = t; | ||
@@ -126,12 +126,8 @@ }); | ||
} | ||
function getBlobFromDataTransferItem(window, item) { | ||
async function getBlobFromDataTransferItem(window, item) { | ||
if (item.kind === 'file') { | ||
return item.getAsFile(); | ||
} | ||
let data = ''; | ||
item.getAsString((s)=>{ | ||
data = s; | ||
}); | ||
return new window.Blob([ | ||
data | ||
await new Promise((r)=>item.getAsString(r)) | ||
], { | ||
@@ -138,0 +134,0 @@ type: item.type |
@@ -9,4 +9,3 @@ 'use strict'; | ||
} | ||
var editableInputTypes; | ||
(function(editableInputTypes) { | ||
var editableInputTypes = /*#__PURE__*/ function(editableInputTypes) { | ||
editableInputTypes["text"] = "text"; | ||
@@ -24,3 +23,4 @@ editableInputTypes["date"] = "date"; | ||
editableInputTypes["week"] = "week"; | ||
})(editableInputTypes || (editableInputTypes = {})); | ||
return editableInputTypes; | ||
}(editableInputTypes || {}); | ||
function isEditableInputOrTextArea(element) { | ||
@@ -27,0 +27,0 @@ return isElementType.isElementType(element, 'textarea') || isElementType.isElementType(element, 'input') && element.type in editableInputTypes; |
@@ -5,4 +5,3 @@ 'use strict'; | ||
var maxLengthSupportedTypes; | ||
(function(maxLengthSupportedTypes) { | ||
var maxLengthSupportedTypes = /*#__PURE__*/ function(maxLengthSupportedTypes) { | ||
maxLengthSupportedTypes["email"] = "email"; | ||
@@ -14,3 +13,4 @@ maxLengthSupportedTypes["password"] = "password"; | ||
maxLengthSupportedTypes["url"] = "url"; | ||
})(maxLengthSupportedTypes || (maxLengthSupportedTypes = {})); | ||
return maxLengthSupportedTypes; | ||
}(maxLengthSupportedTypes || {}); | ||
// can't use .maxLength property because of a jsdom bug: | ||
@@ -20,3 +20,3 @@ // https://github.com/jsdom/jsdom/issues/2927 | ||
var _element_getAttribute; | ||
const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== void 0 ? _element_getAttribute : ''; | ||
const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== undefined ? _element_getAttribute : ''; | ||
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined; | ||
@@ -23,0 +23,0 @@ } |
@@ -17,3 +17,3 @@ 'use strict'; | ||
var _el_fakeFiles; | ||
(_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === void 0 ? void 0 : _el_fakeFiles.restore(); | ||
(_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === undefined ? undefined : _el_fakeFiles.restore(); | ||
const typeDescr = Object.getOwnPropertyDescriptor(el, 'type'); | ||
@@ -43,3 +43,3 @@ const valueDescr = Object.getOwnPropertyDescriptor(el, 'value'); | ||
var _valueDescr_set; | ||
valueDescr === null || valueDescr === void 0 ? void 0 : (_valueDescr_set = valueDescr.set) === null || _valueDescr_set === void 0 ? void 0 : _valueDescr_set.call(el, v); | ||
valueDescr === null || valueDescr === undefined ? undefined : (_valueDescr_set = valueDescr.set) === null || _valueDescr_set === undefined ? undefined : _valueDescr_set.call(el, v); | ||
} | ||
@@ -46,0 +46,0 @@ } |
@@ -112,3 +112,3 @@ 'use strict'; | ||
} | ||
} 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))) { | ||
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable.isContentEditable(node.parentNode) && node.parentNode !== ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === undefined ? undefined : _node_ownerDocument.body))) { | ||
node = node.parentNode; | ||
@@ -115,0 +115,0 @@ } else { |
@@ -7,3 +7,3 @@ 'use strict'; | ||
const activeElement = document.activeElement; | ||
if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.shadowRoot) { | ||
if (activeElement === null || activeElement === undefined ? undefined : activeElement.shadowRoot) { | ||
return getActiveElement(activeElement.shadowRoot); | ||
@@ -20,3 +20,3 @@ } else { | ||
var _getActiveElement; | ||
return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== void 0 ? _getActiveElement : /* istanbul ignore next */ document.body; | ||
return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== undefined ? _getActiveElement : /* istanbul ignore next */ document.body; | ||
} | ||
@@ -23,0 +23,0 @@ |
@@ -73,6 +73,3 @@ 'use strict'; | ||
exports.isDisabled = isDisabled.isDisabled; | ||
Object.defineProperty(exports, "ApiLevel", { | ||
enumerable: true, | ||
get: function () { return level.ApiLevel; } | ||
}); | ||
exports.ApiLevel = level.ApiLevel; | ||
exports.getLevelRef = level.getLevelRef; | ||
@@ -79,0 +76,0 @@ exports.setLevelRef = level.setLevelRef; |
'use strict'; | ||
var bracketDict; | ||
(function(bracketDict) { | ||
var bracketDict = /*#__PURE__*/ function(bracketDict) { | ||
bracketDict["{"] = "}"; | ||
bracketDict["["] = "]"; | ||
})(bracketDict || (bracketDict = {})); | ||
return bracketDict; | ||
}(bracketDict || {}); | ||
/** | ||
@@ -47,7 +47,7 @@ * Read the next key definition from user input | ||
pos += Number(escapedDescriptor); | ||
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]; | ||
const descriptor = escapedDescriptor ? text[pos] : (_text_slice_match = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || _text_slice_match === undefined ? undefined : _text_slice_match[0]; | ||
assertDescriptor(descriptor, text, pos, context); | ||
pos += descriptor.length; | ||
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_ : ''; | ||
const repeatModifier = (_text_slice_match_ = (_text_slice_match1 = text.slice(pos).match(/^>\d+/)) === null || _text_slice_match1 === undefined ? undefined : _text_slice_match1[0]) !== null && _text_slice_match_ !== undefined ? _text_slice_match_ : ''; | ||
pos += repeatModifier.length; | ||
@@ -88,3 +88,3 @@ const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : ''; | ||
function getErrorMessage(expected, found, text, context) { | ||
return `Expected ${expected} but found "${found !== null && found !== void 0 ? found : ''}" in "${text}" | ||
return `Expected ${expected} but found "${found !== null && found !== undefined ? found : ''}" in "${text}" | ||
See ${context === 'pointer' ? `https://testing-library.com/docs/user-event/pointer#pressing-a-button-or-touching-the-screen` : `https://testing-library.com/docs/user-event/keyboard`} | ||
@@ -91,0 +91,0 @@ for more information about how userEvent parses your input.`; |
@@ -7,3 +7,3 @@ 'use strict'; | ||
return node.defaultView; | ||
} else if ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === void 0 ? void 0 : _node_ownerDocument.defaultView) { | ||
} else if ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === undefined ? undefined : _node_ownerDocument.defaultView) { | ||
return node.ownerDocument.defaultView; | ||
@@ -10,0 +10,0 @@ } |
@@ -21,3 +21,3 @@ 'use strict'; | ||
var _el_querySelector; | ||
if (el.hasAttribute('disabled') && !((_el_querySelector = el.querySelector(':scope > legend')) === null || _el_querySelector === void 0 ? void 0 : _el_querySelector.contains(element))) { | ||
if (el.hasAttribute('disabled') && !((_el_querySelector = el.querySelector(':scope > legend')) === null || _el_querySelector === undefined ? undefined : _el_querySelector.contains(element))) { | ||
return true; | ||
@@ -24,0 +24,0 @@ } |
@@ -7,3 +7,3 @@ 'use strict'; | ||
const window = getWindow.getWindow(element); | ||
for(let el = element; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){ | ||
for(let el = element; el === null || el === undefined ? undefined : el.ownerDocument; el = el.parentElement){ | ||
const { display, visibility } = window.getComputedStyle(el); | ||
@@ -10,0 +10,0 @@ if (display === 'none') { |
'use strict'; | ||
exports.ApiLevel = void 0; | ||
(function(ApiLevel) { | ||
var ApiLevel = /*#__PURE__*/ function(ApiLevel) { | ||
ApiLevel[ApiLevel["Trigger"] = 2] = "Trigger"; | ||
ApiLevel[ApiLevel["Call"] = 1] = "Call"; | ||
})(exports.ApiLevel || (exports.ApiLevel = {})); | ||
return ApiLevel; | ||
}({}); | ||
function setLevelRef(instance, level) { | ||
@@ -15,3 +15,4 @@ instance.levelRefs[level] = {}; | ||
exports.ApiLevel = ApiLevel; | ||
exports.getLevelRef = getLevelRef; | ||
exports.setLevelRef = setLevelRef; |
@@ -10,7 +10,7 @@ 'use strict'; | ||
var _checkPointerEvents; | ||
return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === void 0 ? void 0 : _checkPointerEvents.pointerEvents) !== 'none'; | ||
return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === undefined ? undefined : _checkPointerEvents.pointerEvents) !== 'none'; | ||
} | ||
function closestPointerEventsDeclaration(element) { | ||
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 === null || el === undefined ? undefined : el.ownerDocument; el = el.parentElement){ | ||
tree.push(el); | ||
@@ -35,3 +35,3 @@ const pointerEvents = window.getComputedStyle(el).pointerEvents; | ||
if (!needsCheck) { | ||
return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result; | ||
return lastCheck === null || lastCheck === undefined ? undefined : lastCheck.result; | ||
} | ||
@@ -48,3 +48,3 @@ const declaration = closestPointerEventsDeclaration(element); | ||
const declaration = checkPointerEvents(instance, element); | ||
if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') { | ||
if ((declaration === null || declaration === undefined ? undefined : declaration.pointerEvents) === 'none') { | ||
throw new Error([ | ||
@@ -75,3 +75,3 @@ `Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`, | ||
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(); | ||
label = (_element_ownerDocument_getElementById = element.ownerDocument.getElementById(element.getAttribute('aria-labelledby'))) === null || _element_ownerDocument_getElementById === undefined ? undefined : (_element_ownerDocument_getElementById_textContent = _element_ownerDocument_getElementById.textContent) === null || _element_ownerDocument_getElementById_textContent === undefined ? undefined : _element_ownerDocument_getElementById_textContent.trim(); | ||
} else if (isElementType.isElementType(element, [ | ||
@@ -85,14 +85,14 @@ 'button', | ||
'textarea' | ||
]) && ((_element_labels = element.labels) === null || _element_labels === void 0 ? void 0 : _element_labels.length)) { | ||
]) && ((_element_labels = element.labels) === null || _element_labels === undefined ? undefined : _element_labels.length)) { | ||
label = Array.from(element.labels).map((el)=>{ | ||
var _el_textContent; | ||
return (_el_textContent = el.textContent) === null || _el_textContent === void 0 ? void 0 : _el_textContent.trim(); | ||
return (_el_textContent = el.textContent) === null || _el_textContent === undefined ? undefined : _el_textContent.trim(); | ||
}).join('|'); | ||
} else if (isElementType.isElementType(element, 'button')) { | ||
var _element_textContent; | ||
label = (_element_textContent = element.textContent) === null || _element_textContent === void 0 ? void 0 : _element_textContent.trim(); | ||
label = (_element_textContent = element.textContent) === null || _element_textContent === undefined ? undefined : _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 === null || label === undefined ? undefined : label.replace(/\n/g, ' '); | ||
if (Number(label === null || label === undefined ? undefined : label.length) > 30) { | ||
label = `${label === null || label === undefined ? undefined : label.substring(0, 29)}…`; | ||
} | ||
@@ -99,0 +99,0 @@ return label ? `(label=${label})` : ''; |
@@ -1,8 +0,2 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import { writeDataTransferToClipboard } from '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { copySelection } from '../document/copySelection.js'; | ||
@@ -13,3 +7,3 @@ | ||
var _doc_activeElement; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== undefined ? _doc_activeElement : /* istanbul ignore next */ doc.body; | ||
const clipboardData = copySelection(target); | ||
@@ -16,0 +10,0 @@ if (clipboardData.items.length === 0) { |
@@ -1,8 +0,2 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import { writeDataTransferToClipboard } from '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { copySelection } from '../document/copySelection.js'; | ||
@@ -13,3 +7,3 @@ | ||
var _doc_activeElement; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== undefined ? _doc_activeElement : /* istanbul ignore next */ doc.body; | ||
const clipboardData = copySelection(target); | ||
@@ -16,0 +10,0 @@ if (clipboardData.items.length === 0) { |
@@ -1,10 +0,4 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import { createDataTransfer } from '../utils/dataTransfer/DataTransfer.js'; | ||
import { readDataTransferFromClipboard } from '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { getWindow } from '../utils/misc/getWindow.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
@@ -14,5 +8,5 @@ async function paste(clipboardData) { | ||
var _doc_activeElement; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== void 0 ? _doc_activeElement : /* istanbul ignore next */ doc.body; | ||
const target = (_doc_activeElement = doc.activeElement) !== null && _doc_activeElement !== undefined ? _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(()=>{ | ||
const dataTransfer = (_ref = typeof clipboardData === 'string' ? getClipboardDataFromString(doc, clipboardData) : clipboardData) !== null && _ref !== undefined ? _ref : await readDataTransferFromClipboard(doc).catch(()=>{ | ||
throw new Error('`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.'); | ||
@@ -19,0 +13,0 @@ }); |
@@ -1,7 +0,2 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import { assertPointerEvents } from '../utils/pointer/cssPointerEvents.js'; | ||
@@ -8,0 +3,0 @@ |
@@ -1,11 +0,5 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import { createDataTransfer } from '../utils/dataTransfer/DataTransfer.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { getWindow } from '../utils/misc/getWindow.js'; | ||
import { hasOwnSelection } from '../utils/focus/selection.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { getUISelection, getUIValue } from './UI.js'; | ||
@@ -12,0 +6,0 @@ |
@@ -1,9 +0,3 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import { isContentEditable } from '../utils/edit/isContentEditable.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { getUIValue } from './UI.js'; | ||
@@ -10,0 +4,0 @@ |
@@ -1,9 +0,3 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import { isElementType } from '../utils/misc/isElementType.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { isElementType } from '../utils/misc/isElementType.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { startTrackValue, trackOrSetValue } from './trackValue.js'; | ||
@@ -16,4 +10,4 @@ import { setUISelectionClean, setUISelectionRaw, getUIValue, setUIValueClean, isUIValue, isUISelectionStart } from './UI.js'; | ||
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 === null || prototypeDescriptor === undefined ? undefined : prototypeDescriptor.set) ? 'set' : 'value'; | ||
/* istanbul ignore if */ if (typeof (prototypeDescriptor === null || prototypeDescriptor === undefined ? undefined : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) { | ||
throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`); | ||
@@ -29,7 +23,7 @@ } | ||
} | ||
then === null || then === void 0 ? void 0 : then(); | ||
then === null || then === undefined ? undefined : then(); | ||
} | ||
intercept[Interceptor] = Interceptor; | ||
Object.defineProperty(element, propName, { | ||
...objectDescriptor !== null && objectDescriptor !== void 0 ? objectDescriptor : prototypeDescriptor, | ||
...objectDescriptor !== null && objectDescriptor !== undefined ? objectDescriptor : prototypeDescriptor, | ||
[target]: intercept | ||
@@ -36,0 +30,0 @@ }); |
import { dispatchDOMEvent } from '../event/dispatchEvent.js'; | ||
import '../utils/click/isClickableInput.js'; | ||
import { isElementType } from '../utils/misc/isElementType.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { isElementType } from '../utils/misc/isElementType.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { getInitialValue, clearInitialValue } from './UI.js'; | ||
@@ -11,0 +5,0 @@ import '@testing-library/dom'; |
@@ -1,9 +0,3 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { getWindow } from '../utils/misc/getWindow.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { setUIValueClean, setUISelection, hasUISelection } from './UI.js'; | ||
@@ -33,3 +27,3 @@ | ||
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); | ||
(_element_TrackChanges = element[TrackChanges]) === null || _element_TrackChanges === undefined ? undefined : (_element_TrackChanges_tracked = _element_TrackChanges.tracked) === null || _element_TrackChanges_tracked === undefined ? undefined : _element_TrackChanges_tracked.push(v); | ||
if (!element[TrackChanges]) { | ||
@@ -46,3 +40,3 @@ setUIValueClean(element); | ||
element[TrackChanges] = undefined; | ||
if (!(changes === null || changes === void 0 ? void 0 : (_changes_tracked = changes.tracked) === null || _changes_tracked === void 0 ? void 0 : _changes_tracked.length)) { | ||
if (!(changes === null || changes === undefined ? undefined : (_changes_tracked = changes.tracked) === null || _changes_tracked === undefined ? undefined : _changes_tracked.length)) { | ||
return; | ||
@@ -49,0 +43,0 @@ } |
@@ -62,5 +62,5 @@ const UIValue = Symbol('Displayed value in UI'); | ||
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 | ||
const sel = (_element_UISelection = element[UISelection]) !== null && _element_UISelection !== undefined ? _element_UISelection : { | ||
anchorOffset: (_element_selectionStart = element.selectionStart) !== null && _element_selectionStart !== undefined ? _element_selectionStart : 0, | ||
focusOffset: (_element_selectionEnd = element.selectionEnd) !== null && _element_selectionEnd !== undefined ? _element_selectionEnd : 0 | ||
}; | ||
@@ -67,0 +67,0 @@ return { |
@@ -1,12 +0,6 @@ | ||
import '../../utils/click/isClickableInput.js'; | ||
import { isElementType } from '../../utils/misc/isElementType.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { isElementType } from '../../utils/misc/isElementType.js'; | ||
import { getWindow } from '../../utils/misc/getWindow.js'; | ||
import { isFocusable } from '../../utils/focus/isFocusable.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import { cloneEvent } from '../../utils/misc/cloneEvent.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { focusElement, blurElement } from '../focus.js'; | ||
@@ -13,0 +7,0 @@ import { behavior } from './registry.js'; |
@@ -1,8 +0,3 @@ | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import { isEditable } from '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { input } from '../input.js'; | ||
@@ -9,0 +4,0 @@ import { behavior } from './registry.js'; |
import { getUIValue, setUISelection } from '../../document/UI.js'; | ||
import { getValueOrTextContent } from '../../document/getValueOrTextContent.js'; | ||
import '../../utils/click/isClickableInput.js'; | ||
import { isElementType } from '../../utils/misc/isElementType.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import { isContentEditable } from '../../utils/edit/isContentEditable.js'; | ||
import { isEditable } from '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { isElementType } from '../../utils/misc/isElementType.js'; | ||
import { getTabDestination } from '../../utils/focus/getTabDestination.js'; | ||
import { hasOwnSelection } from '../../utils/focus/selection.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { focusElement } from '../focus.js'; | ||
@@ -25,3 +20,3 @@ import { input } from '../input.js'; | ||
var _keydownBehavior_event_key1; | ||
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = keydownBehavior[event.key]) === null || _keydownBehavior_event_key === void 0 ? void 0 : _keydownBehavior_event_key.call(keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== void 0 ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance); | ||
return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = keydownBehavior[event.key]) === null || _keydownBehavior_event_key === undefined ? undefined : _keydownBehavior_event_key.call(keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== undefined ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance); | ||
}; | ||
@@ -81,3 +76,3 @@ const keydownBehavior = { | ||
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; | ||
const newPos = (_getValueOrTextContent_length = (_getValueOrTextContent = getValueOrTextContent(target)) === null || _getValueOrTextContent === undefined ? undefined : _getValueOrTextContent.length) !== null && _getValueOrTextContent_length !== undefined ? _getValueOrTextContent_length : /* istanbul ignore next */ 0; | ||
setSelectionRange(target, newPos, newPos); | ||
@@ -84,0 +79,0 @@ }; |
@@ -1,10 +0,5 @@ | ||
import '../../utils/click/isClickableInput.js'; | ||
import { isElementType } from '../../utils/misc/isElementType.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import { isContentEditable } from '../../utils/edit/isContentEditable.js'; | ||
import { isEditable } from '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { isElementType } from '../../utils/misc/isElementType.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { input } from '../input.js'; | ||
@@ -21,3 +16,3 @@ import { behavior } from './registry.js'; | ||
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 === null || form === undefined ? undefined : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]'); | ||
if (submit) { | ||
@@ -24,0 +19,0 @@ return ()=>instance.dispatchUIEvent(submit, 'click'); |
import { isClickableInput } from '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { behavior } from './registry.js'; | ||
@@ -12,3 +7,3 @@ | ||
var _keyupBehavior_event_key; | ||
return (_keyupBehavior_event_key = keyupBehavior[event.key]) === null || _keyupBehavior_event_key === void 0 ? void 0 : _keyupBehavior_event_key.call(keyupBehavior, event, target, instance); | ||
return (_keyupBehavior_event_key = keyupBehavior[event.key]) === null || _keyupBehavior_event_key === undefined ? undefined : _keyupBehavior_event_key.call(keyupBehavior, event, target, instance); | ||
}; | ||
@@ -15,0 +10,0 @@ const keyupBehavior = { |
@@ -1,8 +0,3 @@ | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import { isEditable } from '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { input } from '../input.js'; | ||
@@ -15,3 +10,3 @@ import { behavior } from './registry.js'; | ||
var _event_clipboardData; | ||
const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === void 0 ? void 0 : _event_clipboardData.getData('text'); | ||
const insertData = (_event_clipboardData = event.clipboardData) === null || _event_clipboardData === undefined ? undefined : _event_clipboardData.getData('text'); | ||
if (insertData) { | ||
@@ -18,0 +13,0 @@ input(instance, target, insertData, 'insertFromPaste'); |
@@ -1,9 +0,3 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { getWindow } from '../utils/misc/getWindow.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { eventMap } from './eventMap.js'; | ||
@@ -16,2 +10,6 @@ | ||
Event: [], | ||
FocusEvent: [ | ||
initUIEvent, | ||
initFocusEvent | ||
], | ||
InputEvent: [ | ||
@@ -42,3 +40,3 @@ initUIEvent, | ||
const event = new (getEventConstructors(window))[EventType](type, defaultInit); | ||
eventInitializer[EventType].forEach((f)=>f(event, init !== null && init !== void 0 ? init : {})); | ||
eventInitializer[EventType].forEach((f)=>f(event, init !== null && init !== undefined ? init : {})); | ||
return event; | ||
@@ -48,45 +46,45 @@ } | ||
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 { | ||
/* eslint-disable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ const Event = (_window_Event = window.Event) !== null && _window_Event !== undefined ? _window_Event : class Event { | ||
}; | ||
var _window_AnimationEvent; | ||
const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !== void 0 ? _window_AnimationEvent : class AnimationEvent extends Event { | ||
const AnimationEvent = (_window_AnimationEvent = window.AnimationEvent) !== null && _window_AnimationEvent !== undefined ? _window_AnimationEvent : class AnimationEvent extends Event { | ||
}; | ||
var _window_ClipboardEvent; | ||
const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !== void 0 ? _window_ClipboardEvent : class ClipboardEvent extends Event { | ||
const ClipboardEvent = (_window_ClipboardEvent = window.ClipboardEvent) !== null && _window_ClipboardEvent !== undefined ? _window_ClipboardEvent : class ClipboardEvent extends Event { | ||
}; | ||
var _window_PopStateEvent; | ||
const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !== void 0 ? _window_PopStateEvent : class PopStateEvent extends Event { | ||
const PopStateEvent = (_window_PopStateEvent = window.PopStateEvent) !== null && _window_PopStateEvent !== undefined ? _window_PopStateEvent : class PopStateEvent extends Event { | ||
}; | ||
var _window_ProgressEvent; | ||
const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !== void 0 ? _window_ProgressEvent : class ProgressEvent extends Event { | ||
const ProgressEvent = (_window_ProgressEvent = window.ProgressEvent) !== null && _window_ProgressEvent !== undefined ? _window_ProgressEvent : class ProgressEvent extends Event { | ||
}; | ||
var _window_TransitionEvent; | ||
const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !== void 0 ? _window_TransitionEvent : class TransitionEvent extends Event { | ||
const TransitionEvent = (_window_TransitionEvent = window.TransitionEvent) !== null && _window_TransitionEvent !== undefined ? _window_TransitionEvent : class TransitionEvent extends Event { | ||
}; | ||
var _window_UIEvent; | ||
const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !== void 0 ? _window_UIEvent : class UIEvent extends Event { | ||
const UIEvent = (_window_UIEvent = window.UIEvent) !== null && _window_UIEvent !== undefined ? _window_UIEvent : class UIEvent extends Event { | ||
}; | ||
var _window_CompositionEvent; | ||
const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !== void 0 ? _window_CompositionEvent : class CompositionEvent extends UIEvent { | ||
const CompositionEvent = (_window_CompositionEvent = window.CompositionEvent) !== null && _window_CompositionEvent !== undefined ? _window_CompositionEvent : class CompositionEvent extends UIEvent { | ||
}; | ||
var _window_FocusEvent; | ||
const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !== void 0 ? _window_FocusEvent : class FocusEvent extends UIEvent { | ||
const FocusEvent = (_window_FocusEvent = window.FocusEvent) !== null && _window_FocusEvent !== undefined ? _window_FocusEvent : class FocusEvent extends UIEvent { | ||
}; | ||
var _window_InputEvent; | ||
const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !== void 0 ? _window_InputEvent : class InputEvent extends UIEvent { | ||
const InputEvent = (_window_InputEvent = window.InputEvent) !== null && _window_InputEvent !== undefined ? _window_InputEvent : class InputEvent extends UIEvent { | ||
}; | ||
var _window_KeyboardEvent; | ||
const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !== void 0 ? _window_KeyboardEvent : class KeyboardEvent extends UIEvent { | ||
const KeyboardEvent = (_window_KeyboardEvent = window.KeyboardEvent) !== null && _window_KeyboardEvent !== undefined ? _window_KeyboardEvent : class KeyboardEvent extends UIEvent { | ||
}; | ||
var _window_MouseEvent; | ||
const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !== void 0 ? _window_MouseEvent : class MouseEvent extends UIEvent { | ||
const MouseEvent = (_window_MouseEvent = window.MouseEvent) !== null && _window_MouseEvent !== undefined ? _window_MouseEvent : class MouseEvent extends UIEvent { | ||
}; | ||
var _window_DragEvent; | ||
const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !== void 0 ? _window_DragEvent : class DragEvent extends MouseEvent { | ||
const DragEvent = (_window_DragEvent = window.DragEvent) !== null && _window_DragEvent !== undefined ? _window_DragEvent : class DragEvent extends MouseEvent { | ||
}; | ||
var _window_PointerEvent; | ||
const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !== void 0 ? _window_PointerEvent : class PointerEvent extends MouseEvent { | ||
const PointerEvent = (_window_PointerEvent = window.PointerEvent) !== null && _window_PointerEvent !== undefined ? _window_PointerEvent : class PointerEvent extends MouseEvent { | ||
}; | ||
var _window_TouchEvent; | ||
const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !== void 0 ? _window_TouchEvent : class TouchEvent extends UIEvent { | ||
const TouchEvent = (_window_TouchEvent = window.TouchEvent) !== null && _window_TouchEvent !== undefined ? _window_TouchEvent : class TouchEvent extends UIEvent { | ||
}; | ||
@@ -114,3 +112,3 @@ /* eslint-enable @typescript-eslint/no-unnecessary-condition, @typescript-eslint/no-extraneous-class */ return { | ||
Object.defineProperty(obj, key, { | ||
get: ()=>value !== null && value !== void 0 ? value : null | ||
get: ()=>value !== null && value !== undefined ? value : null | ||
}); | ||
@@ -120,3 +118,3 @@ } | ||
function sanitizeNumber(n) { | ||
return Number(n !== null && n !== void 0 ? n : 0); | ||
return Number(n !== null && n !== undefined ? n : 0); | ||
} | ||
@@ -128,2 +126,7 @@ function initClipboardEvent(event, { clipboardData }) { | ||
} | ||
function initFocusEvent(event, { relatedTarget }) { | ||
assignProps(event, { | ||
relatedTarget | ||
}); | ||
} | ||
function initInputEvent(event, { data, inputType, isComposing }) { | ||
@@ -139,3 +142,3 @@ assignProps(event, { | ||
view, | ||
detail: sanitizeNumber(detail !== null && detail !== void 0 ? detail : 0) | ||
detail: sanitizeNumber(detail !== null && detail !== undefined ? detail : 0) | ||
}); | ||
@@ -177,3 +180,3 @@ } | ||
} | ||
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, offsetX, offsetY, pageX, pageY }) { | ||
assignProps(event, { | ||
@@ -188,3 +191,7 @@ screenX: sanitizeNumber(screenX), | ||
buttons: sanitizeNumber(buttons), | ||
relatedTarget | ||
relatedTarget, | ||
offsetX: sanitizeNumber(offsetX), | ||
offsetY: sanitizeNumber(offsetY), | ||
pageX: sanitizeNumber(pageX), | ||
pageY: sanitizeNumber(pageY) | ||
}); | ||
@@ -191,0 +198,0 @@ } |
@@ -25,3 +25,3 @@ import './behavior/click.js'; | ||
const type = event.type; | ||
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = behavior[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(behavior, event, target, this); | ||
const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = behavior[type]) === null || _behavior_type === undefined ? undefined : _behavior_type.call(behavior, event, target, this); | ||
if (behaviorImplementation) { | ||
@@ -28,0 +28,0 @@ event.preventDefault(); |
@@ -18,2 +18,10 @@ const eventMap = { | ||
}, | ||
blur: { | ||
EventType: 'FocusEvent', | ||
defaultInit: { | ||
bubbles: false, | ||
cancelable: false, | ||
composed: true | ||
} | ||
}, | ||
click: { | ||
@@ -66,2 +74,26 @@ EventType: 'PointerEvent', | ||
}, | ||
focus: { | ||
EventType: 'FocusEvent', | ||
defaultInit: { | ||
bubbles: false, | ||
cancelable: false, | ||
composed: true | ||
} | ||
}, | ||
focusin: { | ||
EventType: 'FocusEvent', | ||
defaultInit: { | ||
bubbles: true, | ||
cancelable: false, | ||
composed: true | ||
} | ||
}, | ||
focusout: { | ||
EventType: 'FocusEvent', | ||
defaultInit: { | ||
bubbles: true, | ||
cancelable: false, | ||
composed: true | ||
} | ||
}, | ||
keydown: { | ||
@@ -68,0 +100,0 @@ EventType: 'KeyboardEvent', |
@@ -1,14 +0,10 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { getActiveElement } from '../utils/focus/getActiveElement.js'; | ||
import { isFocusable } from '../utils/focus/isFocusable.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import { findClosest } from '../utils/misc/findClosest.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { updateSelectionOnFocus } from './selection/updateSelectionOnFocus.js'; | ||
import { wrapEvent } from './wrapEvent.js'; | ||
// Browsers do not dispatch FocusEvent if the document does not have focus. | ||
// TODO: simulate FocusEvent in browsers | ||
/** | ||
@@ -19,3 +15,3 @@ * Focus closest focusable element. | ||
const activeElement = getActiveElement(element.ownerDocument); | ||
if ((target !== null && target !== void 0 ? target : element.ownerDocument.body) === activeElement) { | ||
if ((target !== null && target !== undefined ? target : element.ownerDocument.body) === activeElement) { | ||
return; | ||
@@ -25,5 +21,5 @@ } else if (target) { | ||
} else { | ||
wrapEvent(()=>activeElement === null || activeElement === void 0 ? void 0 : activeElement.blur()); | ||
wrapEvent(()=>activeElement === null || activeElement === undefined ? undefined : activeElement.blur()); | ||
} | ||
updateSelectionOnFocus(target !== null && target !== void 0 ? target : element.ownerDocument.body); | ||
updateSelectionOnFocus(target !== null && target !== undefined ? target : element.ownerDocument.body); | ||
} | ||
@@ -30,0 +26,0 @@ function blurElement(element) { |
export { dispatchDOMEvent, dispatchEvent, dispatchUIEvent } from './dispatchEvent.js'; | ||
export { blurElement, focusElement } from './focus.js'; | ||
export { input } from './input.js'; | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
export { setSelectionPerMouseDown } from './selection/setSelectionPerMouse.js'; | ||
export { modifySelectionPerMouseMove } from './selection/modifySelectionPerMouse.js'; | ||
export { isAllSelected, selectAll } from './selection/selectAll.js'; |
import { setUIValue, clearInitialValue, getUIValue } from '../document/UI.js'; | ||
import '../utils/click/isClickableInput.js'; | ||
import { isElementType } from '../utils/misc/isElementType.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import { isValidDateOrTimeValue, buildTimeValue } from '../utils/edit/timeValue.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import { supportsMaxLength, getMaxLength } from '../utils/edit/maxLength.js'; | ||
import { getNextCursorPosition } from '../utils/focus/cursor.js'; | ||
import { isElementType } from '../utils/misc/isElementType.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { commitValueAfterInput } from '../document/trackValue.js'; | ||
@@ -157,5 +152,5 @@ import { getInputRange } from './selection/getInputRange.js'; | ||
const valueParts = value.split('e', 2); | ||
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])); | ||
return !(/[^\d.\-e]/.test(value) || Number((_value_match = value.match(/-/g)) === null || _value_match === undefined ? undefined : _value_match.length) > 2 || Number((_value_match1 = value.match(/\./g)) === null || _value_match1 === undefined ? undefined : _value_match1.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1])); | ||
} | ||
export { input }; |
@@ -1,10 +0,4 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { isDisabled } from '../utils/misc/isDisabled.js'; | ||
import { getWindow } from '../utils/misc/getWindow.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { focusElement } from './focus.js'; | ||
@@ -11,0 +5,0 @@ |
@@ -12,3 +12,3 @@ import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js'; | ||
// Multi-range on contenteditable edits the first selection instead of the last | ||
return (_typeAndSelection_selection = typeAndSelection.selection) === null || _typeAndSelection_selection === void 0 ? void 0 : _typeAndSelection_selection.getRangeAt(0); | ||
return (_typeAndSelection_selection = typeAndSelection.selection) === null || _typeAndSelection_selection === undefined ? undefined : _typeAndSelection_selection.getRangeAt(0); | ||
} | ||
@@ -15,0 +15,0 @@ } |
import { getUISelection } from '../../document/UI.js'; | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import { getContentEditable } from '../../utils/edit/isContentEditable.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { hasOwnSelection } from '../../utils/focus/selection.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
@@ -22,6 +16,6 @@ /** | ||
} | ||
const selection = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection(); | ||
const selection = element === null || element === undefined ? undefined : 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 === null || selection === undefined ? undefined : selection.anchorNode) && getContentEditable(selection.anchorNode); | ||
return { | ||
@@ -28,0 +22,0 @@ type: isCE ? 'contenteditable' : 'default', |
import { setUISelection } from '../../document/UI.js'; | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js'; | ||
@@ -22,5 +16,5 @@ | ||
} | ||
(_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); | ||
(_focusNode_ownerDocument = focusNode.ownerDocument) === null || _focusNode_ownerDocument === undefined ? undefined : (_focusNode_ownerDocument_getSelection = _focusNode_ownerDocument.getSelection()) === null || _focusNode_ownerDocument_getSelection === undefined ? undefined : _focusNode_ownerDocument_getSelection.extend(focusNode, focusOffset); | ||
} | ||
export { modifySelection }; |
import { setUISelection } from '../../document/UI.js'; | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { resolveCaretPosition } from './resolveCaretPosition.js'; | ||
@@ -39,4 +33,4 @@ | ||
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 === null || selection === undefined ? undefined : selection.removeAllRanges(); | ||
selection === null || selection === undefined ? undefined : selection.addRange(range.cloneRange()); | ||
} | ||
@@ -43,0 +37,0 @@ } |
import { getUISelection } from '../../document/UI.js'; | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { getNextCursorPosition } from '../../utils/focus/cursor.js'; | ||
import { hasOwnSelection } from '../../utils/focus/selection.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { setSelection } from './setSelection.js'; | ||
@@ -25,3 +19,3 @@ | ||
const selection = node.ownerDocument.getSelection(); | ||
if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) { | ||
if (!(selection === null || selection === undefined ? undefined : selection.focusNode)) { | ||
return; | ||
@@ -28,0 +22,0 @@ } |
import { getUIValue } from '../../document/UI.js'; | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { hasOwnSelection } from '../../utils/focus/selection.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
@@ -15,3 +9,3 @@ function resolveCaretPosition({ target, node, offset }) { | ||
node: target, | ||
offset: offset !== null && offset !== void 0 ? offset : getUIValue(target).length | ||
offset: offset !== null && offset !== undefined ? offset : getUIValue(target).length | ||
}; | ||
@@ -21,3 +15,3 @@ } else if (node) { | ||
node, | ||
offset: offset !== null && offset !== void 0 ? offset : node.nodeType === 3 ? node.nodeValue.length : node.childNodes.length | ||
offset: offset !== null && offset !== undefined ? offset : node.nodeType === 3 ? node.nodeValue.length : node.childNodes.length | ||
}; | ||
@@ -35,3 +29,3 @@ } | ||
let i = offset === undefined ? node.childNodes.length - 1 : 0; | ||
const step = offset === undefined ? -1 : +1; | ||
const step = offset === undefined ? -1 : 1; | ||
while(offset === undefined ? i >= (isRoot ? Math.max(node.childNodes.length - 1, 0) : 0) : i <= node.childNodes.length){ | ||
@@ -55,3 +49,3 @@ if (offset && i === node.childNodes.length) { | ||
node: c, | ||
offset: offset !== null && offset !== void 0 ? offset : c.nodeValue.length | ||
offset: offset !== null && offset !== undefined ? offset : c.nodeValue.length | ||
}; | ||
@@ -58,0 +52,0 @@ } |
import { getUIValue, getUISelection } from '../../document/UI.js'; | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import { getContentEditable } from '../../utils/edit/isContentEditable.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { hasOwnSelection } from '../../utils/focus/selection.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { setSelection } from './setSelection.js'; | ||
@@ -24,3 +18,3 @@ | ||
var _getContentEditable; | ||
const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body; | ||
const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== undefined ? _getContentEditable : target.ownerDocument.body; | ||
setSelection({ | ||
@@ -37,7 +31,7 @@ focusNode, | ||
var _getContentEditable; | ||
const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body; | ||
const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== undefined ? _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 === null || selection === undefined ? undefined : selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length; | ||
} | ||
export { isAllSelected, selectAll }; |
import { setUISelection } from '../../document/UI.js'; | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { getTargetTypeAndSelection } from './getTargetTypeAndSelection.js'; | ||
@@ -22,5 +16,5 @@ | ||
} | ||
(_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); | ||
(_anchorNode_ownerDocument = anchorNode.ownerDocument) === null || _anchorNode_ownerDocument === undefined ? undefined : (_anchorNode_ownerDocument_getSelection = _anchorNode_ownerDocument.getSelection()) === null || _anchorNode_ownerDocument_getSelection === undefined ? undefined : _anchorNode_ownerDocument_getSelection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset); | ||
} | ||
export { setSelection }; |
import { getUIValue, setUISelection } from '../../document/UI.js'; | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { hasNoSelection, hasOwnSelection } from '../../utils/focus/selection.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { resolveCaretPosition } from './resolveCaretPosition.js'; | ||
@@ -32,9 +26,9 @@ | ||
setUISelection(target, { | ||
anchorOffset: start !== null && start !== void 0 ? start : text.length, | ||
focusOffset: end !== null && end !== void 0 ? end : text.length | ||
anchorOffset: start !== null && start !== undefined ? start : text.length, | ||
focusOffset: end !== null && end !== undefined ? end : text.length | ||
}); | ||
return { | ||
node: target, | ||
start: start !== null && start !== void 0 ? start : 0, | ||
end: end !== null && end !== void 0 ? end : text.length | ||
start: start !== null && start !== undefined ? start : 0, | ||
end: end !== null && end !== undefined ? end : text.length | ||
}; | ||
@@ -60,4 +54,4 @@ } else { | ||
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 === null || selection === undefined ? undefined : selection.removeAllRanges(); | ||
selection === null || selection === undefined ? undefined : selection.addRange(range.cloneRange()); | ||
return range; | ||
@@ -73,3 +67,3 @@ } | ||
} | ||
const textPos = pos !== null && pos !== void 0 ? pos : text.length; | ||
const textPos = pos !== null && pos !== undefined ? pos : text.length; | ||
if (clickCount % 3 === 2) { | ||
@@ -76,0 +70,0 @@ return [ |
@@ -1,10 +0,4 @@ | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import { isContentEditable } from '../../utils/edit/isContentEditable.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { hasOwnSelection } from '../../utils/focus/selection.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { setSelection } from './setSelection.js'; | ||
@@ -25,3 +19,3 @@ | ||
} | ||
/* istanbul ignore else */ if (isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === void 0 ? void 0 : _element_firstChild.nodeType) === 3) { | ||
/* istanbul ignore else */ if (isContentEditable(element) && ((_element_firstChild = element.firstChild) === null || _element_firstChild === undefined ? undefined : _element_firstChild.nodeType) === 3) { | ||
return setSelection({ | ||
@@ -28,0 +22,0 @@ focusNode: element.firstChild, |
@@ -1,11 +0,9 @@ | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import { getContentEditable } from '../../utils/edit/isContentEditable.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { hasOwnSelection } from '../../utils/focus/selection.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
// The browser implementation seems to have changed. | ||
// When focus is inside <input type="text"/>, | ||
// Chrome updates Selection to be collapsed at the position of the input element. | ||
// TODO: update implementation to match that of current browsers | ||
/** | ||
@@ -16,3 +14,3 @@ * Reset the Document Selection when moving focus into an element | ||
const selection = element.ownerDocument.getSelection(); | ||
/* istanbul ignore if */ if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) { | ||
/* istanbul ignore if */ if (!(selection === null || selection === undefined ? undefined : selection.focusNode)) { | ||
return; | ||
@@ -32,3 +30,3 @@ } | ||
var _contenteditable_firstChild; | ||
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === void 0 ? void 0 : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable; | ||
const focusNode = ((_contenteditable_firstChild = contenteditable.firstChild) === null || _contenteditable_firstChild === undefined ? undefined : _contenteditable_firstChild.nodeType) === 3 ? contenteditable.firstChild : contenteditable; | ||
selection.setBaseAndExtent(focusNode, 0, focusNode, 0); | ||
@@ -35,0 +33,0 @@ } |
@@ -1,9 +0,3 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import { wait } from '../utils/misc/wait.js'; | ||
import '../options.js'; | ||
import { parseKeyDef } from './parseKeyDef.js'; | ||
@@ -10,0 +4,0 @@ |
@@ -1,8 +0,3 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { readNextDescriptor } from '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
@@ -26,9 +21,9 @@ /** | ||
var _def_code; | ||
return ((_def_code = def.code) === null || _def_code === void 0 ? void 0 : _def_code.toLowerCase()) === descriptor.toLowerCase(); | ||
return ((_def_code = def.code) === null || _def_code === undefined ? undefined : _def_code.toLowerCase()) === descriptor.toLowerCase(); | ||
} else if (type === '{') { | ||
var _def_key; | ||
return ((_def_key = def.key) === null || _def_key === void 0 ? void 0 : _def_key.toLowerCase()) === descriptor.toLowerCase(); | ||
return ((_def_key = def.key) === null || _def_key === undefined ? undefined : _def_key.toLowerCase()) === descriptor.toLowerCase(); | ||
} | ||
return def.key === descriptor; | ||
})) !== null && _keyboardMap_find !== void 0 ? _keyboardMap_find : { | ||
})) !== null && _keyboardMap_find !== undefined ? _keyboardMap_find : { | ||
key: 'Unknown', | ||
@@ -35,0 +30,0 @@ code: 'Unknown', |
@@ -1,3 +0,2 @@ | ||
var PointerEventsCheckLevel; | ||
(function(PointerEventsCheckLevel) { | ||
var PointerEventsCheckLevel = /*#__PURE__*/ function(PointerEventsCheckLevel) { | ||
/** | ||
@@ -10,4 +9,5 @@ * Check pointer events on every user interaction that triggers a bunch of events. | ||
/** No pointer events check */ PointerEventsCheckLevel[PointerEventsCheckLevel["Never"] = 0] = "Never"; | ||
})(PointerEventsCheckLevel || (PointerEventsCheckLevel = {})); | ||
return PointerEventsCheckLevel; | ||
}({}); | ||
export { PointerEventsCheckLevel }; |
@@ -1,9 +0,4 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import { setLevelRef, ApiLevel } from '../utils/misc/level.js'; | ||
import { wait } from '../utils/misc/wait.js'; | ||
import '../options.js'; | ||
import { parseKeyDef } from './parseKeyDef.js'; | ||
@@ -40,7 +35,7 @@ | ||
const position = { | ||
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 === null || previousPosition === void 0 ? void 0 : previousPosition.coords, | ||
target: (_action_target = action.target) !== null && _action_target !== undefined ? _action_target : getPrevTarget(instance, previousPosition), | ||
coords: (_action_coords = action.coords) !== null && _action_coords !== undefined ? _action_coords : previousPosition === null || previousPosition === undefined ? undefined : previousPosition.coords, | ||
caret: { | ||
node: (_action_node = action.node) !== null && _action_node !== void 0 ? _action_node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (_previousPosition_caret = previousPosition.caret) === null || _previousPosition_caret === void 0 ? void 0 : _previousPosition_caret.node, | ||
offset: (_action_offset = action.offset) !== null && _action_offset !== void 0 ? _action_offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === void 0 ? void 0 : (_previousPosition_caret1 = previousPosition.caret) === null || _previousPosition_caret1 === void 0 ? void 0 : _previousPosition_caret1.offset | ||
node: (_action_node = action.node) !== null && _action_node !== undefined ? _action_node : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === undefined ? undefined : (_previousPosition_caret = previousPosition.caret) === null || _previousPosition_caret === undefined ? undefined : _previousPosition_caret.node, | ||
offset: (_action_offset = action.offset) !== null && _action_offset !== undefined ? _action_offset : hasCaretPosition(action) ? undefined : previousPosition === null || previousPosition === undefined ? undefined : (_previousPosition_caret1 = previousPosition.caret) === null || _previousPosition_caret1 === undefined ? undefined : _previousPosition_caret1.offset | ||
} | ||
@@ -68,3 +63,3 @@ }; | ||
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); | ||
return !!((_ref = (_action_target = action.target) !== null && _action_target !== undefined ? _action_target : action.node) !== null && _ref !== undefined ? _ref : action.offset !== undefined); | ||
} | ||
@@ -76,5 +71,5 @@ function getPrevTarget(instance, position) { | ||
var _position_target; | ||
return (_position_target = position.target) !== null && _position_target !== void 0 ? _position_target : instance.config.document.body; | ||
return (_position_target = position.target) !== null && _position_target !== undefined ? _position_target : instance.config.document.body; | ||
} | ||
export { pointer }; |
@@ -1,8 +0,3 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { readNextDescriptor } from '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
@@ -9,0 +4,0 @@ function parseKeyDef(pointerMap, keys) { |
@@ -0,8 +1,6 @@ | ||
import { patchFocus } from '../document/patchFocus.js'; | ||
import { prepareDocument } from '../document/prepareDocument.js'; | ||
import { dispatchEvent, dispatchUIEvent } from '../event/dispatchEvent.js'; | ||
import '../utils/click/isClickableInput.js'; | ||
import { attachClipboardStubToView } from '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import { getWindow } from '../utils/misc/getWindow.js'; | ||
import { getDocumentFromNode } from '../utils/misc/getDocumentFromNode.js'; | ||
@@ -55,4 +53,5 @@ import { setLevelRef, ApiLevel } from '../utils/misc/level.js'; | ||
prepareDocument(config.document); | ||
patchFocus(getWindow(config.document).HTMLElement); | ||
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; | ||
const view = (_config_document_defaultView = config.document.defaultView) !== null && _config_document_defaultView !== undefined ? _config_document_defaultView : /* istanbul ignore next */ globalThis.window; | ||
attachClipboardStubToView(view); | ||
@@ -66,4 +65,5 @@ return createInstance(config).api; | ||
prepareDocument(config.document); | ||
patchFocus(getWindow(config.document).HTMLElement); | ||
var _ref; | ||
const system = (_ref = pointerState !== null && pointerState !== void 0 ? pointerState : keyboardState) !== null && _ref !== void 0 ? _ref : new System(); | ||
const system = (_ref = pointerState !== null && pointerState !== undefined ? pointerState : keyboardState) !== null && _ref !== undefined ? _ref : new System(); | ||
return { | ||
@@ -118,5 +118,5 @@ api: createInstance(config, system).api, | ||
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; | ||
return (_ref = (_options_document = options.document) !== null && _options_document !== undefined ? _options_document : node && getDocumentFromNode(node)) !== null && _ref !== undefined ? _ref : defaults.document; | ||
} | ||
export { createConfig, createInstance, setupDirect, setupMain, setupSub }; |
@@ -1,9 +0,3 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { getActiveElementOrBody } from '../utils/focus/getActiveElement.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
@@ -23,4 +17,3 @@ function _define_property(obj, key, value) { | ||
} | ||
var DOM_KEY_LOCATION; | ||
(function(DOM_KEY_LOCATION) { | ||
var DOM_KEY_LOCATION = /*#__PURE__*/ function(DOM_KEY_LOCATION) { | ||
DOM_KEY_LOCATION[DOM_KEY_LOCATION["STANDARD"] = 0] = "STANDARD"; | ||
@@ -30,3 +23,4 @@ DOM_KEY_LOCATION[DOM_KEY_LOCATION["LEFT"] = 1] = "LEFT"; | ||
DOM_KEY_LOCATION[DOM_KEY_LOCATION["NUMPAD"] = 3] = "NUMPAD"; | ||
})(DOM_KEY_LOCATION || (DOM_KEY_LOCATION = {})); | ||
return DOM_KEY_LOCATION; | ||
}({}); | ||
const modifierKeys = [ | ||
@@ -56,10 +50,8 @@ 'Alt', | ||
isKeyPressed(keyDef) { | ||
return !!this.pressed[String(keyDef.code)]; | ||
return this.pressed.has(String(keyDef.code)); | ||
} | ||
getPressedKeys() { | ||
return Object.values(this.pressed).map((p)=>p.keyDef); | ||
return this.pressed.values().map((p)=>p.keyDef); | ||
} | ||
/** 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); | ||
@@ -69,7 +61,3 @@ const code = String(keyDef.code); | ||
this.setKeydownTarget(target); | ||
var _; | ||
(_ = (_this_pressed = this.pressed)[_code = code]) !== null && _ !== void 0 ? _ : _this_pressed[_code] = { | ||
keyDef, | ||
unpreventedDefault: false | ||
}; | ||
this.pressed.add(code, keyDef); | ||
if (isModifierKey(key)) { | ||
@@ -86,3 +74,5 @@ this.modifiers[key] = true; | ||
} | ||
(_this_pressed_code = this.pressed[code]).unpreventedDefault || (_this_pressed_code.unpreventedDefault = unprevented); | ||
if (unprevented) { | ||
this.pressed.setUnprevented(code); | ||
} | ||
if (unprevented && this.hasKeyPress(key)) { | ||
@@ -99,6 +89,5 @@ instance.dispatchUIEvent(getActiveElementOrBody(instance.config.document), 'keypress', { | ||
const code = String(keyDef.code); | ||
const unprevented = this.pressed[code].unpreventedDefault; | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
delete this.pressed[code]; | ||
if (isModifierKey(key) && !Object.values(this.pressed).find((p)=>p.keyDef.key === key)) { | ||
const unprevented = this.pressed.isUnprevented(code); | ||
this.pressed.delete(code); | ||
if (isModifierKey(key) && !this.pressed.values().find((p)=>p.keyDef.key === key)) { | ||
this.modifiers[key] = false; | ||
@@ -128,3 +117,3 @@ } | ||
constructor(system){ | ||
_define_property(this, "system", void 0); | ||
_define_property(this, "system", undefined); | ||
_define_property(this, "modifiers", { | ||
@@ -144,3 +133,35 @@ Alt: false, | ||
}); | ||
_define_property(this, "pressed", {}); | ||
_define_property(this, "pressed", new class { | ||
add(code, keyDef) { | ||
var _this_registry, _code; | ||
var _; | ||
(_ = (_this_registry = this.registry)[_code = code]) !== null && _ !== undefined ? _ : _this_registry[_code] = { | ||
keyDef, | ||
unpreventedDefault: false | ||
}; | ||
} | ||
has(code) { | ||
return !!this.registry[code]; | ||
} | ||
setUnprevented(code) { | ||
const o = this.registry[code]; | ||
if (o) { | ||
o.unpreventedDefault = true; | ||
} | ||
} | ||
isUnprevented(code) { | ||
var _this_registry_code; | ||
return !!((_this_registry_code = this.registry[code]) === null || _this_registry_code === undefined ? undefined : _this_registry_code.unpreventedDefault); | ||
} | ||
delete(code) { | ||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
delete this.registry[code]; | ||
} | ||
values() { | ||
return Object.values(this.registry); | ||
} | ||
constructor(){ | ||
_define_property(this, "registry", {}); | ||
} | ||
}()); | ||
_define_property(this, "carryChar", ''); | ||
@@ -147,0 +168,0 @@ _define_property(this, "lastKeydownTarget", undefined); |
@@ -46,8 +46,8 @@ import { Buttons } from './buttons.js'; | ||
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 === null || pointermove === undefined ? undefined : pointermove.leave(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.leave(); | ||
pointermove === null || pointermove === undefined ? undefined : pointermove.enter(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.enter(); | ||
pointermove === null || pointermove === undefined ? undefined : pointermove.move(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.move(); | ||
} | ||
@@ -73,5 +73,5 @@ async release(instance, keyDef, position) { | ||
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 === null || mousemove === undefined ? undefined : mousemove.leave(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.enter(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.move(); | ||
this.mouse.down(instance, keyDef, pointer); | ||
@@ -81,5 +81,5 @@ } | ||
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 === null || mousemove === undefined ? undefined : mousemove.leave(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.enter(); | ||
mousemove === null || mousemove === undefined ? undefined : mousemove.move(); | ||
this.mouse.up(instance, keyDef, pointer); | ||
@@ -100,3 +100,3 @@ } | ||
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; | ||
return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== undefined ? _this_mouse_position_target : instance.config.document.body; | ||
} | ||
@@ -108,12 +108,10 @@ setMousePosition(position) { | ||
constructor(system){ | ||
_define_property(this, "system", void 0); | ||
_define_property(this, "mouse", void 0); | ||
_define_property(this, "buttons", void 0); | ||
_define_property(this, "system", undefined); | ||
_define_property(this, "mouse", undefined); | ||
_define_property(this, "buttons", undefined); | ||
_define_property(this, "devices", new class { | ||
get(k) { | ||
var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition | ||
_this_registry, _k; | ||
var _this_registry, _k; | ||
var _; | ||
(_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new Device(); | ||
return this.registry[k]; | ||
return (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== undefined ? _ : _this_registry[_k] = new Device(); | ||
} | ||
@@ -120,0 +118,0 @@ constructor(){ |
@@ -8,11 +8,5 @@ import '../../event/behavior/click.js'; | ||
import '@testing-library/dom'; | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import { isDisabled } from '../../utils/misc/isDisabled.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js'; | ||
import '../../utils/misc/level.js'; | ||
import '../../options.js'; | ||
import { focusElement } from '../../event/focus.js'; | ||
@@ -135,3 +129,3 @@ import { setSelectionPerMouseDown } from '../../event/selection/setSelectionPerMouse.js'; | ||
var _this_position_target; | ||
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body; | ||
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body; | ||
} | ||
@@ -144,4 +138,4 @@ startSelecting(instance, clickCount) { | ||
target: this.getTarget(instance), | ||
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, | ||
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node, | ||
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset, | ||
clickCount | ||
@@ -158,4 +152,4 @@ }); | ||
target: this.getTarget(instance), | ||
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 | ||
node: (_this_position_caret = this.position.caret) === null || _this_position_caret === undefined ? undefined : _this_position_caret.node, | ||
offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === undefined ? undefined : _this_position_caret1.offset | ||
}); | ||
@@ -169,3 +163,3 @@ } | ||
_define_property(this, "buttons", new Buttons()); | ||
_define_property(this, "selecting", void 0); | ||
_define_property(this, "selecting", undefined); | ||
_define_property(this, "buttonDownTarget", {}); | ||
@@ -193,7 +187,7 @@ // According to spec the `detail` on click events should be the number | ||
this.down = { | ||
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0 | ||
[button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== undefined ? _this_count_button : 0 | ||
}; | ||
var _this_count_button1; | ||
this.count = { | ||
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0 | ||
[button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== undefined ? _this_count_button1 : 0 | ||
}; | ||
@@ -200,0 +194,0 @@ return Number(this.count[button]) + 1; |
@@ -1,8 +0,3 @@ | ||
import '../../utils/click/isClickableInput.js'; | ||
import '../../utils/dataTransfer/Clipboard.js'; | ||
import '../../utils/edit/isEditable.js'; | ||
import '../../utils/edit/maxLength.js'; | ||
import '../../utils/keyDef/readNextDescriptor.js'; | ||
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js'; | ||
import '../../utils/misc/level.js'; | ||
import { assertPointerEvents, hasPointerEvents } from '../../utils/pointer/cssPointerEvents.js'; | ||
@@ -98,3 +93,3 @@ import { isDifferentPointerPosition } from './shared.js'; | ||
var _this_position_target; | ||
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body; | ||
return (_this_position_target = this.position.target) !== null && _this_position_target !== undefined ? _this_position_target : instance.config.document.body; | ||
} | ||
@@ -110,5 +105,5 @@ getEventInit() { | ||
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, "pointerId", undefined); | ||
_define_property(this, "pointerType", undefined); | ||
_define_property(this, "isPrimary", undefined); | ||
_define_property(this, "isMultitouch", false); | ||
@@ -115,0 +110,0 @@ _define_property(this, "isCancelled", false); |
function isDifferentPointerPosition(positionA, positionB) { | ||
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); | ||
var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_coords2, _positionB_coords2, _positionA_coords3, _positionB_coords3, _positionA_coords4, _positionB_coords4, _positionA_coords5, _positionB_coords5, _positionA_coords6, _positionB_coords6, _positionA_coords7, _positionB_coords7, _positionA_coords8, _positionB_coords8, _positionA_coords9, _positionB_coords9, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1; | ||
return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords === undefined ? undefined : _positionA_coords.x) !== ((_positionB_coords = positionB.coords) === null || _positionB_coords === undefined ? undefined : _positionB_coords.x) || ((_positionA_coords1 = positionA.coords) === null || _positionA_coords1 === undefined ? undefined : _positionA_coords1.y) !== ((_positionB_coords1 = positionB.coords) === null || _positionB_coords1 === undefined ? undefined : _positionB_coords1.y) || ((_positionA_coords2 = positionA.coords) === null || _positionA_coords2 === undefined ? undefined : _positionA_coords2.clientX) !== ((_positionB_coords2 = positionB.coords) === null || _positionB_coords2 === undefined ? undefined : _positionB_coords2.clientX) || ((_positionA_coords3 = positionA.coords) === null || _positionA_coords3 === undefined ? undefined : _positionA_coords3.clientY) !== ((_positionB_coords3 = positionB.coords) === null || _positionB_coords3 === undefined ? undefined : _positionB_coords3.clientY) || ((_positionA_coords4 = positionA.coords) === null || _positionA_coords4 === undefined ? undefined : _positionA_coords4.offsetX) !== ((_positionB_coords4 = positionB.coords) === null || _positionB_coords4 === undefined ? undefined : _positionB_coords4.offsetX) || ((_positionA_coords5 = positionA.coords) === null || _positionA_coords5 === undefined ? undefined : _positionA_coords5.offsetY) !== ((_positionB_coords5 = positionB.coords) === null || _positionB_coords5 === undefined ? undefined : _positionB_coords5.offsetY) || ((_positionA_coords6 = positionA.coords) === null || _positionA_coords6 === undefined ? undefined : _positionA_coords6.pageX) !== ((_positionB_coords6 = positionB.coords) === null || _positionB_coords6 === undefined ? undefined : _positionB_coords6.pageX) || ((_positionA_coords7 = positionA.coords) === null || _positionA_coords7 === undefined ? undefined : _positionA_coords7.pageY) !== ((_positionB_coords7 = positionB.coords) === null || _positionB_coords7 === undefined ? undefined : _positionB_coords7.pageY) || ((_positionA_coords8 = positionA.coords) === null || _positionA_coords8 === undefined ? undefined : _positionA_coords8.screenX) !== ((_positionB_coords8 = positionB.coords) === null || _positionB_coords8 === undefined ? undefined : _positionB_coords8.screenX) || ((_positionA_coords9 = positionA.coords) === null || _positionA_coords9 === undefined ? undefined : _positionA_coords9.screenY) !== ((_positionB_coords9 = positionB.coords) === null || _positionB_coords9 === undefined ? undefined : _positionB_coords9.screenY) || ((_positionA_caret = positionA.caret) === null || _positionA_caret === undefined ? undefined : _positionA_caret.node) !== ((_positionB_caret = positionB.caret) === null || _positionB_caret === undefined ? undefined : _positionB_caret.node) || ((_positionA_caret1 = positionA.caret) === null || _positionA_caret1 === undefined ? undefined : _positionA_caret1.offset) !== ((_positionB_caret1 = positionB.caret) === null || _positionB_caret1 === undefined ? undefined : _positionB_caret1.offset); | ||
} | ||
export { isDifferentPointerPosition }; |
@@ -8,10 +8,5 @@ import '../event/behavior/click.js'; | ||
import '@testing-library/dom'; | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import { isEditable } from '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { isDisabled } from '../utils/misc/isDisabled.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { focusElement } from '../event/focus.js'; | ||
@@ -18,0 +13,0 @@ import { input } from '../event/input.js'; |
import { getConfig } from '@testing-library/dom'; | ||
import '../utils/click/isClickableInput.js'; | ||
import { isElementType } from '../utils/misc/isElementType.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { isElementType } from '../utils/misc/isElementType.js'; | ||
import { isDisabled } from '../utils/misc/isDisabled.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import { wait } from '../utils/misc/wait.js'; | ||
@@ -11,0 +6,0 @@ import { hasPointerEvents } from '../utils/pointer/cssPointerEvents.js'; |
import { releaseAllKeys } from '../keyboard/index.js'; | ||
import '../utils/click/isClickableInput.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
import { setSelectionRange } from '../event/selection/setSelectionRange.js'; | ||
@@ -19,3 +13,3 @@ | ||
if (initialSelectionStart !== undefined) { | ||
setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== void 0 ? initialSelectionEnd : initialSelectionStart); | ||
setSelectionRange(element, initialSelectionStart, initialSelectionEnd !== null && initialSelectionEnd !== undefined ? initialSelectionEnd : initialSelectionStart); | ||
} | ||
@@ -22,0 +16,0 @@ await this.keyboard(text); |
@@ -1,13 +0,7 @@ | ||
import '../utils/click/isClickableInput.js'; | ||
import { isElementType } from '../utils/misc/isElementType.js'; | ||
import { createFileList } from '../utils/dataTransfer/FileList.js'; | ||
import '../utils/dataTransfer/Clipboard.js'; | ||
import '../utils/edit/isEditable.js'; | ||
import '../utils/edit/maxLength.js'; | ||
import { setFiles } from '../utils/edit/setFiles.js'; | ||
import { isElementType } from '../utils/misc/isElementType.js'; | ||
import { isDisabled } from '../utils/misc/isDisabled.js'; | ||
import { getWindow } from '../utils/misc/getWindow.js'; | ||
import '../utils/keyDef/readNextDescriptor.js'; | ||
import '../utils/misc/level.js'; | ||
import '../options.js'; | ||
@@ -19,3 +13,3 @@ async function upload(element, fileOrFiles) { | ||
})) { | ||
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`); | ||
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === undefined ? undefined : input.tagName} element does not accept file uploads`); | ||
} | ||
@@ -29,5 +23,5 @@ if (isDisabled(element)) return; | ||
// do not fire an input event if the file selection does not change | ||
if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{ | ||
if (files.length === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _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)); | ||
return f === ((_input_files = input.files) === null || _input_files === undefined ? undefined : _input_files.item(i)); | ||
})) { | ||
@@ -34,0 +28,0 @@ return; |
import { isElementType } from '../misc/isElementType.js'; | ||
var clickableInputTypes; | ||
(function(clickableInputTypes) { | ||
var clickableInputTypes = /*#__PURE__*/ function(clickableInputTypes) { | ||
clickableInputTypes["button"] = "button"; | ||
@@ -13,3 +12,4 @@ clickableInputTypes["color"] = "color"; | ||
clickableInputTypes["radio"] = "radio"; | ||
})(clickableInputTypes || (clickableInputTypes = {})); | ||
return clickableInputTypes; | ||
}(clickableInputTypes || {}); | ||
function isClickableInput(element) { | ||
@@ -16,0 +16,0 @@ return isElementType(element, 'button') || isElementType(element, 'input') && element.type in clickableInputTypes; |
@@ -47,3 +47,3 @@ import { getWindow } from '../misc/getWindow.js'; | ||
constructor(d){ | ||
_define_property(this, "data", void 0); | ||
_define_property(this, "data", undefined); | ||
this.data = d; | ||
@@ -78,4 +78,3 @@ } | ||
constructor(...args){ | ||
super(...args); | ||
_define_property(this, "items", []); | ||
super(...args), _define_property(this, "items", []); | ||
} | ||
@@ -87,3 +86,3 @@ }(), { | ||
function isClipboardStub(clipboard) { | ||
return !!(clipboard === null || clipboard === void 0 ? void 0 : clipboard[ClipboardStubControl]); | ||
return !!(clipboard === null || clipboard === undefined ? undefined : clipboard[ClipboardStubControl]); | ||
} | ||
@@ -130,3 +129,3 @@ function attachClipboardStubToView(window) { | ||
const window = document.defaultView; | ||
const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard; | ||
const clipboard = window === null || window === undefined ? undefined : window.navigator.clipboard; | ||
const items = clipboard && await clipboard.read(); | ||
@@ -150,3 +149,3 @@ if (!items) { | ||
const dtItem = clipboardData.items[i]; | ||
const blob = getBlobFromDataTransferItem(window, dtItem); | ||
const blob = await getBlobFromDataTransferItem(window, dtItem); | ||
items.push(createClipboardItem(window, blob)); | ||
@@ -153,0 +152,0 @@ } |
@@ -31,4 +31,4 @@ import { createFileList } from './FileList.js'; | ||
constructor(dataOrFile, type){ | ||
_define_property(this, "kind", void 0); | ||
_define_property(this, "type", void 0); | ||
_define_property(this, "kind", undefined); | ||
_define_property(this, "type", undefined); | ||
_define_property(this, "file", null); | ||
@@ -71,5 +71,5 @@ _define_property(this, "data", undefined); | ||
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)); | ||
const match = (_this_items_find = this.items.find(getTypeMatcher(format, true))) !== null && _this_items_find !== undefined ? _this_items_find : this.items.find(getTypeMatcher(format, false)); | ||
let text = ''; | ||
match === null || match === void 0 ? void 0 : match.getAsString((t)=>{ | ||
match === null || match === undefined ? undefined : match.getAsString((t)=>{ | ||
text = t; | ||
@@ -124,12 +124,8 @@ }); | ||
} | ||
function getBlobFromDataTransferItem(window, item) { | ||
async function getBlobFromDataTransferItem(window, item) { | ||
if (item.kind === 'file') { | ||
return item.getAsFile(); | ||
} | ||
let data = ''; | ||
item.getAsString((s)=>{ | ||
data = s; | ||
}); | ||
return new window.Blob([ | ||
data | ||
await new Promise((r)=>item.getAsString(r)) | ||
], { | ||
@@ -136,0 +132,0 @@ type: item.type |
@@ -7,4 +7,3 @@ import { isElementType } from '../misc/isElementType.js'; | ||
} | ||
var editableInputTypes; | ||
(function(editableInputTypes) { | ||
var editableInputTypes = /*#__PURE__*/ function(editableInputTypes) { | ||
editableInputTypes["text"] = "text"; | ||
@@ -22,3 +21,4 @@ editableInputTypes["date"] = "date"; | ||
editableInputTypes["week"] = "week"; | ||
})(editableInputTypes || (editableInputTypes = {})); | ||
return editableInputTypes; | ||
}(editableInputTypes || {}); | ||
function isEditableInputOrTextArea(element) { | ||
@@ -25,0 +25,0 @@ return isElementType(element, 'textarea') || isElementType(element, 'input') && element.type in editableInputTypes; |
import { isElementType } from '../misc/isElementType.js'; | ||
var maxLengthSupportedTypes; | ||
(function(maxLengthSupportedTypes) { | ||
var maxLengthSupportedTypes = /*#__PURE__*/ function(maxLengthSupportedTypes) { | ||
maxLengthSupportedTypes["email"] = "email"; | ||
@@ -11,3 +10,4 @@ maxLengthSupportedTypes["password"] = "password"; | ||
maxLengthSupportedTypes["url"] = "url"; | ||
})(maxLengthSupportedTypes || (maxLengthSupportedTypes = {})); | ||
return maxLengthSupportedTypes; | ||
}(maxLengthSupportedTypes || {}); | ||
// can't use .maxLength property because of a jsdom bug: | ||
@@ -17,3 +17,3 @@ // https://github.com/jsdom/jsdom/issues/2927 | ||
var _element_getAttribute; | ||
const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== void 0 ? _element_getAttribute : ''; | ||
const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== undefined ? _element_getAttribute : ''; | ||
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined; | ||
@@ -20,0 +20,0 @@ } |
@@ -15,3 +15,3 @@ // It is not possible to create a real FileList programmatically. | ||
var _el_fakeFiles; | ||
(_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === void 0 ? void 0 : _el_fakeFiles.restore(); | ||
(_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === undefined ? undefined : _el_fakeFiles.restore(); | ||
const typeDescr = Object.getOwnPropertyDescriptor(el, 'type'); | ||
@@ -41,3 +41,3 @@ const valueDescr = Object.getOwnPropertyDescriptor(el, 'value'); | ||
var _valueDescr_set; | ||
valueDescr === null || valueDescr === void 0 ? void 0 : (_valueDescr_set = valueDescr.set) === null || _valueDescr_set === void 0 ? void 0 : _valueDescr_set.call(el, v); | ||
valueDescr === null || valueDescr === undefined ? undefined : (_valueDescr_set = valueDescr.set) === null || _valueDescr_set === undefined ? undefined : _valueDescr_set.call(el, v); | ||
} | ||
@@ -44,0 +44,0 @@ } |
@@ -110,3 +110,3 @@ import { isContentEditable } from '../edit/isContentEditable.js'; | ||
} | ||
} 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))) { | ||
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === undefined ? undefined : _node_ownerDocument.body))) { | ||
node = node.parentNode; | ||
@@ -113,0 +113,0 @@ } else { |
@@ -5,3 +5,3 @@ import { isDisabled } from '../misc/isDisabled.js'; | ||
const activeElement = document.activeElement; | ||
if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.shadowRoot) { | ||
if (activeElement === null || activeElement === undefined ? undefined : activeElement.shadowRoot) { | ||
return getActiveElement(activeElement.shadowRoot); | ||
@@ -18,5 +18,5 @@ } else { | ||
var _getActiveElement; | ||
return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== void 0 ? _getActiveElement : /* istanbul ignore next */ document.body; | ||
return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== undefined ? _getActiveElement : /* istanbul ignore next */ document.body; | ||
} | ||
export { getActiveElement, getActiveElementOrBody }; |
@@ -1,6 +0,6 @@ | ||
var bracketDict; | ||
(function(bracketDict) { | ||
var bracketDict = /*#__PURE__*/ function(bracketDict) { | ||
bracketDict["{"] = "}"; | ||
bracketDict["["] = "]"; | ||
})(bracketDict || (bracketDict = {})); | ||
return bracketDict; | ||
}(bracketDict || {}); | ||
/** | ||
@@ -45,7 +45,7 @@ * Read the next key definition from user input | ||
pos += Number(escapedDescriptor); | ||
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]; | ||
const descriptor = escapedDescriptor ? text[pos] : (_text_slice_match = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || _text_slice_match === undefined ? undefined : _text_slice_match[0]; | ||
assertDescriptor(descriptor, text, pos, context); | ||
pos += descriptor.length; | ||
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_ : ''; | ||
const repeatModifier = (_text_slice_match_ = (_text_slice_match1 = text.slice(pos).match(/^>\d+/)) === null || _text_slice_match1 === undefined ? undefined : _text_slice_match1[0]) !== null && _text_slice_match_ !== undefined ? _text_slice_match_ : ''; | ||
pos += repeatModifier.length; | ||
@@ -86,3 +86,3 @@ const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : ''; | ||
function getErrorMessage(expected, found, text, context) { | ||
return `Expected ${expected} but found "${found !== null && found !== void 0 ? found : ''}" in "${text}" | ||
return `Expected ${expected} but found "${found !== null && found !== undefined ? found : ''}" in "${text}" | ||
See ${context === 'pointer' ? `https://testing-library.com/docs/user-event/pointer#pressing-a-button-or-touching-the-screen` : `https://testing-library.com/docs/user-event/keyboard`} | ||
@@ -89,0 +89,0 @@ for more information about how userEvent parses your input.`; |
@@ -5,3 +5,3 @@ function getWindow(node) { | ||
return node.defaultView; | ||
} else if ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === void 0 ? void 0 : _node_ownerDocument.defaultView) { | ||
} else if ((_node_ownerDocument = node.ownerDocument) === null || _node_ownerDocument === undefined ? undefined : _node_ownerDocument.defaultView) { | ||
return node.ownerDocument.defaultView; | ||
@@ -8,0 +8,0 @@ } |
@@ -19,3 +19,3 @@ import { isElementType } from './isElementType.js'; | ||
var _el_querySelector; | ||
if (el.hasAttribute('disabled') && !((_el_querySelector = el.querySelector(':scope > legend')) === null || _el_querySelector === void 0 ? void 0 : _el_querySelector.contains(element))) { | ||
if (el.hasAttribute('disabled') && !((_el_querySelector = el.querySelector(':scope > legend')) === null || _el_querySelector === undefined ? undefined : _el_querySelector.contains(element))) { | ||
return true; | ||
@@ -22,0 +22,0 @@ } |
@@ -5,3 +5,3 @@ import { getWindow } from './getWindow.js'; | ||
const window = getWindow(element); | ||
for(let el = element; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){ | ||
for(let el = element; el === null || el === undefined ? undefined : el.ownerDocument; el = el.parentElement){ | ||
const { display, visibility } = window.getComputedStyle(el); | ||
@@ -8,0 +8,0 @@ if (display === 'none') { |
@@ -1,6 +0,6 @@ | ||
var ApiLevel; | ||
(function(ApiLevel) { | ||
var ApiLevel = /*#__PURE__*/ function(ApiLevel) { | ||
ApiLevel[ApiLevel["Trigger"] = 2] = "Trigger"; | ||
ApiLevel[ApiLevel["Call"] = 1] = "Call"; | ||
})(ApiLevel || (ApiLevel = {})); | ||
return ApiLevel; | ||
}({}); | ||
function setLevelRef(instance, level) { | ||
@@ -7,0 +7,0 @@ instance.levelRefs[level] = {}; |
@@ -8,7 +8,7 @@ import { PointerEventsCheckLevel } from '../../options.js'; | ||
var _checkPointerEvents; | ||
return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === void 0 ? void 0 : _checkPointerEvents.pointerEvents) !== 'none'; | ||
return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === undefined ? undefined : _checkPointerEvents.pointerEvents) !== 'none'; | ||
} | ||
function closestPointerEventsDeclaration(element) { | ||
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 === null || el === undefined ? undefined : el.ownerDocument; el = el.parentElement){ | ||
tree.push(el); | ||
@@ -33,3 +33,3 @@ const pointerEvents = window.getComputedStyle(el).pointerEvents; | ||
if (!needsCheck) { | ||
return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result; | ||
return lastCheck === null || lastCheck === undefined ? undefined : lastCheck.result; | ||
} | ||
@@ -46,3 +46,3 @@ const declaration = closestPointerEventsDeclaration(element); | ||
const declaration = checkPointerEvents(instance, element); | ||
if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') { | ||
if ((declaration === null || declaration === undefined ? undefined : declaration.pointerEvents) === 'none') { | ||
throw new Error([ | ||
@@ -73,3 +73,3 @@ `Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`, | ||
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(); | ||
label = (_element_ownerDocument_getElementById = element.ownerDocument.getElementById(element.getAttribute('aria-labelledby'))) === null || _element_ownerDocument_getElementById === undefined ? undefined : (_element_ownerDocument_getElementById_textContent = _element_ownerDocument_getElementById.textContent) === null || _element_ownerDocument_getElementById_textContent === undefined ? undefined : _element_ownerDocument_getElementById_textContent.trim(); | ||
} else if (isElementType(element, [ | ||
@@ -83,14 +83,14 @@ 'button', | ||
'textarea' | ||
]) && ((_element_labels = element.labels) === null || _element_labels === void 0 ? void 0 : _element_labels.length)) { | ||
]) && ((_element_labels = element.labels) === null || _element_labels === undefined ? undefined : _element_labels.length)) { | ||
label = Array.from(element.labels).map((el)=>{ | ||
var _el_textContent; | ||
return (_el_textContent = el.textContent) === null || _el_textContent === void 0 ? void 0 : _el_textContent.trim(); | ||
return (_el_textContent = el.textContent) === null || _el_textContent === undefined ? undefined : _el_textContent.trim(); | ||
}).join('|'); | ||
} else if (isElementType(element, 'button')) { | ||
var _element_textContent; | ||
label = (_element_textContent = element.textContent) === null || _element_textContent === void 0 ? void 0 : _element_textContent.trim(); | ||
label = (_element_textContent = element.textContent) === null || _element_textContent === undefined ? undefined : _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 === null || label === undefined ? undefined : label.replace(/\n/g, ' '); | ||
if (Number(label === null || label === undefined ? undefined : label.length) > 30) { | ||
label = `${label === null || label === undefined ? undefined : label.substring(0, 29)}…`; | ||
} | ||
@@ -97,0 +97,0 @@ return label ? `(label=${label})` : ''; |
@@ -19,2 +19,10 @@ import { EventType } from './types'; | ||
}; | ||
readonly blur: { | ||
readonly EventType: "FocusEvent"; | ||
readonly defaultInit: { | ||
readonly bubbles: false; | ||
readonly cancelable: false; | ||
readonly composed: true; | ||
}; | ||
}; | ||
readonly click: { | ||
@@ -67,2 +75,26 @@ readonly EventType: "PointerEvent"; | ||
}; | ||
readonly focus: { | ||
readonly EventType: "FocusEvent"; | ||
readonly defaultInit: { | ||
readonly bubbles: false; | ||
readonly cancelable: false; | ||
readonly composed: true; | ||
}; | ||
}; | ||
readonly focusin: { | ||
readonly EventType: "FocusEvent"; | ||
readonly defaultInit: { | ||
readonly bubbles: true; | ||
readonly cancelable: false; | ||
readonly composed: true; | ||
}; | ||
}; | ||
readonly focusout: { | ||
readonly EventType: "FocusEvent"; | ||
readonly defaultInit: { | ||
readonly bubbles: true; | ||
readonly cancelable: false; | ||
readonly composed: true; | ||
}; | ||
}; | ||
readonly keydown: { | ||
@@ -69,0 +101,0 @@ readonly EventType: "KeyboardEvent"; |
@@ -7,3 +7,3 @@ import { eventMap } from './eventMap'; | ||
} | ||
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 FocusEvent ? FocusEventInit : E extends UIEvent ? UIEventInit : EventInit; | ||
export interface PointerCoords { | ||
@@ -10,0 +10,0 @@ x?: number; |
@@ -38,6 +38,3 @@ import { type Instance } from '../setup'; | ||
}; | ||
readonly pressed: Record<string, { | ||
keyDef: keyboardKey; | ||
unpreventedDefault: boolean; | ||
}>; | ||
private readonly pressed; | ||
carryChar: string; | ||
@@ -44,0 +41,0 @@ private lastKeydownTarget; |
export declare function createDataTransfer(window: Window & typeof globalThis, files?: File[]): DataTransfer; | ||
export declare function getBlobFromDataTransferItem(window: Window & typeof globalThis, item: DataTransferItem): Blob; | ||
export declare function getBlobFromDataTransferItem(window: Window & typeof globalThis, item: DataTransferItem): Promise<Blob>; |
{ | ||
"name": "@testing-library/user-event", | ||
"version": "14.5.2", | ||
"version": "14.6.0", | ||
"description": "Fire events the same way the user does", | ||
@@ -44,5 +44,5 @@ "keywords": [ | ||
"@ph.fritsche/toolbox": "^1.0.0-alpha.11", | ||
"@testing-library/dom": "^8.19.0", | ||
"@testing-library/dom": "^10.4.0", | ||
"@testing-library/jest-dom": "^5.16.3", | ||
"@testing-library/react": "^13.4.0", | ||
"@testing-library/react": "^16.1.0", | ||
"@types/jest-in-case": "^1.0.3", | ||
@@ -49,0 +49,0 @@ "@types/react": "^18.0.25", |
308
434957
10783