@testing-library/user-event 14.4.2 → 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 +4 -14
- package/dist/cjs/clipboard/cut.js +4 -14
- package/dist/cjs/clipboard/paste.js +2 -12
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/document/{selection.js → UI.js} +43 -57
- 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 +83 -0
- 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 +39 -43
- package/dist/cjs/event/behavior/keypress.js +8 -9
- package/dist/cjs/event/behavior/keyup.js +5 -7
- package/dist/cjs/event/behavior/paste.js +5 -11
- package/dist/cjs/event/createEvent.js +2 -9
- package/dist/cjs/event/dispatchEvent.js +20 -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 +48 -46
- 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 +9 -17
- 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 +1 -9
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +20 -30
- 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 +65 -37
- package/dist/cjs/system/keyboard.js +7 -9
- package/dist/cjs/system/pointer/index.js +16 -21
- package/dist/cjs/system/pointer/mouse.js +45 -38
- package/dist/cjs/system/pointer/pointer.js +33 -35
- 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 +3 -13
- package/dist/cjs/utils/dataTransfer/Clipboard.js +1 -15
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +4 -15
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +0 -16
- package/dist/cjs/utils/focus/selection.js +1 -271
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/misc/level.js +4 -9
- package/dist/cjs/utils/pointer/cssPointerEvents.js +9 -22
- package/dist/esm/clipboard/copy.js +4 -14
- package/dist/esm/clipboard/cut.js +4 -14
- package/dist/esm/clipboard/paste.js +2 -12
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/document/{selection.js → UI.js} +35 -56
- 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 +81 -1
- package/dist/esm/document/prepareDocument.js +63 -0
- package/dist/esm/document/{value.js → trackValue.js} +3 -61
- 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 +32 -36
- package/dist/esm/event/behavior/keypress.js +8 -9
- package/dist/esm/event/behavior/keyup.js +5 -7
- package/dist/esm/event/behavior/paste.js +5 -11
- package/dist/esm/event/createEvent.js +2 -9
- package/dist/esm/event/dispatchEvent.js +19 -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 +35 -33
- 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 +8 -16
- package/dist/esm/{utils/focus → event/selection}/selectAll.js +12 -21
- 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 +1 -9
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +20 -30
- 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 +59 -32
- package/dist/esm/system/keyboard.js +7 -9
- package/dist/esm/system/pointer/index.js +17 -21
- package/dist/esm/system/pointer/mouse.js +42 -35
- package/dist/esm/system/pointer/pointer.js +32 -34
- 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 +5 -14
- package/dist/esm/utility/upload.js +3 -13
- package/dist/esm/utils/dataTransfer/Clipboard.js +1 -15
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +3 -15
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +0 -16
- package/dist/esm/utils/focus/selection.js +3 -265
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/misc/level.js +4 -9
- package/dist/esm/utils/pointer/cssPointerEvents.js +9 -22
- 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 +3 -2
- package/dist/cjs/document/setRangeText.js +0 -21
- package/dist/cjs/document/value.js +0 -127
- 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 -29
- package/dist/cjs/utils/focus/selectAll.js +0 -56
- package/dist/cjs/utils/misc/eventWrapper.js +0 -15
- package/dist/esm/document/setRangeText.js +0 -17
- 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 -25
- 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
|
@@ -2,23 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('../
|
|
5
|
+
var getWindow = require('../misc/getWindow.js');
|
|
6
6
|
var Blob = require('./Blob.js');
|
|
7
7
|
var DataTransfer = require('./DataTransfer.js');
|
|
8
|
-
require('../../event/eventMap.js');
|
|
9
|
-
require('../../event/behavior/click.js');
|
|
10
|
-
require('../../event/behavior/cut.js');
|
|
11
|
-
require('../../event/behavior/keydown.js');
|
|
12
|
-
require('../../event/behavior/keypress.js');
|
|
13
|
-
require('../../event/behavior/keyup.js');
|
|
14
|
-
require('../../event/behavior/paste.js');
|
|
15
|
-
require('@testing-library/dom');
|
|
16
|
-
require('../edit/maxLength.js');
|
|
17
|
-
require('../edit/isEditable.js');
|
|
18
|
-
var getWindow = require('../misc/getWindow.js');
|
|
19
|
-
require('../keyDef/readNextDescriptor.js');
|
|
20
|
-
require('../misc/level.js');
|
|
21
|
-
require('../../options.js');
|
|
22
8
|
|
|
23
9
|
// Clipboard is not available in jsdom
|
|
24
10
|
// MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData
|
|
@@ -6,11 +6,9 @@ var isElementType = require('../misc/isElementType.js');
|
|
|
6
6
|
var isContentEditable = require('./isContentEditable.js');
|
|
7
7
|
|
|
8
8
|
function isEditable(element) {
|
|
9
|
-
return
|
|
10
|
-
readOnly: false
|
|
11
|
-
}) || isContentEditable.isContentEditable(element);
|
|
9
|
+
return isEditableInputOrTextArea(element) && !element.readOnly || isContentEditable.isContentEditable(element);
|
|
12
10
|
}
|
|
13
|
-
|
|
11
|
+
var editableInputTypes;
|
|
14
12
|
(function(editableInputTypes) {
|
|
15
13
|
editableInputTypes['text'] = 'text';
|
|
16
14
|
editableInputTypes['date'] = 'date';
|
|
@@ -24,12 +22,10 @@ exports.editableInputTypes = void 0;
|
|
|
24
22
|
editableInputTypes['time'] = 'time';
|
|
25
23
|
editableInputTypes['url'] = 'url';
|
|
26
24
|
editableInputTypes['week'] = 'week';
|
|
27
|
-
})(
|
|
28
|
-
function
|
|
29
|
-
return isElementType.isElementType(element, '
|
|
30
|
-
readOnly: false
|
|
31
|
-
}) && Boolean(exports.editableInputTypes[element.type]);
|
|
25
|
+
})(editableInputTypes || (editableInputTypes = {}));
|
|
26
|
+
function isEditableInputOrTextArea(element) {
|
|
27
|
+
return isElementType.isElementType(element, 'textarea') || isElementType.isElementType(element, 'input') && element.type in editableInputTypes;
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
exports.isEditable = isEditable;
|
|
35
|
-
exports.
|
|
31
|
+
exports.isEditableInputOrTextArea = isEditableInputOrTextArea;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var isElementType = require('../misc/isElementType.js');
|
|
6
|
-
var getValue = require('./getValue.js');
|
|
7
6
|
|
|
8
7
|
var maxLengthSupportedTypes;
|
|
9
8
|
(function(maxLengthSupportedTypes) {
|
|
@@ -14,26 +13,16 @@ var maxLengthSupportedTypes;
|
|
|
14
13
|
maxLengthSupportedTypes['text'] = 'text';
|
|
15
14
|
maxLengthSupportedTypes['url'] = 'url';
|
|
16
15
|
})(maxLengthSupportedTypes || (maxLengthSupportedTypes = {}));
|
|
17
|
-
function getSpaceUntilMaxLength(element) {
|
|
18
|
-
const value = getValue.getValue(element);
|
|
19
|
-
/* istanbul ignore if */ if (value === null) {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
const maxLength = getSanitizedMaxLength(element);
|
|
23
|
-
return maxLength ? maxLength - value.length : undefined;
|
|
24
|
-
}
|
|
25
16
|
// can't use .maxLength property because of a jsdom bug:
|
|
26
17
|
// https://github.com/jsdom/jsdom/issues/2927
|
|
27
|
-
function
|
|
28
|
-
if (!supportsMaxLength(element)) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
18
|
+
function getMaxLength(element) {
|
|
31
19
|
var ref;
|
|
32
20
|
const attr = (ref = element.getAttribute('maxlength')) !== null && ref !== void 0 ? ref : '';
|
|
33
21
|
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;
|
|
34
22
|
}
|
|
35
23
|
function supportsMaxLength(element) {
|
|
36
|
-
return isElementType.isElementType(element, 'textarea') || isElementType.isElementType(element, 'input') &&
|
|
24
|
+
return isElementType.isElementType(element, 'textarea') || isElementType.isElementType(element, 'input') && element.type in maxLengthSupportedTypes;
|
|
37
25
|
}
|
|
38
26
|
|
|
39
|
-
exports.
|
|
27
|
+
exports.getMaxLength = getMaxLength;
|
|
28
|
+
exports.supportsMaxLength = supportsMaxLength;
|
|
@@ -32,5 +32,11 @@ function build(onlyDigitsValue, index) {
|
|
|
32
32
|
const validMinutes = Math.min(parsedMinutes, 59);
|
|
33
33
|
return `${validHours.toString().padStart(2, '0')}:${validMinutes.toString().padStart(2, '0')}`;
|
|
34
34
|
}
|
|
35
|
+
function isValidDateOrTimeValue(element, value) {
|
|
36
|
+
const clone = element.cloneNode();
|
|
37
|
+
clone.value = value;
|
|
38
|
+
return clone.value === value;
|
|
39
|
+
}
|
|
35
40
|
|
|
36
41
|
exports.buildTimeValue = buildTimeValue;
|
|
42
|
+
exports.isValidDateOrTimeValue = isValidDateOrTimeValue;
|
|
@@ -2,24 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('../click/isClickableInput.js');
|
|
6
|
-
require('../dataTransfer/Clipboard.js');
|
|
7
|
-
require('../../event/eventMap.js');
|
|
8
|
-
require('../../event/behavior/click.js');
|
|
9
|
-
require('../../event/behavior/cut.js');
|
|
10
|
-
require('../../event/behavior/keydown.js');
|
|
11
|
-
require('../../event/behavior/keypress.js');
|
|
12
|
-
require('../../event/behavior/keyup.js');
|
|
13
|
-
require('../../event/behavior/paste.js');
|
|
14
|
-
require('@testing-library/dom');
|
|
15
5
|
var isContentEditable = require('../edit/isContentEditable.js');
|
|
16
|
-
require('../edit/maxLength.js');
|
|
17
|
-
require('../edit/isEditable.js');
|
|
18
6
|
var isElementType = require('../misc/isElementType.js');
|
|
19
|
-
require('@testing-library/dom/dist/helpers.js');
|
|
20
|
-
require('../keyDef/readNextDescriptor.js');
|
|
21
|
-
require('../misc/level.js');
|
|
22
|
-
require('../../options.js');
|
|
23
7
|
|
|
24
8
|
function getNextCursorPosition(node, offset, direction, inputType) {
|
|
25
9
|
// The behavior at text node zero offset is inconsistent.
|
|
@@ -2,56 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var isElementType = require('../misc/isElementType.js');
|
|
6
5
|
var isClickableInput = require('../click/isClickableInput.js');
|
|
7
|
-
require('../dataTransfer/Clipboard.js');
|
|
8
|
-
var isContentEditable = require('../edit/isContentEditable.js');
|
|
9
|
-
require('../edit/maxLength.js');
|
|
10
6
|
var isEditable = require('../edit/isEditable.js');
|
|
11
|
-
require('@testing-library/dom');
|
|
12
|
-
require('@testing-library/dom/dist/helpers.js');
|
|
13
|
-
var cursor = require('./cursor.js');
|
|
14
|
-
var resolveCaretPosition = require('./resolveCaretPosition.js');
|
|
15
|
-
require('../keyDef/readNextDescriptor.js');
|
|
16
|
-
require('../misc/level.js');
|
|
17
|
-
require('../../options.js');
|
|
18
|
-
require('../../event/eventMap.js');
|
|
19
|
-
require('../../event/behavior/click.js');
|
|
20
|
-
require('../../event/behavior/cut.js');
|
|
21
|
-
require('../../event/behavior/keydown.js');
|
|
22
|
-
require('../../event/behavior/keypress.js');
|
|
23
|
-
require('../../event/behavior/keyup.js');
|
|
24
|
-
require('../../event/behavior/paste.js');
|
|
25
|
-
var selection = require('../../document/selection.js');
|
|
26
|
-
var value = require('../../document/value.js');
|
|
27
7
|
|
|
28
|
-
/**
|
|
29
|
-
* Backward-compatible selection.
|
|
30
|
-
*
|
|
31
|
-
* Handles input elements and contenteditable if it only contains a single text node.
|
|
32
|
-
*/ function setSelectionRange(element, anchorOffset, focusOffset) {
|
|
33
|
-
var ref;
|
|
34
|
-
if (hasOwnSelection(element)) {
|
|
35
|
-
return setSelection({
|
|
36
|
-
focusNode: element,
|
|
37
|
-
anchorOffset,
|
|
38
|
-
focusOffset
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
/* istanbul ignore else */ if (isContentEditable.isContentEditable(element) && ((ref = element.firstChild) === null || ref === void 0 ? void 0 : ref.nodeType) === 3) {
|
|
42
|
-
return setSelection({
|
|
43
|
-
focusNode: element.firstChild,
|
|
44
|
-
anchorOffset,
|
|
45
|
-
focusOffset
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/* istanbul ignore next */ throw new Error('Not implemented. The result of this interaction is unreliable.');
|
|
49
|
-
}
|
|
50
8
|
/**
|
|
51
9
|
* Determine if the element has its own selection implementation
|
|
52
10
|
* and does not interact with the Document Selection API.
|
|
53
11
|
*/ function hasOwnSelection(node) {
|
|
54
|
-
return isElement(node) &&
|
|
12
|
+
return isElement(node) && isEditable.isEditableInputOrTextArea(node);
|
|
55
13
|
}
|
|
56
14
|
function hasNoSelection(node) {
|
|
57
15
|
return isElement(node) && isClickableInput.isClickableInput(node);
|
|
@@ -59,234 +17,6 @@ function hasNoSelection(node) {
|
|
|
59
17
|
function isElement(node) {
|
|
60
18
|
return node.nodeType === 1;
|
|
61
19
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Determine which selection logic and selection ranges to consider.
|
|
64
|
-
*/ function getTargetTypeAndSelection(node) {
|
|
65
|
-
const element = getElement(node);
|
|
66
|
-
if (element && hasOwnSelection(element)) {
|
|
67
|
-
return {
|
|
68
|
-
type: 'input',
|
|
69
|
-
selection: selection.getUISelection(element)
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
const selection$1 = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection();
|
|
73
|
-
// It is possible to extend a single-range selection into a contenteditable.
|
|
74
|
-
// This results in the range acting like a range outside of contenteditable.
|
|
75
|
-
const isCE = isContentEditable.getContentEditable(node) && (selection$1 === null || selection$1 === void 0 ? void 0 : selection$1.anchorNode) && isContentEditable.getContentEditable(selection$1.anchorNode);
|
|
76
|
-
return {
|
|
77
|
-
type: isCE ? 'contenteditable' : 'default',
|
|
78
|
-
selection: selection$1
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function getElement(node) {
|
|
82
|
-
return node.nodeType === 1 ? node : node.parentElement;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Reset the Document Selection when moving focus into an element
|
|
86
|
-
* with own selection implementation.
|
|
87
|
-
*/ function updateSelectionOnFocus(element) {
|
|
88
|
-
const selection = element.ownerDocument.getSelection();
|
|
89
|
-
/* istanbul ignore if */ if (!(selection === null || selection === void 0 ? void 0 : selection.focusNode)) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
// If the focus moves inside an element with own selection implementation,
|
|
93
|
-
// the document selection will be this element.
|
|
94
|
-
// But if the focused element is inside a contenteditable,
|
|
95
|
-
// 1) a collapsed selection will be retained.
|
|
96
|
-
// 2) other selections will be replaced by a cursor
|
|
97
|
-
// 2.a) at the start of the first child if it is a text node
|
|
98
|
-
// 2.b) at the start of the contenteditable.
|
|
99
|
-
if (hasOwnSelection(element)) {
|
|
100
|
-
const contenteditable = isContentEditable.getContentEditable(selection.focusNode);
|
|
101
|
-
if (contenteditable) {
|
|
102
|
-
if (!selection.isCollapsed) {
|
|
103
|
-
var ref;
|
|
104
|
-
const focusNode = ((ref = contenteditable.firstChild) === null || ref === void 0 ? void 0 : ref.nodeType) === 3 ? contenteditable.firstChild : contenteditable;
|
|
105
|
-
selection.setBaseAndExtent(focusNode, 0, focusNode, 0);
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
selection.setBaseAndExtent(element, 0, element, 0);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Get the range that would be overwritten by input.
|
|
114
|
-
*/ function getInputRange(focusNode) {
|
|
115
|
-
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
116
|
-
if (typeAndSelection.type === 'input') {
|
|
117
|
-
return typeAndSelection.selection;
|
|
118
|
-
} else if (typeAndSelection.type === 'contenteditable') {
|
|
119
|
-
var ref;
|
|
120
|
-
// Multi-range on contenteditable edits the first selection instead of the last
|
|
121
|
-
return (ref = typeAndSelection.selection) === null || ref === void 0 ? void 0 : ref.getRangeAt(0);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* Extend/shrink the selection like with Shift+Arrows or Shift+Mouse
|
|
126
|
-
*/ function modifySelection({ focusNode , focusOffset }) {
|
|
127
|
-
var ref, ref1;
|
|
128
|
-
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
129
|
-
if (typeAndSelection.type === 'input') {
|
|
130
|
-
return selection.setUISelection(focusNode, {
|
|
131
|
-
anchorOffset: typeAndSelection.selection.anchorOffset,
|
|
132
|
-
focusOffset
|
|
133
|
-
}, 'modify');
|
|
134
|
-
}
|
|
135
|
-
(ref1 = (ref = focusNode.ownerDocument) === null || ref === void 0 ? void 0 : ref.getSelection()) === null || ref1 === void 0 ? void 0 : ref1.extend(focusNode, focusOffset);
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Set the selection
|
|
139
|
-
*/ function setSelection({ focusNode , focusOffset , anchorNode =focusNode , anchorOffset =focusOffset }) {
|
|
140
|
-
var ref, ref1;
|
|
141
|
-
const typeAndSelection = getTargetTypeAndSelection(focusNode);
|
|
142
|
-
if (typeAndSelection.type === 'input') {
|
|
143
|
-
return selection.setUISelection(focusNode, {
|
|
144
|
-
anchorOffset,
|
|
145
|
-
focusOffset
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
(ref1 = (ref = anchorNode.ownerDocument) === null || ref === void 0 ? void 0 : ref.getSelection()) === null || ref1 === void 0 ? void 0 : ref1.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Move the selection
|
|
152
|
-
*/ function moveSelection(node, direction) {
|
|
153
|
-
// TODO: implement shift
|
|
154
|
-
if (hasOwnSelection(node)) {
|
|
155
|
-
const selection$1 = selection.getUISelection(node);
|
|
156
|
-
setSelection({
|
|
157
|
-
focusNode: node,
|
|
158
|
-
focusOffset: selection$1.startOffset === selection$1.endOffset ? selection$1.focusOffset + direction : direction < 0 ? selection$1.startOffset : selection$1.endOffset
|
|
159
|
-
});
|
|
160
|
-
} else {
|
|
161
|
-
const selection1 = node.ownerDocument.getSelection();
|
|
162
|
-
if (!(selection1 === null || selection1 === void 0 ? void 0 : selection1.focusNode)) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (selection1.isCollapsed) {
|
|
166
|
-
const nextPosition = cursor.getNextCursorPosition(selection1.focusNode, selection1.focusOffset, direction);
|
|
167
|
-
if (nextPosition) {
|
|
168
|
-
setSelection({
|
|
169
|
-
focusNode: nextPosition.node,
|
|
170
|
-
focusOffset: nextPosition.offset
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
} else {
|
|
174
|
-
selection1[direction < 0 ? 'collapseToStart' : 'collapseToEnd']();
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
function setSelectionPerMouseDown({ document , target , clickCount , node , offset }) {
|
|
179
|
-
if (hasNoSelection(target)) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
const targetHasOwnSelection = hasOwnSelection(target);
|
|
183
|
-
// On non-input elements the text selection per multiple click
|
|
184
|
-
// can extend beyond the target boundaries.
|
|
185
|
-
// The exact mechanism what is considered in the same line is unclear.
|
|
186
|
-
// Looks it might be every inline element.
|
|
187
|
-
// TODO: Check what might be considered part of the same line of text.
|
|
188
|
-
const text = String(targetHasOwnSelection ? value.getUIValue(target) : target.textContent);
|
|
189
|
-
const [start, end] = node ? // which elements might be considered in the same line of text.
|
|
190
|
-
// TODO: support expanding initial range on multiple clicks if node is given
|
|
191
|
-
[
|
|
192
|
-
offset,
|
|
193
|
-
offset
|
|
194
|
-
] : getTextRange(text, offset, clickCount);
|
|
195
|
-
// TODO: implement modifying selection per shift/ctrl+mouse
|
|
196
|
-
if (targetHasOwnSelection) {
|
|
197
|
-
selection.setUISelection(target, {
|
|
198
|
-
anchorOffset: start !== null && start !== void 0 ? start : text.length,
|
|
199
|
-
focusOffset: end !== null && end !== void 0 ? end : text.length
|
|
200
|
-
});
|
|
201
|
-
return {
|
|
202
|
-
node: target,
|
|
203
|
-
start: start !== null && start !== void 0 ? start : 0,
|
|
204
|
-
end: end !== null && end !== void 0 ? end : text.length
|
|
205
|
-
};
|
|
206
|
-
} else {
|
|
207
|
-
const { node: startNode , offset: startOffset } = resolveCaretPosition.resolveCaretPosition({
|
|
208
|
-
target,
|
|
209
|
-
node,
|
|
210
|
-
offset: start
|
|
211
|
-
});
|
|
212
|
-
const { node: endNode , offset: endOffset } = resolveCaretPosition.resolveCaretPosition({
|
|
213
|
-
target,
|
|
214
|
-
node,
|
|
215
|
-
offset: end
|
|
216
|
-
});
|
|
217
|
-
const range = target.ownerDocument.createRange();
|
|
218
|
-
try {
|
|
219
|
-
range.setStart(startNode, startOffset);
|
|
220
|
-
range.setEnd(endNode, endOffset);
|
|
221
|
-
} catch (e) {
|
|
222
|
-
throw new Error('The given offset is out of bounds.');
|
|
223
|
-
}
|
|
224
|
-
const selection = document.getSelection();
|
|
225
|
-
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
|
|
226
|
-
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
|
|
227
|
-
return range;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
function getTextRange(text, pos, clickCount) {
|
|
231
|
-
if (clickCount % 3 === 1 || text.length === 0) {
|
|
232
|
-
return [
|
|
233
|
-
pos,
|
|
234
|
-
pos
|
|
235
|
-
];
|
|
236
|
-
}
|
|
237
|
-
const textPos = pos !== null && pos !== void 0 ? pos : text.length;
|
|
238
|
-
if (clickCount % 3 === 2) {
|
|
239
|
-
return [
|
|
240
|
-
textPos - text.substr(0, pos).match(/(\w+|\s+|\W)?$/)[0].length,
|
|
241
|
-
pos === undefined ? pos : pos + text.substr(pos).match(/^(\w+|\s+|\W)?/)[0].length,
|
|
242
|
-
];
|
|
243
|
-
}
|
|
244
|
-
// triple click
|
|
245
|
-
return [
|
|
246
|
-
textPos - text.substr(0, pos).match(/[^\r\n]*$/)[0].length,
|
|
247
|
-
pos === undefined ? pos : pos + text.substr(pos).match(/^[^\r\n]*/)[0].length,
|
|
248
|
-
];
|
|
249
|
-
}
|
|
250
|
-
function modifySelectionPerMouseMove(selectionRange, { document , target , node , offset }) {
|
|
251
|
-
const selectionFocus = resolveCaretPosition.resolveCaretPosition({
|
|
252
|
-
target,
|
|
253
|
-
node,
|
|
254
|
-
offset
|
|
255
|
-
});
|
|
256
|
-
if ('node' in selectionRange) {
|
|
257
|
-
// When the mouse is dragged outside of an input/textarea,
|
|
258
|
-
// the selection is extended to the beginning or end of the input
|
|
259
|
-
// depending on pointer position.
|
|
260
|
-
// TODO: extend selection according to pointer position
|
|
261
|
-
/* istanbul ignore else */ if (selectionFocus.node === selectionRange.node) {
|
|
262
|
-
const anchorOffset = selectionFocus.offset < selectionRange.start ? selectionRange.end : selectionRange.start;
|
|
263
|
-
const focusOffset = selectionFocus.offset > selectionRange.end || selectionFocus.offset < selectionRange.start ? selectionFocus.offset : selectionRange.end;
|
|
264
|
-
selection.setUISelection(selectionRange.node, {
|
|
265
|
-
anchorOffset,
|
|
266
|
-
focusOffset
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
} else {
|
|
270
|
-
const range = selectionRange.cloneRange();
|
|
271
|
-
const cmp = range.comparePoint(selectionFocus.node, selectionFocus.offset);
|
|
272
|
-
if (cmp < 0) {
|
|
273
|
-
range.setStart(selectionFocus.node, selectionFocus.offset);
|
|
274
|
-
} else if (cmp > 0) {
|
|
275
|
-
range.setEnd(selectionFocus.node, selectionFocus.offset);
|
|
276
|
-
}
|
|
277
|
-
const selection = document.getSelection();
|
|
278
|
-
selection === null || selection === void 0 ? void 0 : selection.removeAllRanges();
|
|
279
|
-
selection === null || selection === void 0 ? void 0 : selection.addRange(range.cloneRange());
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
20
|
|
|
283
|
-
exports.getInputRange = getInputRange;
|
|
284
21
|
exports.hasNoSelection = hasNoSelection;
|
|
285
22
|
exports.hasOwnSelection = hasOwnSelection;
|
|
286
|
-
exports.modifySelection = modifySelection;
|
|
287
|
-
exports.modifySelectionPerMouseMove = modifySelectionPerMouseMove;
|
|
288
|
-
exports.moveSelection = moveSelection;
|
|
289
|
-
exports.setSelection = setSelection;
|
|
290
|
-
exports.setSelectionPerMouseDown = setSelectionPerMouseDown;
|
|
291
|
-
exports.setSelectionRange = setSelectionRange;
|
|
292
|
-
exports.updateSelectionOnFocus = updateSelectionOnFocus;
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -7,26 +7,19 @@ var Blob = require('./dataTransfer/Blob.js');
|
|
|
7
7
|
var DataTransfer = require('./dataTransfer/DataTransfer.js');
|
|
8
8
|
var FileList = require('./dataTransfer/FileList.js');
|
|
9
9
|
var Clipboard = require('./dataTransfer/Clipboard.js');
|
|
10
|
-
var
|
|
11
|
-
var input = require('./edit/input.js');
|
|
10
|
+
var timeValue = require('./edit/timeValue.js');
|
|
12
11
|
var isContentEditable = require('./edit/isContentEditable.js');
|
|
13
12
|
var isEditable = require('./edit/isEditable.js');
|
|
13
|
+
var maxLength = require('./edit/maxLength.js');
|
|
14
14
|
var setFiles = require('./edit/setFiles.js');
|
|
15
|
-
var walkRadio = require('./edit/walkRadio.js');
|
|
16
|
-
var blur = require('./focus/blur.js');
|
|
17
|
-
var copySelection = require('./focus/copySelection.js');
|
|
18
15
|
var cursor = require('./focus/cursor.js');
|
|
19
|
-
var focus = require('./focus/focus.js');
|
|
20
16
|
var getActiveElement = require('./focus/getActiveElement.js');
|
|
21
17
|
var getTabDestination = require('./focus/getTabDestination.js');
|
|
22
18
|
var isFocusable = require('./focus/isFocusable.js');
|
|
23
|
-
var selectAll = require('./focus/selectAll.js');
|
|
24
|
-
var resolveCaretPosition = require('./focus/resolveCaretPosition.js');
|
|
25
19
|
var selection = require('./focus/selection.js');
|
|
26
20
|
var selector = require('./focus/selector.js');
|
|
27
21
|
var readNextDescriptor = require('./keyDef/readNextDescriptor.js');
|
|
28
22
|
var cloneEvent = require('./misc/cloneEvent.js');
|
|
29
|
-
var eventWrapper = require('./misc/eventWrapper.js');
|
|
30
23
|
var findClosest = require('./misc/findClosest.js');
|
|
31
24
|
var getDocumentFromNode = require('./misc/getDocumentFromNode.js');
|
|
32
25
|
var getTreeDiff = require('./misc/getTreeDiff.js');
|
|
@@ -52,43 +45,25 @@ exports.detachClipboardStubFromView = Clipboard.detachClipboardStubFromView;
|
|
|
52
45
|
exports.readDataTransferFromClipboard = Clipboard.readDataTransferFromClipboard;
|
|
53
46
|
exports.resetClipboardStubOnView = Clipboard.resetClipboardStubOnView;
|
|
54
47
|
exports.writeDataTransferToClipboard = Clipboard.writeDataTransferToClipboard;
|
|
55
|
-
exports.
|
|
56
|
-
exports.
|
|
48
|
+
exports.buildTimeValue = timeValue.buildTimeValue;
|
|
49
|
+
exports.isValidDateOrTimeValue = timeValue.isValidDateOrTimeValue;
|
|
57
50
|
exports.getContentEditable = isContentEditable.getContentEditable;
|
|
58
51
|
exports.isContentEditable = isContentEditable.isContentEditable;
|
|
59
|
-
Object.defineProperty(exports, 'editableInputTypes', {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
get: function () { return isEditable.editableInputTypes; }
|
|
62
|
-
});
|
|
63
52
|
exports.isEditable = isEditable.isEditable;
|
|
64
|
-
exports.
|
|
53
|
+
exports.isEditableInputOrTextArea = isEditable.isEditableInputOrTextArea;
|
|
54
|
+
exports.getMaxLength = maxLength.getMaxLength;
|
|
55
|
+
exports.supportsMaxLength = maxLength.supportsMaxLength;
|
|
65
56
|
exports.setFiles = setFiles.setFiles;
|
|
66
|
-
exports.walkRadio = walkRadio.walkRadio;
|
|
67
|
-
exports.blur = blur.blur;
|
|
68
|
-
exports.copySelection = copySelection.copySelection;
|
|
69
57
|
exports.getNextCursorPosition = cursor.getNextCursorPosition;
|
|
70
|
-
exports.focus = focus.focus;
|
|
71
58
|
exports.getActiveElement = getActiveElement.getActiveElement;
|
|
72
59
|
exports.getActiveElementOrBody = getActiveElement.getActiveElementOrBody;
|
|
73
60
|
exports.getTabDestination = getTabDestination.getTabDestination;
|
|
74
61
|
exports.isFocusable = isFocusable.isFocusable;
|
|
75
|
-
exports.isAllSelected = selectAll.isAllSelected;
|
|
76
|
-
exports.selectAll = selectAll.selectAll;
|
|
77
|
-
exports.resolveCaretPosition = resolveCaretPosition.resolveCaretPosition;
|
|
78
|
-
exports.getInputRange = selection.getInputRange;
|
|
79
62
|
exports.hasNoSelection = selection.hasNoSelection;
|
|
80
63
|
exports.hasOwnSelection = selection.hasOwnSelection;
|
|
81
|
-
exports.modifySelection = selection.modifySelection;
|
|
82
|
-
exports.modifySelectionPerMouseMove = selection.modifySelectionPerMouseMove;
|
|
83
|
-
exports.moveSelection = selection.moveSelection;
|
|
84
|
-
exports.setSelection = selection.setSelection;
|
|
85
|
-
exports.setSelectionPerMouseDown = selection.setSelectionPerMouseDown;
|
|
86
|
-
exports.setSelectionRange = selection.setSelectionRange;
|
|
87
|
-
exports.updateSelectionOnFocus = selection.updateSelectionOnFocus;
|
|
88
64
|
exports.FOCUSABLE_SELECTOR = selector.FOCUSABLE_SELECTOR;
|
|
89
65
|
exports.readNextDescriptor = readNextDescriptor.readNextDescriptor;
|
|
90
66
|
exports.cloneEvent = cloneEvent.cloneEvent;
|
|
91
|
-
exports.eventWrapper = eventWrapper.eventWrapper;
|
|
92
67
|
exports.findClosest = findClosest.findClosest;
|
|
93
68
|
exports.getDocumentFromNode = getDocumentFromNode.getDocumentFromNode;
|
|
94
69
|
exports.getTreeDiff = getTreeDiff.getTreeDiff;
|
|
@@ -2,21 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var _config, _Level;
|
|
6
5
|
exports.ApiLevel = void 0;
|
|
7
6
|
(function(ApiLevel) {
|
|
8
7
|
ApiLevel[ApiLevel["Trigger"] = 2] = "Trigger";
|
|
9
8
|
ApiLevel[ApiLevel["Call"] = 1] = "Call";
|
|
10
9
|
})(exports.ApiLevel || (exports.ApiLevel = {}));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var ref;
|
|
14
|
-
(ref = (_config = config)[_Level = Level]) !== null && ref !== void 0 ? ref : _config[_Level] = {};
|
|
15
|
-
config[Level][level] = {};
|
|
10
|
+
function setLevelRef(instance, level) {
|
|
11
|
+
instance.levelRefs[level] = {};
|
|
16
12
|
}
|
|
17
|
-
function getLevelRef(
|
|
18
|
-
|
|
19
|
-
return (ref = config[Level]) === null || ref === void 0 ? void 0 : ref[level];
|
|
13
|
+
function getLevelRef(instance, level) {
|
|
14
|
+
return instance.levelRefs[level];
|
|
20
15
|
}
|
|
21
16
|
|
|
22
17
|
exports.getLevelRef = getLevelRef;
|
|
@@ -3,26 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var options = require('../../options.js');
|
|
6
|
-
require('../click/isClickableInput.js');
|
|
7
|
-
require('../dataTransfer/Clipboard.js');
|
|
8
|
-
require('../../event/eventMap.js');
|
|
9
|
-
require('../../event/behavior/click.js');
|
|
10
|
-
require('../../event/behavior/cut.js');
|
|
11
|
-
require('../../event/behavior/keydown.js');
|
|
12
|
-
require('../../event/behavior/keypress.js');
|
|
13
|
-
require('../../event/behavior/keyup.js');
|
|
14
|
-
require('../../event/behavior/paste.js');
|
|
15
|
-
require('@testing-library/dom');
|
|
16
|
-
require('../edit/maxLength.js');
|
|
17
|
-
require('../edit/isEditable.js');
|
|
18
|
-
var isElementType = require('../misc/isElementType.js');
|
|
19
6
|
var getWindow = require('../misc/getWindow.js');
|
|
20
|
-
require('../
|
|
7
|
+
var isElementType = require('../misc/isElementType.js');
|
|
21
8
|
var level = require('../misc/level.js');
|
|
22
9
|
|
|
23
|
-
function hasPointerEvents(
|
|
10
|
+
function hasPointerEvents(instance, element) {
|
|
24
11
|
var ref;
|
|
25
|
-
return ((ref = checkPointerEvents(
|
|
12
|
+
return ((ref = checkPointerEvents(instance, element)) === null || ref === void 0 ? void 0 : ref.pointerEvents) !== 'none';
|
|
26
13
|
}
|
|
27
14
|
function closestPointerEventsDeclaration(element) {
|
|
28
15
|
const window = getWindow.getWindow(element);
|
|
@@ -42,22 +29,22 @@ function closestPointerEventsDeclaration(element) {
|
|
|
42
29
|
return undefined;
|
|
43
30
|
}
|
|
44
31
|
const PointerEventsCheck = Symbol('Last check for pointer-events');
|
|
45
|
-
function checkPointerEvents(
|
|
32
|
+
function checkPointerEvents(instance, element) {
|
|
46
33
|
const lastCheck = element[PointerEventsCheck];
|
|
47
|
-
const needsCheck = config.pointerEventsCheck !== options.PointerEventsCheckLevel.Never && (!lastCheck || hasBitFlag(config.pointerEventsCheck, options.PointerEventsCheckLevel.EachApiCall) && lastCheck[level.ApiLevel.Call] !== level.getLevelRef(
|
|
34
|
+
const needsCheck = instance.config.pointerEventsCheck !== options.PointerEventsCheckLevel.Never && (!lastCheck || hasBitFlag(instance.config.pointerEventsCheck, options.PointerEventsCheckLevel.EachApiCall) && lastCheck[level.ApiLevel.Call] !== level.getLevelRef(instance, level.ApiLevel.Call) || hasBitFlag(instance.config.pointerEventsCheck, options.PointerEventsCheckLevel.EachTrigger) && lastCheck[level.ApiLevel.Trigger] !== level.getLevelRef(instance, level.ApiLevel.Trigger));
|
|
48
35
|
if (!needsCheck) {
|
|
49
36
|
return lastCheck === null || lastCheck === void 0 ? void 0 : lastCheck.result;
|
|
50
37
|
}
|
|
51
38
|
const declaration = closestPointerEventsDeclaration(element);
|
|
52
39
|
element[PointerEventsCheck] = {
|
|
53
|
-
[level.ApiLevel.Call]: level.getLevelRef(
|
|
54
|
-
[level.ApiLevel.Trigger]: level.getLevelRef(
|
|
40
|
+
[level.ApiLevel.Call]: level.getLevelRef(instance, level.ApiLevel.Call),
|
|
41
|
+
[level.ApiLevel.Trigger]: level.getLevelRef(instance, level.ApiLevel.Trigger),
|
|
55
42
|
result: declaration
|
|
56
43
|
};
|
|
57
44
|
return declaration;
|
|
58
45
|
}
|
|
59
|
-
function assertPointerEvents(
|
|
60
|
-
const declaration = checkPointerEvents(
|
|
46
|
+
function assertPointerEvents(instance, element) {
|
|
47
|
+
const declaration = checkPointerEvents(instance, element);
|
|
61
48
|
if ((declaration === null || declaration === void 0 ? void 0 : declaration.pointerEvents) === 'none') {
|
|
62
49
|
throw new Error([
|
|
63
50
|
`Unable to perform pointer interaction as the element ${declaration.tree.length > 1 ? 'inherits' : 'has'} \`pointer-events: none\`:`,
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import '../setup/index.js';
|
|
2
1
|
import '../utils/click/isClickableInput.js';
|
|
3
2
|
import { writeDataTransferToClipboard } from '../utils/dataTransfer/Clipboard.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 '../utils/edit/maxLength.js';
|
|
13
3
|
import '../utils/edit/isEditable.js';
|
|
4
|
+
import '../utils/edit/maxLength.js';
|
|
14
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
15
|
-
import { copySelection } from '../utils/focus/copySelection.js';
|
|
16
6
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
17
7
|
import '../utils/misc/level.js';
|
|
18
8
|
import '../options.js';
|
|
19
|
-
import {
|
|
9
|
+
import { copySelection } from '../document/copySelection.js';
|
|
20
10
|
|
|
21
11
|
async function copy() {
|
|
22
|
-
const doc = this
|
|
12
|
+
const doc = this.config.document;
|
|
23
13
|
var _activeElement;
|
|
24
14
|
const target = (_activeElement = doc.activeElement) !== null && _activeElement !== void 0 ? _activeElement : /* istanbul ignore next */ doc.body;
|
|
25
15
|
const clipboardData = copySelection(target);
|
|
@@ -28,7 +18,7 @@ async function copy() {
|
|
|
28
18
|
}
|
|
29
19
|
if (this.dispatchUIEvent(target, 'copy', {
|
|
30
20
|
clipboardData
|
|
31
|
-
}) && this
|
|
21
|
+
}) && this.config.writeToClipboard) {
|
|
32
22
|
await writeDataTransferToClipboard(doc, clipboardData);
|
|
33
23
|
}
|
|
34
24
|
return clipboardData;
|