@testing-library/user-event 14.0.0-beta.4 → 14.0.0-beta.8
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 +5 -192
- package/dist/index.cjs +2943 -0
- package/dist/{index.js → index.mjs} +397 -214
- package/dist/types/clipboard/copy.d.ts +2 -0
- package/dist/types/clipboard/cut.d.ts +2 -0
- package/dist/types/clipboard/index.d.ts +3 -0
- package/dist/types/clipboard/paste.d.ts +2 -0
- package/dist/types/convenience/click.d.ts +4 -0
- package/dist/types/convenience/hover.d.ts +3 -0
- package/dist/types/convenience/index.d.ts +3 -0
- package/dist/types/convenience/tab.d.ts +4 -0
- package/dist/types/document/index.d.ts +10 -0
- package/dist/types/document/interceptor.d.ts +15 -0
- package/dist/types/document/selection.d.ts +27 -0
- package/dist/types/document/value.d.ts +18 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/keyboard/index.d.ts +7 -0
- package/dist/types/keyboard/keyMap.d.ts +5 -0
- package/dist/types/keyboard/keyboardAction.d.ts +10 -0
- package/dist/types/keyboard/parseKeyDef.d.ts +17 -0
- package/dist/types/keyboard/plugins/arrow.d.ts +6 -0
- package/dist/types/keyboard/plugins/character.d.ts +5 -0
- package/dist/types/keyboard/plugins/combination.d.ts +5 -0
- package/dist/types/keyboard/plugins/control.d.ts +6 -0
- package/dist/types/keyboard/plugins/functional.d.ts +8 -0
- package/dist/types/keyboard/plugins/index.d.ts +7 -0
- package/dist/types/keyboard/plugins/modifiers.d.ts +8 -0
- package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +3 -0
- package/dist/types/keyboard/shared/index.d.ts +1 -0
- package/dist/types/keyboard/types.d.ts +78 -0
- package/dist/types/options.d.ts +117 -0
- package/dist/types/pointer/index.d.ts +10 -0
- package/dist/types/pointer/keyMap.d.ts +2 -0
- package/dist/types/pointer/parseKeyDef.d.ts +6 -0
- package/dist/types/pointer/pointerAction.d.ts +7 -0
- package/dist/types/pointer/pointerMove.d.ts +6 -0
- package/dist/types/pointer/pointerPress.d.ts +8 -0
- package/dist/types/pointer/resolveSelectionTarget.d.ts +5 -0
- package/dist/types/pointer/types.d.ts +61 -0
- package/dist/types/setup/api.d.ts +5 -0
- package/dist/types/setup/config.d.ts +10 -0
- package/dist/types/setup/directApi.d.ts +19 -0
- package/dist/types/setup/index.d.ts +34 -0
- package/dist/types/setup/setup.d.ts +19 -0
- package/dist/types/setup/wrapAsync.d.ts +4 -0
- package/dist/types/utility/clear.d.ts +2 -0
- package/dist/types/utility/index.d.ts +4 -0
- package/dist/types/utility/selectOptions.d.ts +3 -0
- package/dist/types/utility/type.d.ts +9 -0
- package/dist/types/utility/upload.d.ts +5 -0
- package/dist/types/utils/click/isClickableInput.d.ts +1 -0
- package/dist/types/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +9 -0
- package/dist/types/utils/dataTransfer/DataTransfer.d.ts +2 -0
- package/dist/types/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/types/utils/edit/buildTimeValue.d.ts +1 -0
- package/dist/types/utils/edit/calculateNewValue.d.ts +14 -0
- package/dist/types/utils/edit/editInputElement.d.ts +16 -0
- package/dist/types/utils/edit/getValue.d.ts +1 -0
- package/dist/types/utils/edit/isContentEditable.d.ts +7 -0
- package/dist/types/utils/edit/isEditable.d.ts +25 -0
- package/dist/types/utils/edit/isValidDateValue.d.ts +3 -0
- package/dist/types/utils/edit/isValidInputTimeValue.d.ts +3 -0
- package/dist/types/utils/edit/maxLength.d.ts +1 -0
- package/dist/types/utils/edit/prepareInput.d.ts +7 -0
- package/dist/types/utils/edit/setFiles.d.ts +12 -0
- package/dist/types/utils/focus/blur.d.ts +2 -0
- package/dist/types/utils/focus/copySelection.d.ts +1 -0
- package/dist/types/utils/focus/cursor.d.ts +9 -0
- package/dist/types/utils/focus/focus.d.ts +5 -0
- package/dist/types/utils/focus/getActiveElement.d.ts +1 -0
- package/dist/types/utils/focus/getTabDestination.d.ts +1 -0
- package/dist/types/utils/focus/isFocusable.d.ts +1 -0
- package/dist/types/utils/focus/selectAll.d.ts +5 -0
- package/dist/types/utils/focus/selection.d.ts +42 -0
- package/dist/types/utils/focus/selector.d.ts +1 -0
- package/dist/types/utils/index.d.ts +42 -0
- package/dist/types/utils/keyDef/readNextDescriptor.d.ts +19 -0
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +17 -0
- package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
- package/dist/types/utils/misc/eventWrapper.d.ts +1 -0
- package/dist/types/utils/misc/findClosest.d.ts +1 -0
- package/dist/types/utils/misc/getDocumentFromNode.d.ts +1 -0
- package/dist/types/utils/misc/hasFormSubmit.d.ts +1 -0
- package/dist/types/utils/misc/isDescendantOrSelf.d.ts +1 -0
- package/dist/types/utils/misc/isDisabled.d.ts +1 -0
- package/dist/types/utils/misc/isElementType.d.ts +5 -0
- package/dist/types/utils/misc/isVisible.d.ts +1 -0
- package/dist/types/utils/misc/level.d.ts +17 -0
- package/dist/types/utils/misc/wait.d.ts +1 -0
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +15 -0
- package/dist/types/utils/pointer/firePointerEvents.d.ts +25 -0
- package/dist/types/utils/pointer/mouseButtons.d.ts +12 -0
- package/package.json +10 -3
- package/dist/index.d.ts +0 -1110
- package/dist/package.json +0 -1
|
@@ -800,6 +800,111 @@ function supportsMaxLength(element) {
|
|
|
800
800
|
|
|
801
801
|
// src/utils/edit/prepareInput.ts
|
|
802
802
|
import { fireEvent as fireEvent3 } from "@testing-library/dom";
|
|
803
|
+
|
|
804
|
+
// src/utils/focus/cursor.ts
|
|
805
|
+
function getNextCursorPosition(node, offset, direction, inputType) {
|
|
806
|
+
if (isTextNode(node) && offset + direction >= 0 && offset + direction <= node.nodeValue.length) {
|
|
807
|
+
return { node, offset: offset + direction };
|
|
808
|
+
}
|
|
809
|
+
const nextNode = getNextCharacterContentNode(node, offset, direction);
|
|
810
|
+
if (nextNode) {
|
|
811
|
+
if (isTextNode(nextNode)) {
|
|
812
|
+
return {
|
|
813
|
+
node: nextNode,
|
|
814
|
+
offset: direction > 0 ? Math.min(1, nextNode.nodeValue.length) : Math.max(nextNode.nodeValue.length - 1, 0)
|
|
815
|
+
};
|
|
816
|
+
} else if (isElementType(nextNode, "br")) {
|
|
817
|
+
const nextPlusOne = getNextCharacterContentNode(nextNode, void 0, direction);
|
|
818
|
+
if (!nextPlusOne) {
|
|
819
|
+
if (direction < 0 && inputType === "deleteContentBackward") {
|
|
820
|
+
return {
|
|
821
|
+
node: nextNode.parentNode,
|
|
822
|
+
offset: getOffset(nextNode)
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
return void 0;
|
|
826
|
+
} else if (isTextNode(nextPlusOne)) {
|
|
827
|
+
return {
|
|
828
|
+
node: nextPlusOne,
|
|
829
|
+
offset: direction > 0 ? 0 : nextPlusOne.nodeValue.length
|
|
830
|
+
};
|
|
831
|
+
} else if (direction < 0 && isElementType(nextPlusOne, "br")) {
|
|
832
|
+
return {
|
|
833
|
+
node: nextNode.parentNode,
|
|
834
|
+
offset: getOffset(nextNode)
|
|
835
|
+
};
|
|
836
|
+
} else {
|
|
837
|
+
return {
|
|
838
|
+
node: nextPlusOne.parentNode,
|
|
839
|
+
offset: getOffset(nextPlusOne) + (direction > 0 ? 0 : 1)
|
|
840
|
+
};
|
|
841
|
+
}
|
|
842
|
+
} else {
|
|
843
|
+
return {
|
|
844
|
+
node: nextNode.parentNode,
|
|
845
|
+
offset: getOffset(nextNode) + (direction > 0 ? 1 : 0)
|
|
846
|
+
};
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
function getNextCharacterContentNode(node, offset, direction) {
|
|
851
|
+
const nextOffset = Number(offset) + (direction < 0 ? -1 : 0);
|
|
852
|
+
if (offset !== void 0 && isElement2(node) && nextOffset >= 0 && nextOffset < node.children.length) {
|
|
853
|
+
node = node.children[nextOffset];
|
|
854
|
+
}
|
|
855
|
+
return walkNodes(node, direction === 1 ? "next" : "previous", isTreatedAsCharacterContent);
|
|
856
|
+
}
|
|
857
|
+
function isTreatedAsCharacterContent(node) {
|
|
858
|
+
if (isTextNode(node)) {
|
|
859
|
+
return true;
|
|
860
|
+
}
|
|
861
|
+
if (isElement2(node)) {
|
|
862
|
+
if (isElementType(node, ["input", "textarea"])) {
|
|
863
|
+
return node.type !== "hidden";
|
|
864
|
+
} else if (isElementType(node, "br")) {
|
|
865
|
+
return true;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
return false;
|
|
869
|
+
}
|
|
870
|
+
function getOffset(node) {
|
|
871
|
+
let i = 0;
|
|
872
|
+
while (node.previousSibling) {
|
|
873
|
+
i++;
|
|
874
|
+
node = node.previousSibling;
|
|
875
|
+
}
|
|
876
|
+
return i;
|
|
877
|
+
}
|
|
878
|
+
function isElement2(node) {
|
|
879
|
+
return node.nodeType === 1;
|
|
880
|
+
}
|
|
881
|
+
function isTextNode(node) {
|
|
882
|
+
return node.nodeType === 3;
|
|
883
|
+
}
|
|
884
|
+
function walkNodes(node, direction, callback) {
|
|
885
|
+
var _a;
|
|
886
|
+
for (; ; ) {
|
|
887
|
+
const sibling = node[`${direction}Sibling`];
|
|
888
|
+
if (sibling) {
|
|
889
|
+
node = getDescendant(sibling, direction === "next" ? "first" : "last");
|
|
890
|
+
if (callback(node)) {
|
|
891
|
+
return node;
|
|
892
|
+
}
|
|
893
|
+
} else if (node.parentNode && (!isElement2(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((_a = node.ownerDocument) == null ? void 0 : _a.body))) {
|
|
894
|
+
node = node.parentNode;
|
|
895
|
+
} else {
|
|
896
|
+
break;
|
|
897
|
+
}
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
function getDescendant(node, direction) {
|
|
901
|
+
while (node.hasChildNodes()) {
|
|
902
|
+
node = node[`${direction}Child`];
|
|
903
|
+
}
|
|
904
|
+
return node;
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
// src/utils/edit/prepareInput.ts
|
|
803
908
|
function prepareInput(data, element, inputType = "insertText") {
|
|
804
909
|
const inputRange = getInputRange(element);
|
|
805
910
|
if (!inputRange) {
|
|
@@ -808,9 +913,22 @@ function prepareInput(data, element, inputType = "insertText") {
|
|
|
808
913
|
if ("startContainer" in inputRange) {
|
|
809
914
|
return {
|
|
810
915
|
commit: () => {
|
|
811
|
-
|
|
812
|
-
if (
|
|
916
|
+
let del = false;
|
|
917
|
+
if (!inputRange.collapsed) {
|
|
918
|
+
del = true;
|
|
813
919
|
inputRange.deleteContents();
|
|
920
|
+
} else if (["deleteContentBackward", "deleteContentForward"].includes(inputType)) {
|
|
921
|
+
const nextPosition = getNextCursorPosition(inputRange.startContainer, inputRange.startOffset, inputType === "deleteContentBackward" ? -1 : 1, inputType);
|
|
922
|
+
if (nextPosition) {
|
|
923
|
+
del = true;
|
|
924
|
+
const delRange = inputRange.cloneRange();
|
|
925
|
+
if (delRange.comparePoint(nextPosition.node, nextPosition.offset) < 0) {
|
|
926
|
+
delRange.setStart(nextPosition.node, nextPosition.offset);
|
|
927
|
+
} else {
|
|
928
|
+
delRange.setEnd(nextPosition.node, nextPosition.offset);
|
|
929
|
+
}
|
|
930
|
+
delRange.deleteContents();
|
|
931
|
+
}
|
|
814
932
|
}
|
|
815
933
|
if (data) {
|
|
816
934
|
if (inputRange.endContainer.nodeType === 3) {
|
|
@@ -966,15 +1084,30 @@ function readSelectedValueFromInput(target) {
|
|
|
966
1084
|
return val.substring(sel.startOffset, sel.endOffset);
|
|
967
1085
|
}
|
|
968
1086
|
|
|
1087
|
+
// src/utils/misc/findClosest.ts
|
|
1088
|
+
function findClosest(element, callback) {
|
|
1089
|
+
let el = element;
|
|
1090
|
+
do {
|
|
1091
|
+
if (callback(el)) {
|
|
1092
|
+
return el;
|
|
1093
|
+
}
|
|
1094
|
+
el = el.parentElement;
|
|
1095
|
+
} while (el && el !== element.ownerDocument.body);
|
|
1096
|
+
return void 0;
|
|
1097
|
+
}
|
|
1098
|
+
|
|
969
1099
|
// src/utils/focus/focus.ts
|
|
970
1100
|
function focus(element) {
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
if (isAlreadyActive)
|
|
1101
|
+
const target = findClosest(element, isFocusable);
|
|
1102
|
+
const activeElement = getActiveElement(element.ownerDocument);
|
|
1103
|
+
if ((target != null ? target : element.ownerDocument.body) === activeElement) {
|
|
975
1104
|
return;
|
|
976
|
-
|
|
977
|
-
|
|
1105
|
+
} else if (target) {
|
|
1106
|
+
eventWrapper(() => target.focus());
|
|
1107
|
+
} else {
|
|
1108
|
+
eventWrapper(() => activeElement == null ? void 0 : activeElement.blur());
|
|
1109
|
+
}
|
|
1110
|
+
updateSelectionOnFocus(target != null ? target : element.ownerDocument.body);
|
|
978
1111
|
}
|
|
979
1112
|
|
|
980
1113
|
// src/utils/misc/isVisible.ts
|
|
@@ -1175,18 +1308,6 @@ function getErrorMessage(expected, found, text) {
|
|
|
1175
1308
|
for more information about how userEvent parses your input.`;
|
|
1176
1309
|
}
|
|
1177
1310
|
|
|
1178
|
-
// src/utils/misc/findClosest.ts
|
|
1179
|
-
function findClosest(element, callback) {
|
|
1180
|
-
let el = element;
|
|
1181
|
-
do {
|
|
1182
|
-
if (callback(el)) {
|
|
1183
|
-
return el;
|
|
1184
|
-
}
|
|
1185
|
-
el = el.parentElement;
|
|
1186
|
-
} while (el && el !== element.ownerDocument.body);
|
|
1187
|
-
return void 0;
|
|
1188
|
-
}
|
|
1189
|
-
|
|
1190
1311
|
// src/utils/misc/getDocumentFromNode.ts
|
|
1191
1312
|
function getDocumentFromNode(el) {
|
|
1192
1313
|
return isDocument(el) ? el : el.ownerDocument;
|
|
@@ -1207,13 +1328,121 @@ function isDescendantOrSelf(potentialDescendant, potentialAncestor) {
|
|
|
1207
1328
|
return false;
|
|
1208
1329
|
}
|
|
1209
1330
|
|
|
1331
|
+
// src/utils/misc/level.ts
|
|
1332
|
+
var Level = Symbol("Api level refs");
|
|
1333
|
+
function setLevelRef(config, level) {
|
|
1334
|
+
var _a;
|
|
1335
|
+
(_a = config[Level]) != null ? _a : config[Level] = {};
|
|
1336
|
+
config[Level][level] = {};
|
|
1337
|
+
}
|
|
1338
|
+
function getLevelRef(config, level) {
|
|
1339
|
+
var _a;
|
|
1340
|
+
return (_a = config[Level]) == null ? void 0 : _a[level];
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1210
1343
|
// src/utils/misc/wait.ts
|
|
1211
1344
|
function wait(time) {
|
|
1212
1345
|
return new Promise((resolve) => setTimeout(() => resolve(), time));
|
|
1213
1346
|
}
|
|
1214
1347
|
|
|
1215
|
-
// src/utils/misc/
|
|
1348
|
+
// src/utils/misc/hasFormSubmit.ts
|
|
1349
|
+
var hasFormSubmit = (form) => !!(form == null ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]'));
|
|
1350
|
+
|
|
1351
|
+
// src/utils/pointer/cssPointerEvents.ts
|
|
1216
1352
|
import { getWindowFromNode as getWindowFromNode2 } from "@testing-library/dom/dist/helpers.js";
|
|
1353
|
+
|
|
1354
|
+
// src/keyboard/keyMap.ts
|
|
1355
|
+
var defaultKeyMap = [
|
|
1356
|
+
..."0123456789".split("").map((c) => ({ code: `Digit${c}`, key: c })),
|
|
1357
|
+
...")!@#$%^&*(".split("").map((c, i) => ({ code: `Digit${i}`, key: c, shiftKey: true })),
|
|
1358
|
+
..."abcdefghijklmnopqrstuvwxyz".split("").map((c) => ({ code: `Key${c.toUpperCase()}`, key: c })),
|
|
1359
|
+
..."ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").map((c) => ({ code: `Key${c}`, key: c, shiftKey: true })),
|
|
1360
|
+
{ code: "Space", key: " " },
|
|
1361
|
+
{ code: "AltLeft", key: "Alt", location: 1 /* LEFT */ },
|
|
1362
|
+
{ code: "AltRight", key: "Alt", location: 2 /* RIGHT */ },
|
|
1363
|
+
{
|
|
1364
|
+
code: "ShiftLeft",
|
|
1365
|
+
key: "Shift",
|
|
1366
|
+
location: 1 /* LEFT */
|
|
1367
|
+
},
|
|
1368
|
+
{
|
|
1369
|
+
code: "ShiftRight",
|
|
1370
|
+
key: "Shift",
|
|
1371
|
+
location: 2 /* RIGHT */
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
code: "ControlLeft",
|
|
1375
|
+
key: "Control",
|
|
1376
|
+
location: 1 /* LEFT */
|
|
1377
|
+
},
|
|
1378
|
+
{
|
|
1379
|
+
code: "ControlRight",
|
|
1380
|
+
key: "Control",
|
|
1381
|
+
location: 2 /* RIGHT */
|
|
1382
|
+
},
|
|
1383
|
+
{ code: "MetaLeft", key: "Meta", location: 1 /* LEFT */ },
|
|
1384
|
+
{
|
|
1385
|
+
code: "MetaRight",
|
|
1386
|
+
key: "Meta",
|
|
1387
|
+
location: 2 /* RIGHT */
|
|
1388
|
+
},
|
|
1389
|
+
{ code: "OSLeft", key: "OS", location: 1 /* LEFT */ },
|
|
1390
|
+
{ code: "OSRight", key: "OS", location: 2 /* RIGHT */ },
|
|
1391
|
+
{ code: "Tab", key: "Tab" },
|
|
1392
|
+
{ code: "CapsLock", key: "CapsLock" },
|
|
1393
|
+
{ code: "Backspace", key: "Backspace" },
|
|
1394
|
+
{ code: "Enter", key: "Enter" },
|
|
1395
|
+
{ code: "Escape", key: "Escape" },
|
|
1396
|
+
{ code: "ArrowUp", key: "ArrowUp" },
|
|
1397
|
+
{ code: "ArrowDown", key: "ArrowDown" },
|
|
1398
|
+
{ code: "ArrowLeft", key: "ArrowLeft" },
|
|
1399
|
+
{ code: "ArrowRight", key: "ArrowRight" },
|
|
1400
|
+
{ code: "Home", key: "Home" },
|
|
1401
|
+
{ code: "End", key: "End" },
|
|
1402
|
+
{ code: "Delete", key: "Delete" },
|
|
1403
|
+
{ code: "PageUp", key: "PageUp" },
|
|
1404
|
+
{ code: "PageDown", key: "PageDown" },
|
|
1405
|
+
{ code: "Fn", key: "Fn" },
|
|
1406
|
+
{ code: "Symbol", key: "Symbol" },
|
|
1407
|
+
{ code: "AltRight", key: "AltGraph" }
|
|
1408
|
+
];
|
|
1409
|
+
|
|
1410
|
+
// src/pointer/keyMap.ts
|
|
1411
|
+
var defaultKeyMap2 = [
|
|
1412
|
+
{ name: "MouseLeft", pointerType: "mouse", button: "primary" },
|
|
1413
|
+
{ name: "MouseRight", pointerType: "mouse", button: "secondary" },
|
|
1414
|
+
{ name: "MouseMiddle", pointerType: "mouse", button: "auxiliary" },
|
|
1415
|
+
{ name: "TouchA", pointerType: "touch" },
|
|
1416
|
+
{ name: "TouchB", pointerType: "touch" },
|
|
1417
|
+
{ name: "TouchC", pointerType: "touch" }
|
|
1418
|
+
];
|
|
1419
|
+
|
|
1420
|
+
// src/options.ts
|
|
1421
|
+
var PointerEventsCheckLevel = /* @__PURE__ */ ((PointerEventsCheckLevel2) => {
|
|
1422
|
+
PointerEventsCheckLevel2[PointerEventsCheckLevel2["EachTrigger"] = 4] = "EachTrigger";
|
|
1423
|
+
PointerEventsCheckLevel2[PointerEventsCheckLevel2["EachApiCall"] = 2] = "EachApiCall";
|
|
1424
|
+
PointerEventsCheckLevel2[PointerEventsCheckLevel2["EachTarget"] = 1] = "EachTarget";
|
|
1425
|
+
PointerEventsCheckLevel2[PointerEventsCheckLevel2["Never"] = 0] = "Never";
|
|
1426
|
+
return PointerEventsCheckLevel2;
|
|
1427
|
+
})(PointerEventsCheckLevel || {});
|
|
1428
|
+
var defaultOptionsDirect = {
|
|
1429
|
+
applyAccept: true,
|
|
1430
|
+
autoModify: true,
|
|
1431
|
+
delay: 0,
|
|
1432
|
+
document: global.document,
|
|
1433
|
+
keyboardMap: defaultKeyMap,
|
|
1434
|
+
pointerMap: defaultKeyMap2,
|
|
1435
|
+
pointerEventsCheck: 2 /* EachApiCall */,
|
|
1436
|
+
skipAutoClose: false,
|
|
1437
|
+
skipClick: false,
|
|
1438
|
+
skipHover: false,
|
|
1439
|
+
writeToClipboard: false
|
|
1440
|
+
};
|
|
1441
|
+
var defaultOptionsSetup = __spreadProps(__spreadValues({}, defaultOptionsDirect), {
|
|
1442
|
+
writeToClipboard: true
|
|
1443
|
+
});
|
|
1444
|
+
|
|
1445
|
+
// src/utils/pointer/cssPointerEvents.ts
|
|
1217
1446
|
function hasPointerEvents(element) {
|
|
1218
1447
|
const window2 = getWindowFromNode2(element);
|
|
1219
1448
|
for (let el = element; el == null ? void 0 : el.ownerDocument; el = el.parentElement) {
|
|
@@ -1224,9 +1453,26 @@ function hasPointerEvents(element) {
|
|
|
1224
1453
|
}
|
|
1225
1454
|
return true;
|
|
1226
1455
|
}
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1456
|
+
var PointerEventsCheck = Symbol("Last check for pointer-events");
|
|
1457
|
+
function assertPointerEvents(config, element) {
|
|
1458
|
+
const lastCheck = element[PointerEventsCheck];
|
|
1459
|
+
const needsCheck = config.pointerEventsCheck !== 0 /* Never */ && (!lastCheck || hasBitFlag(config.pointerEventsCheck, 2 /* EachApiCall */) && lastCheck[1 /* Call */] !== getLevelRef(config, 1 /* Call */) || hasBitFlag(config.pointerEventsCheck, 4 /* EachTrigger */) && lastCheck[2 /* Trigger */] !== getLevelRef(config, 2 /* Trigger */));
|
|
1460
|
+
if (!needsCheck) {
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
const result = hasPointerEvents(element);
|
|
1464
|
+
element[PointerEventsCheck] = {
|
|
1465
|
+
[1 /* Call */]: getLevelRef(config, 1 /* Call */),
|
|
1466
|
+
[2 /* Trigger */]: getLevelRef(config, 2 /* Trigger */),
|
|
1467
|
+
result
|
|
1468
|
+
};
|
|
1469
|
+
if (!result) {
|
|
1470
|
+
throw new Error('Unable to perform pointer interaction as the element has or inherits pointer-events set to "none".');
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
function hasBitFlag(conf, flag) {
|
|
1474
|
+
return (conf & flag) > 0;
|
|
1475
|
+
}
|
|
1230
1476
|
|
|
1231
1477
|
// src/utils/pointer/firePointerEvents.ts
|
|
1232
1478
|
import { createEvent, fireEvent as fireEvent4 } from "@testing-library/dom";
|
|
@@ -1338,13 +1584,31 @@ function assignPointerInit(obj, { isPrimary, pointerId, pointerType }) {
|
|
|
1338
1584
|
// src/keyboard/plugins/arrow.ts
|
|
1339
1585
|
var keydownBehavior = [
|
|
1340
1586
|
{
|
|
1341
|
-
matches: (keyDef
|
|
1587
|
+
matches: (keyDef) => keyDef.key === "ArrowLeft" || keyDef.key === "ArrowRight",
|
|
1342
1588
|
handle: (keyDef, element) => {
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1589
|
+
if (hasOwnSelection(element)) {
|
|
1590
|
+
const selection = getUISelection(element);
|
|
1591
|
+
setSelection({
|
|
1592
|
+
focusNode: element,
|
|
1593
|
+
focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + (keyDef.key === "ArrowLeft" ? -1 : 1) : keyDef.key === "ArrowLeft" ? selection.startOffset : selection.endOffset
|
|
1594
|
+
});
|
|
1595
|
+
} else {
|
|
1596
|
+
const selection = element.ownerDocument.getSelection();
|
|
1597
|
+
if (!selection) {
|
|
1598
|
+
return;
|
|
1599
|
+
}
|
|
1600
|
+
if (selection.isCollapsed) {
|
|
1601
|
+
const nextPosition = getNextCursorPosition(selection.focusNode, selection.focusOffset, keyDef.key === "ArrowLeft" ? -1 : 1);
|
|
1602
|
+
if (nextPosition) {
|
|
1603
|
+
setSelection({
|
|
1604
|
+
focusNode: nextPosition.node,
|
|
1605
|
+
focusOffset: nextPosition.offset
|
|
1606
|
+
});
|
|
1607
|
+
}
|
|
1608
|
+
} else {
|
|
1609
|
+
selection[keyDef.key === "ArrowLeft" ? "collapseToStart" : "collapseToEnd"]();
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1348
1612
|
}
|
|
1349
1613
|
}
|
|
1350
1614
|
];
|
|
@@ -1893,7 +2157,8 @@ function findNodeAtTextOffset(node, offset, isRoot = true) {
|
|
|
1893
2157
|
|
|
1894
2158
|
// src/pointer/pointerMove.ts
|
|
1895
2159
|
function pointerMove(_0, _1) {
|
|
1896
|
-
return __async(this, arguments, function* ({ pointerName = "mouse", target, coords, node, offset }
|
|
2160
|
+
return __async(this, arguments, function* (config, { pointerName = "mouse", target, coords, node, offset }) {
|
|
2161
|
+
const { pointerState, keyboardState } = config;
|
|
1897
2162
|
if (!(pointerName in pointerState.position)) {
|
|
1898
2163
|
throw new Error(`Trying to move pointer "${pointerName}" which does not exist.`);
|
|
1899
2164
|
}
|
|
@@ -1905,11 +2170,15 @@ function pointerMove(_0, _1) {
|
|
|
1905
2170
|
selectionRange
|
|
1906
2171
|
} = pointerState.position[pointerName];
|
|
1907
2172
|
if (prevTarget && prevTarget !== target) {
|
|
2173
|
+
setLevelRef(config, 2 /* Trigger */);
|
|
2174
|
+
assertPointerEvents(config, prevTarget);
|
|
1908
2175
|
fireMove(prevTarget, prevCoords);
|
|
1909
2176
|
if (!isDescendantOrSelf(target, prevTarget)) {
|
|
1910
2177
|
fireLeave(prevTarget, prevCoords);
|
|
1911
2178
|
}
|
|
1912
2179
|
}
|
|
2180
|
+
setLevelRef(config, 2 /* Trigger */);
|
|
2181
|
+
assertPointerEvents(config, target);
|
|
1913
2182
|
pointerState.position[pointerName] = __spreadProps(__spreadValues({}, pointerState.position[pointerName]), {
|
|
1914
2183
|
target,
|
|
1915
2184
|
coords
|
|
@@ -1976,19 +2245,19 @@ function pointerMove(_0, _1) {
|
|
|
1976
2245
|
}
|
|
1977
2246
|
|
|
1978
2247
|
// src/pointer/pointerPress.ts
|
|
1979
|
-
function pointerPress(
|
|
2248
|
+
function pointerPress(config, action) {
|
|
1980
2249
|
return __async(this, null, function* () {
|
|
1981
2250
|
const { keyDef, target, releasePrevious, releaseSelf } = action;
|
|
1982
|
-
const previous =
|
|
2251
|
+
const previous = config.pointerState.pressed.find((p) => p.keyDef === keyDef);
|
|
1983
2252
|
const pointerName = keyDef.pointerType === "touch" ? keyDef.name : keyDef.pointerType;
|
|
1984
2253
|
const targetIsDisabled = isDisabled(target);
|
|
1985
2254
|
if (previous) {
|
|
1986
|
-
up(
|
|
2255
|
+
up(config, pointerName, action, previous, targetIsDisabled);
|
|
1987
2256
|
}
|
|
1988
2257
|
if (!releasePrevious) {
|
|
1989
|
-
const press = down(
|
|
2258
|
+
const press = down(config, pointerName, action, targetIsDisabled);
|
|
1990
2259
|
if (releaseSelf) {
|
|
1991
|
-
up(
|
|
2260
|
+
up(config, pointerName, action, press, targetIsDisabled);
|
|
1992
2261
|
}
|
|
1993
2262
|
}
|
|
1994
2263
|
});
|
|
@@ -1997,8 +2266,11 @@ function getNextPointerId(state) {
|
|
|
1997
2266
|
state.pointerId = state.pointerId + 1;
|
|
1998
2267
|
return state.pointerId;
|
|
1999
2268
|
}
|
|
2000
|
-
function down(
|
|
2269
|
+
function down(config, pointerName, { keyDef, node, offset, target, coords }, targetIsDisabled) {
|
|
2001
2270
|
var _a, _b, _c;
|
|
2271
|
+
setLevelRef(config, 2 /* Trigger */);
|
|
2272
|
+
assertPointerEvents(config, target);
|
|
2273
|
+
const { pointerState, keyboardState } = config;
|
|
2002
2274
|
const { name, pointerType, button } = keyDef;
|
|
2003
2275
|
const pointerId = pointerType === "mouse" ? 1 : getNextPointerId(pointerState);
|
|
2004
2276
|
pointerState.position[pointerName] = __spreadProps(__spreadValues({}, pointerState.position[pointerName]), {
|
|
@@ -2033,31 +2305,31 @@ function down({ pointerState, keyboardState }, pointerName, { keyDef, node, offs
|
|
|
2033
2305
|
clickCount
|
|
2034
2306
|
};
|
|
2035
2307
|
pointerState.pressed.push(pressObj);
|
|
2036
|
-
if (
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2308
|
+
if (pointerType !== "mouse") {
|
|
2309
|
+
fire("pointerover");
|
|
2310
|
+
fire("pointerenter");
|
|
2311
|
+
}
|
|
2312
|
+
if (pointerType !== "mouse" || !pointerState.pressed.some((p) => p.keyDef !== keyDef && p.keyDef.pointerType === pointerType)) {
|
|
2313
|
+
fire("pointerdown");
|
|
2314
|
+
}
|
|
2315
|
+
if (pointerType === "mouse") {
|
|
2316
|
+
if (!targetIsDisabled) {
|
|
2317
|
+
pressObj.unpreventedDefault = fire("mousedown");
|
|
2040
2318
|
}
|
|
2041
|
-
if (
|
|
2042
|
-
|
|
2319
|
+
if (pressObj.unpreventedDefault) {
|
|
2320
|
+
mousedownDefaultBehavior({
|
|
2321
|
+
target,
|
|
2322
|
+
targetIsDisabled,
|
|
2323
|
+
clickCount,
|
|
2324
|
+
position: pointerState.position[pointerName],
|
|
2325
|
+
node,
|
|
2326
|
+
offset
|
|
2327
|
+
});
|
|
2043
2328
|
}
|
|
2044
|
-
if (
|
|
2045
|
-
|
|
2329
|
+
if (button === "secondary") {
|
|
2330
|
+
fire("contextmenu");
|
|
2046
2331
|
}
|
|
2047
2332
|
}
|
|
2048
|
-
if (pointerType === "mouse" && pressObj.unpreventedDefault) {
|
|
2049
|
-
mousedownDefaultBehavior({
|
|
2050
|
-
target,
|
|
2051
|
-
targetIsDisabled,
|
|
2052
|
-
clickCount,
|
|
2053
|
-
position: pointerState.position[pointerName],
|
|
2054
|
-
node,
|
|
2055
|
-
offset
|
|
2056
|
-
});
|
|
2057
|
-
}
|
|
2058
|
-
if (pointerType === "mouse" && button === "secondary") {
|
|
2059
|
-
fire("contextmenu");
|
|
2060
|
-
}
|
|
2061
2333
|
return pressObj;
|
|
2062
2334
|
function fire(type3) {
|
|
2063
2335
|
return firePointerEvent(target, type3, {
|
|
@@ -2072,7 +2344,7 @@ function down({ pointerState, keyboardState }, pointerName, { keyDef, node, offs
|
|
|
2072
2344
|
});
|
|
2073
2345
|
}
|
|
2074
2346
|
}
|
|
2075
|
-
function up(
|
|
2347
|
+
function up(config, pointerName, {
|
|
2076
2348
|
keyDef: { pointerType, button },
|
|
2077
2349
|
target,
|
|
2078
2350
|
coords,
|
|
@@ -2080,6 +2352,9 @@ function up({ pointerState, keyboardState }, pointerName, {
|
|
|
2080
2352
|
offset
|
|
2081
2353
|
}, pressed, targetIsDisabled) {
|
|
2082
2354
|
var _a;
|
|
2355
|
+
setLevelRef(config, 2 /* Trigger */);
|
|
2356
|
+
assertPointerEvents(config, target);
|
|
2357
|
+
const { pointerState, keyboardState } = config;
|
|
2083
2358
|
pointerState.pressed = pointerState.pressed.filter((p) => p !== pressed);
|
|
2084
2359
|
const { isMultiTouch, isPrimary, pointerId, clickCount } = pressed;
|
|
2085
2360
|
let { unpreventedDefault } = pressed;
|
|
@@ -2087,15 +2362,15 @@ function up({ pointerState, keyboardState }, pointerName, {
|
|
|
2087
2362
|
target,
|
|
2088
2363
|
coords
|
|
2089
2364
|
});
|
|
2090
|
-
if (!
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
if (
|
|
2365
|
+
if (pointerType !== "mouse" || !pointerState.pressed.filter((p) => p.keyDef.pointerType === pointerType).length) {
|
|
2366
|
+
fire("pointerup");
|
|
2367
|
+
}
|
|
2368
|
+
if (pointerType !== "mouse") {
|
|
2369
|
+
fire("pointerout");
|
|
2370
|
+
fire("pointerleave");
|
|
2371
|
+
}
|
|
2372
|
+
if (pointerType !== "mouse" && !isMultiTouch) {
|
|
2373
|
+
if (!targetIsDisabled) {
|
|
2099
2374
|
if (clickCount === 1) {
|
|
2100
2375
|
fire("mouseover");
|
|
2101
2376
|
fire("mouseenter");
|
|
@@ -2103,16 +2378,16 @@ function up({ pointerState, keyboardState }, pointerName, {
|
|
|
2103
2378
|
fire("mousemove");
|
|
2104
2379
|
unpreventedDefault = fire("mousedown") && unpreventedDefault;
|
|
2105
2380
|
}
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
}
|
|
2381
|
+
if (unpreventedDefault) {
|
|
2382
|
+
mousedownDefaultBehavior({
|
|
2383
|
+
target,
|
|
2384
|
+
targetIsDisabled,
|
|
2385
|
+
clickCount,
|
|
2386
|
+
position: pointerState.position[pointerName],
|
|
2387
|
+
node,
|
|
2388
|
+
offset
|
|
2389
|
+
});
|
|
2390
|
+
}
|
|
2116
2391
|
}
|
|
2117
2392
|
delete pointerState.position[pointerName].selectionRange;
|
|
2118
2393
|
if (!targetIsDisabled) {
|
|
@@ -2152,8 +2427,7 @@ function mousedownDefaultBehavior({
|
|
|
2152
2427
|
node,
|
|
2153
2428
|
offset
|
|
2154
2429
|
}) {
|
|
2155
|
-
|
|
2156
|
-
focus((_a = findClosest(target, isFocusable)) != null ? _a : target.ownerDocument.body);
|
|
2430
|
+
focus(target);
|
|
2157
2431
|
if (!targetIsDisabled) {
|
|
2158
2432
|
const hasValue = isElementType(target, ["input", "textarea"]);
|
|
2159
2433
|
const text = String(hasValue ? getUIValue(target) : target.textContent);
|
|
@@ -2215,7 +2489,7 @@ function pointerAction(config, actions) {
|
|
|
2215
2489
|
const pointerName = "pointerName" in action && action.pointerName ? action.pointerName : "keyDef" in action ? action.keyDef.pointerType === "touch" ? action.keyDef.name : action.keyDef.pointerType : "mouse";
|
|
2216
2490
|
const target = (_a = action.target) != null ? _a : getPrevTarget(pointerName, config.pointerState);
|
|
2217
2491
|
const coords = (_b = action.coords) != null ? _b : pointerName in config.pointerState.position ? config.pointerState.position[pointerName].coords : void 0;
|
|
2218
|
-
yield "keyDef" in action ? pointerPress(__spreadProps(__spreadValues({}, action), { target, coords })
|
|
2492
|
+
yield "keyDef" in action ? pointerPress(config, __spreadProps(__spreadValues({}, action), { target, coords })) : pointerMove(config, __spreadProps(__spreadValues({}, action), { target, coords }));
|
|
2219
2493
|
if (typeof config.delay === "number") {
|
|
2220
2494
|
if (i < actions.length - 1) {
|
|
2221
2495
|
yield wait(config.delay);
|
|
@@ -2273,90 +2547,6 @@ function createPointerState(document2) {
|
|
|
2273
2547
|
};
|
|
2274
2548
|
}
|
|
2275
2549
|
|
|
2276
|
-
// src/keyboard/keyMap.ts
|
|
2277
|
-
var defaultKeyMap = [
|
|
2278
|
-
..."0123456789".split("").map((c) => ({ code: `Digit${c}`, key: c })),
|
|
2279
|
-
...")!@#$%^&*(".split("").map((c, i) => ({ code: `Digit${i}`, key: c, shiftKey: true })),
|
|
2280
|
-
..."abcdefghijklmnopqrstuvwxyz".split("").map((c) => ({ code: `Key${c.toUpperCase()}`, key: c })),
|
|
2281
|
-
..."ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").map((c) => ({ code: `Key${c}`, key: c, shiftKey: true })),
|
|
2282
|
-
{ code: "Space", key: " " },
|
|
2283
|
-
{ code: "AltLeft", key: "Alt", location: 1 /* LEFT */ },
|
|
2284
|
-
{ code: "AltRight", key: "Alt", location: 2 /* RIGHT */ },
|
|
2285
|
-
{
|
|
2286
|
-
code: "ShiftLeft",
|
|
2287
|
-
key: "Shift",
|
|
2288
|
-
location: 1 /* LEFT */
|
|
2289
|
-
},
|
|
2290
|
-
{
|
|
2291
|
-
code: "ShiftRight",
|
|
2292
|
-
key: "Shift",
|
|
2293
|
-
location: 2 /* RIGHT */
|
|
2294
|
-
},
|
|
2295
|
-
{
|
|
2296
|
-
code: "ControlLeft",
|
|
2297
|
-
key: "Control",
|
|
2298
|
-
location: 1 /* LEFT */
|
|
2299
|
-
},
|
|
2300
|
-
{
|
|
2301
|
-
code: "ControlRight",
|
|
2302
|
-
key: "Control",
|
|
2303
|
-
location: 2 /* RIGHT */
|
|
2304
|
-
},
|
|
2305
|
-
{ code: "MetaLeft", key: "Meta", location: 1 /* LEFT */ },
|
|
2306
|
-
{
|
|
2307
|
-
code: "MetaRight",
|
|
2308
|
-
key: "Meta",
|
|
2309
|
-
location: 2 /* RIGHT */
|
|
2310
|
-
},
|
|
2311
|
-
{ code: "OSLeft", key: "OS", location: 1 /* LEFT */ },
|
|
2312
|
-
{ code: "OSRight", key: "OS", location: 2 /* RIGHT */ },
|
|
2313
|
-
{ code: "Tab", key: "Tab" },
|
|
2314
|
-
{ code: "CapsLock", key: "CapsLock" },
|
|
2315
|
-
{ code: "Backspace", key: "Backspace" },
|
|
2316
|
-
{ code: "Enter", key: "Enter" },
|
|
2317
|
-
{ code: "Escape", key: "Escape" },
|
|
2318
|
-
{ code: "ArrowUp", key: "ArrowUp" },
|
|
2319
|
-
{ code: "ArrowDown", key: "ArrowDown" },
|
|
2320
|
-
{ code: "ArrowLeft", key: "ArrowLeft" },
|
|
2321
|
-
{ code: "ArrowRight", key: "ArrowRight" },
|
|
2322
|
-
{ code: "Home", key: "Home" },
|
|
2323
|
-
{ code: "End", key: "End" },
|
|
2324
|
-
{ code: "Delete", key: "Delete" },
|
|
2325
|
-
{ code: "PageUp", key: "PageUp" },
|
|
2326
|
-
{ code: "PageDown", key: "PageDown" },
|
|
2327
|
-
{ code: "Fn", key: "Fn" },
|
|
2328
|
-
{ code: "Symbol", key: "Symbol" },
|
|
2329
|
-
{ code: "AltRight", key: "AltGraph" }
|
|
2330
|
-
];
|
|
2331
|
-
|
|
2332
|
-
// src/pointer/keyMap.ts
|
|
2333
|
-
var defaultKeyMap2 = [
|
|
2334
|
-
{ name: "MouseLeft", pointerType: "mouse", button: "primary" },
|
|
2335
|
-
{ name: "MouseRight", pointerType: "mouse", button: "secondary" },
|
|
2336
|
-
{ name: "MouseMiddle", pointerType: "mouse", button: "auxiliary" },
|
|
2337
|
-
{ name: "TouchA", pointerType: "touch" },
|
|
2338
|
-
{ name: "TouchB", pointerType: "touch" },
|
|
2339
|
-
{ name: "TouchC", pointerType: "touch" }
|
|
2340
|
-
];
|
|
2341
|
-
|
|
2342
|
-
// src/options.ts
|
|
2343
|
-
var defaultOptionsDirect = {
|
|
2344
|
-
applyAccept: true,
|
|
2345
|
-
autoModify: true,
|
|
2346
|
-
delay: 0,
|
|
2347
|
-
document: global.document,
|
|
2348
|
-
keyboardMap: defaultKeyMap,
|
|
2349
|
-
pointerMap: defaultKeyMap2,
|
|
2350
|
-
skipAutoClose: false,
|
|
2351
|
-
skipClick: false,
|
|
2352
|
-
skipHover: false,
|
|
2353
|
-
skipPointerEventsCheck: false,
|
|
2354
|
-
writeToClipboard: false
|
|
2355
|
-
};
|
|
2356
|
-
var defaultOptionsSetup = __spreadProps(__spreadValues({}, defaultOptionsDirect), {
|
|
2357
|
-
writeToClipboard: true
|
|
2358
|
-
});
|
|
2359
|
-
|
|
2360
2550
|
// src/setup/config.ts
|
|
2361
2551
|
var Config = Symbol("Config");
|
|
2362
2552
|
|
|
@@ -2384,9 +2574,6 @@ __export(api_exports, {
|
|
|
2384
2574
|
// src/convenience/click.ts
|
|
2385
2575
|
function click(element) {
|
|
2386
2576
|
return __async(this, null, function* () {
|
|
2387
|
-
if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) {
|
|
2388
|
-
throw new Error('unable to click element as it has or inherits pointer-events set to "none".');
|
|
2389
|
-
}
|
|
2390
2577
|
const pointerIn = [];
|
|
2391
2578
|
if (!this[Config].skipHover) {
|
|
2392
2579
|
pointerIn.push({ target: element });
|
|
@@ -2397,17 +2584,11 @@ function click(element) {
|
|
|
2397
2584
|
}
|
|
2398
2585
|
function dblClick(element) {
|
|
2399
2586
|
return __async(this, null, function* () {
|
|
2400
|
-
if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) {
|
|
2401
|
-
throw new Error('unable to double-click element as it has or inherits pointer-events set to "none".');
|
|
2402
|
-
}
|
|
2403
2587
|
return this.pointer([{ target: element }, "[MouseLeft][MouseLeft]"]);
|
|
2404
2588
|
});
|
|
2405
2589
|
}
|
|
2406
2590
|
function tripleClick(element) {
|
|
2407
2591
|
return __async(this, null, function* () {
|
|
2408
|
-
if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) {
|
|
2409
|
-
throw new Error('unable to triple-click element as it has or inherits pointer-events set to "none".');
|
|
2410
|
-
}
|
|
2411
2592
|
return this.pointer([{ target: element }, "[MouseLeft][MouseLeft][MouseLeft]"]);
|
|
2412
2593
|
});
|
|
2413
2594
|
}
|
|
@@ -2415,17 +2596,11 @@ function tripleClick(element) {
|
|
|
2415
2596
|
// src/convenience/hover.ts
|
|
2416
2597
|
function hover(element) {
|
|
2417
2598
|
return __async(this, null, function* () {
|
|
2418
|
-
if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) {
|
|
2419
|
-
throw new Error('unable to hover element as it has or inherits pointer-events set to "none".');
|
|
2420
|
-
}
|
|
2421
2599
|
return this.pointer({ target: element });
|
|
2422
2600
|
});
|
|
2423
2601
|
}
|
|
2424
2602
|
function unhover(element) {
|
|
2425
2603
|
return __async(this, null, function* () {
|
|
2426
|
-
if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) {
|
|
2427
|
-
throw new Error('unable to unhover element as it has or inherits pointer-events set to "none".');
|
|
2428
|
-
}
|
|
2429
2604
|
return this.pointer({ target: element.ownerDocument.body });
|
|
2430
2605
|
});
|
|
2431
2606
|
}
|
|
@@ -2570,7 +2745,7 @@ function selectOptionsBase(newValue, select, values) {
|
|
|
2570
2745
|
if (isElementType(select, "select")) {
|
|
2571
2746
|
if (select.multiple) {
|
|
2572
2747
|
for (const option of selectedOptions) {
|
|
2573
|
-
const withPointerEvents = this[Config].
|
|
2748
|
+
const withPointerEvents = this[Config].pointerEventsCheck === 0 ? true : hasPointerEvents(option);
|
|
2574
2749
|
if (withPointerEvents) {
|
|
2575
2750
|
fireEvent13.pointerOver(option);
|
|
2576
2751
|
fireEvent13.pointerEnter(select);
|
|
@@ -2592,7 +2767,7 @@ function selectOptionsBase(newValue, select, values) {
|
|
|
2592
2767
|
}
|
|
2593
2768
|
}
|
|
2594
2769
|
} else if (selectedOptions.length === 1) {
|
|
2595
|
-
const withPointerEvents = this[Config].
|
|
2770
|
+
const withPointerEvents = this[Config].pointerEventsCheck === 0 ? true : hasPointerEvents(select);
|
|
2596
2771
|
if (withPointerEvents) {
|
|
2597
2772
|
yield this.click(select);
|
|
2598
2773
|
} else {
|
|
@@ -2667,8 +2842,8 @@ function upload(element, fileOrFiles) {
|
|
|
2667
2842
|
return;
|
|
2668
2843
|
yield this.click(element);
|
|
2669
2844
|
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).filter((file) => !this[Config].applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? void 0 : 1);
|
|
2670
|
-
blur(
|
|
2671
|
-
focus(
|
|
2845
|
+
blur(input);
|
|
2846
|
+
focus(input);
|
|
2672
2847
|
if (files.length === ((_a = input.files) == null ? void 0 : _a.length) && files.every((f, i) => {
|
|
2673
2848
|
var _a2;
|
|
2674
2849
|
return f === ((_a2 = input.files) == null ? void 0 : _a2.item(i));
|
|
@@ -2708,7 +2883,7 @@ function setupMain(options = {}) {
|
|
|
2708
2883
|
prepareDocument(doc);
|
|
2709
2884
|
const view = (_a = doc.defaultView) != null ? _a : window;
|
|
2710
2885
|
attachClipboardStubToView(view);
|
|
2711
|
-
return doSetup(__spreadProps(__spreadValues({}, defaultOptionsSetup), {
|
|
2886
|
+
return doSetup(__spreadProps(__spreadValues(__spreadValues({}, defaultOptionsSetup), options), {
|
|
2712
2887
|
keyboardState: createKeyboardState(),
|
|
2713
2888
|
pointerState: createPointerState(doc)
|
|
2714
2889
|
}));
|
|
@@ -2716,26 +2891,35 @@ function setupMain(options = {}) {
|
|
|
2716
2891
|
function setupDirect(options = {}, node) {
|
|
2717
2892
|
const doc = getDocument(options, node);
|
|
2718
2893
|
prepareDocument(doc);
|
|
2719
|
-
|
|
2894
|
+
const config = __spreadValues(__spreadValues({
|
|
2720
2895
|
keyboardState: createKeyboardState(),
|
|
2721
2896
|
pointerState: createPointerState(doc)
|
|
2722
|
-
}, defaultOptionsDirect), options)
|
|
2897
|
+
}, defaultOptionsDirect), options);
|
|
2898
|
+
return {
|
|
2899
|
+
config,
|
|
2900
|
+
api: doSetup(config)
|
|
2901
|
+
};
|
|
2723
2902
|
}
|
|
2724
2903
|
function setupSub(options) {
|
|
2725
2904
|
return doSetup(__spreadValues(__spreadValues({}, this[Config]), options));
|
|
2726
2905
|
}
|
|
2727
|
-
function
|
|
2906
|
+
function wrapAndBindImpl(instance, impl) {
|
|
2728
2907
|
function method(...args) {
|
|
2729
|
-
|
|
2908
|
+
setLevelRef(instance[Config], 1 /* Call */);
|
|
2909
|
+
return wrapAsync(() => impl.apply(instance, args));
|
|
2730
2910
|
}
|
|
2731
2911
|
Object.defineProperty(method, "name", { get: () => impl.name });
|
|
2732
2912
|
return method;
|
|
2733
2913
|
}
|
|
2734
|
-
var wrappedApis = Object.fromEntries(Object.entries(api_exports).map(([name, impl]) => [name, wrapImpl(impl)]));
|
|
2735
2914
|
function doSetup(config) {
|
|
2736
|
-
|
|
2737
|
-
setup: setupSub,
|
|
2915
|
+
const instance = __spreadValues({
|
|
2738
2916
|
[Config]: config
|
|
2917
|
+
}, api_exports);
|
|
2918
|
+
return __spreadProps(__spreadValues({}, Object.fromEntries(Object.entries(api_exports).map(([name, api]) => [
|
|
2919
|
+
name,
|
|
2920
|
+
wrapAndBindImpl(instance, api)
|
|
2921
|
+
]))), {
|
|
2922
|
+
setup: setupSub.bind(instance)
|
|
2739
2923
|
});
|
|
2740
2924
|
}
|
|
2741
2925
|
function getDocument(options, node) {
|
|
@@ -2764,62 +2948,60 @@ __export(directApi_exports, {
|
|
|
2764
2948
|
upload: () => upload2
|
|
2765
2949
|
});
|
|
2766
2950
|
function clear2(element) {
|
|
2767
|
-
return setupDirect().clear(element);
|
|
2951
|
+
return setupDirect().api.clear(element);
|
|
2768
2952
|
}
|
|
2769
2953
|
function click2(element, options = {}) {
|
|
2770
|
-
return setupDirect(options, element).click(element);
|
|
2954
|
+
return setupDirect(options, element).api.click(element);
|
|
2771
2955
|
}
|
|
2772
2956
|
function copy2(options = {}) {
|
|
2773
|
-
return setupDirect(options).copy();
|
|
2957
|
+
return setupDirect(options).api.copy();
|
|
2774
2958
|
}
|
|
2775
2959
|
function cut2(options = {}) {
|
|
2776
|
-
return setupDirect(options).cut();
|
|
2960
|
+
return setupDirect(options).api.cut();
|
|
2777
2961
|
}
|
|
2778
2962
|
function dblClick2(element, options = {}) {
|
|
2779
|
-
return setupDirect(options).dblClick(element);
|
|
2963
|
+
return setupDirect(options).api.dblClick(element);
|
|
2780
2964
|
}
|
|
2781
2965
|
function deselectOptions2(select, values, options = {}) {
|
|
2782
|
-
return setupDirect(options).deselectOptions(select, values);
|
|
2966
|
+
return setupDirect(options).api.deselectOptions(select, values);
|
|
2783
2967
|
}
|
|
2784
2968
|
function hover2(element, options = {}) {
|
|
2785
|
-
return setupDirect(options).hover(element);
|
|
2969
|
+
return setupDirect(options).api.hover(element);
|
|
2786
2970
|
}
|
|
2787
2971
|
function keyboard2(_0) {
|
|
2788
2972
|
return __async(this, arguments, function* (text, options = {}) {
|
|
2789
|
-
const
|
|
2790
|
-
|
|
2791
|
-
return promise.then(() => instance[Config].keyboardState);
|
|
2973
|
+
const { config, api } = setupDirect(options);
|
|
2974
|
+
return api.keyboard(text).then(() => config.keyboardState);
|
|
2792
2975
|
});
|
|
2793
2976
|
}
|
|
2794
2977
|
function pointer2(_0) {
|
|
2795
2978
|
return __async(this, arguments, function* (input, options = {}) {
|
|
2796
|
-
const
|
|
2797
|
-
|
|
2798
|
-
return promise.then(() => instance[Config].pointerState);
|
|
2979
|
+
const { config, api } = setupDirect(options);
|
|
2980
|
+
return api.pointer(input).then(() => config.pointerState);
|
|
2799
2981
|
});
|
|
2800
2982
|
}
|
|
2801
2983
|
function paste2(clipboardData, options) {
|
|
2802
|
-
return setupDirect(options).paste(clipboardData);
|
|
2984
|
+
return setupDirect(options).api.paste(clipboardData);
|
|
2803
2985
|
}
|
|
2804
2986
|
function selectOptions2(select, values, options = {}) {
|
|
2805
|
-
return setupDirect(options).selectOptions(select, values);
|
|
2987
|
+
return setupDirect(options).api.selectOptions(select, values);
|
|
2806
2988
|
}
|
|
2807
2989
|
function tripleClick2(element, options = {}) {
|
|
2808
|
-
return setupDirect(options).tripleClick(element);
|
|
2990
|
+
return setupDirect(options).api.tripleClick(element);
|
|
2809
2991
|
}
|
|
2810
2992
|
function type2(element, text, options = {}) {
|
|
2811
|
-
return setupDirect(options, element).type(element, text, options);
|
|
2993
|
+
return setupDirect(options, element).api.type(element, text, options);
|
|
2812
2994
|
}
|
|
2813
2995
|
function unhover2(element, options = {}) {
|
|
2814
|
-
const
|
|
2815
|
-
|
|
2816
|
-
return
|
|
2996
|
+
const { config, api } = setupDirect(options);
|
|
2997
|
+
config.pointerState.position.mouse.target = element;
|
|
2998
|
+
return api.unhover(element);
|
|
2817
2999
|
}
|
|
2818
3000
|
function upload2(element, fileOrFiles, options = {}) {
|
|
2819
|
-
return setupDirect(options).upload(element, fileOrFiles);
|
|
3001
|
+
return setupDirect(options).api.upload(element, fileOrFiles);
|
|
2820
3002
|
}
|
|
2821
3003
|
function tab2(options = {}) {
|
|
2822
|
-
return setupDirect().tab(options);
|
|
3004
|
+
return setupDirect().api.tab(options);
|
|
2823
3005
|
}
|
|
2824
3006
|
|
|
2825
3007
|
// src/setup/index.ts
|
|
@@ -2827,5 +3009,6 @@ var userEvent = __spreadProps(__spreadValues({}, directApi_exports), {
|
|
|
2827
3009
|
setup: setupMain
|
|
2828
3010
|
});
|
|
2829
3011
|
export {
|
|
3012
|
+
PointerEventsCheckLevel,
|
|
2830
3013
|
userEvent as default
|
|
2831
3014
|
};
|