@testing-library/user-event 14.2.0 → 14.2.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 +22 -14
- package/dist/index.mjs +22 -14
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +3 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -243,9 +244,8 @@ function createClipboardItem(window, ...blobs) {
|
|
|
243
244
|
}(dataMap);
|
|
244
245
|
}
|
|
245
246
|
var ClipboardStubControl = Symbol("Manage ClipboardSub");
|
|
246
|
-
function createClipboardStub(window) {
|
|
247
|
-
|
|
248
|
-
return new (_a = class extends window.EventTarget {
|
|
247
|
+
function createClipboardStub(window, control) {
|
|
248
|
+
return Object.assign(new class Clipboard extends window.EventTarget {
|
|
249
249
|
constructor() {
|
|
250
250
|
super(...arguments);
|
|
251
251
|
this.items = [];
|
|
@@ -269,7 +269,9 @@ function createClipboardStub(window) {
|
|
|
269
269
|
async writeText(text) {
|
|
270
270
|
this.items = [createClipboardItem(window, text)];
|
|
271
271
|
}
|
|
272
|
-
},
|
|
272
|
+
}(), {
|
|
273
|
+
[ClipboardStubControl]: control
|
|
274
|
+
});
|
|
273
275
|
}
|
|
274
276
|
function isClipboardStub(clipboard) {
|
|
275
277
|
return !!(clipboard == null ? void 0 : clipboard[ClipboardStubControl]);
|
|
@@ -279,11 +281,10 @@ function attachClipboardStubToView(window) {
|
|
|
279
281
|
return window.navigator.clipboard[ClipboardStubControl];
|
|
280
282
|
}
|
|
281
283
|
const realClipboard = Object.getOwnPropertyDescriptor(window.navigator, "clipboard");
|
|
282
|
-
let stub
|
|
284
|
+
let stub;
|
|
283
285
|
const control = {
|
|
284
286
|
resetClipboardStub: () => {
|
|
285
|
-
stub = createClipboardStub(window);
|
|
286
|
-
stub[ClipboardStubControl] = control;
|
|
287
|
+
stub = createClipboardStub(window, control);
|
|
287
288
|
},
|
|
288
289
|
detachClipboardStub: () => {
|
|
289
290
|
if (realClipboard) {
|
|
@@ -296,7 +297,7 @@ function attachClipboardStubToView(window) {
|
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
};
|
|
299
|
-
stub
|
|
300
|
+
stub = createClipboardStub(window, control);
|
|
300
301
|
Object.defineProperty(window.navigator, "clipboard", {
|
|
301
302
|
get: () => stub,
|
|
302
303
|
configurable: true
|
|
@@ -996,8 +997,8 @@ function isVisible(element) {
|
|
|
996
997
|
function getTabDestination(activeElement, shift) {
|
|
997
998
|
const document = activeElement.ownerDocument;
|
|
998
999
|
const focusableElements = document.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
999
|
-
const enabledElements = Array.from(focusableElements).filter((el) => el === activeElement || el.getAttribute("tabindex")
|
|
1000
|
-
if (activeElement.getAttribute("tabindex")
|
|
1000
|
+
const enabledElements = Array.from(focusableElements).filter((el) => el === activeElement || !(Number(el.getAttribute("tabindex")) < 0 || isDisabled(el)));
|
|
1001
|
+
if (Number(activeElement.getAttribute("tabindex")) >= 0) {
|
|
1001
1002
|
enabledElements.sort((a, b) => {
|
|
1002
1003
|
const i = Number(a.getAttribute("tabindex"));
|
|
1003
1004
|
const j = Number(b.getAttribute("tabindex"));
|
|
@@ -1037,10 +1038,17 @@ function getTabDestination(activeElement, shift) {
|
|
|
1037
1038
|
}
|
|
1038
1039
|
prunedElements.push(el);
|
|
1039
1040
|
});
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1041
|
+
for (let index = prunedElements.findIndex((el) => el === activeElement); ; ) {
|
|
1042
|
+
index += shift ? -1 : 1;
|
|
1043
|
+
if (index === prunedElements.length) {
|
|
1044
|
+
index = 0;
|
|
1045
|
+
} else if (index === -1) {
|
|
1046
|
+
index = prunedElements.length - 1;
|
|
1047
|
+
}
|
|
1048
|
+
if (prunedElements[index] === activeElement || prunedElements[index] === document.body || isVisible(prunedElements[index])) {
|
|
1049
|
+
return prunedElements[index];
|
|
1050
|
+
}
|
|
1051
|
+
}
|
|
1044
1052
|
}
|
|
1045
1053
|
|
|
1046
1054
|
// src/utils/focus/selectAll.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
@@ -247,9 +248,8 @@ function createClipboardItem(window, ...blobs) {
|
|
|
247
248
|
}(dataMap);
|
|
248
249
|
}
|
|
249
250
|
var ClipboardStubControl = Symbol("Manage ClipboardSub");
|
|
250
|
-
function createClipboardStub(window) {
|
|
251
|
-
|
|
252
|
-
return new (_a = class extends window.EventTarget {
|
|
251
|
+
function createClipboardStub(window, control) {
|
|
252
|
+
return Object.assign(new class Clipboard extends window.EventTarget {
|
|
253
253
|
constructor() {
|
|
254
254
|
super(...arguments);
|
|
255
255
|
this.items = [];
|
|
@@ -281,7 +281,9 @@ function createClipboardStub(window) {
|
|
|
281
281
|
this.items = [createClipboardItem(window, text)];
|
|
282
282
|
});
|
|
283
283
|
}
|
|
284
|
-
},
|
|
284
|
+
}(), {
|
|
285
|
+
[ClipboardStubControl]: control
|
|
286
|
+
});
|
|
285
287
|
}
|
|
286
288
|
function isClipboardStub(clipboard) {
|
|
287
289
|
return !!(clipboard == null ? void 0 : clipboard[ClipboardStubControl]);
|
|
@@ -291,11 +293,10 @@ function attachClipboardStubToView(window) {
|
|
|
291
293
|
return window.navigator.clipboard[ClipboardStubControl];
|
|
292
294
|
}
|
|
293
295
|
const realClipboard = Object.getOwnPropertyDescriptor(window.navigator, "clipboard");
|
|
294
|
-
let stub
|
|
296
|
+
let stub;
|
|
295
297
|
const control = {
|
|
296
298
|
resetClipboardStub: () => {
|
|
297
|
-
stub = createClipboardStub(window);
|
|
298
|
-
stub[ClipboardStubControl] = control;
|
|
299
|
+
stub = createClipboardStub(window, control);
|
|
299
300
|
},
|
|
300
301
|
detachClipboardStub: () => {
|
|
301
302
|
if (realClipboard) {
|
|
@@ -308,7 +309,7 @@ function attachClipboardStubToView(window) {
|
|
|
308
309
|
}
|
|
309
310
|
}
|
|
310
311
|
};
|
|
311
|
-
stub
|
|
312
|
+
stub = createClipboardStub(window, control);
|
|
312
313
|
Object.defineProperty(window.navigator, "clipboard", {
|
|
313
314
|
get: () => stub,
|
|
314
315
|
configurable: true
|
|
@@ -1012,8 +1013,8 @@ function isVisible(element) {
|
|
|
1012
1013
|
function getTabDestination(activeElement, shift) {
|
|
1013
1014
|
const document = activeElement.ownerDocument;
|
|
1014
1015
|
const focusableElements = document.querySelectorAll(FOCUSABLE_SELECTOR);
|
|
1015
|
-
const enabledElements = Array.from(focusableElements).filter((el) => el === activeElement || el.getAttribute("tabindex")
|
|
1016
|
-
if (activeElement.getAttribute("tabindex")
|
|
1016
|
+
const enabledElements = Array.from(focusableElements).filter((el) => el === activeElement || !(Number(el.getAttribute("tabindex")) < 0 || isDisabled(el)));
|
|
1017
|
+
if (Number(activeElement.getAttribute("tabindex")) >= 0) {
|
|
1017
1018
|
enabledElements.sort((a, b) => {
|
|
1018
1019
|
const i = Number(a.getAttribute("tabindex"));
|
|
1019
1020
|
const j = Number(b.getAttribute("tabindex"));
|
|
@@ -1053,10 +1054,17 @@ function getTabDestination(activeElement, shift) {
|
|
|
1053
1054
|
}
|
|
1054
1055
|
prunedElements.push(el);
|
|
1055
1056
|
});
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1057
|
+
for (let index = prunedElements.findIndex((el) => el === activeElement); ; ) {
|
|
1058
|
+
index += shift ? -1 : 1;
|
|
1059
|
+
if (index === prunedElements.length) {
|
|
1060
|
+
index = 0;
|
|
1061
|
+
} else if (index === -1) {
|
|
1062
|
+
index = prunedElements.length - 1;
|
|
1063
|
+
}
|
|
1064
|
+
if (prunedElements[index] === activeElement || prunedElements[index] === document.body || isVisible(prunedElements[index])) {
|
|
1065
|
+
return prunedElements[index];
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1060
1068
|
}
|
|
1061
1069
|
|
|
1062
1070
|
// src/utils/focus/selectAll.ts
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export declare function createClipboardItem(window: Window & typeof globalThis, ...blobs: Array<Blob | string>): ClipboardItem;
|
|
2
|
-
|
|
2
|
+
declare type ClipboardStubControlInstance = {
|
|
3
3
|
resetClipboardStub: () => void;
|
|
4
4
|
detachClipboardStub: () => void;
|
|
5
5
|
};
|
|
6
|
+
export declare function attachClipboardStubToView(window: Window & typeof globalThis): ClipboardStubControlInstance;
|
|
6
7
|
export declare function resetClipboardStubOnView(window: Window & typeof globalThis): void;
|
|
7
8
|
export declare function detachClipboardStubFromView(window: Window & typeof globalThis): void;
|
|
8
9
|
export declare function readDataTransferFromClipboard(document: Document): Promise<DataTransfer>;
|
|
9
10
|
export declare function writeDataTransferToClipboard(document: Document, clipboardData: DataTransfer): Promise<void>;
|
|
11
|
+
export {};
|