@testing-library/user-event 14.5.0 → 14.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/dist/cjs/_interop/dtl.js +4 -7
  2. package/dist/cjs/_interop/dtlEventMap.js +4 -7
  3. package/dist/cjs/_interop/dtlHelpers.js +4 -7
  4. package/dist/cjs/document/interceptor.js +3 -5
  5. package/dist/cjs/document/trackValue.js +2 -2
  6. package/dist/cjs/event/behavior/keydown.js +2 -2
  7. package/dist/cjs/event/behavior/keypress.js +1 -2
  8. package/dist/cjs/event/behavior/keyup.js +2 -2
  9. package/dist/cjs/event/dispatchEvent.js +2 -2
  10. package/dist/cjs/event/eventMap.js +22 -2
  11. package/dist/cjs/event/focus.js +1 -4
  12. package/dist/cjs/event/selection/getTargetTypeAndSelection.js +2 -3
  13. package/dist/cjs/event/selection/modifySelectionPerMouse.js +2 -3
  14. package/dist/cjs/event/selection/moveSelection.js +1 -2
  15. package/dist/cjs/event/selection/selectAll.js +1 -2
  16. package/dist/cjs/event/selection/setSelectionPerMouse.js +2 -3
  17. package/dist/cjs/event/selection/updateSelectionOnFocus.js +1 -2
  18. package/dist/cjs/event/wrapEvent.js +22 -2
  19. package/dist/cjs/pointer/index.js +4 -4
  20. package/dist/cjs/setup/wrapAsync.js +22 -2
  21. package/dist/cjs/system/pointer/index.js +12 -15
  22. package/dist/cjs/utility/selectOptions.js +22 -2
  23. package/dist/cjs/utility/upload.js +1 -2
  24. package/dist/cjs/utils/dataTransfer/Clipboard.js +2 -4
  25. package/dist/cjs/utils/dataTransfer/DataTransfer.js +1 -2
  26. package/dist/cjs/utils/edit/setFiles.js +2 -2
  27. package/dist/cjs/utils/focus/getActiveElement.js +1 -2
  28. package/dist/cjs/utils/misc/getWindow.js +22 -2
  29. package/dist/cjs/utils/misc/isVisible.js +1 -2
  30. package/dist/cjs/utils/pointer/cssPointerEvents.js +7 -11
  31. package/dist/esm/_interop/dtl.js +2 -6
  32. package/dist/esm/_interop/dtlEventMap.js +2 -6
  33. package/dist/esm/_interop/dtlHelpers.js +2 -6
  34. package/dist/esm/document/interceptor.js +3 -5
  35. package/dist/esm/document/trackValue.js +2 -2
  36. package/dist/esm/event/behavior/keydown.js +2 -2
  37. package/dist/esm/event/behavior/keypress.js +1 -2
  38. package/dist/esm/event/behavior/keyup.js +2 -2
  39. package/dist/esm/event/dispatchEvent.js +2 -2
  40. package/dist/esm/event/eventMap.js +2 -2
  41. package/dist/esm/event/focus.js +1 -4
  42. package/dist/esm/event/selection/getTargetTypeAndSelection.js +2 -3
  43. package/dist/esm/event/selection/modifySelectionPerMouse.js +2 -3
  44. package/dist/esm/event/selection/moveSelection.js +1 -2
  45. package/dist/esm/event/selection/selectAll.js +1 -2
  46. package/dist/esm/event/selection/setSelectionPerMouse.js +2 -3
  47. package/dist/esm/event/selection/updateSelectionOnFocus.js +1 -2
  48. package/dist/esm/event/wrapEvent.js +2 -2
  49. package/dist/esm/pointer/index.js +4 -4
  50. package/dist/esm/setup/wrapAsync.js +2 -2
  51. package/dist/esm/system/pointer/index.js +12 -15
  52. package/dist/esm/utility/selectOptions.js +2 -2
  53. package/dist/esm/utility/upload.js +1 -2
  54. package/dist/esm/utils/dataTransfer/Clipboard.js +2 -4
  55. package/dist/esm/utils/dataTransfer/DataTransfer.js +1 -2
  56. package/dist/esm/utils/edit/setFiles.js +2 -2
  57. package/dist/esm/utils/focus/getActiveElement.js +1 -2
  58. package/dist/esm/utils/misc/getWindow.js +2 -2
  59. package/dist/esm/utils/misc/isVisible.js +1 -2
  60. package/dist/esm/utils/pointer/cssPointerEvents.js +7 -11
  61. package/dist/types/_interop/dtl.d.ts +2 -3
  62. package/dist/types/_interop/dtlEventMap.d.ts +2 -3
  63. package/dist/types/_interop/dtlHelpers.d.ts +2 -3
  64. package/package.json +1 -1
@@ -12,9 +12,8 @@ function hasPointerEvents(instance, element) {
12
12
  return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === void 0 ? void 0 : _checkPointerEvents.pointerEvents) !== 'none';
13
13
  }
14
14
  function closestPointerEventsDeclaration(element) {
15
- var _el;
16
15
  const window = getWindow.getWindow(element);
17
- for(let el = element, tree = []; (_el = el) === null || _el === void 0 ? void 0 : _el.ownerDocument; el = el.parentElement){
16
+ for(let el = element, tree = []; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
18
17
  tree.push(el);
19
18
  const pointerEvents = window.getComputedStyle(el).pointerEvents;
20
19
  if (pointerEvents && ![
@@ -34,8 +33,7 @@ function checkPointerEvents(instance, element) {
34
33
  const lastCheck = element[PointerEventsCheck];
35
34
  const needsCheck = instance.config.pointerEventsCheck !== options.PointerEventsCheckLevel.Never && (!lastCheck || hasBitFlag(instance.config.pointerEventsCheck, options.PointerEventsCheckLevel.EachApiCall) && lastCheck[level.ApiLevel.Call] !== level.getLevelRef(instance, level.ApiLevel.Call) || hasBitFlag(instance.config.pointerEventsCheck, options.PointerEventsCheckLevel.EachTrigger) && lastCheck[level.ApiLevel.Trigger] !== level.getLevelRef(instance, level.ApiLevel.Trigger));
36
35
  if (!needsCheck) {
37
- var _lastCheck;
38
- return (_lastCheck = lastCheck) === null || _lastCheck === void 0 ? void 0 : _lastCheck.result;
36
+ return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result;
39
37
  }
40
38
  const declaration = closestPointerEventsDeclaration(element);
41
39
  element[PointerEventsCheck] = {
@@ -46,9 +44,8 @@ function checkPointerEvents(instance, element) {
46
44
  return declaration;
47
45
  }
48
46
  function assertPointerEvents(instance, element) {
49
- var _declaration;
50
47
  const declaration = checkPointerEvents(instance, element);
51
- if (((_declaration = declaration) === null || _declaration === void 0 ? void 0 : _declaration.pointerEvents) === 'none') {
48
+ if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') {
52
49
  throw new Error([
53
50
  `Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`,
54
51
  '',
@@ -68,7 +65,7 @@ function printTree(tree) {
68
65
  ].filter(Boolean).join('')).join('\n');
69
66
  }
70
67
  function getLabelDescr(element) {
71
- var _element_labels, _label, _label1;
68
+ var _element_labels;
72
69
  let label;
73
70
  if (element.hasAttribute('aria-label')) {
74
71
  label = element.getAttribute('aria-label');
@@ -92,10 +89,9 @@ function getLabelDescr(element) {
92
89
  var _element_textContent;
93
90
  label = (_element_textContent = element.textContent) === null || _element_textContent === void 0 ? void 0 : _element_textContent.trim();
94
91
  }
95
- label = (_label = label) === null || _label === void 0 ? void 0 : _label.replace(/\n/g, ' ');
96
- if (Number((_label1 = label) === null || _label1 === void 0 ? void 0 : _label1.length) > 30) {
97
- var _label2;
98
- label = `${(_label2 = label) === null || _label2 === void 0 ? void 0 : _label2.substring(0, 29)}…`;
92
+ label = label === null || label === void 0 ? void 0 : label.replace(/\n/g, ' ');
93
+ if (Number(label === null || label === void 0 ? void 0 : label.length) > 30) {
94
+ label = `${label === null || label === void 0 ? void 0 : label.substring(0, 29)}…`;
99
95
  }
100
96
  return label ? `(label=${label})` : '';
101
97
  }
@@ -1,6 +1,2 @@
1
- import * as def from '@testing-library/dom';
2
- import def__default from '@testing-library/dom';
3
-
4
- var dtl = def__default !== null && def__default !== void 0 ? def__default : def;
5
-
6
- export { dtl as default };
1
+ import * as named from '@testing-library/dom';
2
+ export { named as default };
@@ -1,6 +1,2 @@
1
- import * as def from '@testing-library/dom/dist/event-map.js';
2
- import def__default from '@testing-library/dom/dist/event-map.js';
3
-
4
- var dtlEvents = def__default !== null && def__default !== void 0 ? def__default : def;
5
-
6
- export { dtlEvents as default };
1
+ import * as named from '@testing-library/dom/dist/event-map.js';
2
+ export { named as default };
@@ -1,6 +1,2 @@
1
- import * as def from '@testing-library/dom/dist/helpers.js';
2
- import def__default from '@testing-library/dom/dist/helpers.js';
3
-
4
- var dtlHelpers = def__default !== null && def__default !== void 0 ? def__default : def;
5
-
6
- export { dtlHelpers as default };
1
+ import * as named from '@testing-library/dom/dist/helpers.js';
2
+ export { named as default };
@@ -12,15 +12,13 @@ import { setUISelectionClean, setUISelectionRaw, getUIValue, setUIValueClean, is
12
12
 
13
13
  const Interceptor = Symbol('Interceptor for programmatical calls');
14
14
  function prepareInterceptor(element, propName, interceptorImpl) {
15
- var _prototypeDescriptor, _prototypeDescriptor1;
16
15
  const prototypeDescriptor = Object.getOwnPropertyDescriptor(element.constructor.prototype, propName);
17
16
  const objectDescriptor = Object.getOwnPropertyDescriptor(element, propName);
18
- const target = ((_prototypeDescriptor = prototypeDescriptor) === null || _prototypeDescriptor === void 0 ? void 0 : _prototypeDescriptor.set) ? 'set' : 'value';
19
- /* istanbul ignore if */ if (typeof ((_prototypeDescriptor1 = prototypeDescriptor) === null || _prototypeDescriptor1 === void 0 ? void 0 : _prototypeDescriptor1[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
17
+ const target = (prototypeDescriptor === null || prototypeDescriptor === void 0 ? void 0 : prototypeDescriptor.set) ? 'set' : 'value';
18
+ /* istanbul ignore if */ if (typeof (prototypeDescriptor === null || prototypeDescriptor === void 0 ? void 0 : prototypeDescriptor[target]) !== 'function' || prototypeDescriptor[target][Interceptor]) {
20
19
  throw new Error(`Element ${element.tagName} does not implement "${String(propName)}".`);
21
20
  }
22
21
  function intercept(...args) {
23
- var _then;
24
22
  const { applyNative = false, realArgs, then } = interceptorImpl.call(this, ...args);
25
23
  const realFunc = (!applyNative && objectDescriptor || prototypeDescriptor)[target];
26
24
  if (target === 'set') {
@@ -28,7 +26,7 @@ function prepareInterceptor(element, propName, interceptorImpl) {
28
26
  } else {
29
27
  realFunc.call(this, ...realArgs);
30
28
  }
31
- (_then = then) === null || _then === void 0 ? void 0 : _then();
29
+ then === null || then === void 0 ? void 0 : then();
32
30
  }
33
31
  intercept[Interceptor] = Interceptor;
34
32
  Object.defineProperty(element, propName, {
@@ -39,10 +39,10 @@ function trackOrSetValue(element, v) {
39
39
  }
40
40
  }
41
41
  function commitValueAfterInput(element, cursorOffset) {
42
- var _changes_tracked, _changes;
42
+ var _changes_tracked;
43
43
  const changes = element[TrackChanges];
44
44
  element[TrackChanges] = undefined;
45
- if (!((_changes = changes) === null || _changes === void 0 ? void 0 : (_changes_tracked = _changes.tracked) === null || _changes_tracked === void 0 ? void 0 : _changes_tracked.length)) {
45
+ if (!(changes === null || changes === void 0 ? void 0 : (_changes_tracked = changes.tracked) === null || _changes_tracked === void 0 ? void 0 : _changes_tracked.length)) {
46
46
  return;
47
47
  }
48
48
  const isJustReactStateUpdate = changes.tracked.length === 2 && changes.tracked[0] === changes.previousValue && changes.tracked[1] === element.value;
@@ -21,9 +21,9 @@ import { walkRadio } from '../radio.js';
21
21
  import { behavior } from './registry.js';
22
22
 
23
23
  behavior.keydown = (event, target, instance)=>{
24
- var _keydownBehavior_event_key, _keydownBehavior;
24
+ var _keydownBehavior_event_key;
25
25
  var _keydownBehavior_event_key1;
26
- return (_keydownBehavior_event_key1 = (_keydownBehavior_event_key = (_keydownBehavior = keydownBehavior)[event.key]) === null || _keydownBehavior_event_key === void 0 ? void 0 : _keydownBehavior_event_key.call(_keydownBehavior, event, target, instance)) !== null && _keydownBehavior_event_key1 !== void 0 ? _keydownBehavior_event_key1 : combinationBehavior(event, target, instance);
26
+ 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);
27
27
  };
28
28
  const keydownBehavior = {
29
29
  ArrowDown: (event, target, instance)=>{
@@ -18,9 +18,8 @@ behavior.keypress = (event, target, instance)=>{
18
18
  instance.dispatchUIEvent(target, 'click');
19
19
  };
20
20
  } else if (isElementType(target, 'input')) {
21
- var _form;
22
21
  const form = target.form;
23
- const submit = (_form = form) === null || _form === void 0 ? void 0 : _form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
22
+ const submit = form === null || form === void 0 ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]');
24
23
  if (submit) {
25
24
  return ()=>instance.dispatchUIEvent(submit, 'click');
26
25
  } else if (form && SubmitSingleInputOnEnter.includes(target.type) && form.querySelectorAll('input').length === 1) {
@@ -9,8 +9,8 @@ import '../../options.js';
9
9
  import { behavior } from './registry.js';
10
10
 
11
11
  behavior.keyup = (event, target, instance)=>{
12
- var _keyupBehavior_event_key, _keyupBehavior;
13
- return (_keyupBehavior_event_key = (_keyupBehavior = keyupBehavior)[event.key]) === null || _keyupBehavior_event_key === void 0 ? void 0 : _keyupBehavior_event_key.call(_keyupBehavior, event, target, instance);
12
+ var _keyupBehavior_event_key;
13
+ return (_keyupBehavior_event_key = keyupBehavior[event.key]) === null || _keyupBehavior_event_key === void 0 ? void 0 : _keyupBehavior_event_key.call(keyupBehavior, event, target, instance);
14
14
  };
15
15
  const keyupBehavior = {
16
16
  ' ': (event, target, instance)=>{
@@ -20,9 +20,9 @@ function dispatchUIEvent(target, type, init, preventDefault = false) {
20
20
  return dispatchEvent.call(this, target, event, preventDefault);
21
21
  }
22
22
  function dispatchEvent(target, event, preventDefault = false) {
23
- var _behavior_type, _behavior;
23
+ var _behavior_type;
24
24
  const type = event.type;
25
- const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = (_behavior = behavior)[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(_behavior, event, target, this);
25
+ const behaviorImplementation = preventDefault ? ()=>{} : (_behavior_type = behavior[type]) === null || _behavior_type === void 0 ? void 0 : _behavior_type.call(behavior, event, target, this);
26
26
  if (behaviorImplementation) {
27
27
  event.preventDefault();
28
28
  let defaultPrevented = false;
@@ -1,7 +1,7 @@
1
- import dtlEvents from '../_interop/dtlEventMap.js';
1
+ import * as named from '@testing-library/dom/dist/event-map.js';
2
2
 
3
3
  const eventMap = {
4
- ...dtlEvents.eventMap,
4
+ ...named.eventMap,
5
5
  click: {
6
6
  EventType: 'PointerEvent',
7
7
  defaultInit: {
@@ -22,10 +22,7 @@ import { wrapEvent } from './wrapEvent.js';
22
22
  } else if (target) {
23
23
  wrapEvent(()=>target.focus());
24
24
  } else {
25
- wrapEvent(()=>{
26
- var _activeElement;
27
- return (_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.blur();
28
- });
25
+ wrapEvent(()=>activeElement === null || activeElement === void 0 ? void 0 : activeElement.blur());
29
26
  }
30
27
  updateSelectionOnFocus(target !== null && target !== void 0 ? target : element.ownerDocument.body);
31
28
  }
@@ -13,7 +13,6 @@ import '../../options.js';
13
13
  /**
14
14
  * Determine which selection logic and selection ranges to consider.
15
15
  */ function getTargetTypeAndSelection(node) {
16
- var _element, _selection;
17
16
  const element = getElement(node);
18
17
  if (element && hasOwnSelection(element)) {
19
18
  return {
@@ -21,10 +20,10 @@ import '../../options.js';
21
20
  selection: getUISelection(element)
22
21
  };
23
22
  }
24
- const selection = (_element = element) === null || _element === void 0 ? void 0 : _element.ownerDocument.getSelection();
23
+ const selection = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection();
25
24
  // It is possible to extend a single-range selection into a contenteditable.
26
25
  // This results in the range acting like a range outside of contenteditable.
27
- const isCE = getContentEditable(node) && ((_selection = selection) === null || _selection === void 0 ? void 0 : _selection.anchorNode) && getContentEditable(selection.anchorNode);
26
+ const isCE = getContentEditable(node) && (selection === null || selection === void 0 ? void 0 : selection.anchorNode) && getContentEditable(selection.anchorNode);
28
27
  return {
29
28
  type: isCE ? 'contenteditable' : 'default',
30
29
  selection
@@ -29,7 +29,6 @@ function modifySelectionPerMouseMove(selectionRange, { document, target, node, o
29
29
  });
30
30
  }
31
31
  } else {
32
- var _selection, _selection1;
33
32
  const range = selectionRange.cloneRange();
34
33
  const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);
35
34
  if (cmp < 0) {
@@ -38,8 +37,8 @@ function modifySelectionPerMouseMove(selectionRange, { document, target, node, o
38
37
  range.setEnd(selectionFocus.node, selectionFocus.offset);
39
38
  }
40
39
  const selection = document.getSelection();
41
- (_selection = selection) === null || _selection === void 0 ? void 0 : _selection.removeAllRanges();
42
- (_selection1 = selection) === null || _selection1 === void 0 ? void 0 : _selection1.addRange(range.cloneRange());
40
+ selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
41
+ selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
43
42
  }
44
43
  }
45
44
 
@@ -22,9 +22,8 @@ import { setSelection } from './setSelection.js';
22
22
  focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + direction : direction < 0 ? selection.startOffset : selection.endOffset
23
23
  });
24
24
  } else {
25
- var _selection;
26
25
  const selection = node.ownerDocument.getSelection();
27
- if (!((_selection = selection) === null || _selection === void 0 ? void 0 : _selection.focusNode)) {
26
+ if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) {
28
27
  return;
29
28
  }
30
29
  if (selection.isCollapsed) {
@@ -30,14 +30,13 @@ import { setSelection } from './setSelection.js';
30
30
  });
31
31
  }
32
32
  function isAllSelected(target) {
33
- var _selection;
34
33
  if (hasOwnSelection(target)) {
35
34
  return getUISelection(target).startOffset === 0 && getUISelection(target).endOffset === getUIValue(target).length;
36
35
  }
37
36
  var _getContentEditable;
38
37
  const focusNode = (_getContentEditable = getContentEditable(target)) !== null && _getContentEditable !== void 0 ? _getContentEditable : target.ownerDocument.body;
39
38
  const selection = target.ownerDocument.getSelection();
40
- return ((_selection = selection) === null || _selection === void 0 ? void 0 : _selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
39
+ return (selection === null || selection === void 0 ? void 0 : selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
41
40
  }
42
41
 
43
42
  export { isAllSelected, selectAll };
@@ -39,7 +39,6 @@ function setSelectionPerMouseDown({ document, target, clickCount, node, offset }
39
39
  end: end !== null && end !== void 0 ? end : text.length
40
40
  };
41
41
  } else {
42
- var _selection, _selection1;
43
42
  const { node: startNode, offset: startOffset } = resolveCaretPosition({
44
43
  target,
45
44
  node,
@@ -58,8 +57,8 @@ function setSelectionPerMouseDown({ document, target, clickCount, node, offset }
58
57
  throw new Error('The given offset is out of bounds.');
59
58
  }
60
59
  const selection = document.getSelection();
61
- (_selection = selection) === null || _selection === void 0 ? void 0 : _selection.removeAllRanges();
62
- (_selection1 = selection) === null || _selection1 === void 0 ? void 0 : _selection1.addRange(range.cloneRange());
60
+ selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
61
+ selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
63
62
  return range;
64
63
  }
65
64
  }
@@ -13,9 +13,8 @@ import '../../options.js';
13
13
  * Reset the Document Selection when moving focus into an element
14
14
  * with own selection implementation.
15
15
  */ function updateSelectionOnFocus(element) {
16
- var _selection;
17
16
  const selection = element.ownerDocument.getSelection();
18
- /* istanbul ignore if */ if (!((_selection = selection) === null || _selection === void 0 ? void 0 : _selection.focusNode)) {
17
+ /* istanbul ignore if */ if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) {
19
18
  return;
20
19
  }
21
20
  // If the focus moves inside an element with own selection implementation,
@@ -1,6 +1,6 @@
1
- import dtl from '../_interop/dtl.js';
1
+ import * as named from '@testing-library/dom';
2
2
 
3
- const { getConfig } = dtl;
3
+ const { getConfig } = named;
4
4
  function wrapEvent(cb, _element) {
5
5
  return getConfig().eventWrapper(cb);
6
6
  }
@@ -33,16 +33,16 @@ async function pointer(input) {
33
33
  this.system.pointer.resetClickCount();
34
34
  }
35
35
  async function pointerAction(instance, action) {
36
- var _previousPosition, _previousPosition_caret, _previousPosition1, _previousPosition_caret1, _previousPosition2;
36
+ var _previousPosition_caret, _previousPosition_caret1;
37
37
  const pointerName = 'pointerName' in action && action.pointerName ? action.pointerName : 'keyDef' in action ? instance.system.pointer.getPointerName(action.keyDef) : 'mouse';
38
38
  const previousPosition = instance.system.pointer.getPreviousPosition(pointerName);
39
39
  var _action_target, _action_coords, _action_node, _action_offset;
40
40
  const position = {
41
41
  target: (_action_target = action.target) !== null && _action_target !== void 0 ? _action_target : getPrevTarget(instance, previousPosition),
42
- coords: (_action_coords = action.coords) !== null && _action_coords !== void 0 ? _action_coords : (_previousPosition = previousPosition) === null || _previousPosition === void 0 ? void 0 : _previousPosition.coords,
42
+ coords: (_action_coords = action.coords) !== null && _action_coords !== void 0 ? _action_coords : previousPosition === null || previousPosition === void 0 ? void 0 : previousPosition.coords,
43
43
  caret: {
44
- node: (_action_node = action.node) !== null && _action_node !== void 0 ? _action_node : hasCaretPosition(action) ? undefined : (_previousPosition1 = previousPosition) === null || _previousPosition1 === void 0 ? void 0 : (_previousPosition_caret = _previousPosition1.caret) === null || _previousPosition_caret === void 0 ? void 0 : _previousPosition_caret.node,
45
- offset: (_action_offset = action.offset) !== null && _action_offset !== void 0 ? _action_offset : hasCaretPosition(action) ? undefined : (_previousPosition2 = previousPosition) === null || _previousPosition2 === void 0 ? void 0 : (_previousPosition_caret1 = _previousPosition2.caret) === null || _previousPosition_caret1 === void 0 ? void 0 : _previousPosition_caret1.offset
44
+ 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,
45
+ 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
46
46
  }
47
47
  };
48
48
  if ('keyDef' in action) {
@@ -1,6 +1,6 @@
1
- import dtl from '../_interop/dtl.js';
1
+ import * as named from '@testing-library/dom';
2
2
 
3
- const { getConfig } = dtl;
3
+ const { getConfig } = named;
4
4
  /**
5
5
  * Wrap an internal Promise
6
6
  */ function wrapAsync(implementation) {
@@ -36,7 +36,6 @@ class PointerHost {
36
36
  }
37
37
  }
38
38
  async move(instance, pointerName, position) {
39
- var _pointermove, _mousemove, _pointermove1, _mousemove1, _pointermove2, _mousemove2;
40
39
  const pointer = this.pointers.get(pointerName);
41
40
  // In (some?) browsers this order of events can be observed.
42
41
  // This interweaving of events is probably unnecessary.
@@ -44,12 +43,12 @@ class PointerHost {
44
43
  // the order in which they interweave/follow on a user interaction depends on the implementation.
45
44
  const pointermove = pointer.move(instance, position);
46
45
  const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
47
- (_pointermove = pointermove) === null || _pointermove === void 0 ? void 0 : _pointermove.leave();
48
- (_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
49
- (_pointermove1 = pointermove) === null || _pointermove1 === void 0 ? void 0 : _pointermove1.enter();
50
- (_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
51
- (_pointermove2 = pointermove) === null || _pointermove2 === void 0 ? void 0 : _pointermove2.move();
52
- (_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
46
+ pointermove === null || pointermove === void 0 ? void 0 : pointermove.leave();
47
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
48
+ pointermove === null || pointermove === void 0 ? void 0 : pointermove.enter();
49
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
50
+ pointermove === null || pointermove === void 0 ? void 0 : pointermove.move();
51
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
53
52
  }
54
53
  async release(instance, keyDef, position) {
55
54
  const device = this.devices.get(keyDef.pointerType);
@@ -69,19 +68,17 @@ class PointerHost {
69
68
  }
70
69
  if (!pointer.isPrevented) {
71
70
  if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
72
- var _mousemove, _mousemove1, _mousemove2;
73
71
  const mousemove = this.mouse.move(instance, pointer.position);
74
- (_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
75
- (_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
76
- (_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
72
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
73
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
74
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
77
75
  this.mouse.down(instance, keyDef, pointer);
78
76
  }
79
77
  if (!pointer.isMultitouch) {
80
- var _mousemove3, _mousemove4, _mousemove5;
81
78
  const mousemove = this.mouse.move(instance, pointer.position);
82
- (_mousemove3 = mousemove) === null || _mousemove3 === void 0 ? void 0 : _mousemove3.leave();
83
- (_mousemove4 = mousemove) === null || _mousemove4 === void 0 ? void 0 : _mousemove4.enter();
84
- (_mousemove5 = mousemove) === null || _mousemove5 === void 0 ? void 0 : _mousemove5.move();
79
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
80
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
81
+ mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
85
82
  this.mouse.up(instance, keyDef, pointer);
86
83
  }
87
84
  }
@@ -1,4 +1,4 @@
1
- import dtl from '../_interop/dtl.js';
1
+ import * as named from '@testing-library/dom';
2
2
  import '../utils/click/isClickableInput.js';
3
3
  import '../utils/dataTransfer/Clipboard.js';
4
4
  import '../utils/edit/isEditable.js';
@@ -19,7 +19,7 @@ import '../event/behavior/paste.js';
19
19
  import '../event/eventMap.js';
20
20
  import { focusElement } from '../event/focus.js';
21
21
 
22
- const { getConfig } = dtl;
22
+ const { getConfig } = named;
23
23
  async function selectOptions(select, values) {
24
24
  return selectOptionsBase.call(this, true, select, values);
25
25
  }
@@ -16,8 +16,7 @@ async function upload(element, fileOrFiles) {
16
16
  if (!input || !isElementType(input, 'input', {
17
17
  type: 'file'
18
18
  })) {
19
- var _input;
20
- throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${(_input = input) === null || _input === void 0 ? void 0 : _input.tagName} element does not accept file uploads`);
19
+ throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
21
20
  }
22
21
  if (isDisabled(element)) return;
23
22
  const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
@@ -82,8 +82,7 @@ function createClipboardStub(window, control) {
82
82
  });
83
83
  }
84
84
  function isClipboardStub(clipboard) {
85
- var _clipboard;
86
- return !!((_clipboard = clipboard) === null || _clipboard === void 0 ? void 0 : _clipboard[ClipboardStubControl]);
85
+ return !!(clipboard === null || clipboard === void 0 ? void 0 : clipboard[ClipboardStubControl]);
87
86
  }
88
87
  function attachClipboardStubToView(window) {
89
88
  if (isClipboardStub(window.navigator.clipboard)) {
@@ -124,9 +123,8 @@ function detachClipboardStubFromView(window) {
124
123
  }
125
124
  }
126
125
  async function readDataTransferFromClipboard(document) {
127
- var _window;
128
126
  const window = document.defaultView;
129
- const clipboard = (_window = window) === null || _window === void 0 ? void 0 : _window.navigator.clipboard;
127
+ const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard;
130
128
  const items = clipboard && await clipboard.read();
131
129
  if (!items) {
132
130
  throw new Error('The Clipboard API is unavailable.');
@@ -66,11 +66,10 @@ function getTypeMatcher(type, exact) {
66
66
  function createDataTransferStub(window) {
67
67
  return new class DataTransferStub {
68
68
  getData(format) {
69
- var _match;
70
69
  var _this_items_find;
71
70
  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));
72
71
  let text = '';
73
- (_match = match) === null || _match === void 0 ? void 0 : _match.getAsString((t)=>{
72
+ match === null || match === void 0 ? void 0 : match.getAsString((t)=>{
74
73
  text = t;
75
74
  });
76
75
  return text;
@@ -36,8 +36,8 @@ function setFiles(el, files) {
36
36
  if (v === '') {
37
37
  restore();
38
38
  } else {
39
- var _valueDescr_set, _valueDescr;
40
- (_valueDescr = valueDescr) === null || _valueDescr === void 0 ? void 0 : (_valueDescr_set = _valueDescr.set) === null || _valueDescr_set === void 0 ? void 0 : _valueDescr_set.call(el, v);
39
+ var _valueDescr_set;
40
+ valueDescr === null || valueDescr === void 0 ? void 0 : (_valueDescr_set = valueDescr.set) === null || _valueDescr_set === void 0 ? void 0 : _valueDescr_set.call(el, v);
41
41
  }
42
42
  }
43
43
  },
@@ -1,9 +1,8 @@
1
1
  import { isDisabled } from '../misc/isDisabled.js';
2
2
 
3
3
  function getActiveElement(document) {
4
- var _activeElement;
5
4
  const activeElement = document.activeElement;
6
- if ((_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.shadowRoot) {
5
+ if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.shadowRoot) {
7
6
  return getActiveElement(activeElement.shadowRoot);
8
7
  } else {
9
8
  // Browser does not yield disabled elements as document.activeElement - jsdom does
@@ -1,6 +1,6 @@
1
- import dtlHelpers from '../../_interop/dtlHelpers.js';
1
+ import * as named from '@testing-library/dom/dist/helpers.js';
2
2
 
3
- const { getWindowFromNode } = dtlHelpers;
3
+ const { getWindowFromNode } = named;
4
4
  function getWindow(node) {
5
5
  return getWindowFromNode(node);
6
6
  }
@@ -1,9 +1,8 @@
1
1
  import { getWindow } from './getWindow.js';
2
2
 
3
3
  function isVisible(element) {
4
- var _el;
5
4
  const window = getWindow(element);
6
- for(let el = element; (_el = el) === null || _el === void 0 ? void 0 : _el.ownerDocument; el = el.parentElement){
5
+ for(let el = element; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
7
6
  const { display, visibility } = window.getComputedStyle(el);
8
7
  if (display === 'none') {
9
8
  return false;
@@ -8,9 +8,8 @@ function hasPointerEvents(instance, element) {
8
8
  return ((_checkPointerEvents = checkPointerEvents(instance, element)) === null || _checkPointerEvents === void 0 ? void 0 : _checkPointerEvents.pointerEvents) !== 'none';
9
9
  }
10
10
  function closestPointerEventsDeclaration(element) {
11
- var _el;
12
11
  const window = getWindow(element);
13
- for(let el = element, tree = []; (_el = el) === null || _el === void 0 ? void 0 : _el.ownerDocument; el = el.parentElement){
12
+ for(let el = element, tree = []; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
14
13
  tree.push(el);
15
14
  const pointerEvents = window.getComputedStyle(el).pointerEvents;
16
15
  if (pointerEvents && ![
@@ -30,8 +29,7 @@ function checkPointerEvents(instance, element) {
30
29
  const lastCheck = element[PointerEventsCheck];
31
30
  const needsCheck = instance.config.pointerEventsCheck !== PointerEventsCheckLevel.Never && (!lastCheck || hasBitFlag(instance.config.pointerEventsCheck, PointerEventsCheckLevel.EachApiCall) && lastCheck[ApiLevel.Call] !== getLevelRef(instance, ApiLevel.Call) || hasBitFlag(instance.config.pointerEventsCheck, PointerEventsCheckLevel.EachTrigger) && lastCheck[ApiLevel.Trigger] !== getLevelRef(instance, ApiLevel.Trigger));
32
31
  if (!needsCheck) {
33
- var _lastCheck;
34
- return (_lastCheck = lastCheck) === null || _lastCheck === void 0 ? void 0 : _lastCheck.result;
32
+ return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result;
35
33
  }
36
34
  const declaration = closestPointerEventsDeclaration(element);
37
35
  element[PointerEventsCheck] = {
@@ -42,9 +40,8 @@ function checkPointerEvents(instance, element) {
42
40
  return declaration;
43
41
  }
44
42
  function assertPointerEvents(instance, element) {
45
- var _declaration;
46
43
  const declaration = checkPointerEvents(instance, element);
47
- if (((_declaration = declaration) === null || _declaration === void 0 ? void 0 : _declaration.pointerEvents) === 'none') {
44
+ if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') {
48
45
  throw new Error([
49
46
  `Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`,
50
47
  '',
@@ -64,7 +61,7 @@ function printTree(tree) {
64
61
  ].filter(Boolean).join('')).join('\n');
65
62
  }
66
63
  function getLabelDescr(element) {
67
- var _element_labels, _label, _label1;
64
+ var _element_labels;
68
65
  let label;
69
66
  if (element.hasAttribute('aria-label')) {
70
67
  label = element.getAttribute('aria-label');
@@ -88,10 +85,9 @@ function getLabelDescr(element) {
88
85
  var _element_textContent;
89
86
  label = (_element_textContent = element.textContent) === null || _element_textContent === void 0 ? void 0 : _element_textContent.trim();
90
87
  }
91
- label = (_label = label) === null || _label === void 0 ? void 0 : _label.replace(/\n/g, ' ');
92
- if (Number((_label1 = label) === null || _label1 === void 0 ? void 0 : _label1.length) > 30) {
93
- var _label2;
94
- label = `${(_label2 = label) === null || _label2 === void 0 ? void 0 : _label2.substring(0, 29)}…`;
88
+ label = label === null || label === void 0 ? void 0 : label.replace(/\n/g, ' ');
89
+ if (Number(label === null || label === void 0 ? void 0 : label.length) > 30) {
90
+ label = `${label === null || label === void 0 ? void 0 : label.substring(0, 29)}…`;
95
91
  }
96
92
  return label ? `(label=${label})` : '';
97
93
  }
@@ -1,3 +1,2 @@
1
- import def from '@testing-library/dom';
2
- declare const _default: typeof def;
3
- export default _default;
1
+ import * as named from '@testing-library/dom';
2
+ export default named;
@@ -1,3 +1,2 @@
1
- import def from '@testing-library/dom/dist/event-map.js';
2
- declare const _default: typeof def;
3
- export default _default;
1
+ import * as named from '@testing-library/dom/dist/event-map.js';
2
+ export default named;
@@ -1,3 +1,2 @@
1
- import def from '@testing-library/dom/dist/helpers.js';
2
- declare const _default: typeof def;
3
- export default _default;
1
+ import * as named from '@testing-library/dom/dist/helpers.js';
2
+ export default named;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "14.5.0",
3
+ "version": "14.5.1",
4
4
  "description": "Fire events the same way the user does",
5
5
  "keywords": [
6
6
  "react-testing-library",