@testing-library/user-event 14.4.3 → 14.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/dist/cjs/_interop/dtl.js +30 -0
  2. package/dist/cjs/_interop/dtlEventMap.js +30 -0
  3. package/dist/cjs/_interop/dtlHelpers.js +30 -0
  4. package/dist/cjs/clipboard/copy.js +2 -2
  5. package/dist/cjs/clipboard/cut.js +2 -2
  6. package/dist/cjs/clipboard/paste.js +4 -4
  7. package/dist/cjs/convenience/tab.js +1 -1
  8. package/dist/cjs/document/UI.js +5 -5
  9. package/dist/cjs/document/interceptor.js +6 -4
  10. package/dist/cjs/document/trackValue.js +4 -4
  11. package/dist/cjs/event/behavior/keydown.js +6 -6
  12. package/dist/cjs/event/behavior/keypress.js +4 -3
  13. package/dist/cjs/event/behavior/keyup.js +2 -2
  14. package/dist/cjs/event/behavior/paste.js +2 -2
  15. package/dist/cjs/event/createEvent.js +41 -41
  16. package/dist/cjs/event/dispatchEvent.js +2 -2
  17. package/dist/cjs/event/eventMap.js +2 -2
  18. package/dist/cjs/event/focus.js +2 -2
  19. package/dist/cjs/event/input.js +4 -4
  20. package/dist/cjs/event/selection/getInputRange.js +2 -2
  21. package/dist/cjs/event/selection/getTargetTypeAndSelection.js +3 -2
  22. package/dist/cjs/event/selection/modifySelection.js +3 -3
  23. package/dist/cjs/event/selection/modifySelectionPerMouse.js +4 -3
  24. package/dist/cjs/event/selection/moveSelection.js +6 -5
  25. package/dist/cjs/event/selection/resolveCaretPosition.js +1 -1
  26. package/dist/cjs/event/selection/selectAll.js +6 -5
  27. package/dist/cjs/event/selection/setSelection.js +3 -3
  28. package/dist/cjs/event/selection/setSelectionPerMouse.js +8 -7
  29. package/dist/cjs/event/selection/setSelectionRange.js +2 -2
  30. package/dist/cjs/event/selection/updateSelectionOnFocus.js +4 -3
  31. package/dist/cjs/event/wrapEvent.js +3 -2
  32. package/dist/cjs/index.js +1 -0
  33. package/dist/cjs/keyboard/index.js +2 -2
  34. package/dist/cjs/keyboard/parseKeyDef.js +8 -8
  35. package/dist/cjs/pointer/index.js +11 -11
  36. package/dist/cjs/pointer/keyMap.js +1 -1
  37. package/dist/cjs/pointer/parseKeyDef.js +1 -1
  38. package/dist/cjs/setup/api.js +19 -17
  39. package/dist/cjs/setup/directApi.js +3 -3
  40. package/dist/cjs/setup/setup.js +10 -10
  41. package/dist/cjs/setup/wrapAsync.js +3 -2
  42. package/dist/cjs/system/index.js +15 -2
  43. package/dist/cjs/system/keyboard.js +27 -12
  44. package/dist/cjs/system/pointer/buttons.js +14 -1
  45. package/dist/cjs/system/pointer/device.js +14 -1
  46. package/dist/cjs/system/pointer/index.js +46 -26
  47. package/dist/cjs/system/pointer/mouse.js +33 -19
  48. package/dist/cjs/system/pointer/pointer.js +24 -8
  49. package/dist/cjs/system/pointer/shared.js +2 -2
  50. package/dist/cjs/utility/selectOptions.js +12 -11
  51. package/dist/cjs/utility/type.js +1 -1
  52. package/dist/cjs/utility/upload.js +6 -5
  53. package/dist/cjs/utils/dataTransfer/Clipboard.js +25 -9
  54. package/dist/cjs/utils/dataTransfer/DataTransfer.js +25 -9
  55. package/dist/cjs/utils/edit/maxLength.js +2 -2
  56. package/dist/cjs/utils/edit/setFiles.js +4 -4
  57. package/dist/cjs/utils/focus/cursor.js +2 -2
  58. package/dist/cjs/utils/focus/getActiveElement.js +4 -3
  59. package/dist/cjs/utils/focus/selector.js +1 -1
  60. package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
  61. package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
  62. package/dist/cjs/utils/misc/getWindow.js +3 -2
  63. package/dist/cjs/utils/misc/isDisabled.js +3 -3
  64. package/dist/cjs/utils/misc/isVisible.js +3 -2
  65. package/dist/cjs/utils/misc/wait.js +1 -1
  66. package/dist/cjs/utils/pointer/cssPointerEvents.js +23 -19
  67. package/dist/esm/_interop/dtl.js +6 -0
  68. package/dist/esm/_interop/dtlEventMap.js +6 -0
  69. package/dist/esm/_interop/dtlHelpers.js +6 -0
  70. package/dist/esm/clipboard/copy.js +2 -2
  71. package/dist/esm/clipboard/cut.js +2 -2
  72. package/dist/esm/clipboard/paste.js +4 -4
  73. package/dist/esm/convenience/tab.js +1 -1
  74. package/dist/esm/document/UI.js +5 -5
  75. package/dist/esm/document/interceptor.js +6 -4
  76. package/dist/esm/document/trackValue.js +4 -4
  77. package/dist/esm/event/behavior/keydown.js +6 -6
  78. package/dist/esm/event/behavior/keypress.js +4 -3
  79. package/dist/esm/event/behavior/keyup.js +2 -2
  80. package/dist/esm/event/behavior/paste.js +2 -2
  81. package/dist/esm/event/createEvent.js +41 -41
  82. package/dist/esm/event/dispatchEvent.js +2 -2
  83. package/dist/esm/event/eventMap.js +2 -2
  84. package/dist/esm/event/focus.js +2 -2
  85. package/dist/esm/event/input.js +4 -4
  86. package/dist/esm/event/selection/getInputRange.js +2 -2
  87. package/dist/esm/event/selection/getTargetTypeAndSelection.js +3 -2
  88. package/dist/esm/event/selection/modifySelection.js +3 -3
  89. package/dist/esm/event/selection/modifySelectionPerMouse.js +4 -3
  90. package/dist/esm/event/selection/moveSelection.js +6 -5
  91. package/dist/esm/event/selection/resolveCaretPosition.js +1 -1
  92. package/dist/esm/event/selection/selectAll.js +6 -5
  93. package/dist/esm/event/selection/setSelection.js +3 -3
  94. package/dist/esm/event/selection/setSelectionPerMouse.js +8 -7
  95. package/dist/esm/event/selection/setSelectionRange.js +2 -2
  96. package/dist/esm/event/selection/updateSelectionOnFocus.js +4 -3
  97. package/dist/esm/event/wrapEvent.js +2 -1
  98. package/dist/esm/index.js +1 -1
  99. package/dist/esm/keyboard/index.js +2 -2
  100. package/dist/esm/keyboard/parseKeyDef.js +8 -8
  101. package/dist/esm/pointer/index.js +11 -11
  102. package/dist/esm/pointer/keyMap.js +1 -1
  103. package/dist/esm/pointer/parseKeyDef.js +1 -1
  104. package/dist/esm/setup/api.js +33 -12
  105. package/dist/esm/setup/directApi.js +3 -3
  106. package/dist/esm/setup/setup.js +11 -11
  107. package/dist/esm/setup/wrapAsync.js +2 -1
  108. package/dist/esm/system/index.js +15 -2
  109. package/dist/esm/system/keyboard.js +27 -12
  110. package/dist/esm/system/pointer/buttons.js +14 -1
  111. package/dist/esm/system/pointer/device.js +14 -1
  112. package/dist/esm/system/pointer/index.js +46 -26
  113. package/dist/esm/system/pointer/mouse.js +33 -19
  114. package/dist/esm/system/pointer/pointer.js +24 -8
  115. package/dist/esm/system/pointer/shared.js +2 -2
  116. package/dist/esm/utility/selectOptions.js +8 -7
  117. package/dist/esm/utility/type.js +1 -1
  118. package/dist/esm/utility/upload.js +6 -5
  119. package/dist/esm/utils/dataTransfer/Clipboard.js +25 -9
  120. package/dist/esm/utils/dataTransfer/DataTransfer.js +25 -9
  121. package/dist/esm/utils/edit/maxLength.js +2 -2
  122. package/dist/esm/utils/edit/setFiles.js +4 -4
  123. package/dist/esm/utils/focus/cursor.js +2 -2
  124. package/dist/esm/utils/focus/getActiveElement.js +4 -3
  125. package/dist/esm/utils/focus/selector.js +1 -1
  126. package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
  127. package/dist/esm/utils/misc/getTreeDiff.js +3 -3
  128. package/dist/esm/utils/misc/getWindow.js +2 -1
  129. package/dist/esm/utils/misc/isDisabled.js +3 -3
  130. package/dist/esm/utils/misc/isVisible.js +3 -2
  131. package/dist/esm/utils/misc/wait.js +1 -1
  132. package/dist/esm/utils/pointer/cssPointerEvents.js +23 -19
  133. package/dist/types/_interop/dtl.d.ts +3 -0
  134. package/dist/types/_interop/dtlEventMap.d.ts +3 -0
  135. package/dist/types/_interop/dtlHelpers.d.ts +3 -0
  136. package/dist/types/clipboard/copy.d.ts +1 -1
  137. package/dist/types/clipboard/cut.d.ts +1 -1
  138. package/dist/types/clipboard/paste.d.ts +1 -1
  139. package/dist/types/convenience/click.d.ts +1 -1
  140. package/dist/types/convenience/hover.d.ts +1 -1
  141. package/dist/types/convenience/tab.d.ts +1 -1
  142. package/dist/types/document/UI.d.ts +3 -3
  143. package/dist/types/document/interceptor.d.ts +3 -3
  144. package/dist/types/event/behavior/registry.d.ts +1 -1
  145. package/dist/types/event/createEvent.d.ts +1 -1
  146. package/dist/types/event/dispatchEvent.d.ts +1 -1
  147. package/dist/types/event/eventMap.d.ts +8 -0
  148. package/dist/types/event/input.d.ts +1 -1
  149. package/dist/types/event/radio.d.ts +1 -1
  150. package/dist/types/event/selection/index.d.ts +2 -2
  151. package/dist/types/event/selection/modifySelectionPerMouse.d.ts +1 -1
  152. package/dist/types/event/selection/setSelectionPerMouse.d.ts +1 -1
  153. package/dist/types/event/types.d.ts +3 -3
  154. package/dist/types/index.d.ts +3 -1
  155. package/dist/types/keyboard/index.d.ts +1 -1
  156. package/dist/types/options.d.ts +2 -2
  157. package/dist/types/pointer/index.d.ts +7 -7
  158. package/dist/types/setup/api.d.ts +23 -5
  159. package/dist/types/setup/directApi.d.ts +5 -5
  160. package/dist/types/setup/setup.d.ts +5 -5
  161. package/dist/types/system/keyboard.d.ts +2 -2
  162. package/dist/types/system/pointer/buttons.d.ts +2 -2
  163. package/dist/types/system/pointer/device.d.ts +1 -1
  164. package/dist/types/system/pointer/mouse.d.ts +2 -2
  165. package/dist/types/system/pointer/pointer.d.ts +2 -2
  166. package/dist/types/utility/clear.d.ts +1 -1
  167. package/dist/types/utility/selectOptions.d.ts +1 -1
  168. package/dist/types/utility/type.d.ts +2 -2
  169. package/dist/types/utility/upload.d.ts +1 -1
  170. package/dist/types/utils/click/isClickableInput.d.ts +1 -1
  171. package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
  172. package/dist/types/utils/edit/isEditable.d.ts +2 -2
  173. package/dist/types/utils/edit/maxLength.d.ts +1 -1
  174. package/dist/types/utils/keyDef/readNextDescriptor.d.ts +1 -1
  175. package/dist/types/utils/misc/isElementType.d.ts +1 -1
  176. package/dist/types/utils/misc/level.d.ts +2 -2
  177. package/dist/types/utils/misc/wait.d.ts +1 -1
  178. package/dist/types/utils/pointer/cssPointerEvents.d.ts +1 -1
  179. package/package.json +22 -11
  180. /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
  181. /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
  182. /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
  183. /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
@@ -7,7 +7,19 @@ var device = require('./device.js');
7
7
  var mouse = require('./mouse.js');
8
8
  var pointer = require('./pointer.js');
9
9
 
10
- var _registry, _k;
10
+ function _define_property(obj, key, value) {
11
+ if (key in obj) {
12
+ Object.defineProperty(obj, key, {
13
+ value: value,
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true
17
+ });
18
+ } else {
19
+ obj[key] = value;
20
+ }
21
+ return obj;
22
+ }
11
23
  class PointerHost {
12
24
  isKeyPressed(keyDef) {
13
25
  return this.devices.get(keyDef.pointerType).isPressed(keyDef);
@@ -28,6 +40,7 @@ class PointerHost {
28
40
  }
29
41
  }
30
42
  async move(instance, pointerName, position) {
43
+ var _pointermove, _mousemove, _pointermove1, _mousemove1, _pointermove2, _mousemove2;
31
44
  const pointer = this.pointers.get(pointerName);
32
45
  // In (some?) browsers this order of events can be observed.
33
46
  // This interweaving of events is probably unnecessary.
@@ -35,12 +48,12 @@ class PointerHost {
35
48
  // the order in which they interweave/follow on a user interaction depends on the implementation.
36
49
  const pointermove = pointer.move(instance, position);
37
50
  const mousemove = pointer.pointerType === 'touch' || pointer.isPrevented && pointer.isDown ? undefined : this.mouse.move(instance, position);
38
- pointermove === null || pointermove === void 0 ? void 0 : pointermove.leave();
39
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
40
- pointermove === null || pointermove === void 0 ? void 0 : pointermove.enter();
41
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
42
- pointermove === null || pointermove === void 0 ? void 0 : pointermove.move();
43
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
51
+ (_pointermove = pointermove) === null || _pointermove === void 0 ? void 0 : _pointermove.leave();
52
+ (_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
53
+ (_pointermove1 = pointermove) === null || _pointermove1 === void 0 ? void 0 : _pointermove1.enter();
54
+ (_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
55
+ (_pointermove2 = pointermove) === null || _pointermove2 === void 0 ? void 0 : _pointermove2.move();
56
+ (_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
44
57
  }
45
58
  async release(instance, keyDef, position) {
46
59
  const device = this.devices.get(keyDef.pointerType);
@@ -60,17 +73,19 @@ class PointerHost {
60
73
  }
61
74
  if (!pointer.isPrevented) {
62
75
  if (pointer.pointerType === 'touch' && !pointer.isMultitouch) {
76
+ var _mousemove, _mousemove1, _mousemove2;
63
77
  const mousemove = this.mouse.move(instance, pointer.position);
64
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.leave();
65
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.enter();
66
- mousemove === null || mousemove === void 0 ? void 0 : mousemove.move();
78
+ (_mousemove = mousemove) === null || _mousemove === void 0 ? void 0 : _mousemove.leave();
79
+ (_mousemove1 = mousemove) === null || _mousemove1 === void 0 ? void 0 : _mousemove1.enter();
80
+ (_mousemove2 = mousemove) === null || _mousemove2 === void 0 ? void 0 : _mousemove2.move();
67
81
  this.mouse.down(instance, keyDef, pointer);
68
82
  }
69
83
  if (!pointer.isMultitouch) {
70
- const mousemove1 = this.mouse.move(instance, pointer.position);
71
- mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.leave();
72
- mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.enter();
73
- mousemove1 === null || mousemove1 === void 0 ? void 0 : mousemove1.move();
84
+ var _mousemove3, _mousemove4, _mousemove5;
85
+ const mousemove = this.mouse.move(instance, pointer.position);
86
+ (_mousemove3 = mousemove) === null || _mousemove3 === void 0 ? void 0 : _mousemove3.leave();
87
+ (_mousemove4 = mousemove) === null || _mousemove4 === void 0 ? void 0 : _mousemove4.enter();
88
+ (_mousemove5 = mousemove) === null || _mousemove5 === void 0 ? void 0 : _mousemove5.move();
74
89
  this.mouse.up(instance, keyDef, pointer);
75
90
  }
76
91
  }
@@ -85,25 +100,30 @@ class PointerHost {
85
100
  this.mouse.resetClickCount();
86
101
  }
87
102
  getMouseTarget(instance) {
88
- var _target;
89
- return (_target = this.mouse.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
103
+ var _this_mouse_position_target;
104
+ return (_this_mouse_position_target = this.mouse.position.target) !== null && _this_mouse_position_target !== void 0 ? _this_mouse_position_target : instance.config.document.body;
90
105
  }
91
106
  setMousePosition(position) {
92
107
  this.mouse.position = position;
93
108
  this.pointers.get('mouse').position = position;
94
109
  }
95
110
  constructor(system){
96
- this.devices = new class {
111
+ _define_property(this, "system", void 0);
112
+ _define_property(this, "mouse", void 0);
113
+ _define_property(this, "buttons", void 0);
114
+ _define_property(this, "devices", new class {
97
115
  get(k) {
98
- var ref;
99
- (ref = (_registry = this.registry)[_k = k]) !== null && ref !== void 0 ? ref : _registry[_k] = new device.Device();
116
+ var // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
117
+ _this_registry, _k;
118
+ var _;
119
+ (_ = (_this_registry = this.registry)[_k = k]) !== null && _ !== void 0 ? _ : _this_registry[_k] = new device.Device();
100
120
  return this.registry[k];
101
121
  }
102
122
  constructor(){
103
- this.registry = {};
123
+ _define_property(this, "registry", {});
104
124
  }
105
- }();
106
- this.pointers = new class {
125
+ }());
126
+ _define_property(this, "pointers", new class {
107
127
  new(pointerName, keyDef) {
108
128
  const isPrimary = keyDef.pointerType !== 'touch' || !Object.values(this.registry).some((p)=>p.pointerType === 'touch' && !p.isCancelled);
109
129
  if (!isPrimary) {
@@ -130,16 +150,16 @@ class PointerHost {
130
150
  return pointerName in this.registry;
131
151
  }
132
152
  constructor(){
133
- this.registry = {
153
+ _define_property(this, "registry", {
134
154
  mouse: new pointer.Pointer({
135
155
  pointerId: 1,
136
156
  pointerType: 'mouse',
137
157
  isPrimary: true
138
158
  })
139
- };
140
- this.nextId = 2;
159
+ });
160
+ _define_property(this, "nextId", 2);
141
161
  }
142
- }();
162
+ }());
143
163
  this.system = system;
144
164
  this.buttons = new buttons.Buttons();
145
165
  this.mouse = new mouse.Mouse();
@@ -26,6 +26,19 @@ var modifySelectionPerMouse = require('../../event/selection/modifySelectionPerM
26
26
  var buttons = require('./buttons.js');
27
27
  var shared = require('./shared.js');
28
28
 
29
+ function _define_property(obj, key, value) {
30
+ if (key in obj) {
31
+ Object.defineProperty(obj, key, {
32
+ value: value,
33
+ enumerable: true,
34
+ configurable: true,
35
+ writable: true
36
+ });
37
+ } else {
38
+ obj[key] = value;
39
+ }
40
+ return obj;
41
+ }
29
42
  /**
30
43
  * This object is the single "virtual" mouse that might be controlled by multiple different pointer devices.
31
44
  */ class Mouse {
@@ -123,39 +136,40 @@ var shared = require('./shared.js');
123
136
  return init;
124
137
  }
125
138
  getTarget(instance) {
126
- var _target;
127
- return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
139
+ var _this_position_target;
140
+ return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
128
141
  }
129
142
  startSelecting(instance, clickCount) {
130
- var ref, ref1;
143
+ var _this_position_caret, _this_position_caret1;
131
144
  // TODO: support extending range (shift)
132
145
  this.selecting = setSelectionPerMouse.setSelectionPerMouseDown({
133
146
  document: instance.config.document,
134
147
  target: this.getTarget(instance),
135
- node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
136
- offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset,
148
+ node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
149
+ offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset,
137
150
  clickCount
138
151
  });
139
152
  }
140
153
  modifySelecting(instance) {
141
- var ref, ref1;
154
+ var _this_position_caret, _this_position_caret1;
142
155
  if (!this.selecting) {
143
156
  return;
144
157
  }
145
158
  modifySelectionPerMouse.modifySelectionPerMouseMove(this.selecting, {
146
159
  document: instance.config.document,
147
160
  target: this.getTarget(instance),
148
- node: (ref = this.position.caret) === null || ref === void 0 ? void 0 : ref.node,
149
- offset: (ref1 = this.position.caret) === null || ref1 === void 0 ? void 0 : ref1.offset
161
+ node: (_this_position_caret = this.position.caret) === null || _this_position_caret === void 0 ? void 0 : _this_position_caret.node,
162
+ offset: (_this_position_caret1 = this.position.caret) === null || _this_position_caret1 === void 0 ? void 0 : _this_position_caret1.offset
150
163
  });
151
164
  }
152
165
  endSelecting() {
153
166
  this.selecting = undefined;
154
167
  }
155
168
  constructor(){
156
- this.position = {};
157
- this.buttons = new buttons.Buttons();
158
- this.buttonDownTarget = {};
169
+ _define_property(this, "position", {});
170
+ _define_property(this, "buttons", new buttons.Buttons());
171
+ _define_property(this, "selecting", void 0);
172
+ _define_property(this, "buttonDownTarget", {});
159
173
  // According to spec the `detail` on click events should be the number
160
174
  // of *consecutive* clicks with a specific button.
161
175
  // On `mousedown` and `mouseup` it should be this number increased by one.
@@ -166,7 +180,7 @@ var shared = require('./shared.js');
166
180
  // If there is a delay while a button is pressed,
167
181
  // the `mouseup` and `click` are normal, but a following `mousedown` starts a new click count.
168
182
  // We'll follow the minimal implementation of Webkit.
169
- this.clickCount = new class {
183
+ _define_property(this, "clickCount", new class {
170
184
  incOnClick(button) {
171
185
  const current = this.down[button] === undefined ? undefined : Number(this.down[button]) + 1;
172
186
  this.count = this.count[button] === undefined ? {} : {
@@ -175,13 +189,13 @@ var shared = require('./shared.js');
175
189
  return current;
176
190
  }
177
191
  getOnDown(button) {
178
- var _button;
192
+ var _this_count_button;
179
193
  this.down = {
180
- [button]: (_button = this.count[button]) !== null && _button !== void 0 ? _button : 0
194
+ [button]: (_this_count_button = this.count[button]) !== null && _this_count_button !== void 0 ? _this_count_button : 0
181
195
  };
182
- var _button1;
196
+ var _this_count_button1;
183
197
  this.count = {
184
- [button]: (_button1 = this.count[button]) !== null && _button1 !== void 0 ? _button1 : 0
198
+ [button]: (_this_count_button1 = this.count[button]) !== null && _this_count_button1 !== void 0 ? _this_count_button1 : 0
185
199
  };
186
200
  return Number(this.count[button]) + 1;
187
201
  }
@@ -192,10 +206,10 @@ var shared = require('./shared.js');
192
206
  this.count = {};
193
207
  }
194
208
  constructor(){
195
- this.down = {};
196
- this.count = {};
209
+ _define_property(this, "down", {});
210
+ _define_property(this, "count", {});
197
211
  }
198
- }();
212
+ }());
199
213
  }
200
214
  }
201
215
 
@@ -13,6 +13,19 @@ require('../../utils/misc/level.js');
13
13
  var cssPointerEvents = require('../../utils/pointer/cssPointerEvents.js');
14
14
  var shared = require('./shared.js');
15
15
 
16
+ function _define_property(obj, key, value) {
17
+ if (key in obj) {
18
+ Object.defineProperty(obj, key, {
19
+ value: value,
20
+ enumerable: true,
21
+ configurable: true,
22
+ writable: true
23
+ });
24
+ } else {
25
+ obj[key] = value;
26
+ }
27
+ return obj;
28
+ }
16
29
  class Pointer {
17
30
  init(instance, position) {
18
31
  this.position = position;
@@ -86,8 +99,8 @@ class Pointer {
86
99
  this.isCancelled = true;
87
100
  }
88
101
  getTarget(instance) {
89
- var _target;
90
- return (_target = this.position.target) !== null && _target !== void 0 ? _target : instance.config.document.body;
102
+ var _this_position_target;
103
+ return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
91
104
  }
92
105
  getEventInit() {
93
106
  return {
@@ -97,12 +110,15 @@ class Pointer {
97
110
  isPrimary: this.isPrimary
98
111
  };
99
112
  }
100
- constructor({ pointerId , pointerType , isPrimary }){
101
- this.isMultitouch = false;
102
- this.isCancelled = false;
103
- this.isDown = false;
104
- this.isPrevented = false;
105
- this.position = {};
113
+ constructor({ pointerId, pointerType, isPrimary }){
114
+ _define_property(this, "pointerId", void 0);
115
+ _define_property(this, "pointerType", void 0);
116
+ _define_property(this, "isPrimary", void 0);
117
+ _define_property(this, "isMultitouch", false);
118
+ _define_property(this, "isCancelled", false);
119
+ _define_property(this, "isDown", false);
120
+ _define_property(this, "isPrevented", false);
121
+ _define_property(this, "position", {});
106
122
  this.pointerId = pointerId;
107
123
  this.pointerType = pointerType;
108
124
  this.isPrimary = isPrimary;
@@ -3,8 +3,8 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function isDifferentPointerPosition(positionA, positionB) {
6
- var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7;
7
- return positionA.target !== positionB.target || ((ref = positionA.coords) === null || ref === void 0 ? void 0 : ref.x) !== ((ref1 = positionB.coords) === null || ref1 === void 0 ? void 0 : ref1.y) || ((ref2 = positionA.coords) === null || ref2 === void 0 ? void 0 : ref2.y) !== ((ref3 = positionB.coords) === null || ref3 === void 0 ? void 0 : ref3.y) || ((ref4 = positionA.caret) === null || ref4 === void 0 ? void 0 : ref4.node) !== ((ref5 = positionB.caret) === null || ref5 === void 0 ? void 0 : ref5.node) || ((ref6 = positionA.caret) === null || ref6 === void 0 ? void 0 : ref6.offset) !== ((ref7 = positionB.caret) === null || ref7 === void 0 ? void 0 : ref7.offset);
6
+ var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
7
+ 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);
8
8
  }
9
9
 
10
10
  exports.isDifferentPointerPosition = isDifferentPointerPosition;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var dom = require('@testing-library/dom');
5
+ var dtl = require('../_interop/dtl.js');
6
6
  require('../utils/click/isClickableInput.js');
7
7
  require('../utils/dataTransfer/Clipboard.js');
8
8
  require('../utils/edit/isEditable.js');
@@ -23,6 +23,7 @@ require('../event/behavior/paste.js');
23
23
  require('../event/eventMap.js');
24
24
  var focus = require('../event/focus.js');
25
25
 
26
+ const { getConfig } = dtl;
26
27
  async function selectOptions(select, values) {
27
28
  return selectOptionsBase.call(this, true, select, values);
28
29
  }
@@ -31,7 +32,7 @@ async function deselectOptions(select, values) {
31
32
  }
32
33
  async function selectOptionsBase(newValue, select, values) {
33
34
  if (!newValue && !select.multiple) {
34
- throw dom.getConfig().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
35
+ throw getConfig().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
35
36
  }
36
37
  const valArray = Array.isArray(values) ? values : [
37
38
  values
@@ -45,7 +46,7 @@ async function selectOptionsBase(newValue, select, values) {
45
46
  if (matchingOption) {
46
47
  return matchingOption;
47
48
  } else {
48
- throw dom.getConfig().getElementError(`Value "${String(val)}" not found in options`, select);
49
+ throw getConfig().getElementError(`Value "${String(val)}" not found in options`, select);
49
50
  }
50
51
  }
51
52
  }).filter((option)=>!isDisabled.isDisabled(option));
@@ -86,15 +87,15 @@ async function selectOptionsBase(newValue, select, values) {
86
87
  await wait.wait(this.config);
87
88
  }
88
89
  } else if (selectedOptions.length === 1) {
89
- const withPointerEvents1 = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, select);
90
+ const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : cssPointerEvents.hasPointerEvents(this, select);
90
91
  // the click to open the select options
91
- if (withPointerEvents1) {
92
+ if (withPointerEvents) {
92
93
  await this.click(select);
93
94
  } else {
94
95
  focus.focusElement(select);
95
96
  }
96
97
  selectOption(selectedOptions[0]);
97
- if (withPointerEvents1) {
98
+ if (withPointerEvents) {
98
99
  // the browser triggers another click event on the select for the click on the option
99
100
  // this second click has no 'down' phase
100
101
  this.dispatchUIEvent(select, 'pointerover');
@@ -107,15 +108,15 @@ async function selectOptionsBase(newValue, select, values) {
107
108
  }
108
109
  await wait.wait(this.config);
109
110
  } else {
110
- throw dom.getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
111
+ throw getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
111
112
  }
112
113
  } else if (select.getAttribute('role') === 'listbox') {
113
- for (const option1 of selectedOptions){
114
- await this.click(option1);
115
- await this.unhover(option1);
114
+ for (const option of selectedOptions){
115
+ await this.click(option);
116
+ await this.unhover(option);
116
117
  }
117
118
  } else {
118
- throw dom.getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
119
+ throw getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
119
120
  }
120
121
  }
121
122
 
@@ -13,7 +13,7 @@ require('../utils/misc/level.js');
13
13
  require('../options.js');
14
14
  var setSelectionRange = require('../event/selection/setSelectionRange.js');
15
15
 
16
- async function type(element, text, { skipClick =this.config.skipClick , skipAutoClose =this.config.skipAutoClose , initialSelectionStart , initialSelectionEnd } = {}) {
16
+ async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
17
17
  // TODO: properly type guard
18
18
  // we use this workaround for now to prevent changing behavior
19
19
  if (element.disabled) return;
@@ -20,18 +20,19 @@ async function upload(element, fileOrFiles) {
20
20
  if (!input || !isElementType.isElementType(input, 'input', {
21
21
  type: 'file'
22
22
  })) {
23
- throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input === null || input === void 0 ? void 0 : input.tagName} element does not accept file uploads`);
23
+ var _input;
24
+ throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${(_input = input) === null || _input === void 0 ? void 0 : _input.tagName} element does not accept file uploads`);
24
25
  }
25
26
  if (isDisabled.isDisabled(element)) return;
26
27
  const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
27
28
  fileOrFiles
28
29
  ]).filter((file)=>!this.config.applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1);
29
30
  const fileDialog = ()=>{
30
- var ref;
31
+ var _input_files;
31
32
  // do not fire an input event if the file selection does not change
32
- if (files.length === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.length) && files.every((f, i)=>{
33
- var ref;
34
- return f === ((ref = input.files) === null || ref === void 0 ? void 0 : ref.item(i));
33
+ if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{
34
+ var _input_files;
35
+ return f === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.item(i));
35
36
  })) {
36
37
  return;
37
38
  }
@@ -7,13 +7,26 @@ var Blob = require('./Blob.js');
7
7
  var DataTransfer = require('./DataTransfer.js');
8
8
 
9
9
  // Clipboard is not available in jsdom
10
+ function _define_property(obj, key, value) {
11
+ if (key in obj) {
12
+ Object.defineProperty(obj, key, {
13
+ value: value,
14
+ enumerable: true,
15
+ configurable: true,
16
+ writable: true
17
+ });
18
+ } else {
19
+ obj[key] = value;
20
+ }
21
+ return obj;
22
+ }
10
23
  // MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData
11
24
  // lib.dom.d.ts lists only Promise<Blob|string>
12
25
  // https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/ClipboardItem#syntax
13
26
  function createClipboardItem(window, ...blobs) {
14
27
  const dataMap = Object.fromEntries(blobs.map((b)=>[
15
28
  typeof b === 'string' ? 'text/plain' : b.type,
16
- Promise.resolve(b),
29
+ Promise.resolve(b)
17
30
  ]));
18
31
  // use real ClipboardItem if available
19
32
  /* istanbul ignore if */ if (typeof window.ClipboardItem !== 'undefined') {
@@ -35,6 +48,7 @@ function createClipboardItem(window, ...blobs) {
35
48
  });
36
49
  }
37
50
  constructor(d){
51
+ _define_property(this, "data", void 0);
38
52
  this.data = d;
39
53
  }
40
54
  }(dataMap);
@@ -65,15 +79,15 @@ function createClipboardStub(window, control) {
65
79
  }
66
80
  constructor(...args){
67
81
  super(...args);
68
- this.items = [];
82
+ _define_property(this, "items", []);
69
83
  }
70
84
  }(), {
71
85
  [ClipboardStubControl]: control
72
86
  });
73
87
  }
74
88
  function isClipboardStub(clipboard) {
75
- var ref;
76
- return !!((ref = clipboard) === null || ref === void 0 ? void 0 : ref[ClipboardStubControl]);
89
+ var _clipboard;
90
+ return !!((_clipboard = clipboard) === null || _clipboard === void 0 ? void 0 : _clipboard[ClipboardStubControl]);
77
91
  }
78
92
  function attachClipboardStubToView(window) {
79
93
  if (isClipboardStub(window.navigator.clipboard)) {
@@ -114,8 +128,9 @@ function detachClipboardStubFromView(window) {
114
128
  }
115
129
  }
116
130
  async function readDataTransferFromClipboard(document) {
131
+ var _window;
117
132
  const window = document.defaultView;
118
- const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard;
133
+ const clipboard = (_window = window) === null || _window === void 0 ? void 0 : _window.navigator.clipboard;
119
134
  const items = clipboard && await clipboard.read();
120
135
  if (!items) {
121
136
  throw new Error('The Clipboard API is unavailable.');
@@ -143,11 +158,12 @@ async function writeDataTransferToClipboard(document, clipboardData) {
143
158
  throw new Error('The Clipboard API is unavailable.');
144
159
  }
145
160
  }
146
- /* istanbul ignore else */ if (typeof globalThis.afterEach === 'function') {
147
- globalThis.afterEach(()=>resetClipboardStubOnView(globalThis.window));
161
+ const g = globalThis;
162
+ /* istanbul ignore else */ if (typeof g.afterEach === 'function') {
163
+ g.afterEach(()=>resetClipboardStubOnView(globalThis.window));
148
164
  }
149
- /* istanbul ignore else */ if (typeof globalThis.afterAll === 'function') {
150
- globalThis.afterAll(()=>detachClipboardStubFromView(globalThis.window));
165
+ /* istanbul ignore else */ if (typeof g.afterAll === 'function') {
166
+ g.afterAll(()=>detachClipboardStubFromView(globalThis.window));
151
167
  }
152
168
 
153
169
  exports.attachClipboardStubToView = attachClipboardStubToView;
@@ -4,6 +4,19 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var FileList = require('./FileList.js');
6
6
 
7
+ function _define_property(obj, key, value) {
8
+ if (key in obj) {
9
+ Object.defineProperty(obj, key, {
10
+ value: value,
11
+ enumerable: true,
12
+ configurable: true,
13
+ writable: true
14
+ });
15
+ } else {
16
+ obj[key] = value;
17
+ }
18
+ return obj;
19
+ }
7
20
  // DataTransfer is not implemented in jsdom.
8
21
  // DataTransfer with FileList is being created by the browser on certain events.
9
22
  class DataTransferItemStub {
@@ -19,8 +32,10 @@ class DataTransferItemStub {
19
32
  throw new Error('not implemented');
20
33
  }
21
34
  constructor(dataOrFile, type){
22
- this.file = null;
23
- this.data = undefined;
35
+ _define_property(this, "kind", void 0);
36
+ _define_property(this, "type", void 0);
37
+ _define_property(this, "file", null);
38
+ _define_property(this, "data", undefined);
24
39
  if (typeof dataOrFile === 'string') {
25
40
  this.kind = 'string';
26
41
  this.type = String(type);
@@ -55,10 +70,11 @@ function getTypeMatcher(type, exact) {
55
70
  function createDataTransferStub(window) {
56
71
  return new class DataTransferStub {
57
72
  getData(format) {
58
- var ref;
59
- const match = (ref = this.items.find(getTypeMatcher(format, true))) !== null && ref !== void 0 ? ref : this.items.find(getTypeMatcher(format, false));
73
+ var _match;
74
+ var _this_items_find;
75
+ 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));
60
76
  let text = '';
61
- match === null || match === void 0 ? void 0 : match.getAsString((t)=>{
77
+ (_match = match) === null || _match === void 0 ? void 0 : _match.getAsString((t)=>{
62
78
  text = t;
63
79
  });
64
80
  return text;
@@ -93,10 +109,10 @@ function createDataTransferStub(window) {
93
109
  }
94
110
  /* istanbul ignore next */ setDragImage() {}
95
111
  constructor(){
96
- this.dropEffect = 'none';
97
- this.effectAllowed = 'uninitialized';
98
- this.items = new DataTransferItemListStub();
99
- this.files = FileList.createFileList(window, []);
112
+ _define_property(this, "dropEffect", 'none');
113
+ _define_property(this, "effectAllowed", 'uninitialized');
114
+ _define_property(this, "items", new DataTransferItemListStub());
115
+ _define_property(this, "files", FileList.createFileList(window, []));
100
116
  }
101
117
  }();
102
118
  }
@@ -16,8 +16,8 @@ var maxLengthSupportedTypes;
16
16
  // can't use .maxLength property because of a jsdom bug:
17
17
  // https://github.com/jsdom/jsdom/issues/2927
18
18
  function getMaxLength(element) {
19
- var ref;
20
- const attr = (ref = element.getAttribute('maxlength')) !== null && ref !== void 0 ? ref : '';
19
+ var _element_getAttribute;
20
+ const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== void 0 ? _element_getAttribute : '';
21
21
  return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;
22
22
  }
23
23
  function supportsMaxLength(element) {
@@ -15,8 +15,8 @@ function restoreProperty(obj, prop, descriptor) {
15
15
  }
16
16
  }
17
17
  function setFiles(el, files) {
18
- var ref;
19
- (ref = el[fakeFiles]) === null || ref === void 0 ? void 0 : ref.restore();
18
+ var _el_fakeFiles;
19
+ (_el_fakeFiles = el[fakeFiles]) === null || _el_fakeFiles === void 0 ? void 0 : _el_fakeFiles.restore();
20
20
  const typeDescr = Object.getOwnPropertyDescriptor(el, 'type');
21
21
  const valueDescr = Object.getOwnPropertyDescriptor(el, 'value');
22
22
  const filesDescr = Object.getOwnPropertyDescriptor(el, 'files');
@@ -40,8 +40,8 @@ function setFiles(el, files) {
40
40
  if (v === '') {
41
41
  restore();
42
42
  } else {
43
- var ref;
44
- valueDescr === null || valueDescr === void 0 ? void 0 : (ref = valueDescr.set) === null || ref === void 0 ? void 0 : ref.call(el, v);
43
+ var _valueDescr_set, _valueDescr;
44
+ (_valueDescr = valueDescr) === null || _valueDescr === void 0 ? void 0 : (_valueDescr_set = _valueDescr.set) === null || _valueDescr_set === void 0 ? void 0 : _valueDescr_set.call(el, v);
45
45
  }
46
46
  }
47
47
  },
@@ -104,14 +104,14 @@ function isTextNode(node) {
104
104
  }
105
105
  function walkNodes(node, direction, callback) {
106
106
  for(;;){
107
- var ref;
107
+ var _node_ownerDocument;
108
108
  const sibling = node[`${direction}Sibling`];
109
109
  if (sibling) {
110
110
  node = getDescendant(sibling, direction === 'next' ? 'first' : 'last');
111
111
  if (callback(node)) {
112
112
  return node;
113
113
  }
114
- } else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable.isContentEditable(node.parentNode) && node.parentNode !== ((ref = node.ownerDocument) === null || ref === void 0 ? void 0 : ref.body))) {
114
+ } 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))) {
115
115
  node = node.parentNode;
116
116
  } else {
117
117
  break;
@@ -5,8 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var isDisabled = require('../misc/isDisabled.js');
6
6
 
7
7
  function getActiveElement(document) {
8
+ var _activeElement;
8
9
  const activeElement = document.activeElement;
9
- if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.shadowRoot) {
10
+ if ((_activeElement = activeElement) === null || _activeElement === void 0 ? void 0 : _activeElement.shadowRoot) {
10
11
  return getActiveElement(activeElement.shadowRoot);
11
12
  } else {
12
13
  // Browser does not yield disabled elements as document.activeElement - jsdom does
@@ -17,8 +18,8 @@ function getActiveElement(document) {
17
18
  }
18
19
  }
19
20
  function getActiveElementOrBody(document) {
20
- var ref;
21
- return (ref = getActiveElement(document)) !== null && ref !== void 0 ? ref : /* istanbul ignore next */ document.body;
21
+ var _getActiveElement;
22
+ return (_getActiveElement = getActiveElement(document)) !== null && _getActiveElement !== void 0 ? _getActiveElement : /* istanbul ignore next */ document.body;
22
23
  }
23
24
 
24
25
  exports.getActiveElement = getActiveElement;