@testing-library/user-event 14.4.0 → 14.4.3
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/cjs/clipboard/copy.js +6 -15
- package/dist/cjs/clipboard/cut.js +6 -15
- package/dist/cjs/clipboard/paste.js +6 -14
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/document/UI.js +94 -0
- package/dist/cjs/document/copySelection.js +37 -0
- package/dist/cjs/document/getValueOrTextContent.js +27 -0
- package/dist/cjs/document/index.js +13 -68
- package/dist/cjs/document/interceptor.js +87 -4
- package/dist/cjs/document/prepareDocument.js +67 -0
- package/dist/cjs/document/trackValue.js +65 -0
- package/dist/cjs/event/behavior/click.js +8 -12
- package/dist/cjs/event/behavior/cut.js +5 -11
- package/dist/cjs/event/behavior/keydown.js +43 -43
- package/dist/cjs/event/behavior/keypress.js +9 -10
- package/dist/cjs/event/behavior/keyup.js +6 -7
- package/dist/cjs/event/behavior/paste.js +7 -12
- package/dist/cjs/event/createEvent.js +37 -28
- package/dist/cjs/event/dispatchEvent.js +21 -2
- package/dist/cjs/event/focus.js +44 -0
- package/dist/cjs/event/index.js +24 -17
- package/dist/cjs/{utils/edit → event}/input.js +50 -47
- package/dist/cjs/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/cjs/event/selection/getInputRange.js +20 -0
- package/dist/cjs/event/selection/getTargetTypeAndSelection.js +40 -0
- package/dist/cjs/event/selection/index.js +26 -0
- package/dist/cjs/event/selection/modifySelection.js +30 -0
- package/dist/cjs/event/selection/modifySelectionPerMouse.js +49 -0
- package/dist/cjs/event/selection/moveSelection.js +47 -0
- package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +11 -19
- package/dist/cjs/event/selection/selectAll.js +47 -0
- package/dist/cjs/event/selection/setSelection.js +30 -0
- package/dist/cjs/event/selection/setSelectionPerMouse.js +90 -0
- package/dist/cjs/event/selection/setSelectionRange.js +40 -0
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +45 -0
- package/dist/cjs/keyboard/index.js +13 -23
- package/dist/cjs/keyboard/parseKeyDef.js +8 -13
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +28 -34
- package/dist/cjs/pointer/parseKeyDef.js +1 -9
- package/dist/cjs/setup/directApi.js +6 -6
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +69 -38
- package/dist/cjs/system/index.js +4 -2
- package/dist/cjs/system/keyboard.js +32 -32
- package/dist/cjs/system/pointer/buttons.js +3 -1
- package/dist/cjs/system/pointer/device.js +3 -1
- package/dist/cjs/system/pointer/index.js +82 -79
- package/dist/cjs/system/pointer/mouse.js +97 -81
- package/dist/cjs/system/pointer/pointer.js +45 -46
- package/dist/cjs/system/pointer/shared.js +10 -0
- package/dist/cjs/utility/clear.js +10 -11
- package/dist/cjs/utility/selectOptions.js +17 -19
- package/dist/cjs/utility/type.js +6 -15
- package/dist/cjs/utility/upload.js +9 -15
- package/dist/cjs/utils/dataTransfer/Clipboard.js +11 -21
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +22 -19
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +6 -16
- package/dist/cjs/utils/edit/setFiles.js +4 -2
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +2 -17
- package/dist/cjs/utils/focus/getActiveElement.js +3 -2
- package/dist/cjs/utils/focus/selection.js +1 -266
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -3
- package/dist/cjs/utils/misc/isDisabled.js +2 -1
- package/dist/cjs/utils/misc/isVisible.js +1 -1
- package/dist/cjs/utils/misc/level.js +4 -6
- package/dist/cjs/utils/pointer/cssPointerEvents.js +26 -32
- package/dist/esm/clipboard/copy.js +6 -15
- package/dist/esm/clipboard/cut.js +6 -15
- package/dist/esm/clipboard/paste.js +6 -14
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/document/UI.js +79 -0
- package/dist/esm/document/copySelection.js +33 -0
- package/dist/esm/document/getValueOrTextContent.js +23 -0
- package/dist/esm/document/index.js +4 -66
- package/dist/esm/document/interceptor.js +85 -5
- package/dist/esm/document/prepareDocument.js +63 -0
- package/dist/esm/document/trackValue.js +59 -0
- package/dist/esm/event/behavior/click.js +8 -12
- package/dist/esm/event/behavior/cut.js +5 -11
- package/dist/esm/event/behavior/keydown.js +36 -36
- package/dist/esm/event/behavior/keypress.js +9 -10
- package/dist/esm/event/behavior/keyup.js +6 -7
- package/dist/esm/event/behavior/paste.js +7 -12
- package/dist/esm/event/createEvent.js +37 -28
- package/dist/esm/event/dispatchEvent.js +20 -3
- package/dist/esm/event/focus.js +39 -0
- package/dist/esm/event/index.js +14 -19
- package/dist/esm/{utils/edit → event}/input.js +37 -34
- package/dist/esm/{utils/edit/walkRadio.js → event/radio.js} +13 -7
- package/dist/esm/event/selection/getInputRange.js +16 -0
- package/dist/esm/event/selection/getTargetTypeAndSelection.js +36 -0
- package/dist/esm/event/selection/index.js +9 -0
- package/dist/esm/event/selection/modifySelection.js +26 -0
- package/dist/esm/event/selection/modifySelectionPerMouse.js +45 -0
- package/dist/esm/event/selection/moveSelection.js +43 -0
- package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +11 -19
- package/dist/esm/event/selection/selectAll.js +42 -0
- package/dist/esm/event/selection/setSelection.js +26 -0
- package/dist/esm/event/selection/setSelectionPerMouse.js +86 -0
- package/dist/esm/event/selection/setSelectionRange.js +36 -0
- package/dist/esm/event/selection/updateSelectionOnFocus.js +41 -0
- package/dist/esm/keyboard/index.js +13 -23
- package/dist/esm/keyboard/parseKeyDef.js +8 -13
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +28 -34
- package/dist/esm/pointer/parseKeyDef.js +1 -9
- package/dist/esm/setup/directApi.js +6 -6
- package/dist/esm/setup/index.js +0 -1
- package/dist/esm/setup/setup.js +63 -33
- package/dist/esm/system/index.js +4 -2
- package/dist/esm/system/keyboard.js +32 -32
- package/dist/esm/system/pointer/buttons.js +3 -1
- package/dist/esm/system/pointer/device.js +3 -1
- package/dist/esm/system/pointer/index.js +83 -79
- package/dist/esm/system/pointer/mouse.js +95 -79
- package/dist/esm/system/pointer/pointer.js +44 -45
- package/dist/esm/system/pointer/shared.js +6 -0
- package/dist/esm/utility/clear.js +10 -11
- package/dist/esm/utility/selectOptions.js +17 -19
- package/dist/esm/utility/type.js +6 -15
- package/dist/esm/utility/upload.js +9 -15
- package/dist/esm/utils/dataTransfer/Clipboard.js +11 -21
- package/dist/esm/utils/dataTransfer/DataTransfer.js +22 -19
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +5 -16
- package/dist/esm/utils/edit/setFiles.js +4 -2
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +2 -17
- package/dist/esm/utils/focus/getActiveElement.js +3 -2
- package/dist/esm/utils/focus/selection.js +3 -260
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -3
- package/dist/esm/utils/misc/isDisabled.js +2 -1
- package/dist/esm/utils/misc/isVisible.js +1 -1
- package/dist/esm/utils/misc/level.js +4 -6
- package/dist/esm/utils/pointer/cssPointerEvents.js +26 -32
- package/dist/types/clipboard/copy.d.ts +1 -1
- package/dist/types/clipboard/cut.d.ts +1 -1
- package/dist/types/clipboard/paste.d.ts +1 -1
- package/dist/types/convenience/click.d.ts +1 -1
- package/dist/types/convenience/hover.d.ts +1 -1
- package/dist/types/document/UI.d.ts +42 -0
- package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -0
- package/dist/types/document/getValueOrTextContent.d.ts +1 -0
- package/dist/types/document/index.d.ts +5 -10
- package/dist/types/document/interceptor.d.ts +3 -0
- package/dist/types/document/prepareDocument.d.ts +8 -0
- package/dist/types/document/trackValue.d.ts +17 -0
- package/dist/types/event/behavior/registry.d.ts +2 -2
- package/dist/types/event/dispatchEvent.d.ts +5 -2
- package/dist/types/event/focus.d.ts +5 -0
- package/dist/types/event/index.d.ts +6 -4
- package/dist/types/event/input.d.ts +2 -0
- package/dist/types/event/radio.d.ts +4 -0
- package/dist/types/event/selection/getInputRange.d.ts +5 -0
- package/dist/types/event/selection/getTargetTypeAndSelection.d.ts +10 -0
- package/dist/types/event/selection/index.d.ts +15 -0
- package/dist/types/event/selection/modifySelection.d.ts +8 -0
- package/dist/types/event/selection/modifySelectionPerMouse.d.ts +7 -0
- package/dist/types/event/selection/moveSelection.d.ts +4 -0
- package/dist/types/{utils/focus → event/selection}/resolveCaretPosition.d.ts +0 -0
- package/dist/types/{utils/focus → event/selection}/selectAll.d.ts +0 -0
- package/dist/types/event/selection/setSelection.d.ts +10 -0
- package/dist/types/event/selection/setSelectionPerMouse.d.ts +8 -0
- package/dist/types/event/selection/setSelectionRange.d.ts +6 -0
- package/dist/types/event/selection/updateSelectionOnFocus.d.ts +5 -0
- package/dist/types/keyboard/index.d.ts +2 -2
- package/dist/types/options.d.ts +0 -8
- package/dist/types/pointer/index.d.ts +3 -3
- package/dist/types/setup/directApi.d.ts +1 -1
- package/dist/types/setup/index.d.ts +2 -15
- package/dist/types/setup/setup.d.ts +25 -7
- package/dist/types/system/keyboard.d.ts +3 -3
- package/dist/types/system/pointer/buttons.d.ts +1 -1
- package/dist/types/system/pointer/index.d.ts +7 -25
- package/dist/types/system/pointer/mouse.d.ts +5 -5
- package/dist/types/system/pointer/pointer.d.ts +7 -7
- package/dist/types/system/pointer/shared.d.ts +20 -0
- package/dist/types/utility/clear.d.ts +1 -1
- package/dist/types/utility/selectOptions.d.ts +1 -1
- package/dist/types/utility/type.d.ts +3 -3
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +2 -2
- package/dist/types/utils/edit/isEditable.d.ts +5 -6
- package/dist/types/utils/edit/maxLength.d.ts +14 -1
- package/dist/types/utils/edit/{isValidDateOrTimeValue.d.ts → timeValue.d.ts} +1 -0
- package/dist/types/utils/focus/selection.d.ts +4 -69
- package/dist/types/utils/index.d.ts +2 -9
- package/dist/types/utils/misc/level.d.ts +4 -13
- package/dist/types/utils/misc/wait.d.ts +2 -2
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +4 -4
- package/package.json +29 -4
- package/dist/cjs/document/selection.js +0 -107
- package/dist/cjs/document/setRangeText.js +0 -21
- package/dist/cjs/document/value.js +0 -125
- package/dist/cjs/setup/config.js +0 -7
- package/dist/cjs/utils/edit/getValue.js +0 -35
- package/dist/cjs/utils/edit/isValidDateOrTimeValue.js +0 -11
- package/dist/cjs/utils/focus/blur.js +0 -16
- package/dist/cjs/utils/focus/copySelection.js +0 -46
- package/dist/cjs/utils/focus/focus.js +0 -26
- package/dist/cjs/utils/focus/selectAll.js +0 -54
- package/dist/cjs/utils/misc/eventWrapper.js +0 -15
- package/dist/esm/document/selection.js +0 -99
- package/dist/esm/document/setRangeText.js +0 -17
- package/dist/esm/document/value.js +0 -115
- package/dist/esm/setup/config.js +0 -3
- package/dist/esm/utils/edit/getValue.js +0 -31
- package/dist/esm/utils/edit/isValidDateOrTimeValue.js +0 -7
- package/dist/esm/utils/focus/blur.js +0 -12
- package/dist/esm/utils/focus/copySelection.js +0 -42
- package/dist/esm/utils/focus/focus.js +0 -22
- package/dist/esm/utils/focus/selectAll.js +0 -49
- package/dist/esm/utils/misc/eventWrapper.js +0 -11
- package/dist/types/document/selection.d.ts +0 -29
- package/dist/types/document/setRangeText.d.ts +0 -1
- package/dist/types/document/value.d.ts +0 -26
- package/dist/types/setup/config.d.ts +0 -6
- package/dist/types/utils/edit/buildTimeValue.d.ts +0 -1
- package/dist/types/utils/edit/getValue.d.ts +0 -1
- package/dist/types/utils/edit/input.d.ts +0 -2
- package/dist/types/utils/edit/walkRadio.d.ts +0 -4
- package/dist/types/utils/focus/blur.d.ts +0 -2
- package/dist/types/utils/focus/focus.d.ts +0 -5
- package/dist/types/utils/misc/eventWrapper.d.ts +0 -1
|
@@ -1,20 +1,6 @@
|
|
|
1
|
-
import '../
|
|
1
|
+
import { getWindow } from '../misc/getWindow.js';
|
|
2
2
|
import { readBlobText } from './Blob.js';
|
|
3
3
|
import { createDataTransfer, getBlobFromDataTransferItem } from './DataTransfer.js';
|
|
4
|
-
import '../../event/eventMap.js';
|
|
5
|
-
import '../../event/behavior/click.js';
|
|
6
|
-
import '../../event/behavior/cut.js';
|
|
7
|
-
import '../../event/behavior/keydown.js';
|
|
8
|
-
import '../../event/behavior/keypress.js';
|
|
9
|
-
import '../../event/behavior/keyup.js';
|
|
10
|
-
import '../../event/behavior/paste.js';
|
|
11
|
-
import '@testing-library/dom';
|
|
12
|
-
import '../edit/maxLength.js';
|
|
13
|
-
import '../edit/isEditable.js';
|
|
14
|
-
import { getWindow } from '../misc/getWindow.js';
|
|
15
|
-
import '../keyDef/readNextDescriptor.js';
|
|
16
|
-
import '../misc/level.js';
|
|
17
|
-
import '../../options.js';
|
|
18
4
|
|
|
19
5
|
// Clipboard is not available in jsdom
|
|
20
6
|
// MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData
|
|
@@ -30,9 +16,6 @@ function createClipboardItem(window, ...blobs) {
|
|
|
30
16
|
return new window.ClipboardItem(dataMap);
|
|
31
17
|
}
|
|
32
18
|
return new class ClipboardItem {
|
|
33
|
-
constructor(d){
|
|
34
|
-
this.data = d;
|
|
35
|
-
}
|
|
36
19
|
get types() {
|
|
37
20
|
return Array.from(Object.keys(this.data));
|
|
38
21
|
}
|
|
@@ -47,12 +30,14 @@ function createClipboardItem(window, ...blobs) {
|
|
|
47
30
|
type
|
|
48
31
|
});
|
|
49
32
|
}
|
|
33
|
+
constructor(d){
|
|
34
|
+
this.data = d;
|
|
35
|
+
}
|
|
50
36
|
}(dataMap);
|
|
51
37
|
}
|
|
52
38
|
const ClipboardStubControl = Symbol('Manage ClipboardSub');
|
|
53
39
|
function createClipboardStub(window, control) {
|
|
54
40
|
return Object.assign(new class Clipboard extends window.EventTarget {
|
|
55
|
-
items = [];
|
|
56
41
|
async read() {
|
|
57
42
|
return Array.from(this.items);
|
|
58
43
|
}
|
|
@@ -74,12 +59,17 @@ function createClipboardStub(window, control) {
|
|
|
74
59
|
createClipboardItem(window, text)
|
|
75
60
|
];
|
|
76
61
|
}
|
|
62
|
+
constructor(...args){
|
|
63
|
+
super(...args);
|
|
64
|
+
this.items = [];
|
|
65
|
+
}
|
|
77
66
|
}(), {
|
|
78
67
|
[ClipboardStubControl]: control
|
|
79
68
|
});
|
|
80
69
|
}
|
|
81
70
|
function isClipboardStub(clipboard) {
|
|
82
|
-
|
|
71
|
+
var ref;
|
|
72
|
+
return !!((ref = clipboard) === null || ref === void 0 ? void 0 : ref[ClipboardStubControl]);
|
|
83
73
|
}
|
|
84
74
|
function attachClipboardStubToView(window) {
|
|
85
75
|
if (isClipboardStub(window.navigator.clipboard)) {
|
|
@@ -121,7 +111,7 @@ function detachClipboardStubFromView(window) {
|
|
|
121
111
|
}
|
|
122
112
|
async function readDataTransferFromClipboard(document) {
|
|
123
113
|
const window = document.defaultView;
|
|
124
|
-
const clipboard = window
|
|
114
|
+
const clipboard = window === null || window === void 0 ? void 0 : window.navigator.clipboard;
|
|
125
115
|
const items = clipboard && await clipboard.read();
|
|
126
116
|
if (!items) {
|
|
127
117
|
throw new Error('The Clipboard API is unavailable.');
|
|
@@ -3,19 +3,6 @@ import { createFileList } from './FileList.js';
|
|
|
3
3
|
// DataTransfer is not implemented in jsdom.
|
|
4
4
|
// DataTransfer with FileList is being created by the browser on certain events.
|
|
5
5
|
class DataTransferItemStub {
|
|
6
|
-
file = null;
|
|
7
|
-
data = undefined;
|
|
8
|
-
constructor(dataOrFile, type){
|
|
9
|
-
if (typeof dataOrFile === 'string') {
|
|
10
|
-
this.kind = 'string';
|
|
11
|
-
this.type = String(type);
|
|
12
|
-
this.data = dataOrFile;
|
|
13
|
-
} else {
|
|
14
|
-
this.kind = 'file';
|
|
15
|
-
this.type = dataOrFile.type;
|
|
16
|
-
this.file = dataOrFile;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
6
|
getAsFile() {
|
|
20
7
|
return this.file;
|
|
21
8
|
}
|
|
@@ -27,6 +14,19 @@ class DataTransferItemStub {
|
|
|
27
14
|
/* istanbul ignore next */ webkitGetAsEntry() {
|
|
28
15
|
throw new Error('not implemented');
|
|
29
16
|
}
|
|
17
|
+
constructor(dataOrFile, type){
|
|
18
|
+
this.file = null;
|
|
19
|
+
this.data = undefined;
|
|
20
|
+
if (typeof dataOrFile === 'string') {
|
|
21
|
+
this.kind = 'string';
|
|
22
|
+
this.type = String(type);
|
|
23
|
+
this.data = dataOrFile;
|
|
24
|
+
} else {
|
|
25
|
+
this.kind = 'file';
|
|
26
|
+
this.type = dataOrFile.type;
|
|
27
|
+
this.file = dataOrFile;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
30
|
}
|
|
31
31
|
class DataTransferItemListStub extends Array {
|
|
32
32
|
add(...args) {
|
|
@@ -51,9 +51,10 @@ function getTypeMatcher(type, exact) {
|
|
|
51
51
|
function createDataTransferStub(window) {
|
|
52
52
|
return new class DataTransferStub {
|
|
53
53
|
getData(format) {
|
|
54
|
-
|
|
54
|
+
var ref;
|
|
55
|
+
const match = (ref = this.items.find(getTypeMatcher(format, true))) !== null && ref !== void 0 ? ref : this.items.find(getTypeMatcher(format, false));
|
|
55
56
|
let text = '';
|
|
56
|
-
match
|
|
57
|
+
match === null || match === void 0 ? void 0 : match.getAsString((t)=>{
|
|
57
58
|
text = t;
|
|
58
59
|
});
|
|
59
60
|
return text;
|
|
@@ -77,10 +78,6 @@ function createDataTransferStub(window) {
|
|
|
77
78
|
this.items.clear();
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
dropEffect = 'none';
|
|
81
|
-
effectAllowed = 'uninitialized';
|
|
82
|
-
items = new DataTransferItemListStub();
|
|
83
|
-
files = createFileList(window, []);
|
|
84
81
|
get types() {
|
|
85
82
|
const t = [];
|
|
86
83
|
if (this.files.length) {
|
|
@@ -91,6 +88,12 @@ function createDataTransferStub(window) {
|
|
|
91
88
|
return t;
|
|
92
89
|
}
|
|
93
90
|
/* istanbul ignore next */ setDragImage() {}
|
|
91
|
+
constructor(){
|
|
92
|
+
this.dropEffect = 'none';
|
|
93
|
+
this.effectAllowed = 'uninitialized';
|
|
94
|
+
this.items = new DataTransferItemListStub();
|
|
95
|
+
this.files = createFileList(window, []);
|
|
96
|
+
}
|
|
94
97
|
}();
|
|
95
98
|
}
|
|
96
99
|
function createDataTransfer(window, files = []) {
|
|
@@ -2,9 +2,7 @@ import { isElementType } from '../misc/isElementType.js';
|
|
|
2
2
|
import { isContentEditable } from './isContentEditable.js';
|
|
3
3
|
|
|
4
4
|
function isEditable(element) {
|
|
5
|
-
return
|
|
6
|
-
readOnly: false
|
|
7
|
-
}) || isContentEditable(element);
|
|
5
|
+
return isEditableInputOrTextArea(element) && !element.readOnly || isContentEditable(element);
|
|
8
6
|
}
|
|
9
7
|
var editableInputTypes;
|
|
10
8
|
(function(editableInputTypes) {
|
|
@@ -21,10 +19,8 @@ var editableInputTypes;
|
|
|
21
19
|
editableInputTypes['url'] = 'url';
|
|
22
20
|
editableInputTypes['week'] = 'week';
|
|
23
21
|
})(editableInputTypes || (editableInputTypes = {}));
|
|
24
|
-
function
|
|
25
|
-
return isElementType(element, '
|
|
26
|
-
readOnly: false
|
|
27
|
-
}) && Boolean(editableInputTypes[element.type]);
|
|
22
|
+
function isEditableInputOrTextArea(element) {
|
|
23
|
+
return isElementType(element, 'textarea') || isElementType(element, 'input') && element.type in editableInputTypes;
|
|
28
24
|
}
|
|
29
25
|
|
|
30
|
-
export {
|
|
26
|
+
export { isEditable, isEditableInputOrTextArea };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { isElementType } from '../misc/isElementType.js';
|
|
2
|
-
import { getValue } from './getValue.js';
|
|
3
2
|
|
|
4
3
|
var maxLengthSupportedTypes;
|
|
5
4
|
(function(maxLengthSupportedTypes) {
|
|
@@ -10,25 +9,15 @@ var maxLengthSupportedTypes;
|
|
|
10
9
|
maxLengthSupportedTypes['text'] = 'text';
|
|
11
10
|
maxLengthSupportedTypes['url'] = 'url';
|
|
12
11
|
})(maxLengthSupportedTypes || (maxLengthSupportedTypes = {}));
|
|
13
|
-
function getSpaceUntilMaxLength(element) {
|
|
14
|
-
const value = getValue(element);
|
|
15
|
-
/* istanbul ignore if */ if (value === null) {
|
|
16
|
-
return undefined;
|
|
17
|
-
}
|
|
18
|
-
const maxLength = getSanitizedMaxLength(element);
|
|
19
|
-
return maxLength ? maxLength - value.length : undefined;
|
|
20
|
-
}
|
|
21
12
|
// can't use .maxLength property because of a jsdom bug:
|
|
22
13
|
// https://github.com/jsdom/jsdom/issues/2927
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
const attr = element.getAttribute('maxlength') ?? '';
|
|
14
|
+
function getMaxLength(element) {
|
|
15
|
+
var ref;
|
|
16
|
+
const attr = (ref = element.getAttribute('maxlength')) !== null && ref !== void 0 ? ref : '';
|
|
28
17
|
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;
|
|
29
18
|
}
|
|
30
19
|
function supportsMaxLength(element) {
|
|
31
|
-
return isElementType(element, 'textarea') || isElementType(element, 'input') &&
|
|
20
|
+
return isElementType(element, 'textarea') || isElementType(element, 'input') && element.type in maxLengthSupportedTypes;
|
|
32
21
|
}
|
|
33
22
|
|
|
34
|
-
export {
|
|
23
|
+
export { getMaxLength, supportsMaxLength };
|
|
@@ -11,7 +11,8 @@ function restoreProperty(obj, prop, descriptor) {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
function setFiles(el, files) {
|
|
14
|
-
|
|
14
|
+
var ref;
|
|
15
|
+
(ref = el[fakeFiles]) === null || ref === void 0 ? void 0 : ref.restore();
|
|
15
16
|
const typeDescr = Object.getOwnPropertyDescriptor(el, 'type');
|
|
16
17
|
const valueDescr = Object.getOwnPropertyDescriptor(el, 'value');
|
|
17
18
|
const filesDescr = Object.getOwnPropertyDescriptor(el, 'files');
|
|
@@ -35,7 +36,8 @@ function setFiles(el, files) {
|
|
|
35
36
|
if (v === '') {
|
|
36
37
|
restore();
|
|
37
38
|
} else {
|
|
38
|
-
|
|
39
|
+
var ref;
|
|
40
|
+
valueDescr === null || valueDescr === void 0 ? void 0 : (ref = valueDescr.set) === null || ref === void 0 ? void 0 : ref.call(el, v);
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
},
|
|
@@ -28,5 +28,10 @@ function build(onlyDigitsValue, index) {
|
|
|
28
28
|
const validMinutes = Math.min(parsedMinutes, 59);
|
|
29
29
|
return `${validHours.toString().padStart(2, '0')}:${validMinutes.toString().padStart(2, '0')}`;
|
|
30
30
|
}
|
|
31
|
+
function isValidDateOrTimeValue(element, value) {
|
|
32
|
+
const clone = element.cloneNode();
|
|
33
|
+
clone.value = value;
|
|
34
|
+
return clone.value === value;
|
|
35
|
+
}
|
|
31
36
|
|
|
32
|
-
export { buildTimeValue };
|
|
37
|
+
export { buildTimeValue, isValidDateOrTimeValue };
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import '../click/isClickableInput.js';
|
|
2
|
-
import '../dataTransfer/Clipboard.js';
|
|
3
|
-
import '../../event/eventMap.js';
|
|
4
|
-
import '../../event/behavior/click.js';
|
|
5
|
-
import '../../event/behavior/cut.js';
|
|
6
|
-
import '../../event/behavior/keydown.js';
|
|
7
|
-
import '../../event/behavior/keypress.js';
|
|
8
|
-
import '../../event/behavior/keyup.js';
|
|
9
|
-
import '../../event/behavior/paste.js';
|
|
10
|
-
import '@testing-library/dom';
|
|
11
1
|
import { isContentEditable } from '../edit/isContentEditable.js';
|
|
12
|
-
import '../edit/maxLength.js';
|
|
13
|
-
import '../edit/isEditable.js';
|
|
14
2
|
import { isElementType } from '../misc/isElementType.js';
|
|
15
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
16
|
-
import '../keyDef/readNextDescriptor.js';
|
|
17
|
-
import '../misc/level.js';
|
|
18
|
-
import '../../options.js';
|
|
19
3
|
|
|
20
4
|
function getNextCursorPosition(node, offset, direction, inputType) {
|
|
21
5
|
// The behavior at text node zero offset is inconsistent.
|
|
@@ -116,13 +100,14 @@ function isTextNode(node) {
|
|
|
116
100
|
}
|
|
117
101
|
function walkNodes(node, direction, callback) {
|
|
118
102
|
for(;;){
|
|
103
|
+
var ref;
|
|
119
104
|
const sibling = node[`${direction}Sibling`];
|
|
120
105
|
if (sibling) {
|
|
121
106
|
node = getDescendant(sibling, direction === 'next' ? 'first' : 'last');
|
|
122
107
|
if (callback(node)) {
|
|
123
108
|
return node;
|
|
124
109
|
}
|
|
125
|
-
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== node.ownerDocument
|
|
110
|
+
} else if (node.parentNode && (!isElement(node.parentNode) || !isContentEditable(node.parentNode) && node.parentNode !== ((ref = node.ownerDocument) === null || ref === void 0 ? void 0 : ref.body))) {
|
|
126
111
|
node = node.parentNode;
|
|
127
112
|
} else {
|
|
128
113
|
break;
|
|
@@ -2,7 +2,7 @@ import { isDisabled } from '../misc/isDisabled.js';
|
|
|
2
2
|
|
|
3
3
|
function getActiveElement(document) {
|
|
4
4
|
const activeElement = document.activeElement;
|
|
5
|
-
if (activeElement
|
|
5
|
+
if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.shadowRoot) {
|
|
6
6
|
return getActiveElement(activeElement.shadowRoot);
|
|
7
7
|
} else {
|
|
8
8
|
// Browser does not yield disabled elements as document.activeElement - jsdom does
|
|
@@ -13,7 +13,8 @@ function getActiveElement(document) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
function getActiveElementOrBody(document) {
|
|
16
|
-
|
|
16
|
+
var ref;
|
|
17
|
+
return (ref = getActiveElement(document)) !== null && ref !== void 0 ? ref : /* istanbul ignore next */ document.body;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export { getActiveElement, getActiveElementOrBody };
|
|
@@ -1,52 +1,11 @@
|
|
|
1
|
-
import { isElementType } from '../misc/isElementType.js';
|
|
2
1
|
import { isClickableInput } from '../click/isClickableInput.js';
|
|
3
|
-
import '../
|
|
4
|
-
import { isContentEditable, getContentEditable } from '../edit/isContentEditable.js';
|
|
5
|
-
import '../edit/maxLength.js';
|
|
6
|
-
import { editableInputTypes } from '../edit/isEditable.js';
|
|
7
|
-
import '@testing-library/dom';
|
|
8
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
9
|
-
import { getNextCursorPosition } from './cursor.js';
|
|
10
|
-
import { resolveCaretPosition } from './resolveCaretPosition.js';
|
|
11
|
-
import '../keyDef/readNextDescriptor.js';
|
|
12
|
-
import '../misc/level.js';
|
|
13
|
-
import '../../options.js';
|
|
14
|
-
import '../../event/eventMap.js';
|
|
15
|
-
import '../../event/behavior/click.js';
|
|
16
|
-
import '../../event/behavior/cut.js';
|
|
17
|
-
import '../../event/behavior/keydown.js';
|
|
18
|
-
import '../../event/behavior/keypress.js';
|
|
19
|
-
import '../../event/behavior/keyup.js';
|
|
20
|
-
import '../../event/behavior/paste.js';
|
|
21
|
-
import { setUISelection, getUISelection } from '../../document/selection.js';
|
|
22
|
-
import { getUIValue } from '../../document/value.js';
|
|
2
|
+
import { isEditableInputOrTextArea } from '../edit/isEditable.js';
|
|
23
3
|
|
|
24
|
-
/**
|
|
25
|
-
* Backward-compatible selection.
|
|
26
|
-
*
|
|
27
|
-
* Handles input elements and contenteditable if it only contains a single text node.
|
|
28
|
-
*/ function setSelectionRange(element, anchorOffset, focusOffset) {
|
|
29
|
-
if (hasOwnSelection(element)) {
|
|
30
|
-
return setSelection({
|
|
31
|
-
focusNode: element,
|
|
32
|
-
anchorOffset,
|
|
33
|
-
focusOffset
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
/* istanbul ignore else */ if (isContentEditable(element) && element.firstChild?.nodeType === 3) {
|
|
37
|
-
return setSelection({
|
|
38
|
-
focusNode: element.firstChild,
|
|
39
|
-
anchorOffset,
|
|
40
|
-
focusOffset
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
/* istanbul ignore next */ throw new Error('Not implemented. The result of this interaction is unreliable.');
|
|
44
|
-
}
|
|
45
4
|
/**
|
|
46
5
|
* Determine if the element has its own selection implementation
|
|
47
6
|
* and does not interact with the Document Selection API.
|
|
48
7
|
*/ function hasOwnSelection(node) {
|
|
49
|
-
return isElement(node) && (
|
|
8
|
+
return isElement(node) && isEditableInputOrTextArea(node);
|
|
50
9
|
}
|
|
51
10
|
function hasNoSelection(node) {
|
|
52
11
|
return isElement(node) && isClickableInput(node);
|
|
@@ -54,221 +13,5 @@ function hasNoSelection(node) {
|
|
|
54
13
|
function isElement(node) {
|
|
55
14
|
return node.nodeType === 1;
|
|
56
15
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Determine which selection logic and selection ranges to consider.
|
|
59
|
-
*/ function getTargetTypeAndSelection(node) {
|
|
60
|
-
const element = getElement(node);
|
|
61
|
-
if (element && hasOwnSelection(element)) {
|
|
62
|
-
return {
|
|
63
|
-
type: 'input',
|
|
64
|
-
selection: getUISelection(element)
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const selection = element?.ownerDocument.getSelection();
|
|
68
|
-
// It is possible to extend a single-range selection into a contenteditable.
|
|
69
|
-
// This results in the range acting like a range outside of contenteditable.
|
|
70
|
-
const isCE = getContentEditable(node) && selection?.anchorNode && getContentEditable(selection.anchorNode);
|
|
71
|
-
return {
|
|
72
|
-
type: isCE ? 'contenteditable' : 'default',
|
|
73
|
-
selection
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
function getElement(node) {
|
|
77
|
-
return node.nodeType === 1 ? node : node.parentElement;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Reset the Document Selection when moving focus into an element
|
|
81
|
-
* with own selection implementation.
|
|
82
|
-
*/ function updateSelectionOnFocus(element) {
|
|
83
|
-
const selection = element.ownerDocument.getSelection();
|
|
84
|
-
/* istanbul ignore if */ if (!selection?.focusNode) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
// If the focus moves inside an element with own selection implementation,
|
|
88
|
-
// the document selection will be this element.
|
|
89
|
-
// But if the focused element is inside a contenteditable,
|
|
90
|
-
// 1) a collapsed selection will be retained.
|
|
91
|
-
// 2) other selections will be replaced by a cursor
|
|
92
|
-
// 2.a) at the start of the first child if it is a text node
|
|
93
|
-
// 2.b) at the start of the contenteditable.
|
|
94
|
-
if (hasOwnSelection(element)) {
|
|
95
|
-
const contenteditable = getContentEditable(selection.focusNode);
|
|
96
|
-
if (contenteditable) {
|
|
97
|
-
if (!selection.isCollapsed) {
|
|
98
|
-
const focusNode = contenteditable.firstChild?.nodeType === 3 ? contenteditable.firstChild : contenteditable;
|
|
99
|
-
selection.setBaseAndExtent(focusNode, 0, focusNode, 0);
|
|
100
|
-
}
|
|
101
|
-
} else {
|
|
102
|
-
selection.setBaseAndExtent(element, 0, element, 0);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Get the range that would be overwritten by input.
|
|
108
|
-
*/ function getInputRange(focusNode) {
|
|
109
|
-
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
110
|
-
if (typeAndSelection.type === 'input') {
|
|
111
|
-
return typeAndSelection.selection;
|
|
112
|
-
} else if (typeAndSelection.type === 'contenteditable') {
|
|
113
|
-
// Multi-range on contenteditable edits the first selection instead of the last
|
|
114
|
-
return typeAndSelection.selection?.getRangeAt(0);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
|
|
119
|
-
*/ function modifySelection({ focusNode , focusOffset }) {
|
|
120
|
-
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
121
|
-
if (typeAndSelection.type === 'input') {
|
|
122
|
-
return setUISelection(focusNode, {
|
|
123
|
-
anchorOffset: typeAndSelection.selection.anchorOffset,
|
|
124
|
-
focusOffset
|
|
125
|
-
}, 'modify');
|
|
126
|
-
}
|
|
127
|
-
focusNode.ownerDocument?.getSelection()?.extend(focusNode, focusOffset);
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Set the selection
|
|
131
|
-
*/ function setSelection({ focusNode , focusOffset , anchorNode =focusNode , anchorOffset =focusOffset }) {
|
|
132
|
-
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
133
|
-
if (typeAndSelection.type === 'input') {
|
|
134
|
-
return setUISelection(focusNode, {
|
|
135
|
-
anchorOffset,
|
|
136
|
-
focusOffset
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
anchorNode.ownerDocument?.getSelection()?.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Move the selection
|
|
143
|
-
*/ function moveSelection(node, direction) {
|
|
144
|
-
// TODO: implement shift
|
|
145
|
-
if (hasOwnSelection(node)) {
|
|
146
|
-
const selection = getUISelection(node);
|
|
147
|
-
setSelection({
|
|
148
|
-
focusNode: node,
|
|
149
|
-
focusOffset: selection.startOffset === selection.endOffset ? selection.focusOffset + direction : direction < 0 ? selection.startOffset : selection.endOffset
|
|
150
|
-
});
|
|
151
|
-
} else {
|
|
152
|
-
const selection1 = node.ownerDocument.getSelection();
|
|
153
|
-
if (!selection1?.focusNode) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
if (selection1.isCollapsed) {
|
|
157
|
-
const nextPosition = getNextCursorPosition(selection1.focusNode, selection1.focusOffset, direction);
|
|
158
|
-
if (nextPosition) {
|
|
159
|
-
setSelection({
|
|
160
|
-
focusNode: nextPosition.node,
|
|
161
|
-
focusOffset: nextPosition.offset
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
} else {
|
|
165
|
-
selection1[direction < 0 ? 'collapseToStart' : 'collapseToEnd']();
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
function setSelectionPerMouseDown({ document , target , clickCount , node , offset }) {
|
|
170
|
-
if (hasNoSelection(target)) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
const targetHasOwnSelection = hasOwnSelection(target);
|
|
174
|
-
// On non-input elements the text selection per multiple click
|
|
175
|
-
// can extend beyond the target boundaries.
|
|
176
|
-
// The exact mechanism what is considered in the same line is unclear.
|
|
177
|
-
// Looks it might be every inline element.
|
|
178
|
-
// TODO: Check what might be considered part of the same line of text.
|
|
179
|
-
const text = String(targetHasOwnSelection ? getUIValue(target) : target.textContent);
|
|
180
|
-
const [start, end] = node ? // which elements might be considered in the same line of text.
|
|
181
|
-
// TODO: support expanding initial range on multiple clicks if node is given
|
|
182
|
-
[
|
|
183
|
-
offset,
|
|
184
|
-
offset
|
|
185
|
-
] : getTextRange(text, offset, clickCount);
|
|
186
|
-
// TODO: implement modifying selection per shift/ctrl+mouse
|
|
187
|
-
if (targetHasOwnSelection) {
|
|
188
|
-
setUISelection(target, {
|
|
189
|
-
anchorOffset: start ?? text.length,
|
|
190
|
-
focusOffset: end ?? text.length
|
|
191
|
-
});
|
|
192
|
-
return {
|
|
193
|
-
node: target,
|
|
194
|
-
start: start ?? 0,
|
|
195
|
-
end: end ?? text.length
|
|
196
|
-
};
|
|
197
|
-
} else {
|
|
198
|
-
const { node: startNode , offset: startOffset } = resolveCaretPosition({
|
|
199
|
-
target,
|
|
200
|
-
node,
|
|
201
|
-
offset: start
|
|
202
|
-
});
|
|
203
|
-
const { node: endNode , offset: endOffset } = resolveCaretPosition({
|
|
204
|
-
target,
|
|
205
|
-
node,
|
|
206
|
-
offset: end
|
|
207
|
-
});
|
|
208
|
-
const range = target.ownerDocument.createRange();
|
|
209
|
-
try {
|
|
210
|
-
range.setStart(startNode, startOffset);
|
|
211
|
-
range.setEnd(endNode, endOffset);
|
|
212
|
-
} catch (e) {
|
|
213
|
-
throw new Error('The given offset is out of bounds.');
|
|
214
|
-
}
|
|
215
|
-
const selection = document.getSelection();
|
|
216
|
-
selection?.removeAllRanges();
|
|
217
|
-
selection?.addRange(range.cloneRange());
|
|
218
|
-
return range;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
function getTextRange(text, pos, clickCount) {
|
|
222
|
-
if (clickCount % 3 === 1 || text.length === 0) {
|
|
223
|
-
return [
|
|
224
|
-
pos,
|
|
225
|
-
pos
|
|
226
|
-
];
|
|
227
|
-
}
|
|
228
|
-
const textPos = pos ?? text.length;
|
|
229
|
-
if (clickCount % 3 === 2) {
|
|
230
|
-
return [
|
|
231
|
-
textPos - text.substr(0, pos).match(/(\w+|\s+|\W)?$/)[0].length,
|
|
232
|
-
pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length,
|
|
233
|
-
];
|
|
234
|
-
}
|
|
235
|
-
// triple click
|
|
236
|
-
return [
|
|
237
|
-
textPos - text.substr(0, pos).match(/[^\r\n]*$/)[0].length,
|
|
238
|
-
pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length,
|
|
239
|
-
];
|
|
240
|
-
}
|
|
241
|
-
function modifySelectionPerMouseMove(selectionRange, { document , target , node , offset }) {
|
|
242
|
-
const selectionFocus = resolveCaretPosition({
|
|
243
|
-
target,
|
|
244
|
-
node,
|
|
245
|
-
offset
|
|
246
|
-
});
|
|
247
|
-
if ('node' in selectionRange) {
|
|
248
|
-
// When the mouse is dragged outside of an input/textarea,
|
|
249
|
-
// the selection is extended to the beginning or end of the input
|
|
250
|
-
// depending on pointer position.
|
|
251
|
-
// TODO: extend selection according to pointer position
|
|
252
|
-
/* istanbul ignore else */ if (selectionFocus.node === selectionRange.node) {
|
|
253
|
-
const anchorOffset = selectionFocus.offset < selectionRange.start ? selectionRange.end : selectionRange.start;
|
|
254
|
-
const focusOffset = selectionFocus.offset > selectionRange.end || selectionFocus.offset < selectionRange.start ? selectionFocus.offset : selectionRange.end;
|
|
255
|
-
setUISelection(selectionRange.node, {
|
|
256
|
-
anchorOffset,
|
|
257
|
-
focusOffset
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
} else {
|
|
261
|
-
const range = selectionRange.cloneRange();
|
|
262
|
-
const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);
|
|
263
|
-
if (cmp < 0) {
|
|
264
|
-
range.setStart(selectionFocus.node, selectionFocus.offset);
|
|
265
|
-
} else if (cmp > 0) {
|
|
266
|
-
range.setEnd(selectionFocus.node, selectionFocus.offset);
|
|
267
|
-
}
|
|
268
|
-
const selection = document.getSelection();
|
|
269
|
-
selection?.removeAllRanges();
|
|
270
|
-
selection?.addRange(range.cloneRange());
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
16
|
|
|
274
|
-
export {
|
|
17
|
+
export { hasNoSelection, hasOwnSelection };
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -3,26 +3,19 @@ export { readBlobText } from './dataTransfer/Blob.js';
|
|
|
3
3
|
export { createDataTransfer, getBlobFromDataTransferItem } from './dataTransfer/DataTransfer.js';
|
|
4
4
|
export { createFileList } from './dataTransfer/FileList.js';
|
|
5
5
|
export { attachClipboardStubToView, createClipboardItem, detachClipboardStubFromView, readDataTransferFromClipboard, resetClipboardStubOnView, writeDataTransferToClipboard } from './dataTransfer/Clipboard.js';
|
|
6
|
-
export {
|
|
7
|
-
export { input } from './edit/input.js';
|
|
6
|
+
export { buildTimeValue, isValidDateOrTimeValue } from './edit/timeValue.js';
|
|
8
7
|
export { getContentEditable, isContentEditable } from './edit/isContentEditable.js';
|
|
9
|
-
export {
|
|
8
|
+
export { isEditable, isEditableInputOrTextArea } from './edit/isEditable.js';
|
|
9
|
+
export { getMaxLength, supportsMaxLength } from './edit/maxLength.js';
|
|
10
10
|
export { setFiles } from './edit/setFiles.js';
|
|
11
|
-
export { walkRadio } from './edit/walkRadio.js';
|
|
12
|
-
export { blur } from './focus/blur.js';
|
|
13
|
-
export { copySelection } from './focus/copySelection.js';
|
|
14
11
|
export { getNextCursorPosition } from './focus/cursor.js';
|
|
15
|
-
export { focus } from './focus/focus.js';
|
|
16
12
|
export { getActiveElement, getActiveElementOrBody } from './focus/getActiveElement.js';
|
|
17
13
|
export { getTabDestination } from './focus/getTabDestination.js';
|
|
18
14
|
export { isFocusable } from './focus/isFocusable.js';
|
|
19
|
-
export {
|
|
20
|
-
export { resolveCaretPosition } from './focus/resolveCaretPosition.js';
|
|
21
|
-
export { getInputRange, hasNoSelection, hasOwnSelection, modifySelection, modifySelectionPerMouseMove, moveSelection, setSelection, setSelectionPerMouseDown, setSelectionRange, updateSelectionOnFocus } from './focus/selection.js';
|
|
15
|
+
export { hasNoSelection, hasOwnSelection } from './focus/selection.js';
|
|
22
16
|
export { FOCUSABLE_SELECTOR } from './focus/selector.js';
|
|
23
17
|
export { readNextDescriptor } from './keyDef/readNextDescriptor.js';
|
|
24
18
|
export { cloneEvent } from './misc/cloneEvent.js';
|
|
25
|
-
export { eventWrapper } from './misc/eventWrapper.js';
|
|
26
19
|
export { findClosest } from './misc/findClosest.js';
|
|
27
20
|
export { getDocumentFromNode } from './misc/getDocumentFromNode.js';
|
|
28
21
|
export { getTreeDiff } from './misc/getTreeDiff.js';
|
|
@@ -37,14 +37,16 @@ function readPrintableChar(text, pos, context) {
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
function readTag(text, pos, startBracket, context) {
|
|
40
|
+
var ref, ref1;
|
|
40
41
|
const releasePreviousModifier = text[pos] === '/' ? '/' : '';
|
|
41
42
|
pos += releasePreviousModifier.length;
|
|
42
43
|
const escapedDescriptor = startBracket === '{' && text[pos] === '\\';
|
|
43
44
|
pos += Number(escapedDescriptor);
|
|
44
|
-
const descriptor = escapedDescriptor ? text[pos] : text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)
|
|
45
|
+
const descriptor = escapedDescriptor ? text[pos] : (ref = text.slice(pos).match(startBracket === '{' ? /^\w+|^[^}>/]/ : /^\w+/)) === null || ref === void 0 ? void 0 : ref[0];
|
|
45
46
|
assertDescriptor(descriptor, text, pos, context);
|
|
46
47
|
pos += descriptor.length;
|
|
47
|
-
|
|
48
|
+
var ref2;
|
|
49
|
+
const repeatModifier = (ref2 = (ref1 = text.slice(pos).match(/^>\d+/)) === null || ref1 === void 0 ? void 0 : ref1[0]) !== null && ref2 !== void 0 ? ref2 : '';
|
|
48
50
|
pos += repeatModifier.length;
|
|
49
51
|
const releaseSelfModifier = text[pos] === '/' || !repeatModifier && text[pos] === '>' ? text[pos] : '';
|
|
50
52
|
pos += releaseSelfModifier.length;
|
|
@@ -80,7 +82,7 @@ function hasReleaseSelf(releaseSelfModifier, repeatModifier) {
|
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
function getErrorMessage(expected, found, text, context) {
|
|
83
|
-
return `Expected ${expected} but found "${found
|
|
85
|
+
return `Expected ${expected} but found "${found !== null && found !== void 0 ? found : ''}" in "${text}"
|
|
84
86
|
See ${context === 'pointer' ? `https://testing-library.com/docs/user-event/pointer#pressing-a-button-or-touching-the-screen` : `https://testing-library.com/docs/user-event/keyboard`}
|
|
85
87
|
for more information about how userEvent parses your input.`;
|
|
86
88
|
}
|
|
@@ -15,7 +15,8 @@ function isDisabled(element) {
|
|
|
15
15
|
return true;
|
|
16
16
|
}
|
|
17
17
|
} else if (isElementType(el, 'fieldset')) {
|
|
18
|
-
|
|
18
|
+
var ref;
|
|
19
|
+
if (el.hasAttribute('disabled') && !((ref = el.querySelector(':scope > legend')) === null || ref === void 0 ? void 0 : ref.contains(element))) {
|
|
19
20
|
return true;
|
|
20
21
|
}
|
|
21
22
|
} else if (el.tagName.includes('-')) {
|
|
@@ -2,7 +2,7 @@ import { getWindow } from './getWindow.js';
|
|
|
2
2
|
|
|
3
3
|
function isVisible(element) {
|
|
4
4
|
const window = getWindow(element);
|
|
5
|
-
for(let el = element; el
|
|
5
|
+
for(let el = element; el === null || el === void 0 ? void 0 : el.ownerDocument; el = el.parentElement){
|
|
6
6
|
const { display , visibility } = window.getComputedStyle(el);
|
|
7
7
|
if (display === 'none') {
|
|
8
8
|
return false;
|