@testing-library/user-event 13.4.1 → 14.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/clear.d.ts +2 -2
- package/dist/clear.js +14 -29
- package/dist/click.d.ts +4 -3
- package/dist/click.js +29 -143
- package/dist/document/index.d.ts +10 -0
- package/dist/document/index.js +100 -0
- package/dist/document/interceptor.d.ts +15 -0
- package/dist/document/interceptor.js +37 -0
- package/dist/document/selection.d.ts +27 -0
- package/dist/document/selection.js +90 -0
- package/dist/document/value.d.ts +18 -0
- package/dist/document/value.js +77 -0
- package/dist/hover.d.ts +3 -3
- package/dist/hover.js +15 -57
- package/dist/index.d.ts +4 -21
- package/dist/index.js +4 -29
- package/dist/keyboard/getNextKeyDef.d.ts +3 -0
- package/dist/keyboard/getNextKeyDef.js +59 -87
- package/dist/keyboard/index.d.ts +1 -0
- package/dist/keyboard/index.js +4 -0
- package/dist/keyboard/keyMap.js +4 -0
- package/dist/keyboard/keyboardImplementation.js +28 -8
- package/dist/keyboard/plugins/arrow.js +7 -12
- package/dist/keyboard/plugins/character.js +29 -57
- package/dist/keyboard/plugins/combination.d.ts +5 -0
- package/dist/keyboard/plugins/combination.js +17 -0
- package/dist/keyboard/plugins/control.js +5 -16
- package/dist/keyboard/plugins/functional.js +33 -15
- package/dist/keyboard/plugins/index.js +5 -5
- package/dist/keyboard/shared/index.d.ts +0 -2
- package/dist/keyboard/shared/index.js +0 -26
- package/dist/keyboard/types.d.ts +8 -0
- package/dist/paste.d.ts +3 -2
- package/dist/paste.js +8 -15
- package/dist/pointer/index.d.ts +18 -0
- package/dist/pointer/index.js +90 -0
- package/dist/pointer/keyMap.d.ts +2 -0
- package/dist/pointer/keyMap.js +29 -0
- package/dist/pointer/parseKeyDef.d.ts +6 -0
- package/dist/pointer/parseKeyDef.js +36 -0
- package/dist/pointer/pointerAction.d.ts +6 -0
- package/dist/pointer/pointerAction.js +52 -0
- package/dist/pointer/pointerMove.d.ts +5 -0
- package/dist/pointer/pointerMove.js +136 -0
- package/dist/pointer/pointerPress.d.ts +7 -0
- package/dist/pointer/pointerPress.js +330 -0
- package/dist/pointer/resolveSelectionTarget.d.ts +5 -0
- package/dist/pointer/resolveSelectionTarget.js +75 -0
- package/dist/pointer/types.d.ts +72 -0
- package/dist/pointer/types.js +1 -0
- package/dist/selectOptions.d.ts +4 -0
- package/dist/{select-options.js → selectOptions.js} +18 -20
- package/dist/setup.d.ts +92 -0
- package/dist/setup.js +203 -0
- package/dist/tab.d.ts +3 -4
- package/dist/tab.js +3 -136
- package/dist/type.d.ts +14 -0
- package/dist/type.js +74 -0
- package/dist/upload.d.ts +4 -3
- package/dist/upload.js +3 -9
- package/dist/utils/edit/calculateNewValue.d.ts +12 -5
- package/dist/utils/edit/calculateNewValue.js +19 -21
- package/dist/utils/edit/editInputElement.d.ts +16 -0
- package/dist/utils/edit/editInputElement.js +53 -0
- package/dist/utils/edit/getValue.d.ts +1 -1
- package/dist/utils/edit/getValue.js +3 -1
- package/dist/utils/edit/isContentEditable.d.ts +4 -0
- package/dist/utils/edit/isContentEditable.js +14 -0
- package/dist/utils/edit/isEditable.d.ts +1 -0
- package/dist/utils/edit/prepareInput.d.ts +7 -0
- package/dist/utils/edit/prepareInput.js +77 -0
- package/dist/{blur.d.ts → utils/focus/blur.d.ts} +0 -0
- package/dist/utils/focus/blur.js +19 -0
- package/dist/{focus.d.ts → utils/focus/focus.d.ts} +0 -0
- package/dist/utils/focus/focus.js +22 -0
- package/dist/utils/focus/getTabDestination.d.ts +1 -0
- package/dist/utils/focus/getTabDestination.js +71 -0
- package/dist/utils/focus/isFocusable.js +1 -3
- package/dist/utils/focus/selectAll.d.ts +5 -0
- package/dist/utils/focus/selectAll.js +51 -0
- package/dist/utils/focus/selection.d.ts +42 -0
- package/dist/utils/focus/selection.js +190 -0
- package/dist/utils/index.d.ts +13 -6
- package/dist/utils/index.js +145 -54
- package/dist/utils/keyDef/readNextDescriptor.d.ts +19 -0
- package/dist/utils/keyDef/readNextDescriptor.js +102 -0
- package/dist/utils/misc/findClosest.d.ts +1 -0
- package/dist/utils/misc/findClosest.js +20 -0
- package/dist/utils/misc/hasFormSubmit.d.ts +1 -0
- package/dist/utils/misc/hasFormSubmit.js +10 -0
- package/dist/utils/misc/isDescendantOrSelf.d.ts +1 -0
- package/dist/utils/misc/isDescendantOrSelf.js +20 -0
- package/dist/utils/pointer/firePointerEvents.d.ts +25 -0
- package/dist/utils/pointer/firePointerEvents.js +112 -0
- package/dist/utils/pointer/mouseButtons.d.ts +12 -0
- package/dist/utils/pointer/mouseButtons.js +45 -0
- package/package.json +4 -3
- package/dist/blur.js +0 -15
- package/dist/dom-helpers.d.ts +0 -3
- package/dist/focus.js +0 -15
- package/dist/keyboard/shared/carryValue.d.ts +0 -2
- package/dist/keyboard/shared/carryValue.js +0 -13
- package/dist/keyboard/shared/fireInputEvent.d.ts +0 -17
- package/dist/keyboard/shared/fireInputEvent.js +0 -110
- package/dist/select-options.d.ts +0 -4
- package/dist/type/index.d.ts +0 -7
- package/dist/type/index.js +0 -33
- package/dist/type/typeImplementation.d.ts +0 -10
- package/dist/type/typeImplementation.js +0 -64
- package/dist/utils/click/getMouseEventOptions.d.ts +0 -31
- package/dist/utils/click/getMouseEventOptions.js +0 -61
- package/dist/utils/edit/cursorPosition.d.ts +0 -2
- package/dist/utils/edit/cursorPosition.js +0 -35
- package/dist/utils/edit/hasUnreliableEmptyValue.d.ts +0 -10
- package/dist/utils/edit/hasUnreliableEmptyValue.js +0 -21
- package/dist/utils/edit/selectionRange.d.ts +0 -16
- package/dist/utils/edit/selectionRange.js +0 -104
- package/dist/utils/misc/isDocument.d.ts +0 -1
- package/dist/utils/misc/isDocument.js +0 -10
- package/dist/utils/misc/isLabelWithInternallyDisabledControl.d.ts +0 -1
- package/dist/utils/misc/isLabelWithInternallyDisabledControl.js +0 -22
package/dist/utils/index.js
CHANGED
|
@@ -4,19 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
var _getMouseEventOptions = require("./click/getMouseEventOptions");
|
|
8
|
-
|
|
9
|
-
Object.keys(_getMouseEventOptions).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _getMouseEventOptions[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _getMouseEventOptions[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
7
|
var _isClickableInput = require("./click/isClickableInput");
|
|
21
8
|
|
|
22
9
|
Object.keys(_isClickableInput).forEach(function (key) {
|
|
@@ -56,15 +43,15 @@ Object.keys(_calculateNewValue).forEach(function (key) {
|
|
|
56
43
|
});
|
|
57
44
|
});
|
|
58
45
|
|
|
59
|
-
var
|
|
46
|
+
var _editInputElement = require("./edit/editInputElement");
|
|
60
47
|
|
|
61
|
-
Object.keys(
|
|
48
|
+
Object.keys(_editInputElement).forEach(function (key) {
|
|
62
49
|
if (key === "default" || key === "__esModule") return;
|
|
63
|
-
if (key in exports && exports[key] ===
|
|
50
|
+
if (key in exports && exports[key] === _editInputElement[key]) return;
|
|
64
51
|
Object.defineProperty(exports, key, {
|
|
65
52
|
enumerable: true,
|
|
66
53
|
get: function () {
|
|
67
|
-
return
|
|
54
|
+
return _editInputElement[key];
|
|
68
55
|
}
|
|
69
56
|
});
|
|
70
57
|
});
|
|
@@ -82,19 +69,6 @@ Object.keys(_getValue).forEach(function (key) {
|
|
|
82
69
|
});
|
|
83
70
|
});
|
|
84
71
|
|
|
85
|
-
var _hasUnreliableEmptyValue = require("./edit/hasUnreliableEmptyValue");
|
|
86
|
-
|
|
87
|
-
Object.keys(_hasUnreliableEmptyValue).forEach(function (key) {
|
|
88
|
-
if (key === "default" || key === "__esModule") return;
|
|
89
|
-
if (key in exports && exports[key] === _hasUnreliableEmptyValue[key]) return;
|
|
90
|
-
Object.defineProperty(exports, key, {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
get: function () {
|
|
93
|
-
return _hasUnreliableEmptyValue[key];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
72
|
var _isContentEditable = require("./edit/isContentEditable");
|
|
99
73
|
|
|
100
74
|
Object.keys(_isContentEditable).forEach(function (key) {
|
|
@@ -160,15 +134,41 @@ Object.keys(_maxLength).forEach(function (key) {
|
|
|
160
134
|
});
|
|
161
135
|
});
|
|
162
136
|
|
|
163
|
-
var
|
|
137
|
+
var _prepareInput = require("./edit/prepareInput");
|
|
138
|
+
|
|
139
|
+
Object.keys(_prepareInput).forEach(function (key) {
|
|
140
|
+
if (key === "default" || key === "__esModule") return;
|
|
141
|
+
if (key in exports && exports[key] === _prepareInput[key]) return;
|
|
142
|
+
Object.defineProperty(exports, key, {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function () {
|
|
145
|
+
return _prepareInput[key];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
var _blur = require("./focus/blur");
|
|
151
|
+
|
|
152
|
+
Object.keys(_blur).forEach(function (key) {
|
|
153
|
+
if (key === "default" || key === "__esModule") return;
|
|
154
|
+
if (key in exports && exports[key] === _blur[key]) return;
|
|
155
|
+
Object.defineProperty(exports, key, {
|
|
156
|
+
enumerable: true,
|
|
157
|
+
get: function () {
|
|
158
|
+
return _blur[key];
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
var _focus = require("./focus/focus");
|
|
164
164
|
|
|
165
|
-
Object.keys(
|
|
165
|
+
Object.keys(_focus).forEach(function (key) {
|
|
166
166
|
if (key === "default" || key === "__esModule") return;
|
|
167
|
-
if (key in exports && exports[key] ===
|
|
167
|
+
if (key in exports && exports[key] === _focus[key]) return;
|
|
168
168
|
Object.defineProperty(exports, key, {
|
|
169
169
|
enumerable: true,
|
|
170
170
|
get: function () {
|
|
171
|
-
return
|
|
171
|
+
return _focus[key];
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
});
|
|
@@ -186,6 +186,19 @@ Object.keys(_getActiveElement).forEach(function (key) {
|
|
|
186
186
|
});
|
|
187
187
|
});
|
|
188
188
|
|
|
189
|
+
var _getTabDestination = require("./focus/getTabDestination");
|
|
190
|
+
|
|
191
|
+
Object.keys(_getTabDestination).forEach(function (key) {
|
|
192
|
+
if (key === "default" || key === "__esModule") return;
|
|
193
|
+
if (key in exports && exports[key] === _getTabDestination[key]) return;
|
|
194
|
+
Object.defineProperty(exports, key, {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function () {
|
|
197
|
+
return _getTabDestination[key];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
189
202
|
var _isFocusable = require("./focus/isFocusable");
|
|
190
203
|
|
|
191
204
|
Object.keys(_isFocusable).forEach(function (key) {
|
|
@@ -199,6 +212,32 @@ Object.keys(_isFocusable).forEach(function (key) {
|
|
|
199
212
|
});
|
|
200
213
|
});
|
|
201
214
|
|
|
215
|
+
var _selectAll = require("./focus/selectAll");
|
|
216
|
+
|
|
217
|
+
Object.keys(_selectAll).forEach(function (key) {
|
|
218
|
+
if (key === "default" || key === "__esModule") return;
|
|
219
|
+
if (key in exports && exports[key] === _selectAll[key]) return;
|
|
220
|
+
Object.defineProperty(exports, key, {
|
|
221
|
+
enumerable: true,
|
|
222
|
+
get: function () {
|
|
223
|
+
return _selectAll[key];
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
var _selection = require("./focus/selection");
|
|
229
|
+
|
|
230
|
+
Object.keys(_selection).forEach(function (key) {
|
|
231
|
+
if (key === "default" || key === "__esModule") return;
|
|
232
|
+
if (key in exports && exports[key] === _selection[key]) return;
|
|
233
|
+
Object.defineProperty(exports, key, {
|
|
234
|
+
enumerable: true,
|
|
235
|
+
get: function () {
|
|
236
|
+
return _selection[key];
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
|
|
202
241
|
var _selector = require("./focus/selector");
|
|
203
242
|
|
|
204
243
|
Object.keys(_selector).forEach(function (key) {
|
|
@@ -212,6 +251,19 @@ Object.keys(_selector).forEach(function (key) {
|
|
|
212
251
|
});
|
|
213
252
|
});
|
|
214
253
|
|
|
254
|
+
var _readNextDescriptor = require("./keyDef/readNextDescriptor");
|
|
255
|
+
|
|
256
|
+
Object.keys(_readNextDescriptor).forEach(function (key) {
|
|
257
|
+
if (key === "default" || key === "__esModule") return;
|
|
258
|
+
if (key in exports && exports[key] === _readNextDescriptor[key]) return;
|
|
259
|
+
Object.defineProperty(exports, key, {
|
|
260
|
+
enumerable: true,
|
|
261
|
+
get: function () {
|
|
262
|
+
return _readNextDescriptor[key];
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
|
|
215
267
|
var _eventWrapper = require("./misc/eventWrapper");
|
|
216
268
|
|
|
217
269
|
Object.keys(_eventWrapper).forEach(function (key) {
|
|
@@ -225,67 +277,67 @@ Object.keys(_eventWrapper).forEach(function (key) {
|
|
|
225
277
|
});
|
|
226
278
|
});
|
|
227
279
|
|
|
228
|
-
var
|
|
280
|
+
var _findClosest = require("./misc/findClosest");
|
|
229
281
|
|
|
230
|
-
Object.keys(
|
|
282
|
+
Object.keys(_findClosest).forEach(function (key) {
|
|
231
283
|
if (key === "default" || key === "__esModule") return;
|
|
232
|
-
if (key in exports && exports[key] ===
|
|
284
|
+
if (key in exports && exports[key] === _findClosest[key]) return;
|
|
233
285
|
Object.defineProperty(exports, key, {
|
|
234
286
|
enumerable: true,
|
|
235
287
|
get: function () {
|
|
236
|
-
return
|
|
288
|
+
return _findClosest[key];
|
|
237
289
|
}
|
|
238
290
|
});
|
|
239
291
|
});
|
|
240
292
|
|
|
241
|
-
var
|
|
293
|
+
var _isDescendantOrSelf = require("./misc/isDescendantOrSelf");
|
|
242
294
|
|
|
243
|
-
Object.keys(
|
|
295
|
+
Object.keys(_isDescendantOrSelf).forEach(function (key) {
|
|
244
296
|
if (key === "default" || key === "__esModule") return;
|
|
245
|
-
if (key in exports && exports[key] ===
|
|
297
|
+
if (key in exports && exports[key] === _isDescendantOrSelf[key]) return;
|
|
246
298
|
Object.defineProperty(exports, key, {
|
|
247
299
|
enumerable: true,
|
|
248
300
|
get: function () {
|
|
249
|
-
return
|
|
301
|
+
return _isDescendantOrSelf[key];
|
|
250
302
|
}
|
|
251
303
|
});
|
|
252
304
|
});
|
|
253
305
|
|
|
254
|
-
var
|
|
306
|
+
var _isElementType = require("./misc/isElementType");
|
|
255
307
|
|
|
256
|
-
Object.keys(
|
|
308
|
+
Object.keys(_isElementType).forEach(function (key) {
|
|
257
309
|
if (key === "default" || key === "__esModule") return;
|
|
258
|
-
if (key in exports && exports[key] ===
|
|
310
|
+
if (key in exports && exports[key] === _isElementType[key]) return;
|
|
259
311
|
Object.defineProperty(exports, key, {
|
|
260
312
|
enumerable: true,
|
|
261
313
|
get: function () {
|
|
262
|
-
return
|
|
314
|
+
return _isElementType[key];
|
|
263
315
|
}
|
|
264
316
|
});
|
|
265
317
|
});
|
|
266
318
|
|
|
267
|
-
var
|
|
319
|
+
var _isVisible = require("./misc/isVisible");
|
|
268
320
|
|
|
269
|
-
Object.keys(
|
|
321
|
+
Object.keys(_isVisible).forEach(function (key) {
|
|
270
322
|
if (key === "default" || key === "__esModule") return;
|
|
271
|
-
if (key in exports && exports[key] ===
|
|
323
|
+
if (key in exports && exports[key] === _isVisible[key]) return;
|
|
272
324
|
Object.defineProperty(exports, key, {
|
|
273
325
|
enumerable: true,
|
|
274
326
|
get: function () {
|
|
275
|
-
return
|
|
327
|
+
return _isVisible[key];
|
|
276
328
|
}
|
|
277
329
|
});
|
|
278
330
|
});
|
|
279
331
|
|
|
280
|
-
var
|
|
332
|
+
var _isDisabled = require("./misc/isDisabled");
|
|
281
333
|
|
|
282
|
-
Object.keys(
|
|
334
|
+
Object.keys(_isDisabled).forEach(function (key) {
|
|
283
335
|
if (key === "default" || key === "__esModule") return;
|
|
284
|
-
if (key in exports && exports[key] ===
|
|
336
|
+
if (key in exports && exports[key] === _isDisabled[key]) return;
|
|
285
337
|
Object.defineProperty(exports, key, {
|
|
286
338
|
enumerable: true,
|
|
287
339
|
get: function () {
|
|
288
|
-
return
|
|
340
|
+
return _isDisabled[key];
|
|
289
341
|
}
|
|
290
342
|
});
|
|
291
343
|
});
|
|
@@ -314,4 +366,43 @@ Object.keys(_hasPointerEvents).forEach(function (key) {
|
|
|
314
366
|
return _hasPointerEvents[key];
|
|
315
367
|
}
|
|
316
368
|
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
var _hasFormSubmit = require("./misc/hasFormSubmit");
|
|
372
|
+
|
|
373
|
+
Object.keys(_hasFormSubmit).forEach(function (key) {
|
|
374
|
+
if (key === "default" || key === "__esModule") return;
|
|
375
|
+
if (key in exports && exports[key] === _hasFormSubmit[key]) return;
|
|
376
|
+
Object.defineProperty(exports, key, {
|
|
377
|
+
enumerable: true,
|
|
378
|
+
get: function () {
|
|
379
|
+
return _hasFormSubmit[key];
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
});
|
|
383
|
+
|
|
384
|
+
var _firePointerEvents = require("./pointer/firePointerEvents");
|
|
385
|
+
|
|
386
|
+
Object.keys(_firePointerEvents).forEach(function (key) {
|
|
387
|
+
if (key === "default" || key === "__esModule") return;
|
|
388
|
+
if (key in exports && exports[key] === _firePointerEvents[key]) return;
|
|
389
|
+
Object.defineProperty(exports, key, {
|
|
390
|
+
enumerable: true,
|
|
391
|
+
get: function () {
|
|
392
|
+
return _firePointerEvents[key];
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
var _mouseButtons = require("./pointer/mouseButtons");
|
|
398
|
+
|
|
399
|
+
Object.keys(_mouseButtons).forEach(function (key) {
|
|
400
|
+
if (key === "default" || key === "__esModule") return;
|
|
401
|
+
if (key in exports && exports[key] === _mouseButtons[key]) return;
|
|
402
|
+
Object.defineProperty(exports, key, {
|
|
403
|
+
enumerable: true,
|
|
404
|
+
get: function () {
|
|
405
|
+
return _mouseButtons[key];
|
|
406
|
+
}
|
|
407
|
+
});
|
|
317
408
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read the next key definition from user input
|
|
3
|
+
*
|
|
4
|
+
* Describe key per `{descriptor}` or `[descriptor]`.
|
|
5
|
+
* Everything else will be interpreted as a single character as descriptor - e.g. `a`.
|
|
6
|
+
* Brackets `{` and `[` can be escaped by doubling - e.g. `foo[[bar` translates to `foo[bar`.
|
|
7
|
+
* A previously pressed key can be released per `{/descriptor}`.
|
|
8
|
+
* Keeping the key pressed can be written as `{descriptor>}`.
|
|
9
|
+
* When keeping the key pressed you can choose how long the key is pressed `{descriptor>3}`.
|
|
10
|
+
* You can then release the key per `{descriptor>3/}` or keep it pressed and continue with the next key.
|
|
11
|
+
*/
|
|
12
|
+
export declare function readNextDescriptor(text: string): {
|
|
13
|
+
consumedLength: number;
|
|
14
|
+
descriptor: string;
|
|
15
|
+
releasePrevious: boolean;
|
|
16
|
+
repeat: number;
|
|
17
|
+
releaseSelf: boolean | undefined;
|
|
18
|
+
type: string;
|
|
19
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.readNextDescriptor = readNextDescriptor;
|
|
7
|
+
var bracketDict;
|
|
8
|
+
/**
|
|
9
|
+
* Read the next key definition from user input
|
|
10
|
+
*
|
|
11
|
+
* Describe key per `{descriptor}` or `[descriptor]`.
|
|
12
|
+
* Everything else will be interpreted as a single character as descriptor - e.g. `a`.
|
|
13
|
+
* Brackets `{` and `[` can be escaped by doubling - e.g. `foo[[bar` translates to `foo[bar`.
|
|
14
|
+
* A previously pressed key can be released per `{/descriptor}`.
|
|
15
|
+
* Keeping the key pressed can be written as `{descriptor>}`.
|
|
16
|
+
* When keeping the key pressed you can choose how long the key is pressed `{descriptor>3}`.
|
|
17
|
+
* You can then release the key per `{descriptor>3/}` or keep it pressed and continue with the next key.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
(function (bracketDict) {
|
|
21
|
+
bracketDict["{"] = "}";
|
|
22
|
+
bracketDict["["] = "]";
|
|
23
|
+
})(bracketDict || (bracketDict = {}));
|
|
24
|
+
|
|
25
|
+
function readNextDescriptor(text) {
|
|
26
|
+
let pos = 0;
|
|
27
|
+
const startBracket = text[pos] in bracketDict ? text[pos] : '';
|
|
28
|
+
pos += startBracket.length; // `foo{{bar` is an escaped char at position 3,
|
|
29
|
+
// but `foo{{{>5}bar` should be treated as `{` pressed down for 5 keydowns.
|
|
30
|
+
|
|
31
|
+
const startBracketRepeated = startBracket ? text.match(new RegExp(`^\\${startBracket}+`))[0].length : 0;
|
|
32
|
+
const isEscapedChar = startBracketRepeated === 2 || startBracket === '{' && startBracketRepeated > 3;
|
|
33
|
+
const type = isEscapedChar ? '' : startBracket;
|
|
34
|
+
return {
|
|
35
|
+
type,
|
|
36
|
+
...(type === '' ? readPrintableChar(text, pos) : readTag(text, pos, type))
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function readPrintableChar(text, pos) {
|
|
41
|
+
const descriptor = text[pos];
|
|
42
|
+
assertDescriptor(descriptor, text, pos);
|
|
43
|
+
pos += descriptor.length;
|
|
44
|
+
return {
|
|
45
|
+
consumedLength: pos,
|
|
46
|
+
descriptor,
|
|
47
|
+
releasePrevious: false,
|
|
48
|
+
releaseSelf: true,
|
|
49
|
+
repeat: 1
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function readTag(text, pos, startBracket) {
|
|
54
|
+
var _text$slice$match, _text$slice$match$, _text$slice$match2;
|
|
55
|
+
|
|
56
|
+
const releasePreviousModifier = text[pos] === '/' ? '/' : '';
|
|
57
|
+
pos += releasePreviousModifier.length;
|
|
58
|
+
const descriptor = (_text$slice$match = text.slice(pos).match(/^\w+/)) == null ? void 0 : _text$slice$match[0];
|
|
59
|
+
assertDescriptor(descriptor, text, pos);
|
|
60
|
+
pos += descriptor.length;
|
|
61
|
+
const repeatModifier = (_text$slice$match$ = (_text$slice$match2 = text.slice(pos).match(/^>\d+/)) == null ? void 0 : _text$slice$match2[0]) != null ? _text$slice$match$ : '';
|
|
62
|
+
pos += repeatModifier.length;
|
|
63
|
+
const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : '';
|
|
64
|
+
pos += releaseSelfModifier.length;
|
|
65
|
+
const expectedEndBracket = bracketDict[startBracket];
|
|
66
|
+
const endBracket = text[pos] === expectedEndBracket ? expectedEndBracket : '';
|
|
67
|
+
|
|
68
|
+
if (!endBracket) {
|
|
69
|
+
throw new Error(getErrorMessage([!repeatModifier && 'repeat modifier', !releaseSelfModifier && 'release modifier', `"${expectedEndBracket}"`].filter(Boolean).join(' or '), text[pos], text));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
pos += endBracket.length;
|
|
73
|
+
return {
|
|
74
|
+
consumedLength: pos,
|
|
75
|
+
descriptor,
|
|
76
|
+
releasePrevious: !!releasePreviousModifier,
|
|
77
|
+
repeat: repeatModifier ? Math.max(Number(repeatModifier.substr(1)), 1) : 1,
|
|
78
|
+
releaseSelf: hasReleaseSelf(releaseSelfModifier, repeatModifier)
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function assertDescriptor(descriptor, text, pos) {
|
|
83
|
+
if (!descriptor) {
|
|
84
|
+
throw new Error(getErrorMessage('key descriptor', text[pos], text));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function hasReleaseSelf(releaseSelfModifier, repeatModifier) {
|
|
89
|
+
if (releaseSelfModifier) {
|
|
90
|
+
return releaseSelfModifier === '/';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (repeatModifier) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function getErrorMessage(expected, found, text) {
|
|
99
|
+
return `Expected ${expected} but found "${found != null ? found : ''}" in "${text}"
|
|
100
|
+
See https://github.com/testing-library/user-event/blob/main/README.md#keyboardtext-options
|
|
101
|
+
for more information about how userEvent parses your input.`;
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findClosest(element: Element, callback: (e: Element) => boolean): Element | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.findClosest = findClosest;
|
|
7
|
+
|
|
8
|
+
function findClosest(element, callback) {
|
|
9
|
+
let el = element;
|
|
10
|
+
|
|
11
|
+
do {
|
|
12
|
+
if (callback(el)) {
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
el = el.parentElement;
|
|
17
|
+
} while (el && el !== element.ownerDocument.body);
|
|
18
|
+
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hasFormSubmit: (form: HTMLFormElement | null) => form is HTMLFormElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.hasFormSubmit = void 0;
|
|
7
|
+
|
|
8
|
+
const hasFormSubmit = form => !!(form && (form.querySelector('input[type="submit"]') || form.querySelector('button[type="submit"]')));
|
|
9
|
+
|
|
10
|
+
exports.hasFormSubmit = hasFormSubmit;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDescendantOrSelf(potentialDescendant: Element, potentialAncestor: Element): boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isDescendantOrSelf = isDescendantOrSelf;
|
|
7
|
+
|
|
8
|
+
function isDescendantOrSelf(potentialDescendant, potentialAncestor) {
|
|
9
|
+
let el = potentialDescendant;
|
|
10
|
+
|
|
11
|
+
do {
|
|
12
|
+
if (el === potentialAncestor) {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
el = el.parentElement;
|
|
17
|
+
} while (el);
|
|
18
|
+
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { pointerState } from '../../pointer/types';
|
|
2
|
+
import type { keyboardState } from '../../keyboard/types';
|
|
3
|
+
import { MouseButton } from './mouseButtons';
|
|
4
|
+
export declare function firePointerEvent(target: Element, type: string, { pointerState, keyboardState, pointerType, button, coords, pointerId, isPrimary, clickCount, }: {
|
|
5
|
+
pointerState: pointerState;
|
|
6
|
+
keyboardState: keyboardState;
|
|
7
|
+
pointerType?: 'mouse' | 'pen' | 'touch';
|
|
8
|
+
button?: MouseButton;
|
|
9
|
+
coords?: PointerCoords;
|
|
10
|
+
pointerId?: number;
|
|
11
|
+
isPrimary?: boolean;
|
|
12
|
+
clickCount?: number;
|
|
13
|
+
}): boolean;
|
|
14
|
+
export interface PointerCoords {
|
|
15
|
+
x?: number;
|
|
16
|
+
y?: number;
|
|
17
|
+
clientX?: number;
|
|
18
|
+
clientY?: number;
|
|
19
|
+
offsetX?: number;
|
|
20
|
+
offsetY?: number;
|
|
21
|
+
pageX?: number;
|
|
22
|
+
pageY?: number;
|
|
23
|
+
screenX?: number;
|
|
24
|
+
screenY?: number;
|
|
25
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.firePointerEvent = firePointerEvent;
|
|
7
|
+
|
|
8
|
+
var _dom = require("@testing-library/dom");
|
|
9
|
+
|
|
10
|
+
var _eventMap = require("@testing-library/dom/dist/event-map");
|
|
11
|
+
|
|
12
|
+
var _mouseButtons = require("./mouseButtons");
|
|
13
|
+
|
|
14
|
+
function firePointerEvent(target, type, {
|
|
15
|
+
pointerState,
|
|
16
|
+
keyboardState,
|
|
17
|
+
pointerType,
|
|
18
|
+
button,
|
|
19
|
+
coords,
|
|
20
|
+
pointerId,
|
|
21
|
+
isPrimary,
|
|
22
|
+
clickCount
|
|
23
|
+
}) {
|
|
24
|
+
const init = { ...coords,
|
|
25
|
+
altKey: keyboardState.modifiers.alt,
|
|
26
|
+
ctrlKey: keyboardState.modifiers.ctrl,
|
|
27
|
+
metaKey: keyboardState.modifiers.meta,
|
|
28
|
+
shiftKey: keyboardState.modifiers.shift
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
if (type === 'click' || type.startsWith('pointer')) {
|
|
32
|
+
init.pointerId = pointerId;
|
|
33
|
+
init.pointerType = pointerType;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (['pointerdown', 'pointerup'].includes(type)) {
|
|
37
|
+
init.isPrimary = isPrimary;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (['mousedown', 'mouseup', 'pointerdown', 'pointerup', 'click'].includes(type)) {
|
|
41
|
+
init.button = (0, _mouseButtons.getMouseButton)(button != null ? button : 0);
|
|
42
|
+
init.buttons = (0, _mouseButtons.getMouseButtons)(...pointerState.pressed.filter(p => p.keyDef.pointerType === pointerType).map(p => {
|
|
43
|
+
var _p$keyDef$button;
|
|
44
|
+
|
|
45
|
+
return (_p$keyDef$button = p.keyDef.button) != null ? _p$keyDef$button : 0;
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (['mousedown', 'mouseup', 'click', 'dblclick'].includes(type)) {
|
|
50
|
+
init.detail = clickCount;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const eventKey = Object.keys(_eventMap.eventMap).find(k => k.toLowerCase() === type);
|
|
54
|
+
|
|
55
|
+
const event = _dom.createEvent[eventKey](target, init); // see https://github.com/testing-library/react-testing-library/issues/268
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
assignPositionInit(event, init);
|
|
59
|
+
assignPointerInit(event, init);
|
|
60
|
+
return (0, _dom.fireEvent)(target, event);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function assignProps(obj, props) {
|
|
64
|
+
for (const [key, value] of Object.entries(props)) {
|
|
65
|
+
Object.defineProperty(obj, key, {
|
|
66
|
+
get: () => value
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function assignPositionInit(obj, {
|
|
72
|
+
x,
|
|
73
|
+
y,
|
|
74
|
+
clientX,
|
|
75
|
+
clientY,
|
|
76
|
+
offsetX,
|
|
77
|
+
offsetY,
|
|
78
|
+
pageX,
|
|
79
|
+
pageY,
|
|
80
|
+
screenX,
|
|
81
|
+
screenY
|
|
82
|
+
}) {
|
|
83
|
+
var _ref, _ref2, _ref3, _ref4;
|
|
84
|
+
|
|
85
|
+
assignProps(obj, {
|
|
86
|
+
/* istanbul ignore start */
|
|
87
|
+
x: (_ref = x != null ? x : clientX) != null ? _ref : 0,
|
|
88
|
+
y: (_ref2 = y != null ? y : clientY) != null ? _ref2 : 0,
|
|
89
|
+
clientX: (_ref3 = x != null ? x : clientX) != null ? _ref3 : 0,
|
|
90
|
+
clientY: (_ref4 = y != null ? y : clientY) != null ? _ref4 : 0,
|
|
91
|
+
offsetX: offsetX != null ? offsetX : 0,
|
|
92
|
+
offsetY: offsetY != null ? offsetY : 0,
|
|
93
|
+
pageX: pageX != null ? pageX : 0,
|
|
94
|
+
pageY: pageY != null ? pageY : 0,
|
|
95
|
+
screenX: screenX != null ? screenX : 0,
|
|
96
|
+
screenY: screenY != null ? screenY : 0
|
|
97
|
+
/* istanbul ignore end */
|
|
98
|
+
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function assignPointerInit(obj, {
|
|
103
|
+
isPrimary,
|
|
104
|
+
pointerId,
|
|
105
|
+
pointerType
|
|
106
|
+
}) {
|
|
107
|
+
assignProps(obj, {
|
|
108
|
+
isPrimary,
|
|
109
|
+
pointerId,
|
|
110
|
+
pointerType
|
|
111
|
+
});
|
|
112
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const MouseButton: {
|
|
2
|
+
readonly primary: 0;
|
|
3
|
+
readonly secondary: 1;
|
|
4
|
+
readonly auxiliary: 2;
|
|
5
|
+
readonly back: 3;
|
|
6
|
+
readonly X1: 3;
|
|
7
|
+
readonly forward: 4;
|
|
8
|
+
readonly X2: 4;
|
|
9
|
+
};
|
|
10
|
+
export declare type MouseButton = keyof typeof MouseButton | number;
|
|
11
|
+
export declare function getMouseButton(button: MouseButton): number;
|
|
12
|
+
export declare function getMouseButtons(...buttons: Array<MouseButton>): number;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MouseButton = void 0;
|
|
7
|
+
exports.getMouseButton = getMouseButton;
|
|
8
|
+
exports.getMouseButtons = getMouseButtons;
|
|
9
|
+
const MouseButton = {
|
|
10
|
+
primary: 0,
|
|
11
|
+
secondary: 1,
|
|
12
|
+
auxiliary: 2,
|
|
13
|
+
back: 3,
|
|
14
|
+
X1: 3,
|
|
15
|
+
forward: 4,
|
|
16
|
+
X2: 4
|
|
17
|
+
};
|
|
18
|
+
exports.MouseButton = MouseButton;
|
|
19
|
+
// Some legacy...
|
|
20
|
+
const MouseButtonFlip = {
|
|
21
|
+
auxiliary: 1,
|
|
22
|
+
secondary: 2,
|
|
23
|
+
1: 2,
|
|
24
|
+
2: 1
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
function getMouseButton(button) {
|
|
28
|
+
if (button in MouseButtonFlip) {
|
|
29
|
+
return MouseButtonFlip[button];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return typeof button === 'number' ? button : MouseButton[button];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getMouseButtons(...buttons) {
|
|
36
|
+
let v = 0;
|
|
37
|
+
|
|
38
|
+
for (const t of buttons) {
|
|
39
|
+
const pos = typeof t === 'number' ? t : MouseButton[t]; // eslint-disable-next-line no-bitwise
|
|
40
|
+
|
|
41
|
+
v |= 2 ** pos;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return v;
|
|
45
|
+
}
|