@testing-library/user-event 14.0.0-beta.5 → 14.0.0-beta.6
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 +184 -48
- package/dist/index.mjs +184 -48
- package/dist/types/utils/focus/cursor.d.ts +9 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -787,6 +787,111 @@ function supportsMaxLength(element) {
|
|
|
787
787
|
|
|
788
788
|
// src/utils/edit/prepareInput.ts
|
|
789
789
|
var import_dom3 = require("@testing-library/dom");
|
|
790
|
+
|
|
791
|
+
// src/utils/focus/cursor.ts
|
|
792
|
+
function getNextCursorPosition(node, offset, direction, inputType) {
|
|
793
|
+
if (isTextNode(node) && offset + direction >= 0 && offset + direction <= node.nodeValue.length) {
|
|
794
|
+
return { node, offset: offset + direction };
|
|
795
|
+
}
|
|
796
|
+
const nextNode = getNextCharacterContentNode(node, offset, direction);
|
|
797
|
+
if (nextNode) {
|
|
798
|
+
if (isTextNode(nextNode)) {
|
|
799
|
+
return {
|
|
800
|
+
node: nextNode,
|
|
801
|
+
offset: direction > 0 ? Math.min(1, nextNode.nodeValue.length) : Math.max(nextNode.nodeValue.length - 1, 0)
|
|
802
|
+
};
|
|
803
|
+
} else if (isElementType(nextNode, "br")) {
|
|
804
|
+
const nextPlusOne = getNextCharacterContentNode(nextNode, void 0, direction);
|
|
805
|
+
if (!nextPlusOne) {
|
|
806
|
+
if (direction < 0 && inputType === "deleteContentBackward") {
|
|
807
|
+
return {
|
|
808
|
+
node: nextNode.parentNode,
|
|
809
|
+
offset: getOffset(nextNode)
|
|
810
|
+
};
|
|
811
|
+
}
|
|
812
|
+
return void 0;
|
|
813
|
+
} else if (isTextNode(nextPlusOne)) {
|
|
814
|
+
return {
|
|
815
|
+
node: nextPlusOne,
|
|
816
|
+
offset: direction > 0 ? 0 : nextPlusOne.nodeValue.length
|
|
817
|
+
};
|
|
818
|
+
} else if (direction < 0 && isElementType(nextPlusOne, "br")) {
|
|
819
|
+
return {
|
|
820
|
+
node: nextNode.parentNode,
|
|
821
|
+
offset: getOffset(nextNode)
|
|
822
|
+
};
|
|
823
|
+
} else {
|
|
824
|
+
return {
|
|
825
|
+
node: nextPlusOne.parentNode,
|
|
826
|
+
offset: getOffset(nextPlusOne) + (direction > 0 ? 0 : 1)
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
} else {
|
|
830
|
+
return {
|
|
831
|
+
node: nextNode.parentNode,
|
|
832
|
+
offset: getOffset(nextNode) + (direction > 0 ? 1 : 0)
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
function getNextCharacterContentNode(node, offset, direction) {
|
|
838
|
+
const nextOffset = Number(offset) + (direction < 0 ? -1 : 0);
|
|
839
|
+
if (offset !== void 0 && isElement2(node) && nextOffset >= 0 && nextOffset < node.children.length) {
|
|
840
|
+
node = node.children[nextOffset];
|
|
841
|
+
}
|
|
842
|
+
return walkNodes(node, direction === 1 ? "next" : "previous", isTreatedAsCharacterContent);
|
|
843
|
+
}
|
|
844
|
+
function isTreatedAsCharacterContent(node) {
|
|
845
|
+
if (isTextNode(node)) {
|
|
846
|
+
return true;
|
|
847
|
+
}
|
|
848
|
+
if (isElement2(node)) {
|
|
849
|
+
if (isElementType(node, ["input", "textarea"])) {
|
|
850
|
+
return node.type !== "hidden";
|
|
851
|
+
} else if (isElementType(node, "br")) {
|
|
852
|
+
return true;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
return false;
|
|
856
|
+
}
|
|
857
|
+
function getOffset(node) {
|
|
858
|
+
let i = 0;
|
|
859
|
+
while (node.previousSibling) {
|
|
860
|
+
i++;
|
|
861
|
+
node = node.previousSibling;
|
|
862
|
+
}
|
|
863
|
+
return i;
|
|
864
|
+
}
|
|
865
|
+
function isElement2(node) {
|
|
866
|
+
return node.nodeType === 1;
|
|
867
|
+
}
|
|
868
|
+
function isTextNode(node) {
|
|
869
|
+
return node.nodeType === 3;
|
|
870
|
+
}
|
|
871
|
+
function walkNodes(node, direction, callback) {
|
|
872
|
+
var _a;
|
|
873
|
+
for (; ; ) {
|
|
874
|
+
const sibling = node[`${direction}Sibling`];
|
|
875
|
+
if (sibling) {
|
|
876
|
+
node = getDescendant(sibling, direction === "next" ? "first" : "last");
|
|
877
|
+
if (callback(node)) {
|
|
878
|
+
return node;
|
|
879
|
+
}
|
|
880
|
+
} else if (node.parentNode && (!isElement2(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((_a = node.ownerDocument) == null ? void 0 : _a.body))) {
|
|
881
|
+
node = node.parentNode;
|
|
882
|
+
} else {
|
|
883
|
+
break;
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
function getDescendant(node, direction) {
|
|
888
|
+
while (node.hasChildNodes()) {
|
|
889
|
+
node = node[`${direction}Child`];
|
|
890
|
+
}
|
|
891
|
+
return node;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
// src/utils/edit/prepareInput.ts
|
|
790
895
|
function prepareInput(data, element, inputType = "insertText") {
|
|
791
896
|
const inputRange = getInputRange(element);
|
|
792
897
|
if (!inputRange) {
|
|
@@ -795,9 +900,22 @@ function prepareInput(data, element, inputType = "insertText") {
|
|
|
795
900
|
if ("startContainer" in inputRange) {
|
|
796
901
|
return {
|
|
797
902
|
commit: () => {
|
|
798
|
-
|
|
799
|
-
if (
|
|
903
|
+
let del = false;
|
|
904
|
+
if (!inputRange.collapsed) {
|
|
905
|
+
del = true;
|
|
800
906
|
inputRange.deleteContents();
|
|
907
|
+
} else if (["deleteContentBackward", "deleteContentForward"].includes(inputType)) {
|
|
908
|
+
const nextPosition = getNextCursorPosition(inputRange.startContainer, inputRange.startOffset, inputType === "deleteContentBackward" ? -1 : 1, inputType);
|
|
909
|
+
if (nextPosition) {
|
|
910
|
+
del = true;
|
|
911
|
+
const delRange = inputRange.cloneRange();
|
|
912
|
+
if (delRange.comparePoint(nextPosition.node, nextPosition.offset) < 0) {
|
|
913
|
+
delRange.setStart(nextPosition.node, nextPosition.offset);
|
|
914
|
+
} else {
|
|
915
|
+
delRange.setEnd(nextPosition.node, nextPosition.offset);
|
|
916
|
+
}
|
|
917
|
+
delRange.deleteContents();
|
|
918
|
+
}
|
|
801
919
|
}
|
|
802
920
|
if (data) {
|
|
803
921
|
if (inputRange.endContainer.nodeType === 3) {
|
|
@@ -1325,13 +1443,31 @@ function assignPointerInit(obj, { isPrimary, pointerId, pointerType }) {
|
|
|
1325
1443
|
// src/keyboard/plugins/arrow.ts
|
|
1326
1444
|
var keydownBehavior = [
|
|
1327
1445
|
{
|
|
1328
|
-
matches: (keyDef
|
|
1446
|
+
matches: (keyDef) => keyDef.key === "ArrowLeft" || keyDef.key === "ArrowRight",
|
|
1329
1447
|
handle: (keyDef, element) => {
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1448
|
+
if (hasOwnSelection(element)) {
|
|
1449
|
+
const selection = getUISelection(element);
|
|
1450
|
+
setSelection({
|
|
1451
|
+
focusNode: element,
|
|
1452
|
+
focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + (keyDef.key === "ArrowLeft" ? -1 : 1) : keyDef.key === "ArrowLeft" ? selection.startOffset : selection.endOffset
|
|
1453
|
+
});
|
|
1454
|
+
} else {
|
|
1455
|
+
const selection = element.ownerDocument.getSelection();
|
|
1456
|
+
if (!selection) {
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
if (selection.isCollapsed) {
|
|
1460
|
+
const nextPosition = getNextCursorPosition(selection.focusNode, selection.focusOffset, keyDef.key === "ArrowLeft" ? -1 : 1);
|
|
1461
|
+
if (nextPosition) {
|
|
1462
|
+
setSelection({
|
|
1463
|
+
focusNode: nextPosition.node,
|
|
1464
|
+
focusOffset: nextPosition.offset
|
|
1465
|
+
});
|
|
1466
|
+
}
|
|
1467
|
+
} else {
|
|
1468
|
+
selection[keyDef.key === "ArrowLeft" ? "collapseToStart" : "collapseToEnd"]();
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1335
1471
|
}
|
|
1336
1472
|
}
|
|
1337
1473
|
];
|
|
@@ -2002,31 +2138,31 @@ function down({ pointerState, keyboardState }, pointerName, { keyDef, node, offs
|
|
|
2002
2138
|
clickCount
|
|
2003
2139
|
};
|
|
2004
2140
|
pointerState.pressed.push(pressObj);
|
|
2005
|
-
if (
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2141
|
+
if (pointerType !== "mouse") {
|
|
2142
|
+
fire("pointerover");
|
|
2143
|
+
fire("pointerenter");
|
|
2144
|
+
}
|
|
2145
|
+
if (pointerType !== "mouse" || !pointerState.pressed.some((p) => p.keyDef !== keyDef && p.keyDef.pointerType === pointerType)) {
|
|
2146
|
+
fire("pointerdown");
|
|
2147
|
+
}
|
|
2148
|
+
if (pointerType === "mouse") {
|
|
2149
|
+
if (!targetIsDisabled) {
|
|
2150
|
+
pressObj.unpreventedDefault = fire("mousedown");
|
|
2009
2151
|
}
|
|
2010
|
-
if (
|
|
2011
|
-
|
|
2152
|
+
if (pressObj.unpreventedDefault) {
|
|
2153
|
+
mousedownDefaultBehavior({
|
|
2154
|
+
target,
|
|
2155
|
+
targetIsDisabled,
|
|
2156
|
+
clickCount,
|
|
2157
|
+
position: pointerState.position[pointerName],
|
|
2158
|
+
node,
|
|
2159
|
+
offset
|
|
2160
|
+
});
|
|
2012
2161
|
}
|
|
2013
|
-
if (
|
|
2014
|
-
|
|
2162
|
+
if (button === "secondary") {
|
|
2163
|
+
fire("contextmenu");
|
|
2015
2164
|
}
|
|
2016
2165
|
}
|
|
2017
|
-
if (pointerType === "mouse" && pressObj.unpreventedDefault) {
|
|
2018
|
-
mousedownDefaultBehavior({
|
|
2019
|
-
target,
|
|
2020
|
-
targetIsDisabled,
|
|
2021
|
-
clickCount,
|
|
2022
|
-
position: pointerState.position[pointerName],
|
|
2023
|
-
node,
|
|
2024
|
-
offset
|
|
2025
|
-
});
|
|
2026
|
-
}
|
|
2027
|
-
if (pointerType === "mouse" && button === "secondary") {
|
|
2028
|
-
fire("contextmenu");
|
|
2029
|
-
}
|
|
2030
2166
|
return pressObj;
|
|
2031
2167
|
function fire(type3) {
|
|
2032
2168
|
return firePointerEvent(target, type3, {
|
|
@@ -2056,15 +2192,15 @@ function up({ pointerState, keyboardState }, pointerName, {
|
|
|
2056
2192
|
target,
|
|
2057
2193
|
coords
|
|
2058
2194
|
});
|
|
2059
|
-
if (!
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
if (
|
|
2195
|
+
if (pointerType !== "mouse" || !pointerState.pressed.filter((p) => p.keyDef.pointerType === pointerType).length) {
|
|
2196
|
+
fire("pointerup");
|
|
2197
|
+
}
|
|
2198
|
+
if (pointerType !== "mouse") {
|
|
2199
|
+
fire("pointerout");
|
|
2200
|
+
fire("pointerleave");
|
|
2201
|
+
}
|
|
2202
|
+
if (pointerType !== "mouse" && !isMultiTouch) {
|
|
2203
|
+
if (!targetIsDisabled) {
|
|
2068
2204
|
if (clickCount === 1) {
|
|
2069
2205
|
fire("mouseover");
|
|
2070
2206
|
fire("mouseenter");
|
|
@@ -2072,16 +2208,16 @@ function up({ pointerState, keyboardState }, pointerName, {
|
|
|
2072
2208
|
fire("mousemove");
|
|
2073
2209
|
unpreventedDefault = fire("mousedown") && unpreventedDefault;
|
|
2074
2210
|
}
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
}
|
|
2211
|
+
if (unpreventedDefault) {
|
|
2212
|
+
mousedownDefaultBehavior({
|
|
2213
|
+
target,
|
|
2214
|
+
targetIsDisabled,
|
|
2215
|
+
clickCount,
|
|
2216
|
+
position: pointerState.position[pointerName],
|
|
2217
|
+
node,
|
|
2218
|
+
offset
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2085
2221
|
}
|
|
2086
2222
|
delete pointerState.position[pointerName].selectionRange;
|
|
2087
2223
|
if (!targetIsDisabled) {
|
package/dist/index.mjs
CHANGED
|
@@ -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) {
|
|
@@ -1338,13 +1456,31 @@ function assignPointerInit(obj, { isPrimary, pointerId, pointerType }) {
|
|
|
1338
1456
|
// src/keyboard/plugins/arrow.ts
|
|
1339
1457
|
var keydownBehavior = [
|
|
1340
1458
|
{
|
|
1341
|
-
matches: (keyDef
|
|
1459
|
+
matches: (keyDef) => keyDef.key === "ArrowLeft" || keyDef.key === "ArrowRight",
|
|
1342
1460
|
handle: (keyDef, element) => {
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1461
|
+
if (hasOwnSelection(element)) {
|
|
1462
|
+
const selection = getUISelection(element);
|
|
1463
|
+
setSelection({
|
|
1464
|
+
focusNode: element,
|
|
1465
|
+
focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + (keyDef.key === "ArrowLeft" ? -1 : 1) : keyDef.key === "ArrowLeft" ? selection.startOffset : selection.endOffset
|
|
1466
|
+
});
|
|
1467
|
+
} else {
|
|
1468
|
+
const selection = element.ownerDocument.getSelection();
|
|
1469
|
+
if (!selection) {
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
if (selection.isCollapsed) {
|
|
1473
|
+
const nextPosition = getNextCursorPosition(selection.focusNode, selection.focusOffset, keyDef.key === "ArrowLeft" ? -1 : 1);
|
|
1474
|
+
if (nextPosition) {
|
|
1475
|
+
setSelection({
|
|
1476
|
+
focusNode: nextPosition.node,
|
|
1477
|
+
focusOffset: nextPosition.offset
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
} else {
|
|
1481
|
+
selection[keyDef.key === "ArrowLeft" ? "collapseToStart" : "collapseToEnd"]();
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1348
1484
|
}
|
|
1349
1485
|
}
|
|
1350
1486
|
];
|
|
@@ -2033,31 +2169,31 @@ function down({ pointerState, keyboardState }, pointerName, { keyDef, node, offs
|
|
|
2033
2169
|
clickCount
|
|
2034
2170
|
};
|
|
2035
2171
|
pointerState.pressed.push(pressObj);
|
|
2036
|
-
if (
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2172
|
+
if (pointerType !== "mouse") {
|
|
2173
|
+
fire("pointerover");
|
|
2174
|
+
fire("pointerenter");
|
|
2175
|
+
}
|
|
2176
|
+
if (pointerType !== "mouse" || !pointerState.pressed.some((p) => p.keyDef !== keyDef && p.keyDef.pointerType === pointerType)) {
|
|
2177
|
+
fire("pointerdown");
|
|
2178
|
+
}
|
|
2179
|
+
if (pointerType === "mouse") {
|
|
2180
|
+
if (!targetIsDisabled) {
|
|
2181
|
+
pressObj.unpreventedDefault = fire("mousedown");
|
|
2040
2182
|
}
|
|
2041
|
-
if (
|
|
2042
|
-
|
|
2183
|
+
if (pressObj.unpreventedDefault) {
|
|
2184
|
+
mousedownDefaultBehavior({
|
|
2185
|
+
target,
|
|
2186
|
+
targetIsDisabled,
|
|
2187
|
+
clickCount,
|
|
2188
|
+
position: pointerState.position[pointerName],
|
|
2189
|
+
node,
|
|
2190
|
+
offset
|
|
2191
|
+
});
|
|
2043
2192
|
}
|
|
2044
|
-
if (
|
|
2045
|
-
|
|
2193
|
+
if (button === "secondary") {
|
|
2194
|
+
fire("contextmenu");
|
|
2046
2195
|
}
|
|
2047
2196
|
}
|
|
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
2197
|
return pressObj;
|
|
2062
2198
|
function fire(type3) {
|
|
2063
2199
|
return firePointerEvent(target, type3, {
|
|
@@ -2087,15 +2223,15 @@ function up({ pointerState, keyboardState }, pointerName, {
|
|
|
2087
2223
|
target,
|
|
2088
2224
|
coords
|
|
2089
2225
|
});
|
|
2090
|
-
if (!
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
if (
|
|
2226
|
+
if (pointerType !== "mouse" || !pointerState.pressed.filter((p) => p.keyDef.pointerType === pointerType).length) {
|
|
2227
|
+
fire("pointerup");
|
|
2228
|
+
}
|
|
2229
|
+
if (pointerType !== "mouse") {
|
|
2230
|
+
fire("pointerout");
|
|
2231
|
+
fire("pointerleave");
|
|
2232
|
+
}
|
|
2233
|
+
if (pointerType !== "mouse" && !isMultiTouch) {
|
|
2234
|
+
if (!targetIsDisabled) {
|
|
2099
2235
|
if (clickCount === 1) {
|
|
2100
2236
|
fire("mouseover");
|
|
2101
2237
|
fire("mouseenter");
|
|
@@ -2103,16 +2239,16 @@ function up({ pointerState, keyboardState }, pointerName, {
|
|
|
2103
2239
|
fire("mousemove");
|
|
2104
2240
|
unpreventedDefault = fire("mousedown") && unpreventedDefault;
|
|
2105
2241
|
}
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
}
|
|
2242
|
+
if (unpreventedDefault) {
|
|
2243
|
+
mousedownDefaultBehavior({
|
|
2244
|
+
target,
|
|
2245
|
+
targetIsDisabled,
|
|
2246
|
+
clickCount,
|
|
2247
|
+
position: pointerState.position[pointerName],
|
|
2248
|
+
node,
|
|
2249
|
+
offset
|
|
2250
|
+
});
|
|
2251
|
+
}
|
|
2116
2252
|
}
|
|
2117
2253
|
delete pointerState.position[pointerName].selectionRange;
|
|
2118
2254
|
if (!targetIsDisabled) {
|
|
@@ -16,6 +16,7 @@ export * from './edit/prepareInput';
|
|
|
16
16
|
export * from './edit/setFiles';
|
|
17
17
|
export * from './focus/blur';
|
|
18
18
|
export * from './focus/copySelection';
|
|
19
|
+
export * from './focus/cursor';
|
|
19
20
|
export * from './focus/focus';
|
|
20
21
|
export * from './focus/getActiveElement';
|
|
21
22
|
export * from './focus/getTabDestination';
|