@testing-library/user-event 14.4.2 → 14.5.0
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/_interop/dtl.js +30 -0
- package/dist/cjs/_interop/dtlEventMap.js +30 -0
- package/dist/cjs/_interop/dtlHelpers.js +30 -0
- package/dist/cjs/clipboard/copy.js +6 -16
- package/dist/cjs/clipboard/cut.js +6 -16
- package/dist/cjs/clipboard/paste.js +6 -16
- package/dist/cjs/convenience/click.js +1 -4
- package/dist/cjs/convenience/hover.js +2 -12
- package/dist/cjs/convenience/tab.js +1 -1
- 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 +89 -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 -47
- package/dist/cjs/event/behavior/keypress.js +12 -12
- package/dist/cjs/event/behavior/keyup.js +6 -8
- package/dist/cjs/event/behavior/paste.js +7 -13
- package/dist/cjs/event/createEvent.js +43 -50
- package/dist/cjs/event/dispatchEvent.js +21 -3
- package/dist/cjs/event/eventMap.js +2 -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 +52 -50
- 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 +41 -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 +50 -0
- package/dist/cjs/event/selection/moveSelection.js +48 -0
- package/dist/cjs/{utils/focus → event/selection}/resolveCaretPosition.js +10 -18
- package/dist/cjs/event/selection/selectAll.js +48 -0
- package/dist/cjs/event/selection/setSelection.js +30 -0
- package/dist/cjs/event/selection/setSelectionPerMouse.js +91 -0
- package/dist/cjs/event/selection/setSelectionRange.js +40 -0
- package/dist/cjs/event/selection/updateSelectionOnFocus.js +46 -0
- package/dist/cjs/event/wrapEvent.js +3 -2
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/keyboard/index.js +13 -23
- package/dist/cjs/keyboard/parseKeyDef.js +9 -17
- package/dist/cjs/options.js +0 -28
- package/dist/cjs/pointer/index.js +28 -38
- package/dist/cjs/pointer/keyMap.js +1 -1
- package/dist/cjs/pointer/parseKeyDef.js +2 -10
- package/dist/cjs/setup/api.js +19 -17
- package/dist/cjs/setup/directApi.js +6 -6
- package/dist/cjs/setup/index.js +0 -2
- package/dist/cjs/setup/setup.js +70 -42
- package/dist/cjs/setup/wrapAsync.js +3 -2
- package/dist/cjs/system/index.js +15 -2
- package/dist/cjs/system/keyboard.js +34 -21
- package/dist/cjs/system/pointer/buttons.js +14 -1
- package/dist/cjs/system/pointer/device.js +14 -1
- package/dist/cjs/system/pointer/index.js +60 -45
- package/dist/cjs/system/pointer/mouse.js +77 -56
- package/dist/cjs/system/pointer/pointer.js +56 -42
- package/dist/cjs/system/pointer/shared.js +10 -0
- package/dist/cjs/utility/clear.js +10 -11
- package/dist/cjs/utility/selectOptions.js +28 -29
- package/dist/cjs/utility/type.js +6 -15
- package/dist/cjs/utility/upload.js +9 -18
- package/dist/cjs/utils/dataTransfer/Clipboard.js +26 -24
- package/dist/cjs/utils/dataTransfer/DataTransfer.js +25 -9
- package/dist/cjs/utils/edit/isEditable.js +6 -10
- package/dist/cjs/utils/edit/maxLength.js +6 -17
- package/dist/cjs/utils/edit/setFiles.js +4 -4
- package/dist/cjs/utils/edit/{buildTimeValue.js → timeValue.js} +6 -0
- package/dist/cjs/utils/focus/cursor.js +2 -18
- package/dist/cjs/utils/focus/getActiveElement.js +4 -3
- package/dist/cjs/utils/focus/selection.js +1 -271
- package/dist/cjs/utils/focus/selector.js +1 -1
- package/dist/cjs/utils/index.js +7 -32
- package/dist/cjs/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/cjs/utils/misc/getTreeDiff.js +3 -3
- package/dist/cjs/utils/misc/getWindow.js +3 -2
- package/dist/cjs/utils/misc/isDisabled.js +3 -3
- package/dist/cjs/utils/misc/isVisible.js +3 -2
- package/dist/cjs/utils/misc/level.js +4 -9
- package/dist/cjs/utils/misc/wait.js +1 -1
- package/dist/cjs/utils/pointer/cssPointerEvents.js +31 -40
- package/dist/esm/_interop/dtl.js +6 -0
- package/dist/esm/_interop/dtlEventMap.js +6 -0
- package/dist/esm/_interop/dtlHelpers.js +6 -0
- package/dist/esm/clipboard/copy.js +6 -16
- package/dist/esm/clipboard/cut.js +6 -16
- package/dist/esm/clipboard/paste.js +6 -16
- package/dist/esm/convenience/click.js +1 -4
- package/dist/esm/convenience/hover.js +2 -12
- package/dist/esm/convenience/tab.js +1 -1
- 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 +87 -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 -40
- package/dist/esm/event/behavior/keypress.js +12 -12
- package/dist/esm/event/behavior/keyup.js +6 -8
- package/dist/esm/event/behavior/paste.js +7 -13
- package/dist/esm/event/createEvent.js +43 -50
- package/dist/esm/event/dispatchEvent.js +20 -4
- package/dist/esm/event/eventMap.js +2 -2
- package/dist/esm/event/focus.js +39 -0
- package/dist/esm/event/index.js +14 -19
- package/dist/esm/{utils/edit → event}/input.js +39 -37
- 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 +37 -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 +46 -0
- package/dist/esm/event/selection/moveSelection.js +44 -0
- package/dist/esm/{utils/focus → event/selection}/resolveCaretPosition.js +9 -17
- package/dist/esm/event/selection/selectAll.js +43 -0
- package/dist/esm/event/selection/setSelection.js +26 -0
- package/dist/esm/event/selection/setSelectionPerMouse.js +87 -0
- package/dist/esm/event/selection/setSelectionRange.js +36 -0
- package/dist/esm/event/selection/updateSelectionOnFocus.js +42 -0
- package/dist/esm/event/wrapEvent.js +2 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/keyboard/index.js +13 -23
- package/dist/esm/keyboard/parseKeyDef.js +9 -17
- package/dist/esm/options.js +1 -26
- package/dist/esm/pointer/index.js +28 -38
- package/dist/esm/pointer/keyMap.js +1 -1
- package/dist/esm/pointer/parseKeyDef.js +2 -10
- package/dist/esm/setup/api.js +33 -12
- package/dist/esm/setup/directApi.js +6 -6
- package/dist/esm/setup/index.js +0 -1
- package/dist/esm/setup/setup.js +66 -39
- package/dist/esm/setup/wrapAsync.js +2 -1
- package/dist/esm/system/index.js +15 -2
- package/dist/esm/system/keyboard.js +34 -21
- package/dist/esm/system/pointer/buttons.js +14 -1
- package/dist/esm/system/pointer/device.js +14 -1
- package/dist/esm/system/pointer/index.js +61 -45
- package/dist/esm/system/pointer/mouse.js +74 -53
- package/dist/esm/system/pointer/pointer.js +55 -41
- package/dist/esm/system/pointer/shared.js +6 -0
- package/dist/esm/utility/clear.js +10 -11
- package/dist/esm/utility/selectOptions.js +24 -25
- package/dist/esm/utility/type.js +5 -14
- package/dist/esm/utility/upload.js +9 -18
- package/dist/esm/utils/dataTransfer/Clipboard.js +26 -24
- package/dist/esm/utils/dataTransfer/DataTransfer.js +25 -9
- package/dist/esm/utils/edit/isEditable.js +4 -8
- package/dist/esm/utils/edit/maxLength.js +5 -17
- package/dist/esm/utils/edit/setFiles.js +4 -4
- package/dist/esm/utils/edit/{buildTimeValue.js → timeValue.js} +6 -1
- package/dist/esm/utils/focus/cursor.js +2 -18
- package/dist/esm/utils/focus/getActiveElement.js +4 -3
- package/dist/esm/utils/focus/selection.js +3 -265
- package/dist/esm/utils/focus/selector.js +1 -1
- package/dist/esm/utils/index.js +4 -11
- package/dist/esm/utils/keyDef/readNextDescriptor.js +5 -5
- package/dist/esm/utils/misc/getTreeDiff.js +3 -3
- package/dist/esm/utils/misc/getWindow.js +2 -1
- package/dist/esm/utils/misc/isDisabled.js +3 -3
- package/dist/esm/utils/misc/isVisible.js +3 -2
- package/dist/esm/utils/misc/level.js +4 -9
- package/dist/esm/utils/misc/wait.js +1 -1
- package/dist/esm/utils/pointer/cssPointerEvents.js +31 -40
- package/dist/types/_interop/dtl.d.ts +3 -0
- package/dist/types/_interop/dtlEventMap.d.ts +3 -0
- package/dist/types/_interop/dtlHelpers.d.ts +3 -0
- 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/convenience/tab.d.ts +1 -1
- package/dist/types/document/UI.d.ts +42 -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 +6 -3
- 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/createEvent.d.ts +1 -1
- package/dist/types/event/dispatchEvent.d.ts +5 -2
- package/dist/types/event/eventMap.d.ts +8 -0
- 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/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/event/types.d.ts +3 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/types/keyboard/index.d.ts +2 -2
- package/dist/types/options.d.ts +2 -10
- package/dist/types/pointer/index.d.ts +7 -7
- package/dist/types/setup/api.d.ts +23 -5
- package/dist/types/setup/directApi.d.ts +5 -5
- 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 +4 -4
- package/dist/types/system/pointer/buttons.d.ts +2 -2
- package/dist/types/system/pointer/device.d.ts +1 -1
- package/dist/types/system/pointer/index.d.ts +7 -25
- package/dist/types/system/pointer/mouse.d.ts +6 -6
- package/dist/types/system/pointer/pointer.d.ts +8 -8
- 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 +4 -4
- package/dist/types/utility/upload.d.ts +1 -1
- package/dist/types/utils/click/isClickableInput.d.ts +2 -2
- package/dist/types/utils/dataTransfer/Clipboard.d.ts +1 -1
- package/dist/types/utils/edit/isEditable.d.ts +6 -7
- 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/keyDef/readNextDescriptor.d.ts +1 -1
- package/dist/types/utils/misc/isElementType.d.ts +1 -1
- 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 +24 -12
- package/dist/cjs/document/selection.js +0 -108
- 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/selection.js +0 -100
- package/dist/esm/document/setRangeText.js +0 -17
- package/dist/esm/document/value.js +0 -117
- 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/focus/selectAll.js +0 -51
- 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
- /package/dist/cjs/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/cjs/{utils/misc → _interop}/dom-helpers.d.js +0 -0
- /package/dist/esm/{event → _interop}/dom-events.d.js +0 -0
- /package/dist/esm/{utils/misc → _interop}/dom-helpers.d.js +0 -0
- /package/dist/types/{utils/focus → document}/copySelection.d.ts +0 -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
|
@@ -1,91 +1,102 @@
|
|
|
1
|
-
import { dispatchUIEvent } from '../../event/index.js';
|
|
2
1
|
import '../../utils/click/isClickableInput.js';
|
|
3
2
|
import '../../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../../utils/edit/maxLength.js';
|
|
5
3
|
import '../../utils/edit/isEditable.js';
|
|
6
|
-
import '
|
|
4
|
+
import '../../utils/edit/maxLength.js';
|
|
7
5
|
import '@testing-library/dom/dist/helpers.js';
|
|
8
6
|
import '../../utils/keyDef/readNextDescriptor.js';
|
|
9
7
|
import { getTreeDiff } from '../../utils/misc/getTreeDiff.js';
|
|
10
8
|
import '../../utils/misc/level.js';
|
|
11
9
|
import { assertPointerEvents, hasPointerEvents } from '../../utils/pointer/cssPointerEvents.js';
|
|
12
|
-
import { isDifferentPointerPosition } from './
|
|
10
|
+
import { isDifferentPointerPosition } from './shared.js';
|
|
13
11
|
|
|
12
|
+
function _define_property(obj, key, value) {
|
|
13
|
+
if (key in obj) {
|
|
14
|
+
Object.defineProperty(obj, key, {
|
|
15
|
+
value: value,
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true
|
|
19
|
+
});
|
|
20
|
+
} else {
|
|
21
|
+
obj[key] = value;
|
|
22
|
+
}
|
|
23
|
+
return obj;
|
|
24
|
+
}
|
|
14
25
|
class Pointer {
|
|
15
|
-
init(
|
|
26
|
+
init(instance, position) {
|
|
16
27
|
this.position = position;
|
|
17
|
-
const target = this.getTarget(
|
|
28
|
+
const target = this.getTarget(instance);
|
|
18
29
|
const [, enter] = getTreeDiff(null, target);
|
|
19
30
|
const init = this.getEventInit();
|
|
20
|
-
assertPointerEvents(
|
|
21
|
-
dispatchUIEvent(
|
|
22
|
-
enter.forEach((el)=>dispatchUIEvent(
|
|
31
|
+
assertPointerEvents(instance, target);
|
|
32
|
+
instance.dispatchUIEvent(target, 'pointerover', init);
|
|
33
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
|
|
23
34
|
return this;
|
|
24
35
|
}
|
|
25
|
-
move(
|
|
36
|
+
move(instance, position) {
|
|
26
37
|
const prevPosition = this.position;
|
|
27
|
-
const prevTarget = this.getTarget(
|
|
38
|
+
const prevTarget = this.getTarget(instance);
|
|
28
39
|
this.position = position;
|
|
29
40
|
if (!isDifferentPointerPosition(prevPosition, position)) {
|
|
30
41
|
return;
|
|
31
42
|
}
|
|
32
|
-
const nextTarget = this.getTarget(
|
|
43
|
+
const nextTarget = this.getTarget(instance);
|
|
33
44
|
const init = this.getEventInit();
|
|
34
45
|
const [leave, enter] = getTreeDiff(prevTarget, nextTarget);
|
|
35
46
|
return {
|
|
36
47
|
leave: ()=>{
|
|
37
|
-
if (hasPointerEvents(
|
|
48
|
+
if (hasPointerEvents(instance, prevTarget)) {
|
|
38
49
|
if (prevTarget !== nextTarget) {
|
|
39
|
-
dispatchUIEvent(
|
|
40
|
-
leave.forEach((el)=>dispatchUIEvent(
|
|
50
|
+
instance.dispatchUIEvent(prevTarget, 'pointerout', init);
|
|
51
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
|
|
41
52
|
}
|
|
42
53
|
}
|
|
43
54
|
},
|
|
44
55
|
enter: ()=>{
|
|
45
|
-
assertPointerEvents(
|
|
56
|
+
assertPointerEvents(instance, nextTarget);
|
|
46
57
|
if (prevTarget !== nextTarget) {
|
|
47
|
-
dispatchUIEvent(
|
|
48
|
-
enter.forEach((el)=>dispatchUIEvent(
|
|
58
|
+
instance.dispatchUIEvent(nextTarget, 'pointerover', init);
|
|
59
|
+
enter.forEach((el)=>instance.dispatchUIEvent(el, 'pointerenter', init));
|
|
49
60
|
}
|
|
50
61
|
},
|
|
51
62
|
move: ()=>{
|
|
52
|
-
dispatchUIEvent(
|
|
63
|
+
instance.dispatchUIEvent(nextTarget, 'pointermove', init);
|
|
53
64
|
}
|
|
54
65
|
};
|
|
55
66
|
}
|
|
56
|
-
down(
|
|
67
|
+
down(instance, _keyDef) {
|
|
57
68
|
if (this.isDown) {
|
|
58
69
|
return;
|
|
59
70
|
}
|
|
60
|
-
const target = this.getTarget(
|
|
61
|
-
assertPointerEvents(
|
|
71
|
+
const target = this.getTarget(instance);
|
|
72
|
+
assertPointerEvents(instance, target);
|
|
62
73
|
this.isDown = true;
|
|
63
|
-
this.isPrevented = !dispatchUIEvent(
|
|
74
|
+
this.isPrevented = !instance.dispatchUIEvent(target, 'pointerdown', this.getEventInit());
|
|
64
75
|
}
|
|
65
|
-
up(
|
|
76
|
+
up(instance, _keyDef) {
|
|
66
77
|
if (!this.isDown) {
|
|
67
78
|
return;
|
|
68
79
|
}
|
|
69
|
-
const target = this.getTarget(
|
|
70
|
-
assertPointerEvents(
|
|
80
|
+
const target = this.getTarget(instance);
|
|
81
|
+
assertPointerEvents(instance, target);
|
|
71
82
|
this.isDown = false;
|
|
72
|
-
dispatchUIEvent(
|
|
83
|
+
instance.dispatchUIEvent(target, 'pointerup', this.getEventInit());
|
|
73
84
|
}
|
|
74
|
-
release(
|
|
75
|
-
const target = this.getTarget(
|
|
85
|
+
release(instance) {
|
|
86
|
+
const target = this.getTarget(instance);
|
|
76
87
|
const [leave] = getTreeDiff(target, null);
|
|
77
88
|
const init = this.getEventInit();
|
|
78
89
|
// Currently there is no PointerEventsCheckLevel that would
|
|
79
90
|
// make this check not use the *asserted* cached value from `up`.
|
|
80
|
-
/* istanbul ignore else */ if (hasPointerEvents(
|
|
81
|
-
dispatchUIEvent(
|
|
82
|
-
leave.forEach((el)=>dispatchUIEvent(
|
|
91
|
+
/* istanbul ignore else */ if (hasPointerEvents(instance, target)) {
|
|
92
|
+
instance.dispatchUIEvent(target, 'pointerout', init);
|
|
93
|
+
leave.forEach((el)=>instance.dispatchUIEvent(el, 'pointerleave', init));
|
|
83
94
|
}
|
|
84
95
|
this.isCancelled = true;
|
|
85
96
|
}
|
|
86
|
-
getTarget(
|
|
87
|
-
var
|
|
88
|
-
return (
|
|
97
|
+
getTarget(instance) {
|
|
98
|
+
var _this_position_target;
|
|
99
|
+
return (_this_position_target = this.position.target) !== null && _this_position_target !== void 0 ? _this_position_target : instance.config.document.body;
|
|
89
100
|
}
|
|
90
101
|
getEventInit() {
|
|
91
102
|
return {
|
|
@@ -95,12 +106,15 @@ class Pointer {
|
|
|
95
106
|
isPrimary: this.isPrimary
|
|
96
107
|
};
|
|
97
108
|
}
|
|
98
|
-
constructor({ pointerId
|
|
99
|
-
this
|
|
100
|
-
this
|
|
101
|
-
this
|
|
102
|
-
this
|
|
103
|
-
this
|
|
109
|
+
constructor({ pointerId, pointerType, isPrimary }){
|
|
110
|
+
_define_property(this, "pointerId", void 0);
|
|
111
|
+
_define_property(this, "pointerType", void 0);
|
|
112
|
+
_define_property(this, "isPrimary", void 0);
|
|
113
|
+
_define_property(this, "isMultitouch", false);
|
|
114
|
+
_define_property(this, "isCancelled", false);
|
|
115
|
+
_define_property(this, "isDown", false);
|
|
116
|
+
_define_property(this, "isPrevented", false);
|
|
117
|
+
_define_property(this, "position", {});
|
|
104
118
|
this.pointerId = pointerId;
|
|
105
119
|
this.pointerType = pointerType;
|
|
106
120
|
this.isPrimary = isPrimary;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
function isDifferentPointerPosition(positionA, positionB) {
|
|
2
|
+
var _positionA_coords, _positionB_coords, _positionA_coords1, _positionB_coords1, _positionA_caret, _positionB_caret, _positionA_caret1, _positionB_caret1;
|
|
3
|
+
return positionA.target !== positionB.target || ((_positionA_coords = positionA.coords) === null || _positionA_coords === void 0 ? void 0 : _positionA_coords.x) !== ((_positionB_coords = positionB.coords) === null || _positionB_coords === void 0 ? void 0 : _positionB_coords.y) || ((_positionA_coords1 = positionA.coords) === null || _positionA_coords1 === void 0 ? void 0 : _positionA_coords1.y) !== ((_positionB_coords1 = positionB.coords) === null || _positionB_coords1 === void 0 ? void 0 : _positionB_coords1.y) || ((_positionA_caret = positionA.caret) === null || _positionA_caret === void 0 ? void 0 : _positionA_caret.node) !== ((_positionB_caret = positionB.caret) === null || _positionB_caret === void 0 ? void 0 : _positionB_caret.node) || ((_positionA_caret1 = positionA.caret) === null || _positionA_caret1 === void 0 ? void 0 : _positionA_caret1.offset) !== ((_positionB_caret1 = positionB.caret) === null || _positionB_caret1 === void 0 ? void 0 : _positionB_caret1.offset);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export { isDifferentPointerPosition };
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import '../setup/index.js';
|
|
2
|
-
import '../utils/click/isClickableInput.js';
|
|
3
|
-
import '../utils/dataTransfer/Clipboard.js';
|
|
4
|
-
import '../event/eventMap.js';
|
|
5
1
|
import '../event/behavior/click.js';
|
|
6
2
|
import '../event/behavior/cut.js';
|
|
7
3
|
import '../event/behavior/keydown.js';
|
|
@@ -9,22 +5,25 @@ import '../event/behavior/keypress.js';
|
|
|
9
5
|
import '../event/behavior/keyup.js';
|
|
10
6
|
import '../event/behavior/paste.js';
|
|
11
7
|
import '@testing-library/dom';
|
|
12
|
-
import
|
|
8
|
+
import '../event/eventMap.js';
|
|
9
|
+
import '../utils/click/isClickableInput.js';
|
|
10
|
+
import '../utils/dataTransfer/Clipboard.js';
|
|
13
11
|
import { isEditable } from '../utils/edit/isEditable.js';
|
|
14
|
-
import
|
|
15
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
12
|
+
import '../utils/edit/maxLength.js';
|
|
16
13
|
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
17
|
-
import
|
|
14
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
18
15
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
19
16
|
import '../utils/misc/level.js';
|
|
20
17
|
import '../options.js';
|
|
21
|
-
import {
|
|
18
|
+
import { focusElement } from '../event/focus.js';
|
|
19
|
+
import { input } from '../event/input.js';
|
|
20
|
+
import { selectAll, isAllSelected } from '../event/selection/selectAll.js';
|
|
22
21
|
|
|
23
22
|
async function clear(element) {
|
|
24
23
|
if (!isEditable(element) || isDisabled(element)) {
|
|
25
24
|
throw new Error('clear()` is only supported on editable elements.');
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
focusElement(element);
|
|
28
27
|
if (element.ownerDocument.activeElement !== element) {
|
|
29
28
|
throw new Error('The element to be cleared could not be focused.');
|
|
30
29
|
}
|
|
@@ -32,7 +31,7 @@ async function clear(element) {
|
|
|
32
31
|
if (!isAllSelected(element)) {
|
|
33
32
|
throw new Error('The element content to be cleared could not be selected.');
|
|
34
33
|
}
|
|
35
|
-
input(this
|
|
34
|
+
input(this, element, '', 'deleteContentBackward');
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
export { clear };
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import dtl from '../_interop/dtl.js';
|
|
2
2
|
import '../utils/click/isClickableInput.js';
|
|
3
3
|
import '../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 '../utils/edit/maxLength.js';
|
|
12
4
|
import '../utils/edit/isEditable.js';
|
|
13
|
-
import
|
|
14
|
-
import '@testing-library/dom/dist/helpers.js';
|
|
15
|
-
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
5
|
+
import '../utils/edit/maxLength.js';
|
|
16
6
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
7
|
+
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
8
|
+
import '@testing-library/dom/dist/helpers.js';
|
|
17
9
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
18
10
|
import '../utils/misc/level.js';
|
|
19
11
|
import { wait } from '../utils/misc/wait.js';
|
|
20
12
|
import { hasPointerEvents } from '../utils/pointer/cssPointerEvents.js';
|
|
21
|
-
import '../
|
|
22
|
-
import
|
|
13
|
+
import '../event/behavior/click.js';
|
|
14
|
+
import '../event/behavior/cut.js';
|
|
15
|
+
import '../event/behavior/keydown.js';
|
|
16
|
+
import '../event/behavior/keypress.js';
|
|
17
|
+
import '../event/behavior/keyup.js';
|
|
18
|
+
import '../event/behavior/paste.js';
|
|
19
|
+
import '../event/eventMap.js';
|
|
20
|
+
import { focusElement } from '../event/focus.js';
|
|
23
21
|
|
|
22
|
+
const { getConfig } = dtl;
|
|
24
23
|
async function selectOptions(select, values) {
|
|
25
24
|
return selectOptionsBase.call(this, true, select, values);
|
|
26
25
|
}
|
|
@@ -60,7 +59,7 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
60
59
|
if (isElementType(select, 'select')) {
|
|
61
60
|
if (select.multiple) {
|
|
62
61
|
for (const option of selectedOptions){
|
|
63
|
-
const withPointerEvents = this
|
|
62
|
+
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, option);
|
|
64
63
|
// events fired for multiple select are weird. Can't use hover...
|
|
65
64
|
if (withPointerEvents) {
|
|
66
65
|
this.dispatchUIEvent(option, 'pointerover');
|
|
@@ -72,7 +71,7 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
72
71
|
this.dispatchUIEvent(option, 'pointerdown');
|
|
73
72
|
this.dispatchUIEvent(option, 'mousedown');
|
|
74
73
|
}
|
|
75
|
-
|
|
74
|
+
focusElement(select);
|
|
76
75
|
if (withPointerEvents) {
|
|
77
76
|
this.dispatchUIEvent(option, 'pointerup');
|
|
78
77
|
this.dispatchUIEvent(option, 'mouseup');
|
|
@@ -81,18 +80,18 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
81
80
|
if (withPointerEvents) {
|
|
82
81
|
this.dispatchUIEvent(option, 'click');
|
|
83
82
|
}
|
|
84
|
-
await wait(this
|
|
83
|
+
await wait(this.config);
|
|
85
84
|
}
|
|
86
85
|
} else if (selectedOptions.length === 1) {
|
|
87
|
-
const
|
|
86
|
+
const withPointerEvents = this.config.pointerEventsCheck === 0 ? true : hasPointerEvents(this, select);
|
|
88
87
|
// the click to open the select options
|
|
89
|
-
if (
|
|
88
|
+
if (withPointerEvents) {
|
|
90
89
|
await this.click(select);
|
|
91
90
|
} else {
|
|
92
|
-
|
|
91
|
+
focusElement(select);
|
|
93
92
|
}
|
|
94
93
|
selectOption(selectedOptions[0]);
|
|
95
|
-
if (
|
|
94
|
+
if (withPointerEvents) {
|
|
96
95
|
// the browser triggers another click event on the select for the click on the option
|
|
97
96
|
// this second click has no 'down' phase
|
|
98
97
|
this.dispatchUIEvent(select, 'pointerover');
|
|
@@ -103,14 +102,14 @@ async function selectOptionsBase(newValue, select, values) {
|
|
|
103
102
|
this.dispatchUIEvent(select, 'mouseup');
|
|
104
103
|
this.dispatchUIEvent(select, 'click');
|
|
105
104
|
}
|
|
106
|
-
await wait(this
|
|
105
|
+
await wait(this.config);
|
|
107
106
|
} else {
|
|
108
107
|
throw getConfig().getElementError(`Cannot select multiple options on a non-multiple select`, select);
|
|
109
108
|
}
|
|
110
109
|
} else if (select.getAttribute('role') === 'listbox') {
|
|
111
|
-
for (const
|
|
112
|
-
await this.click(
|
|
113
|
-
await this.unhover(
|
|
110
|
+
for (const option of selectedOptions){
|
|
111
|
+
await this.click(option);
|
|
112
|
+
await this.unhover(option);
|
|
114
113
|
}
|
|
115
114
|
} else {
|
|
116
115
|
throw getConfig().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
|
package/dist/esm/utility/type.js
CHANGED
|
@@ -1,24 +1,15 @@
|
|
|
1
|
+
import { releaseAllKeys } from '../keyboard/index.js';
|
|
1
2
|
import '../utils/click/isClickableInput.js';
|
|
2
3
|
import '../utils/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
|
-
import '../utils/edit/maxLength.js';
|
|
12
4
|
import '../utils/edit/isEditable.js';
|
|
13
|
-
import
|
|
5
|
+
import '../utils/edit/maxLength.js';
|
|
14
6
|
import '@testing-library/dom/dist/helpers.js';
|
|
15
7
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
16
8
|
import '../utils/misc/level.js';
|
|
17
9
|
import '../options.js';
|
|
18
|
-
import {
|
|
19
|
-
import { Config } from '../setup/config.js';
|
|
10
|
+
import { setSelectionRange } from '../event/selection/setSelectionRange.js';
|
|
20
11
|
|
|
21
|
-
async function type(element, text, { skipClick =this
|
|
12
|
+
async function type(element, text, { skipClick = this.config.skipClick, skipAutoClose = this.config.skipAutoClose, initialSelectionStart, initialSelectionEnd } = {}) {
|
|
22
13
|
// TODO: properly type guard
|
|
23
14
|
// we use this workaround for now to prevent changing behavior
|
|
24
15
|
if (element.disabled) return;
|
|
@@ -30,7 +21,7 @@ async function type(element, text, { skipClick =this[Config].skipClick , skipAut
|
|
|
30
21
|
}
|
|
31
22
|
await this.keyboard(text);
|
|
32
23
|
if (!skipAutoClose) {
|
|
33
|
-
await releaseAllKeys(this
|
|
24
|
+
await releaseAllKeys(this);
|
|
34
25
|
}
|
|
35
26
|
}
|
|
36
27
|
|
|
@@ -1,43 +1,34 @@
|
|
|
1
1
|
import '../utils/click/isClickableInput.js';
|
|
2
2
|
import { createFileList } from '../utils/dataTransfer/FileList.js';
|
|
3
3
|
import '../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
4
|
import '../utils/edit/isEditable.js';
|
|
5
|
+
import '../utils/edit/maxLength.js';
|
|
14
6
|
import { setFiles } from '../utils/edit/setFiles.js';
|
|
15
|
-
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
16
7
|
import { isElementType } from '../utils/misc/isElementType.js';
|
|
8
|
+
import { isDisabled } from '../utils/misc/isDisabled.js';
|
|
17
9
|
import { getWindow } from '../utils/misc/getWindow.js';
|
|
18
10
|
import '../utils/keyDef/readNextDescriptor.js';
|
|
19
11
|
import '../utils/misc/level.js';
|
|
20
12
|
import '../options.js';
|
|
21
|
-
import '../setup/index.js';
|
|
22
|
-
import { Config } from '../setup/config.js';
|
|
23
13
|
|
|
24
14
|
async function upload(element, fileOrFiles) {
|
|
25
15
|
const input = isElementType(element, 'label') ? element.control : element;
|
|
26
16
|
if (!input || !isElementType(input, 'input', {
|
|
27
17
|
type: 'file'
|
|
28
18
|
})) {
|
|
29
|
-
|
|
19
|
+
var _input;
|
|
20
|
+
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${(_input = input) === null || _input === void 0 ? void 0 : _input.tagName} element does not accept file uploads`);
|
|
30
21
|
}
|
|
31
22
|
if (isDisabled(element)) return;
|
|
32
23
|
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [
|
|
33
24
|
fileOrFiles
|
|
34
|
-
]).filter((file)=>!this
|
|
25
|
+
]).filter((file)=>!this.config.applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1);
|
|
35
26
|
const fileDialog = ()=>{
|
|
36
|
-
var
|
|
27
|
+
var _input_files;
|
|
37
28
|
// do not fire an input event if the file selection does not change
|
|
38
|
-
if (files.length === ((
|
|
39
|
-
var
|
|
40
|
-
return f === ((
|
|
29
|
+
if (files.length === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.length) && files.every((f, i)=>{
|
|
30
|
+
var _input_files;
|
|
31
|
+
return f === ((_input_files = input.files) === null || _input_files === void 0 ? void 0 : _input_files.item(i));
|
|
41
32
|
})) {
|
|
42
33
|
return;
|
|
43
34
|
}
|
|
@@ -1,29 +1,28 @@
|
|
|
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
|
|
6
|
+
function _define_property(obj, key, value) {
|
|
7
|
+
if (key in obj) {
|
|
8
|
+
Object.defineProperty(obj, key, {
|
|
9
|
+
value: value,
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true
|
|
13
|
+
});
|
|
14
|
+
} else {
|
|
15
|
+
obj[key] = value;
|
|
16
|
+
}
|
|
17
|
+
return obj;
|
|
18
|
+
}
|
|
20
19
|
// MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData
|
|
21
20
|
// lib.dom.d.ts lists only Promise<Blob|string>
|
|
22
21
|
// https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/ClipboardItem#syntax
|
|
23
22
|
function createClipboardItem(window, ...blobs) {
|
|
24
23
|
const dataMap = Object.fromEntries(blobs.map((b)=>[
|
|
25
24
|
typeof b === 'string' ? 'text/plain' : b.type,
|
|
26
|
-
Promise.resolve(b)
|
|
25
|
+
Promise.resolve(b)
|
|
27
26
|
]));
|
|
28
27
|
// use real ClipboardItem if available
|
|
29
28
|
/* istanbul ignore if */ if (typeof window.ClipboardItem !== 'undefined') {
|
|
@@ -45,6 +44,7 @@ function createClipboardItem(window, ...blobs) {
|
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
46
|
constructor(d){
|
|
47
|
+
_define_property(this, "data", void 0);
|
|
48
48
|
this.data = d;
|
|
49
49
|
}
|
|
50
50
|
}(dataMap);
|
|
@@ -75,15 +75,15 @@ function createClipboardStub(window, control) {
|
|
|
75
75
|
}
|
|
76
76
|
constructor(...args){
|
|
77
77
|
super(...args);
|
|
78
|
-
this
|
|
78
|
+
_define_property(this, "items", []);
|
|
79
79
|
}
|
|
80
80
|
}(), {
|
|
81
81
|
[ClipboardStubControl]: control
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
84
|
function isClipboardStub(clipboard) {
|
|
85
|
-
var
|
|
86
|
-
return !!((
|
|
85
|
+
var _clipboard;
|
|
86
|
+
return !!((_clipboard = clipboard) === null || _clipboard === void 0 ? void 0 : _clipboard[ClipboardStubControl]);
|
|
87
87
|
}
|
|
88
88
|
function attachClipboardStubToView(window) {
|
|
89
89
|
if (isClipboardStub(window.navigator.clipboard)) {
|
|
@@ -124,8 +124,9 @@ function detachClipboardStubFromView(window) {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
async function readDataTransferFromClipboard(document) {
|
|
127
|
+
var _window;
|
|
127
128
|
const window = document.defaultView;
|
|
128
|
-
const clipboard = window === null ||
|
|
129
|
+
const clipboard = (_window = window) === null || _window === void 0 ? void 0 : _window.navigator.clipboard;
|
|
129
130
|
const items = clipboard && await clipboard.read();
|
|
130
131
|
if (!items) {
|
|
131
132
|
throw new Error('The Clipboard API is unavailable.');
|
|
@@ -153,11 +154,12 @@ async function writeDataTransferToClipboard(document, clipboardData) {
|
|
|
153
154
|
throw new Error('The Clipboard API is unavailable.');
|
|
154
155
|
}
|
|
155
156
|
}
|
|
156
|
-
|
|
157
|
-
|
|
157
|
+
const g = globalThis;
|
|
158
|
+
/* istanbul ignore else */ if (typeof g.afterEach === 'function') {
|
|
159
|
+
g.afterEach(()=>resetClipboardStubOnView(globalThis.window));
|
|
158
160
|
}
|
|
159
|
-
/* istanbul ignore else */ if (typeof
|
|
160
|
-
|
|
161
|
+
/* istanbul ignore else */ if (typeof g.afterAll === 'function') {
|
|
162
|
+
g.afterAll(()=>detachClipboardStubFromView(globalThis.window));
|
|
161
163
|
}
|
|
162
164
|
|
|
163
165
|
export { attachClipboardStubToView, createClipboardItem, detachClipboardStubFromView, readDataTransferFromClipboard, resetClipboardStubOnView, writeDataTransferToClipboard };
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import { createFileList } from './FileList.js';
|
|
2
2
|
|
|
3
|
+
function _define_property(obj, key, value) {
|
|
4
|
+
if (key in obj) {
|
|
5
|
+
Object.defineProperty(obj, key, {
|
|
6
|
+
value: value,
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true
|
|
10
|
+
});
|
|
11
|
+
} else {
|
|
12
|
+
obj[key] = value;
|
|
13
|
+
}
|
|
14
|
+
return obj;
|
|
15
|
+
}
|
|
3
16
|
// DataTransfer is not implemented in jsdom.
|
|
4
17
|
// DataTransfer with FileList is being created by the browser on certain events.
|
|
5
18
|
class DataTransferItemStub {
|
|
@@ -15,8 +28,10 @@ class DataTransferItemStub {
|
|
|
15
28
|
throw new Error('not implemented');
|
|
16
29
|
}
|
|
17
30
|
constructor(dataOrFile, type){
|
|
18
|
-
this
|
|
19
|
-
this
|
|
31
|
+
_define_property(this, "kind", void 0);
|
|
32
|
+
_define_property(this, "type", void 0);
|
|
33
|
+
_define_property(this, "file", null);
|
|
34
|
+
_define_property(this, "data", undefined);
|
|
20
35
|
if (typeof dataOrFile === 'string') {
|
|
21
36
|
this.kind = 'string';
|
|
22
37
|
this.type = String(type);
|
|
@@ -51,10 +66,11 @@ function getTypeMatcher(type, exact) {
|
|
|
51
66
|
function createDataTransferStub(window) {
|
|
52
67
|
return new class DataTransferStub {
|
|
53
68
|
getData(format) {
|
|
54
|
-
var
|
|
55
|
-
|
|
69
|
+
var _match;
|
|
70
|
+
var _this_items_find;
|
|
71
|
+
const match = (_this_items_find = this.items.find(getTypeMatcher(format, true))) !== null && _this_items_find !== void 0 ? _this_items_find : this.items.find(getTypeMatcher(format, false));
|
|
56
72
|
let text = '';
|
|
57
|
-
match === null ||
|
|
73
|
+
(_match = match) === null || _match === void 0 ? void 0 : _match.getAsString((t)=>{
|
|
58
74
|
text = t;
|
|
59
75
|
});
|
|
60
76
|
return text;
|
|
@@ -89,10 +105,10 @@ function createDataTransferStub(window) {
|
|
|
89
105
|
}
|
|
90
106
|
/* istanbul ignore next */ setDragImage() {}
|
|
91
107
|
constructor(){
|
|
92
|
-
this
|
|
93
|
-
this
|
|
94
|
-
this
|
|
95
|
-
this
|
|
108
|
+
_define_property(this, "dropEffect", 'none');
|
|
109
|
+
_define_property(this, "effectAllowed", 'uninitialized');
|
|
110
|
+
_define_property(this, "items", new DataTransferItemListStub());
|
|
111
|
+
_define_property(this, "files", createFileList(window, []));
|
|
96
112
|
}
|
|
97
113
|
}();
|
|
98
114
|
}
|
|
@@ -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,26 +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
|
-
var ref;
|
|
28
|
-
const attr = (ref = element.getAttribute('maxlength')) !== null && ref !== void 0 ? ref : '';
|
|
14
|
+
function getMaxLength(element) {
|
|
15
|
+
var _element_getAttribute;
|
|
16
|
+
const attr = (_element_getAttribute = element.getAttribute('maxlength')) !== null && _element_getAttribute !== void 0 ? _element_getAttribute : '';
|
|
29
17
|
return /^\d+$/.test(attr) && Number(attr) >= 0 ? Number(attr) : undefined;
|
|
30
18
|
}
|
|
31
19
|
function supportsMaxLength(element) {
|
|
32
|
-
return isElementType(element, 'textarea') || isElementType(element, 'input') &&
|
|
20
|
+
return isElementType(element, 'textarea') || isElementType(element, 'input') && element.type in maxLengthSupportedTypes;
|
|
33
21
|
}
|
|
34
22
|
|
|
35
|
-
export {
|
|
23
|
+
export { getMaxLength, supportsMaxLength };
|