@testing-library/user-event 14.0.0-beta.1 → 14.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -192
- package/dist/index.cjs +3003 -0
- package/dist/index.mjs +3074 -0
- package/dist/types/clipboard/copy.d.ts +2 -0
- package/dist/types/clipboard/cut.d.ts +2 -0
- package/dist/{clipboard → types/clipboard}/index.d.ts +0 -0
- package/dist/types/clipboard/paste.d.ts +2 -0
- package/dist/types/convenience/click.d.ts +4 -0
- package/dist/types/convenience/hover.d.ts +3 -0
- package/dist/{convenience → types/convenience}/index.d.ts +0 -0
- package/dist/types/convenience/tab.d.ts +4 -0
- package/dist/{document → types/document}/index.d.ts +0 -0
- package/dist/{document → types/document}/interceptor.d.ts +0 -0
- package/dist/{document → types/document}/selection.d.ts +0 -0
- package/dist/{document → types/document}/value.d.ts +0 -0
- package/dist/types/event/behavior/click.d.ts +1 -0
- package/dist/types/event/behavior/index.d.ts +3 -0
- package/dist/types/event/behavior/registry.d.ts +9 -0
- package/dist/types/event/createEvent.d.ts +8 -0
- package/dist/types/event/dispatchEvent.d.ts +2 -0
- package/dist/types/event/eventTypes.d.ts +2 -0
- package/dist/types/event/index.d.ts +6 -0
- package/dist/types/event/types.d.ts +13 -0
- package/dist/types/event/wrapEvent.d.ts +1 -0
- package/dist/{index.d.ts → types/index.d.ts} +1 -0
- package/dist/{keyboard → types/keyboard}/index.d.ts +2 -2
- package/dist/{keyboard → types/keyboard}/keyMap.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/keyboardAction.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/parseKeyDef.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/arrow.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/character.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/combination.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/control.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/plugins/functional.d.ts +0 -3
- package/dist/{keyboard → types/keyboard}/plugins/index.d.ts +0 -0
- package/dist/types/keyboard/plugins/modifiers.d.ts +8 -0
- package/dist/types/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +4 -0
- package/dist/{keyboard → types/keyboard}/shared/index.d.ts +0 -0
- package/dist/{keyboard → types/keyboard}/types.d.ts +19 -5
- package/dist/{options.d.ts → types/options.d.ts} +23 -8
- package/dist/types/pointer/firePointerEvents.d.ts +11 -0
- package/dist/{pointer → types/pointer}/index.d.ts +2 -2
- package/dist/{pointer → types/pointer}/keyMap.d.ts +0 -0
- package/dist/{pointer → types/pointer}/parseKeyDef.d.ts +0 -0
- package/dist/{pointer → types/pointer}/pointerAction.d.ts +0 -0
- package/dist/types/pointer/pointerMove.d.ts +6 -0
- package/dist/{pointer → types/pointer}/pointerPress.d.ts +2 -2
- package/dist/{pointer → types/pointer}/resolveSelectionTarget.d.ts +0 -0
- package/dist/{pointer → types/pointer}/types.d.ts +2 -1
- package/dist/{setup → types/setup}/api.d.ts +0 -0
- package/dist/{setup → types/setup}/config.d.ts +0 -0
- package/dist/{setup → types/setup}/directApi.d.ts +1 -2
- package/dist/{setup → types/setup}/index.d.ts +8 -2
- package/dist/types/setup/setup.d.ts +20 -0
- package/dist/{setup → types/setup}/wrapAsync.d.ts +0 -0
- package/dist/types/utility/clear.d.ts +2 -0
- package/dist/{utility → types/utility}/index.d.ts +0 -0
- package/dist/types/utility/selectOptions.d.ts +3 -0
- package/dist/types/utility/type.d.ts +9 -0
- package/dist/types/utility/upload.d.ts +5 -0
- package/dist/{utils → types/utils}/click/isClickableInput.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/Blob.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/Clipboard.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/DataTransfer.d.ts +0 -0
- package/dist/{utils → types/utils}/dataTransfer/FileList.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/buildTimeValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/calculateNewValue.d.ts +0 -0
- package/dist/types/utils/edit/editInputElement.d.ts +14 -0
- package/dist/{utils → types/utils}/edit/getValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isContentEditable.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isEditable.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isValidDateValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/isValidInputTimeValue.d.ts +0 -0
- package/dist/{utils → types/utils}/edit/maxLength.d.ts +0 -0
- package/dist/types/utils/edit/prepareInput.d.ts +8 -0
- package/dist/{utils → types/utils}/edit/setFiles.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/blur.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/copySelection.d.ts +0 -0
- package/dist/types/utils/focus/cursor.d.ts +9 -0
- package/dist/{utils → types/utils}/focus/focus.d.ts +3 -0
- package/dist/{utils → types/utils}/focus/getActiveElement.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/getTabDestination.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/isFocusable.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selectAll.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selection.d.ts +0 -0
- package/dist/{utils → types/utils}/focus/selector.d.ts +0 -0
- package/dist/{utils → types/utils}/index.d.ts +6 -2
- package/dist/{utils → types/utils}/keyDef/readNextDescriptor.d.ts +0 -0
- package/dist/types/utils/keyboard/getKeyEventProps.d.ts +5 -0
- package/dist/types/utils/keyboard/getUIEventModifiers.d.ts +15 -0
- package/dist/types/utils/misc/cloneEvent.d.ts +1 -0
- package/dist/{utils → types/utils}/misc/eventWrapper.d.ts +0 -0
- package/dist/types/utils/misc/findClosest.d.ts +1 -0
- package/dist/{utils → types/utils}/misc/getDocumentFromNode.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/hasFormSubmit.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isDescendantOrSelf.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isDisabled.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isElementType.d.ts +0 -0
- package/dist/{utils → types/utils}/misc/isVisible.d.ts +0 -0
- package/dist/types/utils/misc/level.d.ts +17 -0
- package/dist/{utils → types/utils}/misc/wait.d.ts +0 -0
- package/dist/types/utils/pointer/cssPointerEvents.d.ts +15 -0
- package/dist/{utils → types/utils}/pointer/mouseButtons.d.ts +0 -0
- package/package.json +13 -30
- package/CHANGELOG.md +0 -5
- package/dist/clipboard/copy.d.ts +0 -2
- package/dist/clipboard/copy.js +0 -36
- package/dist/clipboard/cut.d.ts +0 -2
- package/dist/clipboard/cut.js +0 -42
- package/dist/clipboard/index.js +0 -44
- package/dist/clipboard/paste.d.ts +0 -2
- package/dist/clipboard/paste.js +0 -47
- package/dist/convenience/click.d.ts +0 -4
- package/dist/convenience/click.js +0 -52
- package/dist/convenience/hover.d.ts +0 -3
- package/dist/convenience/hover.js +0 -31
- package/dist/convenience/index.js +0 -44
- package/dist/convenience/tab.d.ts +0 -4
- package/dist/convenience/tab.js +0 -12
- package/dist/document/index.js +0 -100
- package/dist/document/interceptor.js +0 -37
- package/dist/document/selection.js +0 -90
- package/dist/document/value.js +0 -77
- package/dist/index.js +0 -13
- package/dist/keyboard/getEventProps.d.ts +0 -15
- package/dist/keyboard/getEventProps.js +0 -27
- package/dist/keyboard/index.js +0 -42
- package/dist/keyboard/keyMap.js +0 -119
- package/dist/keyboard/keyboardAction.js +0 -156
- package/dist/keyboard/parseKeyDef.js +0 -61
- package/dist/keyboard/plugins/arrow.js +0 -28
- package/dist/keyboard/plugins/character.js +0 -173
- package/dist/keyboard/plugins/combination.js +0 -19
- package/dist/keyboard/plugins/control.js +0 -52
- package/dist/keyboard/plugins/functional.js +0 -158
- package/dist/keyboard/plugins/index.js +0 -33
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.d.ts +0 -3
- package/dist/keyboard/shared/fireChangeForInputTimeIfValid.js +0 -20
- package/dist/keyboard/shared/index.js +0 -18
- package/dist/keyboard/types.js +0 -19
- package/dist/options.js +0 -36
- package/dist/pointer/index.js +0 -56
- package/dist/pointer/keyMap.js +0 -29
- package/dist/pointer/parseKeyDef.js +0 -34
- package/dist/pointer/pointerAction.js +0 -46
- package/dist/pointer/pointerMove.d.ts +0 -6
- package/dist/pointer/pointerMove.js +0 -136
- package/dist/pointer/pointerPress.js +0 -330
- package/dist/pointer/resolveSelectionTarget.js +0 -75
- package/dist/pointer/types.js +0 -1
- package/dist/setup/api.js +0 -111
- package/dist/setup/config.js +0 -8
- package/dist/setup/directApi.js +0 -95
- package/dist/setup/index.js +0 -27
- package/dist/setup/setup.d.ts +0 -74
- package/dist/setup/setup.js +0 -98
- package/dist/setup/wrapAsync.js +0 -15
- package/dist/utility/clear.d.ts +0 -2
- package/dist/utility/clear.js +0 -30
- package/dist/utility/index.js +0 -57
- package/dist/utility/selectOptions.d.ts +0 -3
- package/dist/utility/selectOptions.js +0 -132
- package/dist/utility/type.d.ts +0 -9
- package/dist/utility/type.js +0 -37
- package/dist/utility/upload.d.ts +0 -5
- package/dist/utility/upload.js +0 -64
- package/dist/utils/click/isClickableInput.js +0 -14
- package/dist/utils/dataTransfer/Blob.js +0 -21
- package/dist/utils/dataTransfer/Clipboard.js +0 -188
- package/dist/utils/dataTransfer/DataTransfer.js +0 -158
- package/dist/utils/dataTransfer/FileList.js +0 -23
- package/dist/utils/edit/buildTimeValue.js +0 -44
- package/dist/utils/edit/calculateNewValue.js +0 -46
- package/dist/utils/edit/editInputElement.d.ts +0 -16
- package/dist/utils/edit/editInputElement.js +0 -53
- package/dist/utils/edit/getValue.js +0 -23
- package/dist/utils/edit/isContentEditable.js +0 -25
- package/dist/utils/edit/isEditable.js +0 -42
- package/dist/utils/edit/isValidDateValue.js +0 -12
- package/dist/utils/edit/isValidInputTimeValue.js +0 -12
- package/dist/utils/edit/maxLength.js +0 -50
- package/dist/utils/edit/prepareInput.d.ts +0 -7
- package/dist/utils/edit/prepareInput.js +0 -77
- package/dist/utils/edit/setFiles.js +0 -72
- package/dist/utils/focus/blur.js +0 -19
- package/dist/utils/focus/copySelection.js +0 -36
- package/dist/utils/focus/focus.js +0 -22
- package/dist/utils/focus/getActiveElement.js +0 -26
- package/dist/utils/focus/getTabDestination.js +0 -71
- package/dist/utils/focus/isFocusable.js +0 -12
- package/dist/utils/focus/selectAll.js +0 -51
- package/dist/utils/focus/selection.js +0 -190
- package/dist/utils/focus/selector.js +0 -8
- package/dist/utils/index.js +0 -499
- package/dist/utils/keyDef/readNextDescriptor.js +0 -102
- package/dist/utils/misc/eventWrapper.js +0 -16
- package/dist/utils/misc/findClosest.d.ts +0 -1
- package/dist/utils/misc/findClosest.js +0 -20
- package/dist/utils/misc/getDocumentFromNode.js +0 -14
- package/dist/utils/misc/hasFormSubmit.js +0 -10
- package/dist/utils/misc/hasPointerEvents.d.ts +0 -15
- package/dist/utils/misc/hasPointerEvents.js +0 -24
- package/dist/utils/misc/isDescendantOrSelf.js +0 -20
- package/dist/utils/misc/isDisabled.js +0 -12
- package/dist/utils/misc/isElementType.js +0 -24
- package/dist/utils/misc/isVisible.js +0 -24
- package/dist/utils/misc/wait.js +0 -10
- package/dist/utils/pointer/firePointerEvents.d.ts +0 -25
- package/dist/utils/pointer/firePointerEvents.js +0 -112
- package/dist/utils/pointer/mouseButtons.js +0 -45
package/dist/setup/config.js
DELETED
package/dist/setup/directApi.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.clear = clear;
|
|
7
|
-
exports.click = click;
|
|
8
|
-
exports.copy = copy;
|
|
9
|
-
exports.cut = cut;
|
|
10
|
-
exports.dblClick = dblClick;
|
|
11
|
-
exports.deselectOptions = deselectOptions;
|
|
12
|
-
exports.hover = hover;
|
|
13
|
-
exports.keyboard = keyboard;
|
|
14
|
-
exports.paste = paste;
|
|
15
|
-
exports.pointer = pointer;
|
|
16
|
-
exports.selectOptions = selectOptions;
|
|
17
|
-
exports.tab = tab;
|
|
18
|
-
exports.tripleClick = tripleClick;
|
|
19
|
-
exports.type = type;
|
|
20
|
-
exports.unhover = unhover;
|
|
21
|
-
exports.upload = upload;
|
|
22
|
-
|
|
23
|
-
var _setup = require("./setup");
|
|
24
|
-
|
|
25
|
-
var _config = require("./config");
|
|
26
|
-
|
|
27
|
-
function clear(element) {
|
|
28
|
-
return (0, _setup.setupDirect)().clear(element);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function click(element, options = {}) {
|
|
32
|
-
return (0, _setup.setupDirect)(options, element).click(element);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function copy(options = {}) {
|
|
36
|
-
return (0, _setup.setupDirect)(options).copy();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function cut(options = {}) {
|
|
40
|
-
return (0, _setup.setupDirect)(options).cut();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function dblClick(element, options = {}) {
|
|
44
|
-
return (0, _setup.setupDirect)(options).dblClick(element);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function deselectOptions(select, values, options = {}) {
|
|
48
|
-
return (0, _setup.setupDirect)(options).deselectOptions(select, values);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function hover(element, options = {}) {
|
|
52
|
-
return (0, _setup.setupDirect)(options).hover(element);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
async function keyboard(text, options = {}) {
|
|
56
|
-
const instance = (0, _setup.setupDirect)(options);
|
|
57
|
-
const promise = instance.keyboard(text);
|
|
58
|
-
return promise.then(() => instance[_config.Config].keyboardState);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function pointer(input, options = {}) {
|
|
62
|
-
const instance = (0, _setup.setupDirect)(options);
|
|
63
|
-
const promise = instance.pointer(input);
|
|
64
|
-
return promise.then(() => instance[_config.Config].pointerState);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function paste(clipboardData, options) {
|
|
68
|
-
return (0, _setup.setupDirect)(options).paste(clipboardData);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function selectOptions(select, values, options = {}) {
|
|
72
|
-
return (0, _setup.setupDirect)(options).selectOptions(select, values);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function tripleClick(element, options = {}) {
|
|
76
|
-
return (0, _setup.setupDirect)(options).tripleClick(element);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function type(element, text, options = {}) {
|
|
80
|
-
return (0, _setup.setupDirect)(options, element).type(element, text, options);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
function unhover(element, options = {}) {
|
|
84
|
-
const instance = (0, _setup.setupDirect)(options);
|
|
85
|
-
instance[_config.Config].pointerState.position.mouse.target = element;
|
|
86
|
-
return instance.unhover(element);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function upload(element, fileOrFiles, options = {}) {
|
|
90
|
-
return (0, _setup.setupDirect)(options).upload(element, fileOrFiles);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function tab(options = {}) {
|
|
94
|
-
return (0, _setup.setupDirect)().tab(options);
|
|
95
|
-
}
|
package/dist/setup/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "Config", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _config.Config;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
exports.userEvent = void 0;
|
|
13
|
-
|
|
14
|
-
var _setup = require("./setup");
|
|
15
|
-
|
|
16
|
-
var _config = require("./config");
|
|
17
|
-
|
|
18
|
-
var directApi = _interopRequireWildcard(require("./directApi"));
|
|
19
|
-
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
|
|
22
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
-
|
|
24
|
-
const userEvent = { ...directApi,
|
|
25
|
-
setup: _setup.setupMain
|
|
26
|
-
};
|
|
27
|
-
exports.userEvent = userEvent;
|
package/dist/setup/setup.d.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Options } from '../options';
|
|
2
|
-
import type { UserEvent } from './index';
|
|
3
|
-
import { Config } from './config';
|
|
4
|
-
import * as userEventApi from './api';
|
|
5
|
-
/**
|
|
6
|
-
* Start a "session" with userEvent.
|
|
7
|
-
* All APIs returned by this function share an input device state and a default configuration.
|
|
8
|
-
*/
|
|
9
|
-
export declare function setupMain(options?: Options): {
|
|
10
|
-
setup: typeof setupSub;
|
|
11
|
-
[Config]: Config;
|
|
12
|
-
click: typeof userEventApi.click;
|
|
13
|
-
dblClick: typeof userEventApi.dblClick;
|
|
14
|
-
tripleClick: typeof userEventApi.tripleClick;
|
|
15
|
-
hover: typeof userEventApi.hover;
|
|
16
|
-
unhover: typeof userEventApi.unhover;
|
|
17
|
-
tab: typeof userEventApi.tab;
|
|
18
|
-
keyboard: typeof userEventApi.keyboard;
|
|
19
|
-
copy: typeof userEventApi.copy;
|
|
20
|
-
cut: typeof userEventApi.cut;
|
|
21
|
-
paste: typeof userEventApi.paste;
|
|
22
|
-
pointer: typeof userEventApi.pointer;
|
|
23
|
-
clear: typeof userEventApi.clear;
|
|
24
|
-
deselectOptions: typeof userEventApi.deselectOptions;
|
|
25
|
-
selectOptions: typeof userEventApi.selectOptions;
|
|
26
|
-
type: typeof userEventApi.type;
|
|
27
|
-
upload: typeof userEventApi.upload;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Setup in direct call per `userEvent.anyApi()`
|
|
31
|
-
*/
|
|
32
|
-
export declare function setupDirect(options?: Partial<Config>, node?: Node): {
|
|
33
|
-
setup: typeof setupSub;
|
|
34
|
-
[Config]: Config;
|
|
35
|
-
click: typeof userEventApi.click;
|
|
36
|
-
dblClick: typeof userEventApi.dblClick;
|
|
37
|
-
tripleClick: typeof userEventApi.tripleClick;
|
|
38
|
-
hover: typeof userEventApi.hover;
|
|
39
|
-
unhover: typeof userEventApi.unhover;
|
|
40
|
-
tab: typeof userEventApi.tab;
|
|
41
|
-
keyboard: typeof userEventApi.keyboard;
|
|
42
|
-
copy: typeof userEventApi.copy;
|
|
43
|
-
cut: typeof userEventApi.cut;
|
|
44
|
-
paste: typeof userEventApi.paste;
|
|
45
|
-
pointer: typeof userEventApi.pointer;
|
|
46
|
-
clear: typeof userEventApi.clear;
|
|
47
|
-
deselectOptions: typeof userEventApi.deselectOptions;
|
|
48
|
-
selectOptions: typeof userEventApi.selectOptions;
|
|
49
|
-
type: typeof userEventApi.type;
|
|
50
|
-
upload: typeof userEventApi.upload;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Create a set of callbacks with different default settings but the same state.
|
|
54
|
-
*/
|
|
55
|
-
export declare function setupSub(this: UserEvent, options: Options): {
|
|
56
|
-
setup: typeof setupSub;
|
|
57
|
-
[Config]: Config;
|
|
58
|
-
click: typeof userEventApi.click;
|
|
59
|
-
dblClick: typeof userEventApi.dblClick;
|
|
60
|
-
tripleClick: typeof userEventApi.tripleClick;
|
|
61
|
-
hover: typeof userEventApi.hover;
|
|
62
|
-
unhover: typeof userEventApi.unhover;
|
|
63
|
-
tab: typeof userEventApi.tab;
|
|
64
|
-
keyboard: typeof userEventApi.keyboard;
|
|
65
|
-
copy: typeof userEventApi.copy;
|
|
66
|
-
cut: typeof userEventApi.cut;
|
|
67
|
-
paste: typeof userEventApi.paste;
|
|
68
|
-
pointer: typeof userEventApi.pointer;
|
|
69
|
-
clear: typeof userEventApi.clear;
|
|
70
|
-
deselectOptions: typeof userEventApi.deselectOptions;
|
|
71
|
-
selectOptions: typeof userEventApi.selectOptions;
|
|
72
|
-
type: typeof userEventApi.type;
|
|
73
|
-
upload: typeof userEventApi.upload;
|
|
74
|
-
};
|
package/dist/setup/setup.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.setupDirect = setupDirect;
|
|
7
|
-
exports.setupMain = setupMain;
|
|
8
|
-
exports.setupSub = setupSub;
|
|
9
|
-
|
|
10
|
-
var _document = require("../document");
|
|
11
|
-
|
|
12
|
-
var _keyboard = require("../keyboard");
|
|
13
|
-
|
|
14
|
-
var _pointer = require("../pointer");
|
|
15
|
-
|
|
16
|
-
var _options = require("../options");
|
|
17
|
-
|
|
18
|
-
var _utils = require("../utils");
|
|
19
|
-
|
|
20
|
-
var _config = require("./config");
|
|
21
|
-
|
|
22
|
-
var userEventApi = _interopRequireWildcard(require("./api"));
|
|
23
|
-
|
|
24
|
-
var _wrapAsync = require("./wrapAsync");
|
|
25
|
-
|
|
26
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
-
|
|
28
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Start a "session" with userEvent.
|
|
32
|
-
* All APIs returned by this function share an input device state and a default configuration.
|
|
33
|
-
*/
|
|
34
|
-
function setupMain(options = {}) {
|
|
35
|
-
var _doc$defaultView;
|
|
36
|
-
|
|
37
|
-
const doc = getDocument(options);
|
|
38
|
-
(0, _document.prepareDocument)(doc);
|
|
39
|
-
const view = (_doc$defaultView = doc.defaultView) != null ? _doc$defaultView :
|
|
40
|
-
/* istanbul ignore next */
|
|
41
|
-
window;
|
|
42
|
-
(0, _utils.attachClipboardStubToView)(view);
|
|
43
|
-
return doSetup({ ..._options.defaultOptionsSetup,
|
|
44
|
-
keyboardState: (0, _keyboard.createKeyboardState)(),
|
|
45
|
-
pointerState: (0, _pointer.createPointerState)(doc)
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Setup in direct call per `userEvent.anyApi()`
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
function setupDirect(options = {}, node) {
|
|
54
|
-
const doc = getDocument(options, node);
|
|
55
|
-
(0, _document.prepareDocument)(doc);
|
|
56
|
-
return doSetup({
|
|
57
|
-
keyboardState: (0, _keyboard.createKeyboardState)(),
|
|
58
|
-
pointerState: (0, _pointer.createPointerState)(doc),
|
|
59
|
-
..._options.defaultOptionsDirect,
|
|
60
|
-
...options
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Create a set of callbacks with different default settings but the same state.
|
|
65
|
-
*/
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
function setupSub(options) {
|
|
69
|
-
return doSetup({ ...this[_config.Config],
|
|
70
|
-
...options
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function wrapImpl(impl) {
|
|
75
|
-
function method(...args) {
|
|
76
|
-
return (0, _wrapAsync.wrapAsync)(() => impl.apply(this, args));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
Object.defineProperty(method, 'name', {
|
|
80
|
-
get: () => impl.name
|
|
81
|
-
});
|
|
82
|
-
return method;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const wrappedApis = Object.fromEntries(Object.entries(userEventApi).map(([name, impl]) => [name, wrapImpl(impl)]));
|
|
86
|
-
|
|
87
|
-
function doSetup(config) {
|
|
88
|
-
return { ...wrappedApis,
|
|
89
|
-
setup: setupSub,
|
|
90
|
-
[_config.Config]: config
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function getDocument(options, node) {
|
|
95
|
-
var _ref, _options$document;
|
|
96
|
-
|
|
97
|
-
return (_ref = (_options$document = options.document) != null ? _options$document : node && (0, _utils.getDocumentFromNode)(node)) != null ? _ref : document;
|
|
98
|
-
}
|
package/dist/setup/wrapAsync.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.wrapAsync = wrapAsync;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Wrap an internal Promise
|
|
12
|
-
*/
|
|
13
|
-
function wrapAsync(implementation) {
|
|
14
|
-
return (0, _dom.getConfig)().asyncWrapper(implementation);
|
|
15
|
-
}
|
package/dist/utility/clear.d.ts
DELETED
package/dist/utility/clear.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.clear = clear;
|
|
7
|
-
|
|
8
|
-
var _utils = require("../utils");
|
|
9
|
-
|
|
10
|
-
async function clear(element) {
|
|
11
|
-
var _prepareInput;
|
|
12
|
-
|
|
13
|
-
if (!(0, _utils.isEditable)(element) || (0, _utils.isDisabled)(element)) {
|
|
14
|
-
throw new Error('clear()` is only supported on editable elements.');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
(0, _utils.focus)(element);
|
|
18
|
-
|
|
19
|
-
if (element.ownerDocument.activeElement !== element) {
|
|
20
|
-
throw new Error('The element to be cleared could not be focused.');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
(0, _utils.selectAll)(element);
|
|
24
|
-
|
|
25
|
-
if (!(0, _utils.isAllSelected)(element)) {
|
|
26
|
-
throw new Error('The element content to be cleared could not be selected.');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
(_prepareInput = (0, _utils.prepareInput)('', element, 'deleteContentBackward')) == null ? void 0 : _prepareInput.commit();
|
|
30
|
-
}
|
package/dist/utility/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _clear = require("./clear");
|
|
8
|
-
|
|
9
|
-
Object.keys(_clear).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _clear[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _clear[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _selectOptions = require("./selectOptions");
|
|
21
|
-
|
|
22
|
-
Object.keys(_selectOptions).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _selectOptions[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function () {
|
|
28
|
-
return _selectOptions[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
var _type = require("./type");
|
|
34
|
-
|
|
35
|
-
Object.keys(_type).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (key in exports && exports[key] === _type[key]) return;
|
|
38
|
-
Object.defineProperty(exports, key, {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function () {
|
|
41
|
-
return _type[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var _upload = require("./upload");
|
|
47
|
-
|
|
48
|
-
Object.keys(_upload).forEach(function (key) {
|
|
49
|
-
if (key === "default" || key === "__esModule") return;
|
|
50
|
-
if (key in exports && exports[key] === _upload[key]) return;
|
|
51
|
-
Object.defineProperty(exports, key, {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function () {
|
|
54
|
-
return _upload[key];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { UserEvent } from '../setup';
|
|
2
|
-
export declare function selectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
3
|
-
export declare function deselectOptions(this: UserEvent, select: Element, values: HTMLElement | HTMLElement[] | string[] | string): Promise<void>;
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.deselectOptions = deselectOptions;
|
|
7
|
-
exports.selectOptions = selectOptions;
|
|
8
|
-
|
|
9
|
-
var _dom = require("@testing-library/dom");
|
|
10
|
-
|
|
11
|
-
var _utils = require("../utils");
|
|
12
|
-
|
|
13
|
-
var _setup = require("../setup");
|
|
14
|
-
|
|
15
|
-
async function selectOptions(select, values) {
|
|
16
|
-
return selectOptionsBase.call(this, true, select, values);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function deselectOptions(select, values) {
|
|
20
|
-
return selectOptionsBase.call(this, false, select, values);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
async function selectOptionsBase(newValue, select, values) {
|
|
24
|
-
if (!newValue && !select.multiple) {
|
|
25
|
-
throw (0, _dom.getConfig)().getElementError(`Unable to deselect an option in a non-multiple select. Use selectOptions to change the selection instead.`, select);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const valArray = Array.isArray(values) ? values : [values];
|
|
29
|
-
const allOptions = Array.from(select.querySelectorAll('option, [role="option"]'));
|
|
30
|
-
const selectedOptions = valArray.map(val => {
|
|
31
|
-
if (typeof val !== 'string' && allOptions.includes(val)) {
|
|
32
|
-
return val;
|
|
33
|
-
} else {
|
|
34
|
-
const matchingOption = allOptions.find(o => o.value === val || o.innerHTML === val);
|
|
35
|
-
|
|
36
|
-
if (matchingOption) {
|
|
37
|
-
return matchingOption;
|
|
38
|
-
} else {
|
|
39
|
-
throw (0, _dom.getConfig)().getElementError(`Value "${String(val)}" not found in options`, select);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}).filter(option => !(0, _utils.isDisabled)(option));
|
|
43
|
-
if ((0, _utils.isDisabled)(select) || !selectedOptions.length) return;
|
|
44
|
-
|
|
45
|
-
if ((0, _utils.isElementType)(select, 'select')) {
|
|
46
|
-
if (select.multiple) {
|
|
47
|
-
for (const option of selectedOptions) {
|
|
48
|
-
const withPointerEvents = this[_setup.Config].skipPointerEventsCheck ? true : (0, _utils.hasPointerEvents)(option); // events fired for multiple select are weird. Can't use hover...
|
|
49
|
-
|
|
50
|
-
if (withPointerEvents) {
|
|
51
|
-
_dom.fireEvent.pointerOver(option);
|
|
52
|
-
|
|
53
|
-
_dom.fireEvent.pointerEnter(select);
|
|
54
|
-
|
|
55
|
-
_dom.fireEvent.mouseOver(option);
|
|
56
|
-
|
|
57
|
-
_dom.fireEvent.mouseEnter(select);
|
|
58
|
-
|
|
59
|
-
_dom.fireEvent.pointerMove(option);
|
|
60
|
-
|
|
61
|
-
_dom.fireEvent.mouseMove(option);
|
|
62
|
-
|
|
63
|
-
_dom.fireEvent.pointerDown(option);
|
|
64
|
-
|
|
65
|
-
_dom.fireEvent.mouseDown(option);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
(0, _utils.focus)(select);
|
|
69
|
-
|
|
70
|
-
if (withPointerEvents) {
|
|
71
|
-
_dom.fireEvent.pointerUp(option);
|
|
72
|
-
|
|
73
|
-
_dom.fireEvent.mouseUp(option);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
selectOption(option);
|
|
77
|
-
|
|
78
|
-
if (withPointerEvents) {
|
|
79
|
-
_dom.fireEvent.click(option);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
} else if (selectedOptions.length === 1) {
|
|
83
|
-
const withPointerEvents = this[_setup.Config].skipPointerEventsCheck ? true : (0, _utils.hasPointerEvents)(select); // the click to open the select options
|
|
84
|
-
|
|
85
|
-
if (withPointerEvents) {
|
|
86
|
-
await this.click(select);
|
|
87
|
-
} else {
|
|
88
|
-
(0, _utils.focus)(select);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
selectOption(selectedOptions[0]);
|
|
92
|
-
|
|
93
|
-
if (withPointerEvents) {
|
|
94
|
-
// the browser triggers another click event on the select for the click on the option
|
|
95
|
-
// this second click has no 'down' phase
|
|
96
|
-
_dom.fireEvent.pointerOver(select);
|
|
97
|
-
|
|
98
|
-
_dom.fireEvent.pointerEnter(select);
|
|
99
|
-
|
|
100
|
-
_dom.fireEvent.mouseOver(select);
|
|
101
|
-
|
|
102
|
-
_dom.fireEvent.mouseEnter(select);
|
|
103
|
-
|
|
104
|
-
_dom.fireEvent.pointerUp(select);
|
|
105
|
-
|
|
106
|
-
_dom.fireEvent.mouseUp(select);
|
|
107
|
-
|
|
108
|
-
_dom.fireEvent.click(select);
|
|
109
|
-
}
|
|
110
|
-
} else {
|
|
111
|
-
throw (0, _dom.getConfig)().getElementError(`Cannot select multiple options on a non-multiple select`, select);
|
|
112
|
-
}
|
|
113
|
-
} else if (select.getAttribute('role') === 'listbox') {
|
|
114
|
-
for (const option of selectedOptions) {
|
|
115
|
-
await this.click(option);
|
|
116
|
-
await this.unhover(option);
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
throw (0, _dom.getConfig)().getElementError(`Cannot select options on elements that are neither select nor listbox elements`, select);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
function selectOption(option) {
|
|
123
|
-
option.selected = newValue;
|
|
124
|
-
(0, _dom.fireEvent)(select, (0, _dom.createEvent)('input', select, {
|
|
125
|
-
bubbles: true,
|
|
126
|
-
cancelable: false,
|
|
127
|
-
composed: true
|
|
128
|
-
}));
|
|
129
|
-
|
|
130
|
-
_dom.fireEvent.change(select);
|
|
131
|
-
}
|
|
132
|
-
}
|
package/dist/utility/type.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { UserEvent } from '../setup';
|
|
2
|
-
import { Config } from '../setup/config';
|
|
3
|
-
export interface typeOptions {
|
|
4
|
-
skipClick?: Config['skipClick'];
|
|
5
|
-
skipAutoClose?: Config['skipClick'];
|
|
6
|
-
initialSelectionStart?: number;
|
|
7
|
-
initialSelectionEnd?: number;
|
|
8
|
-
}
|
|
9
|
-
export declare function type(this: UserEvent, element: Element, text: string, { skipClick, skipAutoClose, initialSelectionStart, initialSelectionEnd, }?: typeOptions): Promise<void>;
|
package/dist/utility/type.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.type = type;
|
|
7
|
-
|
|
8
|
-
var _utils = require("../utils");
|
|
9
|
-
|
|
10
|
-
var _keyboard = require("../keyboard");
|
|
11
|
-
|
|
12
|
-
var _config = require("../setup/config");
|
|
13
|
-
|
|
14
|
-
async function type(element, text, {
|
|
15
|
-
skipClick = this[_config.Config].skipClick,
|
|
16
|
-
skipAutoClose = this[_config.Config].skipAutoClose,
|
|
17
|
-
initialSelectionStart,
|
|
18
|
-
initialSelectionEnd
|
|
19
|
-
} = {}) {
|
|
20
|
-
// TODO: properly type guard
|
|
21
|
-
// we use this workaround for now to prevent changing behavior
|
|
22
|
-
if (element.disabled) return;
|
|
23
|
-
|
|
24
|
-
if (!skipClick) {
|
|
25
|
-
await this.click(element);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (initialSelectionStart !== undefined) {
|
|
29
|
-
(0, _utils.setSelectionRange)(element, initialSelectionStart, initialSelectionEnd != null ? initialSelectionEnd : initialSelectionStart);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
await this.keyboard(text);
|
|
33
|
-
|
|
34
|
-
if (!skipAutoClose) {
|
|
35
|
-
await (0, _keyboard.releaseAllKeys)(this[_config.Config]);
|
|
36
|
-
}
|
|
37
|
-
}
|
package/dist/utility/upload.d.ts
DELETED
package/dist/utility/upload.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.upload = upload;
|
|
7
|
-
|
|
8
|
-
var _dom = require("@testing-library/dom");
|
|
9
|
-
|
|
10
|
-
var _utils = require("../utils");
|
|
11
|
-
|
|
12
|
-
var _setup = require("../setup");
|
|
13
|
-
|
|
14
|
-
async function upload(element, fileOrFiles) {
|
|
15
|
-
var _input$files;
|
|
16
|
-
|
|
17
|
-
const input = (0, _utils.isElementType)(element, 'label') ? element.control : element;
|
|
18
|
-
|
|
19
|
-
if (!input || !(0, _utils.isElementType)(input, 'input', {
|
|
20
|
-
type: 'file'
|
|
21
|
-
})) {
|
|
22
|
-
throw new TypeError(`The ${input === element ? 'given' : 'associated'} ${input == null ? void 0 : input.tagName} element does not accept file uploads`);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if ((0, _utils.isDisabled)(element)) return;
|
|
26
|
-
await this.click(element);
|
|
27
|
-
const files = (Array.isArray(fileOrFiles) ? fileOrFiles : [fileOrFiles]).filter(file => !this[_setup.Config].applyAccept || isAcceptableFile(file, input.accept)).slice(0, input.multiple ? undefined : 1); // blur fires when the file selector pops up
|
|
28
|
-
|
|
29
|
-
(0, _utils.blur)(element); // focus fires when they make their selection
|
|
30
|
-
|
|
31
|
-
(0, _utils.focus)(element); // do not fire an input event if the file selection does not change
|
|
32
|
-
|
|
33
|
-
if (files.length === ((_input$files = input.files) == null ? void 0 : _input$files.length) && files.every((f, i) => {
|
|
34
|
-
var _input$files2;
|
|
35
|
-
|
|
36
|
-
return f === ((_input$files2 = input.files) == null ? void 0 : _input$files2.item(i));
|
|
37
|
-
})) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
(0, _utils.setFiles)(input, (0, _utils.createFileList)(files));
|
|
42
|
-
|
|
43
|
-
_dom.fireEvent.input(input);
|
|
44
|
-
|
|
45
|
-
_dom.fireEvent.change(input);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function isAcceptableFile(file, accept) {
|
|
49
|
-
if (!accept) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const wildcards = ['audio/*', 'image/*', 'video/*'];
|
|
54
|
-
return accept.split(',').some(acceptToken => {
|
|
55
|
-
if (acceptToken.startsWith('.')) {
|
|
56
|
-
// tokens starting with a dot represent a file extension
|
|
57
|
-
return file.name.endsWith(acceptToken);
|
|
58
|
-
} else if (wildcards.includes(acceptToken)) {
|
|
59
|
-
return file.type.startsWith(acceptToken.substr(0, acceptToken.length - 1));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return file.type === acceptToken;
|
|
63
|
-
});
|
|
64
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isClickableInput = isClickableInput;
|
|
7
|
-
|
|
8
|
-
var _isElementType = require("../misc/isElementType");
|
|
9
|
-
|
|
10
|
-
const CLICKABLE_INPUT_TYPES = ['button', 'color', 'file', 'image', 'reset', 'submit', 'checkbox', 'radio'];
|
|
11
|
-
|
|
12
|
-
function isClickableInput(element) {
|
|
13
|
-
return (0, _isElementType.isElementType)(element, 'button') || (0, _isElementType.isElementType)(element, 'input') && CLICKABLE_INPUT_TYPES.includes(element.type);
|
|
14
|
-
}
|