@testing-library/user-event 14.1.0 → 14.1.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.
- package/dist/index.cjs +195 -201
- package/dist/index.mjs +206 -212
- package/dist/types/options.d.ts +1 -1
- package/package.json +2 -1
package/dist/index.mjs
CHANGED
|
@@ -158,8 +158,8 @@ var DataTransferStub = class {
|
|
|
158
158
|
this.files = createFileList([]);
|
|
159
159
|
}
|
|
160
160
|
getData(format) {
|
|
161
|
-
var
|
|
162
|
-
const match = (
|
|
161
|
+
var _a;
|
|
162
|
+
const match = (_a = this.items.find(getTypeMatcher(format, true))) != null ? _a : this.items.find(getTypeMatcher(format, false));
|
|
163
163
|
let text = "";
|
|
164
164
|
match == null ? void 0 : match.getAsString((t) => {
|
|
165
165
|
text = t;
|
|
@@ -197,12 +197,12 @@ var DataTransferStub = class {
|
|
|
197
197
|
setDragImage() {
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
|
-
function createDataTransfer(
|
|
201
|
-
const dt = typeof
|
|
200
|
+
function createDataTransfer(window, files = []) {
|
|
201
|
+
const dt = typeof window.DataTransfer === "undefined" ? new DataTransferStub() : new window.DataTransfer();
|
|
202
202
|
Object.defineProperty(dt, "files", { get: () => createFileList(files) });
|
|
203
203
|
return dt;
|
|
204
204
|
}
|
|
205
|
-
function getBlobFromDataTransferItem(
|
|
205
|
+
function getBlobFromDataTransferItem(window, item) {
|
|
206
206
|
if (item.kind === "file") {
|
|
207
207
|
return item.getAsFile();
|
|
208
208
|
}
|
|
@@ -210,7 +210,7 @@ function getBlobFromDataTransferItem(window2, item) {
|
|
|
210
210
|
item.getAsString((s) => {
|
|
211
211
|
data = s;
|
|
212
212
|
});
|
|
213
|
-
return new
|
|
213
|
+
return new window.Blob([data], { type: item.type });
|
|
214
214
|
}
|
|
215
215
|
|
|
216
216
|
// src/utils/misc/getWindow.ts
|
|
@@ -220,95 +220,88 @@ function getWindow(node) {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
// src/utils/dataTransfer/Clipboard.ts
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
var ClipboardItemStub = class {
|
|
226
|
-
constructor(data) {
|
|
227
|
-
this[_a] = window;
|
|
228
|
-
this.data = data;
|
|
229
|
-
}
|
|
230
|
-
get types() {
|
|
231
|
-
return Array.from(Object.keys(this.data));
|
|
232
|
-
}
|
|
233
|
-
getType(type3) {
|
|
234
|
-
return __async(this, null, function* () {
|
|
235
|
-
const data = yield this.data[type3];
|
|
236
|
-
if (!data) {
|
|
237
|
-
throw new Error(`${type3} is not one of the available MIME types on this item.`);
|
|
238
|
-
}
|
|
239
|
-
return data instanceof this[Window].Blob ? data : new this[Window].Blob([data], { type: type3 });
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
};
|
|
243
|
-
_a = Window;
|
|
244
|
-
var ClipboardStubControl = Symbol("Manage ClipboardSub");
|
|
245
|
-
var _a2;
|
|
246
|
-
var ClipboardStub = class extends window.EventTarget {
|
|
247
|
-
constructor() {
|
|
248
|
-
super(...arguments);
|
|
249
|
-
this.items = [];
|
|
250
|
-
this[_a2] = window;
|
|
251
|
-
}
|
|
252
|
-
read() {
|
|
253
|
-
return __async(this, null, function* () {
|
|
254
|
-
return Array.from(this.items);
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
readText() {
|
|
258
|
-
return __async(this, null, function* () {
|
|
259
|
-
let text = "";
|
|
260
|
-
for (const item of this.items) {
|
|
261
|
-
const type3 = item.types.includes("text/plain") ? "text/plain" : item.types.find((t) => t.startsWith("text/"));
|
|
262
|
-
if (type3) {
|
|
263
|
-
text += yield item.getType(type3).then((b) => readBlobText(b, this[Window].FileReader));
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return text;
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
write(data) {
|
|
270
|
-
return __async(this, null, function* () {
|
|
271
|
-
this.items = data;
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
|
-
writeText(text) {
|
|
275
|
-
return __async(this, null, function* () {
|
|
276
|
-
this.items = [createClipboardItem(this[Window], text)];
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
_a2 = Window, ClipboardStubControl;
|
|
281
|
-
function createClipboardItem(window2, ...blobs) {
|
|
282
|
-
const data = Object.fromEntries(blobs.map((b) => [
|
|
223
|
+
function createClipboardItem(window, ...blobs) {
|
|
224
|
+
const dataMap = Object.fromEntries(blobs.map((b) => [
|
|
283
225
|
typeof b === "string" ? "text/plain" : b.type,
|
|
284
226
|
Promise.resolve(b)
|
|
285
227
|
]));
|
|
286
|
-
if (typeof
|
|
287
|
-
|
|
288
|
-
item[Window] = window2;
|
|
289
|
-
return item;
|
|
290
|
-
} else {
|
|
291
|
-
return new window2.ClipboardItem(data);
|
|
228
|
+
if (typeof window.ClipboardItem !== "undefined") {
|
|
229
|
+
return new window.ClipboardItem(dataMap);
|
|
292
230
|
}
|
|
231
|
+
return new class ClipboardItem {
|
|
232
|
+
constructor(d) {
|
|
233
|
+
this.data = d;
|
|
234
|
+
}
|
|
235
|
+
get types() {
|
|
236
|
+
return Array.from(Object.keys(this.data));
|
|
237
|
+
}
|
|
238
|
+
getType(type3) {
|
|
239
|
+
return __async(this, null, function* () {
|
|
240
|
+
const value = yield this.data[type3];
|
|
241
|
+
if (!value) {
|
|
242
|
+
throw new Error(`${type3} is not one of the available MIME types on this item.`);
|
|
243
|
+
}
|
|
244
|
+
return value instanceof window.Blob ? value : new window.Blob([value], { type: type3 });
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}(dataMap);
|
|
248
|
+
}
|
|
249
|
+
var ClipboardStubControl = Symbol("Manage ClipboardSub");
|
|
250
|
+
function createClipboardStub(window) {
|
|
251
|
+
var _a;
|
|
252
|
+
return new (_a = class extends window.EventTarget {
|
|
253
|
+
constructor() {
|
|
254
|
+
super(...arguments);
|
|
255
|
+
this.items = [];
|
|
256
|
+
}
|
|
257
|
+
read() {
|
|
258
|
+
return __async(this, null, function* () {
|
|
259
|
+
return Array.from(this.items);
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
readText() {
|
|
263
|
+
return __async(this, null, function* () {
|
|
264
|
+
let text = "";
|
|
265
|
+
for (const item of this.items) {
|
|
266
|
+
const type3 = item.types.includes("text/plain") ? "text/plain" : item.types.find((t) => t.startsWith("text/"));
|
|
267
|
+
if (type3) {
|
|
268
|
+
text += yield item.getType(type3).then((b) => readBlobText(b, window.FileReader));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return text;
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
write(data) {
|
|
275
|
+
return __async(this, null, function* () {
|
|
276
|
+
this.items = data;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
writeText(text) {
|
|
280
|
+
return __async(this, null, function* () {
|
|
281
|
+
this.items = [createClipboardItem(window, text)];
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}, ClipboardStubControl, _a)();
|
|
285
|
+
}
|
|
286
|
+
function isClipboardStub(clipboard) {
|
|
287
|
+
return !!(clipboard == null ? void 0 : clipboard[ClipboardStubControl]);
|
|
293
288
|
}
|
|
294
|
-
function attachClipboardStubToView(
|
|
295
|
-
if (
|
|
296
|
-
return
|
|
289
|
+
function attachClipboardStubToView(window) {
|
|
290
|
+
if (isClipboardStub(window.navigator.clipboard)) {
|
|
291
|
+
return window.navigator.clipboard[ClipboardStubControl];
|
|
297
292
|
}
|
|
298
|
-
const realClipboard = Object.getOwnPropertyDescriptor(
|
|
299
|
-
let stub =
|
|
300
|
-
stub[Window] = window2;
|
|
293
|
+
const realClipboard = Object.getOwnPropertyDescriptor(window.navigator, "clipboard");
|
|
294
|
+
let stub = createClipboardStub(window);
|
|
301
295
|
const control = {
|
|
302
296
|
resetClipboardStub: () => {
|
|
303
|
-
stub =
|
|
304
|
-
stub[Window] = window2;
|
|
297
|
+
stub = createClipboardStub(window);
|
|
305
298
|
stub[ClipboardStubControl] = control;
|
|
306
299
|
},
|
|
307
300
|
detachClipboardStub: () => {
|
|
308
301
|
if (realClipboard) {
|
|
309
|
-
Object.defineProperty(
|
|
302
|
+
Object.defineProperty(window.navigator, "clipboard", realClipboard);
|
|
310
303
|
} else {
|
|
311
|
-
Object.defineProperty(
|
|
304
|
+
Object.defineProperty(window.navigator, "clipboard", {
|
|
312
305
|
value: void 0,
|
|
313
306
|
configurable: true
|
|
314
307
|
});
|
|
@@ -316,48 +309,48 @@ function attachClipboardStubToView(window2) {
|
|
|
316
309
|
}
|
|
317
310
|
};
|
|
318
311
|
stub[ClipboardStubControl] = control;
|
|
319
|
-
Object.defineProperty(
|
|
312
|
+
Object.defineProperty(window.navigator, "clipboard", {
|
|
320
313
|
get: () => stub,
|
|
321
314
|
configurable: true
|
|
322
315
|
});
|
|
323
316
|
return stub[ClipboardStubControl];
|
|
324
317
|
}
|
|
325
|
-
function resetClipboardStubOnView(
|
|
326
|
-
if (
|
|
327
|
-
|
|
318
|
+
function resetClipboardStubOnView(window) {
|
|
319
|
+
if (isClipboardStub(window.navigator.clipboard)) {
|
|
320
|
+
window.navigator.clipboard[ClipboardStubControl].resetClipboardStub();
|
|
328
321
|
}
|
|
329
322
|
}
|
|
330
|
-
function detachClipboardStubFromView(
|
|
331
|
-
if (
|
|
332
|
-
|
|
323
|
+
function detachClipboardStubFromView(window) {
|
|
324
|
+
if (isClipboardStub(window.navigator.clipboard)) {
|
|
325
|
+
window.navigator.clipboard[ClipboardStubControl].detachClipboardStub();
|
|
333
326
|
}
|
|
334
327
|
}
|
|
335
|
-
function readDataTransferFromClipboard(
|
|
328
|
+
function readDataTransferFromClipboard(document) {
|
|
336
329
|
return __async(this, null, function* () {
|
|
337
|
-
const
|
|
338
|
-
const clipboard =
|
|
330
|
+
const window = document.defaultView;
|
|
331
|
+
const clipboard = window == null ? void 0 : window.navigator.clipboard;
|
|
339
332
|
const items = clipboard && (yield clipboard.read());
|
|
340
333
|
if (!items) {
|
|
341
334
|
throw new Error("The Clipboard API is unavailable.");
|
|
342
335
|
}
|
|
343
|
-
const dt = createDataTransfer(
|
|
336
|
+
const dt = createDataTransfer(window);
|
|
344
337
|
for (const item of items) {
|
|
345
338
|
for (const type3 of item.types) {
|
|
346
|
-
dt.setData(type3, yield item.getType(type3).then((b) => readBlobText(b,
|
|
339
|
+
dt.setData(type3, yield item.getType(type3).then((b) => readBlobText(b, window.FileReader)));
|
|
347
340
|
}
|
|
348
341
|
}
|
|
349
342
|
return dt;
|
|
350
343
|
});
|
|
351
344
|
}
|
|
352
|
-
function writeDataTransferToClipboard(
|
|
345
|
+
function writeDataTransferToClipboard(document, clipboardData) {
|
|
353
346
|
return __async(this, null, function* () {
|
|
354
|
-
const
|
|
355
|
-
const clipboard =
|
|
347
|
+
const window = getWindow(document);
|
|
348
|
+
const clipboard = window.navigator.clipboard;
|
|
356
349
|
const items = [];
|
|
357
350
|
for (let i = 0; i < clipboardData.items.length; i++) {
|
|
358
351
|
const dtItem = clipboardData.items[i];
|
|
359
|
-
const blob = getBlobFromDataTransferItem(
|
|
360
|
-
items.push(createClipboardItem(
|
|
352
|
+
const blob = getBlobFromDataTransferItem(window, dtItem);
|
|
353
|
+
items.push(createClipboardItem(window, blob));
|
|
361
354
|
}
|
|
362
355
|
const written = clipboard && (yield clipboard.write(items).then(() => true, () => false));
|
|
363
356
|
if (!written) {
|
|
@@ -365,11 +358,11 @@ function writeDataTransferToClipboard(document2, clipboardData) {
|
|
|
365
358
|
}
|
|
366
359
|
});
|
|
367
360
|
}
|
|
368
|
-
if (typeof afterEach === "function") {
|
|
369
|
-
afterEach(() => resetClipboardStubOnView(window));
|
|
361
|
+
if (typeof globalThis.afterEach === "function") {
|
|
362
|
+
globalThis.afterEach(() => resetClipboardStubOnView(globalThis.window));
|
|
370
363
|
}
|
|
371
|
-
if (typeof afterAll === "function") {
|
|
372
|
-
afterAll(() => detachClipboardStubFromView(window));
|
|
364
|
+
if (typeof globalThis.afterAll === "function") {
|
|
365
|
+
globalThis.afterAll(() => detachClipboardStubFromView(globalThis.window));
|
|
373
366
|
}
|
|
374
367
|
|
|
375
368
|
// src/utils/edit/isContentEditable.ts
|
|
@@ -396,6 +389,7 @@ function getValue(element) {
|
|
|
396
389
|
}
|
|
397
390
|
|
|
398
391
|
// src/utils/edit/buildTimeValue.ts
|
|
392
|
+
var parseInt = globalThis.parseInt;
|
|
399
393
|
function buildTimeValue(value) {
|
|
400
394
|
const onlyDigitsValue = value.replace(/\D/g, "");
|
|
401
395
|
if (onlyDigitsValue.length < 2) {
|
|
@@ -452,11 +446,11 @@ function getSpaceUntilMaxLength(element) {
|
|
|
452
446
|
return maxLength ? maxLength - value.length : void 0;
|
|
453
447
|
}
|
|
454
448
|
function getSanitizedMaxLength(element) {
|
|
455
|
-
var
|
|
449
|
+
var _a;
|
|
456
450
|
if (!supportsMaxLength(element)) {
|
|
457
451
|
return void 0;
|
|
458
452
|
}
|
|
459
|
-
const attr = (
|
|
453
|
+
const attr = (_a = element.getAttribute("maxlength")) != null ? _a : "";
|
|
460
454
|
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : void 0;
|
|
461
455
|
}
|
|
462
456
|
function supportsMaxLength(element) {
|
|
@@ -594,9 +588,9 @@ function commitInput(config, element, newOffset, inputInit) {
|
|
|
594
588
|
}
|
|
595
589
|
}
|
|
596
590
|
function isValidNumberInput(value) {
|
|
597
|
-
var
|
|
591
|
+
var _a, _b;
|
|
598
592
|
const valueParts = value.split("e", 2);
|
|
599
|
-
return !(/[^\d.\-e]/.test(value) || Number((
|
|
593
|
+
return !(/[^\d.\-e]/.test(value) || Number((_a = value.match(/-/g)) == null ? void 0 : _a.length) > 2 || Number((_b = value.match(/\./g)) == null ? void 0 : _b.length) > 1 || valueParts[1] && !/^-?\d*$/.test(valueParts[1]));
|
|
600
594
|
}
|
|
601
595
|
|
|
602
596
|
// src/utils/edit/isEditable.ts
|
|
@@ -625,8 +619,8 @@ function isEditableInput(element) {
|
|
|
625
619
|
// src/utils/edit/setFiles.ts
|
|
626
620
|
var fakeFiles = Symbol("files and value properties are mocked");
|
|
627
621
|
function setFiles(el, files) {
|
|
628
|
-
var
|
|
629
|
-
(
|
|
622
|
+
var _a;
|
|
623
|
+
(_a = el[fakeFiles]) == null ? void 0 : _a.restore();
|
|
630
624
|
const objectDescriptors = Object.getOwnPropertyDescriptors(el);
|
|
631
625
|
const prototypeDescriptors = Object.getOwnPropertyDescriptors(Object.getPrototypeOf(el));
|
|
632
626
|
function restore() {
|
|
@@ -644,11 +638,11 @@ function setFiles(el, files) {
|
|
|
644
638
|
value: __spreadProps(__spreadValues(__spreadValues({}, prototypeDescriptors.value), objectDescriptors.value), {
|
|
645
639
|
get: () => files.length ? `C:\\fakepath\\${files[0].name}` : "",
|
|
646
640
|
set(v) {
|
|
647
|
-
var
|
|
641
|
+
var _a2;
|
|
648
642
|
if (v === "") {
|
|
649
643
|
restore();
|
|
650
644
|
} else {
|
|
651
|
-
(
|
|
645
|
+
(_a2 = objectDescriptors.value.set) == null ? void 0 : _a2.call(el, v);
|
|
652
646
|
}
|
|
653
647
|
}
|
|
654
648
|
}),
|
|
@@ -675,7 +669,7 @@ function eventWrapper(cb) {
|
|
|
675
669
|
|
|
676
670
|
// src/utils/misc/isDisabled.ts
|
|
677
671
|
function isDisabled(element) {
|
|
678
|
-
var
|
|
672
|
+
var _a;
|
|
679
673
|
for (let el = element; el; el = el.parentElement) {
|
|
680
674
|
if (isElementType(el, [
|
|
681
675
|
"button",
|
|
@@ -689,7 +683,7 @@ function isDisabled(element) {
|
|
|
689
683
|
return true;
|
|
690
684
|
}
|
|
691
685
|
} else if (isElementType(el, "fieldset")) {
|
|
692
|
-
if (el.hasAttribute("disabled") && !((
|
|
686
|
+
if (el.hasAttribute("disabled") && !((_a = el.querySelector(":scope > legend")) == null ? void 0 : _a.contains(element))) {
|
|
693
687
|
return true;
|
|
694
688
|
}
|
|
695
689
|
} else if (el.tagName.includes("-")) {
|
|
@@ -702,13 +696,13 @@ function isDisabled(element) {
|
|
|
702
696
|
}
|
|
703
697
|
|
|
704
698
|
// src/utils/focus/getActiveElement.ts
|
|
705
|
-
function getActiveElement(
|
|
706
|
-
const activeElement =
|
|
699
|
+
function getActiveElement(document) {
|
|
700
|
+
const activeElement = document.activeElement;
|
|
707
701
|
if (activeElement == null ? void 0 : activeElement.shadowRoot) {
|
|
708
702
|
return getActiveElement(activeElement.shadowRoot);
|
|
709
703
|
} else {
|
|
710
704
|
if (isDisabled(activeElement)) {
|
|
711
|
-
return
|
|
705
|
+
return document.ownerDocument ? document.ownerDocument.body : document.body;
|
|
712
706
|
}
|
|
713
707
|
return activeElement;
|
|
714
708
|
}
|
|
@@ -822,7 +816,7 @@ function isTextNode(node) {
|
|
|
822
816
|
return node.nodeType === 3;
|
|
823
817
|
}
|
|
824
818
|
function walkNodes(node, direction, callback) {
|
|
825
|
-
var
|
|
819
|
+
var _a;
|
|
826
820
|
for (; ; ) {
|
|
827
821
|
const sibling = node[`${direction}Sibling`];
|
|
828
822
|
if (sibling) {
|
|
@@ -830,7 +824,7 @@ function walkNodes(node, direction, callback) {
|
|
|
830
824
|
if (callback(node)) {
|
|
831
825
|
return node;
|
|
832
826
|
}
|
|
833
|
-
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((
|
|
827
|
+
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((_a = node.ownerDocument) == null ? void 0 : _a.body))) {
|
|
834
828
|
node = node.parentNode;
|
|
835
829
|
} else {
|
|
836
830
|
break;
|
|
@@ -846,7 +840,7 @@ function getDescendant(node, direction) {
|
|
|
846
840
|
|
|
847
841
|
// src/utils/focus/selection.ts
|
|
848
842
|
function setSelectionRange(element, anchorOffset, focusOffset) {
|
|
849
|
-
var
|
|
843
|
+
var _a;
|
|
850
844
|
if (hasOwnSelection(element)) {
|
|
851
845
|
return setSelection({
|
|
852
846
|
focusNode: element,
|
|
@@ -854,7 +848,7 @@ function setSelectionRange(element, anchorOffset, focusOffset) {
|
|
|
854
848
|
focusOffset
|
|
855
849
|
});
|
|
856
850
|
}
|
|
857
|
-
if (isContentEditable(element) && ((
|
|
851
|
+
if (isContentEditable(element) && ((_a = element.firstChild) == null ? void 0 : _a.nodeType) === 3) {
|
|
858
852
|
return setSelection({
|
|
859
853
|
focusNode: element.firstChild,
|
|
860
854
|
anchorOffset,
|
|
@@ -888,7 +882,7 @@ function getElement2(node) {
|
|
|
888
882
|
return node.nodeType === 1 ? node : node.parentElement;
|
|
889
883
|
}
|
|
890
884
|
function updateSelectionOnFocus(element) {
|
|
891
|
-
var
|
|
885
|
+
var _a;
|
|
892
886
|
const selection = element.ownerDocument.getSelection();
|
|
893
887
|
if (!(selection == null ? void 0 : selection.focusNode)) {
|
|
894
888
|
return;
|
|
@@ -897,7 +891,7 @@ function updateSelectionOnFocus(element) {
|
|
|
897
891
|
const contenteditable = getContentEditable(selection.focusNode);
|
|
898
892
|
if (contenteditable) {
|
|
899
893
|
if (!selection.isCollapsed) {
|
|
900
|
-
const focusNode = ((
|
|
894
|
+
const focusNode = ((_a = contenteditable.firstChild) == null ? void 0 : _a.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
|
|
901
895
|
selection.setBaseAndExtent(focusNode, 0, focusNode, 0);
|
|
902
896
|
}
|
|
903
897
|
} else {
|
|
@@ -906,12 +900,12 @@ function updateSelectionOnFocus(element) {
|
|
|
906
900
|
}
|
|
907
901
|
}
|
|
908
902
|
function getInputRange(focusNode) {
|
|
909
|
-
var
|
|
903
|
+
var _a;
|
|
910
904
|
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
911
905
|
if (typeAndSelection.type === "input") {
|
|
912
906
|
return typeAndSelection.selection;
|
|
913
907
|
} else if (typeAndSelection.type === "contenteditable") {
|
|
914
|
-
return (
|
|
908
|
+
return (_a = typeAndSelection.selection) == null ? void 0 : _a.getRangeAt(0);
|
|
915
909
|
}
|
|
916
910
|
}
|
|
917
911
|
function setSelection({
|
|
@@ -920,7 +914,7 @@ function setSelection({
|
|
|
920
914
|
anchorNode = focusNode,
|
|
921
915
|
anchorOffset = focusOffset
|
|
922
916
|
}) {
|
|
923
|
-
var
|
|
917
|
+
var _a, _b;
|
|
924
918
|
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
925
919
|
if (typeAndSelection.type === "input") {
|
|
926
920
|
return setUISelection(focusNode, {
|
|
@@ -928,7 +922,7 @@ function setSelection({
|
|
|
928
922
|
focusOffset
|
|
929
923
|
});
|
|
930
924
|
}
|
|
931
|
-
(_b = (
|
|
925
|
+
(_b = (_a = anchorNode.ownerDocument) == null ? void 0 : _a.getSelection()) == null ? void 0 : _b.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
932
926
|
}
|
|
933
927
|
function moveSelection(node, direction) {
|
|
934
928
|
if (hasOwnSelection(node)) {
|
|
@@ -1001,9 +995,9 @@ function focus(element) {
|
|
|
1001
995
|
|
|
1002
996
|
// src/utils/misc/isVisible.ts
|
|
1003
997
|
function isVisible(element) {
|
|
1004
|
-
const
|
|
998
|
+
const window = getWindow(element);
|
|
1005
999
|
for (let el = element; el == null ? void 0 : el.ownerDocument; el = el.parentElement) {
|
|
1006
|
-
const { display, visibility } =
|
|
1000
|
+
const { display, visibility } = window.getComputedStyle(el);
|
|
1007
1001
|
if (display === "none") {
|
|
1008
1002
|
return false;
|
|
1009
1003
|
}
|
|
@@ -1016,8 +1010,8 @@ function isVisible(element) {
|
|
|
1016
1010
|
|
|
1017
1011
|
// src/utils/focus/getTabDestination.ts
|
|
1018
1012
|
function getTabDestination(activeElement, shift) {
|
|
1019
|
-
const
|
|
1020
|
-
const focusableElements =
|
|
1013
|
+
const document = activeElement.ownerDocument;
|
|
1014
|
+
const focusableElements = document.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
1021
1015
|
const enabledElements = Array.from(focusableElements).filter((el) => el === activeElement || el.getAttribute("tabindex") !== "-1" && !isDisabled(el) && isVisible(el));
|
|
1022
1016
|
if (activeElement.getAttribute("tabindex") !== "-1") {
|
|
1023
1017
|
enabledElements.sort((a, b) => {
|
|
@@ -1034,7 +1028,7 @@ function getTabDestination(activeElement, shift) {
|
|
|
1034
1028
|
});
|
|
1035
1029
|
}
|
|
1036
1030
|
const checkedRadio = {};
|
|
1037
|
-
let prunedElements = [
|
|
1031
|
+
let prunedElements = [document.body];
|
|
1038
1032
|
const activeRadioGroup = isElementType(activeElement, "input", {
|
|
1039
1033
|
type: "radio"
|
|
1040
1034
|
}) ? activeElement.name : void 0;
|
|
@@ -1067,7 +1061,7 @@ function getTabDestination(activeElement, shift) {
|
|
|
1067
1061
|
|
|
1068
1062
|
// src/utils/focus/selectAll.ts
|
|
1069
1063
|
function selectAll(target) {
|
|
1070
|
-
var
|
|
1064
|
+
var _a;
|
|
1071
1065
|
if (isElementType(target, "textarea") || isElementType(target, "input") && target.type in editableInputTypes) {
|
|
1072
1066
|
return setSelection({
|
|
1073
1067
|
focusNode: target,
|
|
@@ -1075,7 +1069,7 @@ function selectAll(target) {
|
|
|
1075
1069
|
focusOffset: getUIValue(target).length
|
|
1076
1070
|
});
|
|
1077
1071
|
}
|
|
1078
|
-
const focusNode = (
|
|
1072
|
+
const focusNode = (_a = getContentEditable(target)) != null ? _a : target.ownerDocument.body;
|
|
1079
1073
|
setSelection({
|
|
1080
1074
|
focusNode,
|
|
1081
1075
|
anchorOffset: 0,
|
|
@@ -1083,11 +1077,11 @@ function selectAll(target) {
|
|
|
1083
1077
|
});
|
|
1084
1078
|
}
|
|
1085
1079
|
function isAllSelected(target) {
|
|
1086
|
-
var
|
|
1080
|
+
var _a;
|
|
1087
1081
|
if (isElementType(target, "textarea") || isElementType(target, "input") && target.type in editableInputTypes) {
|
|
1088
1082
|
return getUISelection(target).startOffset === 0 && getUISelection(target).endOffset === getUIValue(target).length;
|
|
1089
1083
|
}
|
|
1090
|
-
const focusNode = (
|
|
1084
|
+
const focusNode = (_a = getContentEditable(target)) != null ? _a : target.ownerDocument.body;
|
|
1091
1085
|
const selection = target.ownerDocument.getSelection();
|
|
1092
1086
|
return (selection == null ? void 0 : selection.anchorNode) === focusNode && selection.focusNode === focusNode && selection.anchorOffset === 0 && selection.focusOffset === focusNode.childNodes.length;
|
|
1093
1087
|
}
|
|
@@ -1147,12 +1141,12 @@ function readPrintableChar(text, pos, context) {
|
|
|
1147
1141
|
};
|
|
1148
1142
|
}
|
|
1149
1143
|
function readTag(text, pos, startBracket, context) {
|
|
1150
|
-
var
|
|
1144
|
+
var _a, _b, _c;
|
|
1151
1145
|
const releasePreviousModifier = text[pos] === "/" ? "/" : "";
|
|
1152
1146
|
pos += releasePreviousModifier.length;
|
|
1153
1147
|
const escapedDescriptor = startBracket === "{" && text[pos] === "\\";
|
|
1154
1148
|
pos += Number(escapedDescriptor);
|
|
1155
|
-
const descriptor = escapedDescriptor ? text[pos] : (
|
|
1149
|
+
const descriptor = escapedDescriptor ? text[pos] : (_a = text.slice(pos).match(startBracket === "{" ? /^\w+|^[^}>/]/ : /^\w+/)) == null ? void 0 : _a[0];
|
|
1156
1150
|
assertDescriptor(descriptor, text, pos, context);
|
|
1157
1151
|
pos += descriptor.length;
|
|
1158
1152
|
const repeatModifier = (_c = (_b = text.slice(pos).match(/^>\d+/)) == null ? void 0 : _b[0]) != null ? _c : "";
|
|
@@ -1224,13 +1218,13 @@ function isDescendantOrSelf(potentialDescendant, potentialAncestor) {
|
|
|
1224
1218
|
// src/utils/misc/level.ts
|
|
1225
1219
|
var Level = Symbol("Api level refs");
|
|
1226
1220
|
function setLevelRef(config, level) {
|
|
1227
|
-
var
|
|
1228
|
-
(
|
|
1221
|
+
var _a;
|
|
1222
|
+
(_a = config[Level]) != null ? _a : config[Level] = {};
|
|
1229
1223
|
config[Level][level] = {};
|
|
1230
1224
|
}
|
|
1231
1225
|
function getLevelRef(config, level) {
|
|
1232
|
-
var
|
|
1233
|
-
return (
|
|
1226
|
+
var _a;
|
|
1227
|
+
return (_a = config[Level]) == null ? void 0 : _a[level];
|
|
1234
1228
|
}
|
|
1235
1229
|
|
|
1236
1230
|
// src/utils/misc/wait.ts
|
|
@@ -1240,7 +1234,7 @@ function wait(config) {
|
|
|
1240
1234
|
return;
|
|
1241
1235
|
}
|
|
1242
1236
|
return Promise.all([
|
|
1243
|
-
new Promise((resolve) => setTimeout(() => resolve(), delay)),
|
|
1237
|
+
new Promise((resolve) => globalThis.setTimeout(() => resolve(), delay)),
|
|
1244
1238
|
config.advanceTimers(delay)
|
|
1245
1239
|
]);
|
|
1246
1240
|
}
|
|
@@ -1323,7 +1317,7 @@ var defaultOptionsDirect = {
|
|
|
1323
1317
|
applyAccept: true,
|
|
1324
1318
|
autoModify: true,
|
|
1325
1319
|
delay: 0,
|
|
1326
|
-
document:
|
|
1320
|
+
document: globalThis.document,
|
|
1327
1321
|
keyboardMap: defaultKeyMap,
|
|
1328
1322
|
pointerMap: defaultKeyMap2,
|
|
1329
1323
|
pointerEventsCheck: 2 /* EachApiCall */,
|
|
@@ -1339,9 +1333,9 @@ var defaultOptionsSetup = __spreadProps(__spreadValues({}, defaultOptionsDirect)
|
|
|
1339
1333
|
|
|
1340
1334
|
// src/utils/pointer/cssPointerEvents.ts
|
|
1341
1335
|
function hasPointerEvents(element) {
|
|
1342
|
-
const
|
|
1336
|
+
const window = getWindow(element);
|
|
1343
1337
|
for (let el = element; el == null ? void 0 : el.ownerDocument; el = el.parentElement) {
|
|
1344
|
-
const pointerEvents =
|
|
1338
|
+
const pointerEvents = window.getComputedStyle(el).pointerEvents;
|
|
1345
1339
|
if (pointerEvents && !["inherit", "unset"].includes(pointerEvents)) {
|
|
1346
1340
|
return pointerEvents !== "none";
|
|
1347
1341
|
}
|
|
@@ -1453,9 +1447,9 @@ function assignPositionInit(obj, {
|
|
|
1453
1447
|
screenX,
|
|
1454
1448
|
screenY
|
|
1455
1449
|
}) {
|
|
1456
|
-
var
|
|
1450
|
+
var _a, _b, _c, _d;
|
|
1457
1451
|
assignProps(obj, {
|
|
1458
|
-
x: (
|
|
1452
|
+
x: (_a = x != null ? x : clientX) != null ? _a : 0,
|
|
1459
1453
|
y: (_b = y != null ? y : clientY) != null ? _b : 0,
|
|
1460
1454
|
clientX: (_c = x != null ? x : clientX) != null ? _c : 0,
|
|
1461
1455
|
clientY: (_d = y != null ? y : clientY) != null ? _d : 0,
|
|
@@ -1509,8 +1503,8 @@ behavior.cut = (event, target, config) => {
|
|
|
1509
1503
|
|
|
1510
1504
|
// src/event/behavior/keydown.ts
|
|
1511
1505
|
behavior.keydown = (event, target, config) => {
|
|
1512
|
-
var
|
|
1513
|
-
return (_b = (
|
|
1506
|
+
var _a, _b;
|
|
1507
|
+
return (_b = (_a = keydownBehavior[event.key]) == null ? void 0 : _a.call(keydownBehavior, event, target, config)) != null ? _b : combinationBehavior(event, target, config);
|
|
1514
1508
|
};
|
|
1515
1509
|
var keydownBehavior = {
|
|
1516
1510
|
ArrowLeft: (event, target) => () => moveSelection(target, -1),
|
|
@@ -1532,8 +1526,8 @@ var keydownBehavior = {
|
|
|
1532
1526
|
End: (event, target) => {
|
|
1533
1527
|
if (isElementType(target, ["input", "textarea"]) || isContentEditable(target)) {
|
|
1534
1528
|
return () => {
|
|
1535
|
-
var
|
|
1536
|
-
const newPos = (_b = (
|
|
1529
|
+
var _a, _b;
|
|
1530
|
+
const newPos = (_b = (_a = getValue(target)) == null ? void 0 : _a.length) != null ? _b : 0;
|
|
1537
1531
|
setSelectionRange(target, newPos, newPos);
|
|
1538
1532
|
};
|
|
1539
1533
|
}
|
|
@@ -1625,8 +1619,8 @@ var SubmitSingleInputOnEnter = [
|
|
|
1625
1619
|
|
|
1626
1620
|
// src/event/behavior/keyup.ts
|
|
1627
1621
|
behavior.keyup = (event, target, config) => {
|
|
1628
|
-
var
|
|
1629
|
-
return (
|
|
1622
|
+
var _a;
|
|
1623
|
+
return (_a = keyupBehavior[event.key]) == null ? void 0 : _a.call(keyupBehavior, event, target, config);
|
|
1630
1624
|
};
|
|
1631
1625
|
var keyupBehavior = {
|
|
1632
1626
|
" ": (event, target, config) => {
|
|
@@ -1640,8 +1634,8 @@ var keyupBehavior = {
|
|
|
1640
1634
|
behavior.paste = (event, target, config) => {
|
|
1641
1635
|
if (isEditable(target)) {
|
|
1642
1636
|
return () => {
|
|
1643
|
-
var
|
|
1644
|
-
const insertData = (
|
|
1637
|
+
var _a;
|
|
1638
|
+
const insertData = (_a = event.clipboardData) == null ? void 0 : _a.getData("text");
|
|
1645
1639
|
if (insertData) {
|
|
1646
1640
|
input(config, target, insertData, "insertFromPaste");
|
|
1647
1641
|
}
|
|
@@ -1657,10 +1651,10 @@ function wrapEvent(cb, _element) {
|
|
|
1657
1651
|
|
|
1658
1652
|
// src/event/dispatchEvent.ts
|
|
1659
1653
|
function dispatchEvent(config, target, event, preventDefault = false) {
|
|
1660
|
-
var
|
|
1654
|
+
var _a, _b;
|
|
1661
1655
|
const type3 = event.type;
|
|
1662
1656
|
const behaviorImplementation = preventDefault ? () => {
|
|
1663
|
-
} : (_b = (
|
|
1657
|
+
} : (_b = (_a = behavior)[type3]) == null ? void 0 : _b.call(_a, event, target, config);
|
|
1664
1658
|
if (behaviorImplementation) {
|
|
1665
1659
|
event.preventDefault();
|
|
1666
1660
|
let defaultPrevented = false;
|
|
@@ -1776,9 +1770,9 @@ function setUISelection(element, {
|
|
|
1776
1770
|
}
|
|
1777
1771
|
}
|
|
1778
1772
|
function getUISelection(element) {
|
|
1779
|
-
var
|
|
1773
|
+
var _a, _b, _c;
|
|
1780
1774
|
const sel = (_c = element[UISelection]) != null ? _c : {
|
|
1781
|
-
anchorOffset: (
|
|
1775
|
+
anchorOffset: (_a = element.selectionStart) != null ? _a : 0,
|
|
1782
1776
|
focusOffset: (_b = element.selectionEnd) != null ? _b : 0
|
|
1783
1777
|
};
|
|
1784
1778
|
return __spreadProps(__spreadValues({}, sel), {
|
|
@@ -1840,8 +1834,8 @@ function startTrackValue(element) {
|
|
|
1840
1834
|
});
|
|
1841
1835
|
}
|
|
1842
1836
|
function trackOrSetValue(element, v) {
|
|
1843
|
-
var
|
|
1844
|
-
(_b = (
|
|
1837
|
+
var _a, _b, _c;
|
|
1838
|
+
(_b = (_a = element[TrackChanges]) == null ? void 0 : _a.tracked) == null ? void 0 : _b.push(v);
|
|
1845
1839
|
if (!((_c = element[TrackChanges]) == null ? void 0 : _c.tracked)) {
|
|
1846
1840
|
setCleanValue(element, v);
|
|
1847
1841
|
}
|
|
@@ -1851,10 +1845,10 @@ function setCleanValue(element, v) {
|
|
|
1851
1845
|
setUISelection(element, { focusOffset: v.length });
|
|
1852
1846
|
}
|
|
1853
1847
|
function endTrackValue(element) {
|
|
1854
|
-
var
|
|
1848
|
+
var _a, _b;
|
|
1855
1849
|
const changes = element[TrackChanges];
|
|
1856
1850
|
element[TrackChanges] = void 0;
|
|
1857
|
-
const isJustReactStateUpdate = ((
|
|
1851
|
+
const isJustReactStateUpdate = ((_a = changes == null ? void 0 : changes.tracked) == null ? void 0 : _a.length) === 2 && changes.tracked[0] === changes.previousValue && changes.tracked[1] === changes.nextValue;
|
|
1858
1852
|
if (((_b = changes == null ? void 0 : changes.tracked) == null ? void 0 : _b.length) && !isJustReactStateUpdate) {
|
|
1859
1853
|
setCleanValue(element, changes.tracked[changes.tracked.length - 1]);
|
|
1860
1854
|
}
|
|
@@ -1863,21 +1857,21 @@ function endTrackValue(element) {
|
|
|
1863
1857
|
|
|
1864
1858
|
// src/document/index.ts
|
|
1865
1859
|
var isPrepared = Symbol("Node prepared with document state workarounds");
|
|
1866
|
-
function prepareDocument(
|
|
1867
|
-
if (
|
|
1860
|
+
function prepareDocument(document) {
|
|
1861
|
+
if (document[isPrepared]) {
|
|
1868
1862
|
return;
|
|
1869
1863
|
}
|
|
1870
|
-
|
|
1864
|
+
document.addEventListener("focus", (e) => {
|
|
1871
1865
|
const el = e.target;
|
|
1872
1866
|
prepareElement(el);
|
|
1873
1867
|
}, {
|
|
1874
1868
|
capture: true,
|
|
1875
1869
|
passive: true
|
|
1876
1870
|
});
|
|
1877
|
-
if (
|
|
1878
|
-
prepareElement(
|
|
1871
|
+
if (document.activeElement) {
|
|
1872
|
+
prepareElement(document.activeElement);
|
|
1879
1873
|
}
|
|
1880
|
-
|
|
1874
|
+
document.addEventListener("blur", (e) => {
|
|
1881
1875
|
const el = e.target;
|
|
1882
1876
|
const initialValue = getInitialValue(el);
|
|
1883
1877
|
if (initialValue !== void 0) {
|
|
@@ -1890,7 +1884,7 @@ function prepareDocument(document2) {
|
|
|
1890
1884
|
capture: true,
|
|
1891
1885
|
passive: true
|
|
1892
1886
|
});
|
|
1893
|
-
|
|
1887
|
+
document[isPrepared] = isPrepared;
|
|
1894
1888
|
}
|
|
1895
1889
|
function prepareElement(el) {
|
|
1896
1890
|
if (el[isPrepared]) {
|
|
@@ -1927,11 +1921,11 @@ function isModifierLock(key) {
|
|
|
1927
1921
|
return modifierLocks.includes(key);
|
|
1928
1922
|
}
|
|
1929
1923
|
function preKeydownBehavior(config, { key }, element) {
|
|
1930
|
-
var
|
|
1924
|
+
var _a;
|
|
1931
1925
|
if (isModifierKey(key)) {
|
|
1932
1926
|
config.keyboardState.modifiers[key] = true;
|
|
1933
1927
|
if (key === "AltGraph") {
|
|
1934
|
-
const ctrlKeyDef = (
|
|
1928
|
+
const ctrlKeyDef = (_a = config.keyboardMap.find((k) => k.key === "Control")) != null ? _a : { key: "Control", code: "Control" };
|
|
1935
1929
|
dispatchUIEvent(config, element, "keydown", getKeyEventProps(ctrlKeyDef));
|
|
1936
1930
|
}
|
|
1937
1931
|
} else if (isModifierLock(key)) {
|
|
@@ -1951,9 +1945,9 @@ function preKeyupBehavior(config, { key }) {
|
|
|
1951
1945
|
}
|
|
1952
1946
|
}
|
|
1953
1947
|
function postKeyupBehavior(config, { key }, element) {
|
|
1954
|
-
var
|
|
1948
|
+
var _a;
|
|
1955
1949
|
if (key === "AltGraph") {
|
|
1956
|
-
const ctrlKeyDef = (
|
|
1950
|
+
const ctrlKeyDef = (_a = config.keyboardMap.find((k) => k.key === "Control")) != null ? _a : { key: "Control", code: "Control" };
|
|
1957
1951
|
dispatchUIEvent(config, element, "keyup", getKeyEventProps(ctrlKeyDef));
|
|
1958
1952
|
}
|
|
1959
1953
|
}
|
|
@@ -1971,8 +1965,8 @@ function keyboardAction(config, actions) {
|
|
|
1971
1965
|
}
|
|
1972
1966
|
function keyboardKeyAction(_0, _1) {
|
|
1973
1967
|
return __async(this, arguments, function* (config, { keyDef, releasePrevious, releaseSelf, repeat }) {
|
|
1974
|
-
const { document
|
|
1975
|
-
const getCurrentElement = () => getActive(
|
|
1968
|
+
const { document, keyboardState } = config;
|
|
1969
|
+
const getCurrentElement = () => getActive(document);
|
|
1976
1970
|
const pressed = keyboardState.pressed.find((p) => p.keyDef === keyDef);
|
|
1977
1971
|
if (pressed) {
|
|
1978
1972
|
yield keyup(keyDef, getCurrentElement, config, pressed.unpreventedDefault);
|
|
@@ -1994,9 +1988,9 @@ function keyboardKeyAction(_0, _1) {
|
|
|
1994
1988
|
}
|
|
1995
1989
|
});
|
|
1996
1990
|
}
|
|
1997
|
-
function getActive(
|
|
1998
|
-
var
|
|
1999
|
-
return (
|
|
1991
|
+
function getActive(document) {
|
|
1992
|
+
var _a;
|
|
1993
|
+
return (_a = getActiveElement(document)) != null ? _a : document.body;
|
|
2000
1994
|
}
|
|
2001
1995
|
function releaseAllKeys(config) {
|
|
2002
1996
|
return __async(this, null, function* () {
|
|
@@ -2038,13 +2032,13 @@ function keyup(keyDef, getCurrentElement, config, unprevented) {
|
|
|
2038
2032
|
});
|
|
2039
2033
|
}
|
|
2040
2034
|
function hasKeyPress(keyDef, config) {
|
|
2041
|
-
var
|
|
2042
|
-
return (((
|
|
2035
|
+
var _a;
|
|
2036
|
+
return (((_a = keyDef.key) == null ? void 0 : _a.length) === 1 || keyDef.key === "Enter") && !config.keyboardState.modifiers.Control && !config.keyboardState.modifiers.Alt;
|
|
2043
2037
|
}
|
|
2044
2038
|
|
|
2045
2039
|
// src/keyboard/parseKeyDef.ts
|
|
2046
2040
|
function parseKeyDef(keyboardMap, text) {
|
|
2047
|
-
var
|
|
2041
|
+
var _a;
|
|
2048
2042
|
const defs = [];
|
|
2049
2043
|
do {
|
|
2050
2044
|
const {
|
|
@@ -2055,15 +2049,15 @@ function parseKeyDef(keyboardMap, text) {
|
|
|
2055
2049
|
releaseSelf = true,
|
|
2056
2050
|
repeat
|
|
2057
2051
|
} = readNextDescriptor(text, "keyboard");
|
|
2058
|
-
const keyDef = (
|
|
2059
|
-
var
|
|
2052
|
+
const keyDef = (_a = keyboardMap.find((def) => {
|
|
2053
|
+
var _a2, _b;
|
|
2060
2054
|
if (type3 === "[") {
|
|
2061
|
-
return ((
|
|
2055
|
+
return ((_a2 = def.code) == null ? void 0 : _a2.toLowerCase()) === descriptor.toLowerCase();
|
|
2062
2056
|
} else if (type3 === "{") {
|
|
2063
2057
|
return ((_b = def.key) == null ? void 0 : _b.toLowerCase()) === descriptor.toLowerCase();
|
|
2064
2058
|
}
|
|
2065
2059
|
return def.key === descriptor;
|
|
2066
|
-
})) != null ?
|
|
2060
|
+
})) != null ? _a : {
|
|
2067
2061
|
key: "Unknown",
|
|
2068
2062
|
code: "Unknown",
|
|
2069
2063
|
[type3 === "[" ? "code" : "key"]: descriptor
|
|
@@ -2142,8 +2136,8 @@ function firePointerEvent(config, target, type3, {
|
|
|
2142
2136
|
}
|
|
2143
2137
|
init.button = getMouseButton(button != null ? button : 0);
|
|
2144
2138
|
init.buttons = getMouseButtons(...config.pointerState.pressed.filter((p) => p.keyDef.pointerType === pointerType).map((p) => {
|
|
2145
|
-
var
|
|
2146
|
-
return (
|
|
2139
|
+
var _a;
|
|
2140
|
+
return (_a = p.keyDef.button) != null ? _a : 0;
|
|
2147
2141
|
}));
|
|
2148
2142
|
if (["mousedown", "mouseup", "click", "dblclick", "contextmenu"].includes(type3)) {
|
|
2149
2143
|
init.detail = clickCount;
|
|
@@ -2305,7 +2299,7 @@ function getNextPointerId(state) {
|
|
|
2305
2299
|
return state.pointerId;
|
|
2306
2300
|
}
|
|
2307
2301
|
function down(config, pointerName, { keyDef, node, offset, target, coords }, targetIsDisabled) {
|
|
2308
|
-
var
|
|
2302
|
+
var _a, _b, _c;
|
|
2309
2303
|
setLevelRef(config, 2 /* Trigger */);
|
|
2310
2304
|
assertPointerEvents(config, target);
|
|
2311
2305
|
const { pointerState } = config;
|
|
@@ -2328,7 +2322,7 @@ function down(config, pointerName, { keyDef, node, offset, target, coords }, tar
|
|
|
2328
2322
|
}
|
|
2329
2323
|
}
|
|
2330
2324
|
}
|
|
2331
|
-
if (((
|
|
2325
|
+
if (((_a = pointerState.activeClickCount) == null ? void 0 : _a[0]) !== name) {
|
|
2332
2326
|
delete pointerState.activeClickCount;
|
|
2333
2327
|
}
|
|
2334
2328
|
const clickCount = Number((_c = (_b = pointerState.activeClickCount) == null ? void 0 : _b[1]) != null ? _c : 0) + 1;
|
|
@@ -2512,11 +2506,11 @@ function getTextRange(text, pos, clickCount) {
|
|
|
2512
2506
|
// src/pointer/pointerAction.ts
|
|
2513
2507
|
function pointerAction(config, actions) {
|
|
2514
2508
|
return __async(this, null, function* () {
|
|
2515
|
-
var
|
|
2509
|
+
var _a, _b;
|
|
2516
2510
|
for (let i = 0; i < actions.length; i++) {
|
|
2517
2511
|
const action = actions[i];
|
|
2518
2512
|
const pointerName = "pointerName" in action && action.pointerName ? action.pointerName : "keyDef" in action ? action.keyDef.pointerType === "touch" ? action.keyDef.name : action.keyDef.pointerType : "mouse";
|
|
2519
|
-
const target = (
|
|
2513
|
+
const target = (_a = action.target) != null ? _a : getPrevTarget(pointerName, config.pointerState);
|
|
2520
2514
|
const coords = (_b = action.coords) != null ? _b : pointerName in config.pointerState.position ? config.pointerState.position[pointerName].coords : void 0;
|
|
2521
2515
|
yield "keyDef" in action ? pointerPress(config, __spreadProps(__spreadValues({}, action), { target, coords })) : pointerMove(config, __spreadProps(__spreadValues({}, action), { target, coords }));
|
|
2522
2516
|
if (i < actions.length - 1) {
|
|
@@ -2550,14 +2544,14 @@ function pointer(input2) {
|
|
|
2550
2544
|
return pointerAction(this[Config], actions).then(() => void 0);
|
|
2551
2545
|
});
|
|
2552
2546
|
}
|
|
2553
|
-
function createPointerState(
|
|
2547
|
+
function createPointerState(document) {
|
|
2554
2548
|
return {
|
|
2555
2549
|
pointerId: 1,
|
|
2556
2550
|
position: {
|
|
2557
2551
|
mouse: {
|
|
2558
2552
|
pointerType: "mouse",
|
|
2559
2553
|
pointerId: 1,
|
|
2560
|
-
target:
|
|
2554
|
+
target: document.body,
|
|
2561
2555
|
coords: {
|
|
2562
2556
|
clientX: 0,
|
|
2563
2557
|
clientY: 0,
|
|
@@ -2644,9 +2638,9 @@ function tab() {
|
|
|
2644
2638
|
// src/clipboard/copy.ts
|
|
2645
2639
|
function copy() {
|
|
2646
2640
|
return __async(this, null, function* () {
|
|
2647
|
-
var
|
|
2641
|
+
var _a;
|
|
2648
2642
|
const doc = this[Config].document;
|
|
2649
|
-
const target = (
|
|
2643
|
+
const target = (_a = doc.activeElement) != null ? _a : doc.body;
|
|
2650
2644
|
const clipboardData = copySelection(target);
|
|
2651
2645
|
if (clipboardData.items.length === 0) {
|
|
2652
2646
|
return;
|
|
@@ -2663,9 +2657,9 @@ function copy() {
|
|
|
2663
2657
|
// src/clipboard/cut.ts
|
|
2664
2658
|
function cut() {
|
|
2665
2659
|
return __async(this, null, function* () {
|
|
2666
|
-
var
|
|
2660
|
+
var _a;
|
|
2667
2661
|
const doc = this[Config].document;
|
|
2668
|
-
const target = (
|
|
2662
|
+
const target = (_a = doc.activeElement) != null ? _a : doc.body;
|
|
2669
2663
|
const clipboardData = copySelection(target);
|
|
2670
2664
|
if (clipboardData.items.length === 0) {
|
|
2671
2665
|
return;
|
|
@@ -2682,9 +2676,9 @@ function cut() {
|
|
|
2682
2676
|
// src/clipboard/paste.ts
|
|
2683
2677
|
function paste(clipboardData) {
|
|
2684
2678
|
return __async(this, null, function* () {
|
|
2685
|
-
var
|
|
2679
|
+
var _a, _b;
|
|
2686
2680
|
const doc = this[Config].document;
|
|
2687
|
-
const target = (
|
|
2681
|
+
const target = (_a = doc.activeElement) != null ? _a : doc.body;
|
|
2688
2682
|
const dataTransfer = (_b = typeof clipboardData === "string" ? getClipboardDataFromString(doc, clipboardData) : clipboardData) != null ? _b : yield readDataTransferFromClipboard(doc).catch(() => {
|
|
2689
2683
|
throw new Error("`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.");
|
|
2690
2684
|
});
|
|
@@ -2848,10 +2842,10 @@ function upload(element, fileOrFiles) {
|
|
|
2848
2842
|
return;
|
|
2849
2843
|
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).filter((file) => !this[Config].applyAccept || isAcceptableFile(file, input2.accept)).slice(0, input2.multiple ? void 0 : 1);
|
|
2850
2844
|
const fileDialog = () => {
|
|
2851
|
-
var
|
|
2852
|
-
if (files.length === ((
|
|
2853
|
-
var
|
|
2854
|
-
return f === ((
|
|
2845
|
+
var _a;
|
|
2846
|
+
if (files.length === ((_a = input2.files) == null ? void 0 : _a.length) && files.every((f, i) => {
|
|
2847
|
+
var _a2;
|
|
2848
|
+
return f === ((_a2 = input2.files) == null ? void 0 : _a2.item(i));
|
|
2855
2849
|
})) {
|
|
2856
2850
|
return;
|
|
2857
2851
|
}
|
|
@@ -2887,22 +2881,22 @@ function wrapAsync(implementation) {
|
|
|
2887
2881
|
|
|
2888
2882
|
// src/setup/setup.ts
|
|
2889
2883
|
function createConfig(options = {}, defaults = defaultOptionsSetup, node) {
|
|
2890
|
-
const
|
|
2884
|
+
const document = getDocument(options, node, defaults);
|
|
2891
2885
|
const {
|
|
2892
2886
|
keyboardState = createKeyboardState(),
|
|
2893
|
-
pointerState = createPointerState(
|
|
2887
|
+
pointerState = createPointerState(document)
|
|
2894
2888
|
} = options;
|
|
2895
2889
|
return __spreadProps(__spreadValues(__spreadValues({}, defaults), options), {
|
|
2896
|
-
document
|
|
2890
|
+
document,
|
|
2897
2891
|
keyboardState,
|
|
2898
2892
|
pointerState
|
|
2899
2893
|
});
|
|
2900
2894
|
}
|
|
2901
2895
|
function setupMain(options = {}) {
|
|
2902
|
-
var
|
|
2896
|
+
var _a;
|
|
2903
2897
|
const config = createConfig(options);
|
|
2904
2898
|
prepareDocument(config.document);
|
|
2905
|
-
const view = (
|
|
2899
|
+
const view = (_a = config.document.defaultView) != null ? _a : globalThis.window;
|
|
2906
2900
|
attachClipboardStubToView(view);
|
|
2907
2901
|
return doSetup(config);
|
|
2908
2902
|
}
|
|
@@ -2937,9 +2931,9 @@ function doSetup(config) {
|
|
|
2937
2931
|
setup: setupSub.bind(instance)
|
|
2938
2932
|
});
|
|
2939
2933
|
}
|
|
2940
|
-
function getDocument(options, node) {
|
|
2941
|
-
var
|
|
2942
|
-
return (_b = (
|
|
2934
|
+
function getDocument(options, node, defaults) {
|
|
2935
|
+
var _a, _b;
|
|
2936
|
+
return (_b = (_a = options.document) != null ? _a : node && getDocumentFromNode(node)) != null ? _b : defaults.document;
|
|
2943
2937
|
}
|
|
2944
2938
|
|
|
2945
2939
|
// src/setup/directApi.ts
|