@testing-library/user-event 14.0.0-alpha.12 → 14.0.0-alpha.13
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/paste.d.ts +4 -5
- package/dist/paste.js +39 -35
- package/dist/setup.js +17 -3
- package/dist/utils/dataTransfer/Blob.d.ts +1 -0
- package/dist/utils/dataTransfer/Blob.js +21 -0
- package/dist/utils/dataTransfer/Clipboard.d.ts +7 -0
- package/dist/utils/dataTransfer/Clipboard.js +143 -0
- package/dist/utils/dataTransfer/DataTransfer.d.ts +1 -0
- package/dist/utils/dataTransfer/DataTransfer.js +143 -0
- package/dist/utils/dataTransfer/FileList.d.ts +1 -0
- package/dist/utils/dataTransfer/FileList.js +13 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +52 -0
- package/package.json +1 -1
package/dist/paste.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import type { UserEvent } from './setup';
|
|
2
|
-
interface pasteOptions {
|
|
3
|
-
|
|
4
|
-
initialSelectionEnd?: number;
|
|
2
|
+
export interface pasteOptions {
|
|
3
|
+
document?: Document;
|
|
5
4
|
}
|
|
6
|
-
export declare function paste(this: UserEvent,
|
|
7
|
-
export
|
|
5
|
+
export declare function paste(this: UserEvent, clipboardData?: undefined, options?: pasteOptions): Promise<void>;
|
|
6
|
+
export declare function paste(this: UserEvent, clipboardData: DataTransfer | string, options?: pasteOptions): void;
|
package/dist/paste.js
CHANGED
|
@@ -9,52 +9,56 @@ var _dom = require("@testing-library/dom");
|
|
|
9
9
|
|
|
10
10
|
var _utils = require("./utils");
|
|
11
11
|
|
|
12
|
-
function
|
|
13
|
-
|
|
12
|
+
function paste(clipboardData, options) {
|
|
13
|
+
var _options$document, _doc$activeElement;
|
|
14
|
+
|
|
15
|
+
const doc = (_options$document = options == null ? void 0 : options.document) != null ? _options$document : document;
|
|
16
|
+
const target = (_doc$activeElement = doc.activeElement) != null ? _doc$activeElement :
|
|
17
|
+
/* istanbul ignore next */
|
|
18
|
+
doc.body;
|
|
19
|
+
const data = typeof clipboardData === 'string' ? getClipboardDataFromString(clipboardData) : clipboardData;
|
|
20
|
+
return data ? pasteImpl(target, data) : readClipboardDataFromClipboardApi(doc).then(dt => pasteImpl(target, dt));
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
var _prepareInput;
|
|
23
|
+
function pasteImpl(target, clipboardData) {
|
|
24
|
+
_dom.fireEvent.paste(target, {
|
|
25
|
+
clipboardData
|
|
26
|
+
});
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
throw new TypeError(`The given ${element.tagName} element is currently unsupported.
|
|
25
|
-
A PR extending this implementation would be very much welcome at https://github.com/testing-library/user-event`);
|
|
26
|
-
}
|
|
28
|
+
if ((0, _utils.isEditable)(target)) {
|
|
29
|
+
const data = clipboardData.getData('text').substr(0, (0, _utils.getSpaceUntilMaxLength)(target));
|
|
27
30
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
+
if (data) {
|
|
32
|
+
var _prepareInput;
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// at the end of the current input value. So, if the selection start
|
|
35
|
-
// and end are both the default of 0, then we'll go ahead and change
|
|
36
|
-
// them to the length of the current value.
|
|
37
|
-
// the only time it would make sense to pass the initialSelectionStart or
|
|
38
|
-
// initialSelectionEnd is if you have an input with a value and want to
|
|
39
|
-
// explicitely start typing with the cursor at 0. Not super common.
|
|
40
|
-
|
|
41
|
-
if (element.selectionStart === 0 && element.selectionEnd === 0) {
|
|
42
|
-
(0, _utils.setSelectionRange)(element, initialSelectionStart != null ? initialSelectionStart : element.value.length, initialSelectionEnd != null ? initialSelectionEnd : element.value.length);
|
|
34
|
+
(_prepareInput = (0, _utils.prepareInput)(data, target, 'insertFromPaste')) == null ? void 0 : _prepareInput.commit();
|
|
35
|
+
}
|
|
43
36
|
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getClipboardDataFromString(text) {
|
|
40
|
+
const dt = (0, _utils.createDataTransfer)();
|
|
41
|
+
dt.setData('text', text);
|
|
42
|
+
return dt;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function readClipboardDataFromClipboardApi(document) {
|
|
46
|
+
var _document$defaultView;
|
|
44
47
|
|
|
45
|
-
|
|
48
|
+
const clipboard = (_document$defaultView = document.defaultView) == null ? void 0 : _document$defaultView.navigator.clipboard;
|
|
49
|
+
const items = clipboard && (await clipboard.read());
|
|
46
50
|
|
|
47
|
-
if (
|
|
48
|
-
|
|
51
|
+
if (!items) {
|
|
52
|
+
throw new Error('`userEvent.paste()` without `clipboardData` requires the `ClipboardAPI` to be available.');
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
const inputRange = (0, _utils.getInputRange)(element);
|
|
53
|
-
/* istanbul ignore if */
|
|
55
|
+
const dt = (0, _utils.createDataTransfer)();
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
+
for (const item of items) {
|
|
58
|
+
for (const type of item.types) {
|
|
59
|
+
dt.setData(type, await item.getType(type).then(b => (0, _utils.readBlobText)(b)));
|
|
60
|
+
}
|
|
57
61
|
}
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
return dt;
|
|
60
64
|
}
|
package/dist/setup.js
CHANGED
|
@@ -28,6 +28,8 @@ var _type = require("./type");
|
|
|
28
28
|
|
|
29
29
|
var _upload = require("./upload");
|
|
30
30
|
|
|
31
|
+
var _utils = require("./utils");
|
|
32
|
+
|
|
31
33
|
const userEventApis = {
|
|
32
34
|
clear: _clear.clear,
|
|
33
35
|
click: _click.click,
|
|
@@ -51,9 +53,14 @@ exports.userEventApis = userEventApis;
|
|
|
51
53
|
* All APIs returned by this function share an input device state and a default configuration.
|
|
52
54
|
*/
|
|
53
55
|
function setup(options = {}) {
|
|
54
|
-
var _options$document;
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
var _options$document, _doc$defaultView;
|
|
57
|
+
|
|
58
|
+
const doc = (_options$document = options.document) != null ? _options$document : document;
|
|
59
|
+
(0, _document.prepareDocument)(doc);
|
|
60
|
+
const view = (_doc$defaultView = doc.defaultView) != null ? _doc$defaultView :
|
|
61
|
+
/* istanbul ignore next */
|
|
62
|
+
window;
|
|
63
|
+
(0, _utils.attachClipboardStubToView)(view);
|
|
57
64
|
return _setup(options, {
|
|
58
65
|
keyboardState: (0, _keyboard.createKeyboardState)(),
|
|
59
66
|
pointerState: (0, _pointer.createPointerState)()
|
|
@@ -91,6 +98,9 @@ function _setup({
|
|
|
91
98
|
const clickDefaults = {
|
|
92
99
|
skipHover
|
|
93
100
|
};
|
|
101
|
+
const clipboardDefaults = {
|
|
102
|
+
document
|
|
103
|
+
};
|
|
94
104
|
const typeDefaults = {
|
|
95
105
|
delay,
|
|
96
106
|
skipAutoClose,
|
|
@@ -141,7 +151,11 @@ function _setup({
|
|
|
141
151
|
return ret.then(() => undefined);
|
|
142
152
|
}
|
|
143
153
|
},
|
|
154
|
+
// paste needs typecasting because of the overloading
|
|
144
155
|
paste: (...args) => {
|
|
156
|
+
args[1] = { ...clipboardDefaults,
|
|
157
|
+
...args[1]
|
|
158
|
+
};
|
|
145
159
|
return _paste.paste.call(userEvent, ...args);
|
|
146
160
|
},
|
|
147
161
|
// pointer needs typecasting because of the overloading
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function readBlobText(blob: Blob): Promise<string>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.readBlobText = readBlobText;
|
|
7
|
+
|
|
8
|
+
// jsdom does not implement Blob.text()
|
|
9
|
+
function readBlobText(blob) {
|
|
10
|
+
return new Promise((res, rej) => {
|
|
11
|
+
const fr = new FileReader();
|
|
12
|
+
fr.onerror = rej;
|
|
13
|
+
fr.onabort = rej;
|
|
14
|
+
|
|
15
|
+
fr.onload = () => {
|
|
16
|
+
res(String(fr.result));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
fr.readAsText(blob);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function createClipboardItem(...blobs: Array<Blob | string>): ClipboardItem;
|
|
2
|
+
export declare function attachClipboardStubToView(window: Window & typeof globalThis): {
|
|
3
|
+
resetClipboardStub: () => void;
|
|
4
|
+
detachClipboardStub: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare function resetClipboardStubOnView(window: Window & typeof globalThis): void;
|
|
7
|
+
export declare function detachClipboardStubFromView(window: Window & typeof globalThis): void;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.attachClipboardStubToView = attachClipboardStubToView;
|
|
7
|
+
exports.createClipboardItem = createClipboardItem;
|
|
8
|
+
exports.detachClipboardStubFromView = detachClipboardStubFromView;
|
|
9
|
+
exports.resetClipboardStubOnView = resetClipboardStubOnView;
|
|
10
|
+
|
|
11
|
+
var _ = require("..");
|
|
12
|
+
|
|
13
|
+
// Clipboard is not available in jsdom
|
|
14
|
+
class ClipboardItemStub {
|
|
15
|
+
constructor(data) {
|
|
16
|
+
this.data = void 0;
|
|
17
|
+
this.data = data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get types() {
|
|
21
|
+
return Array.from(Object.keys(this.data));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
async getType(type) {
|
|
25
|
+
const data = await this.data[type];
|
|
26
|
+
|
|
27
|
+
if (!data) {
|
|
28
|
+
throw new Error(`${type} is not one of the available MIME types on this item.`);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return data instanceof Blob ? data : new Blob([data], {
|
|
32
|
+
type
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const ClipboardStubControl = Symbol('Manage ClipboardSub');
|
|
39
|
+
|
|
40
|
+
class ClipboardStub extends EventTarget {
|
|
41
|
+
constructor(...args) {
|
|
42
|
+
super(...args);
|
|
43
|
+
this.items = [];
|
|
44
|
+
this[ClipboardStubControl] = void 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async read() {
|
|
48
|
+
return Array.from(this.items);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async readText() {
|
|
52
|
+
let text = '';
|
|
53
|
+
|
|
54
|
+
for (const item of this.items) {
|
|
55
|
+
const type = item.types.includes('text/plain') ? 'text/plain' : item.types.find(t => t.startsWith('text/'));
|
|
56
|
+
|
|
57
|
+
if (type) {
|
|
58
|
+
text += await item.getType(type).then(b => (0, _.readBlobText)(b));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return text;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
async write(data) {
|
|
66
|
+
this.items = data;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async writeText(text) {
|
|
70
|
+
this.items = [createClipboardItem(text)];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
} // MDN lists string|Blob|Promise<Blob|string> as possible types in ClipboardItemData
|
|
74
|
+
// lib.dom.d.ts lists only Promise<Blob|string>
|
|
75
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem/ClipboardItem#syntax
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
function createClipboardItem(...blobs) {
|
|
79
|
+
// use real ClipboardItem if available
|
|
80
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
81
|
+
const constructor = typeof ClipboardItem === 'undefined' ? ClipboardItemStub :
|
|
82
|
+
/* istanbul ignore next */
|
|
83
|
+
ClipboardItem;
|
|
84
|
+
return new constructor(Object.fromEntries(blobs.map(b => [typeof b === 'string' ? 'text/plain' : b.type, Promise.resolve(b)])));
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function attachClipboardStubToView(window) {
|
|
88
|
+
if (window.navigator.clipboard instanceof ClipboardStub) {
|
|
89
|
+
return window.navigator.clipboard[ClipboardStubControl];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const realClipboard = Object.getOwnPropertyDescriptor(window.navigator, 'clipboard');
|
|
93
|
+
let stub = new ClipboardStub();
|
|
94
|
+
const control = {
|
|
95
|
+
resetClipboardStub: () => {
|
|
96
|
+
stub = new ClipboardStub();
|
|
97
|
+
stub[ClipboardStubControl] = control;
|
|
98
|
+
},
|
|
99
|
+
detachClipboardStub: () => {
|
|
100
|
+
/* istanbul ignore if */
|
|
101
|
+
if (realClipboard) {
|
|
102
|
+
Object.defineProperty(window.navigator, 'clipboard', realClipboard);
|
|
103
|
+
} else {
|
|
104
|
+
Object.defineProperty(window.navigator, 'clipboard', {
|
|
105
|
+
value: undefined,
|
|
106
|
+
configurable: true
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
stub[ClipboardStubControl] = control;
|
|
112
|
+
Object.defineProperty(window.navigator, 'clipboard', {
|
|
113
|
+
get: () => stub,
|
|
114
|
+
configurable: true
|
|
115
|
+
});
|
|
116
|
+
return stub[ClipboardStubControl];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function resetClipboardStubOnView(window) {
|
|
120
|
+
if (window.navigator.clipboard instanceof ClipboardStub) {
|
|
121
|
+
window.navigator.clipboard[ClipboardStubControl].resetClipboardStub();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function detachClipboardStubFromView(window) {
|
|
126
|
+
if (window.navigator.clipboard instanceof ClipboardStub) {
|
|
127
|
+
window.navigator.clipboard[ClipboardStubControl].detachClipboardStub();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/* istanbul ignore else */
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
if (afterEach) {
|
|
135
|
+
afterEach(() => resetClipboardStubOnView(window));
|
|
136
|
+
}
|
|
137
|
+
/* istanbul ignore else */
|
|
138
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
if (afterAll) {
|
|
142
|
+
afterAll(() => detachClipboardStubFromView(window));
|
|
143
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createDataTransfer(files?: File[]): DataTransfer;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createDataTransfer = createDataTransfer;
|
|
7
|
+
|
|
8
|
+
var _FileList = require("./FileList");
|
|
9
|
+
|
|
10
|
+
// DataTransfer is not implemented in jsdom.
|
|
11
|
+
// DataTransfer with FileList is being created by the browser on certain events.
|
|
12
|
+
class DataTransferItemStub {
|
|
13
|
+
constructor(dataOrFile, type) {
|
|
14
|
+
this.kind = void 0;
|
|
15
|
+
this.type = void 0;
|
|
16
|
+
this.file = null;
|
|
17
|
+
this.data = undefined;
|
|
18
|
+
|
|
19
|
+
if (typeof dataOrFile === 'string') {
|
|
20
|
+
this.kind = 'string';
|
|
21
|
+
this.type = String(type);
|
|
22
|
+
this.data = dataOrFile;
|
|
23
|
+
} else {
|
|
24
|
+
this.kind = 'file';
|
|
25
|
+
this.type = dataOrFile.type;
|
|
26
|
+
this.file = dataOrFile;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getAsFile() {
|
|
31
|
+
return this.file;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
getAsString(callback) {
|
|
35
|
+
if (typeof this.data === 'string') {
|
|
36
|
+
callback(this.data);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/* istanbul ignore next */
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
webkitGetAsEntry() {
|
|
43
|
+
throw new Error('not implemented');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class DataTransferItemListStub extends Array {
|
|
49
|
+
add(...args) {
|
|
50
|
+
const item = new DataTransferItemStub(args[0], args[1]);
|
|
51
|
+
this.push(item);
|
|
52
|
+
return item;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
clear() {
|
|
56
|
+
this.splice(0, this.length);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
remove(index) {
|
|
60
|
+
this.splice(index, 1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function getTypeMatcher(type, exact) {
|
|
66
|
+
const [group, sub] = type.split('/');
|
|
67
|
+
const isGroup = !sub || sub === '*';
|
|
68
|
+
return item => {
|
|
69
|
+
return exact ? item.type === (isGroup ? group : type) : isGroup ? item.type.startsWith(`${group}/`) : item.type === group;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
class DataTransferStub {
|
|
74
|
+
constructor() {
|
|
75
|
+
this.dropEffect = 'none';
|
|
76
|
+
this.effectAllowed = 'uninitialized';
|
|
77
|
+
this.items = new DataTransferItemListStub();
|
|
78
|
+
this.files = (0, _FileList.createFileList)([]);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
getData(format) {
|
|
82
|
+
var _this$items$find;
|
|
83
|
+
|
|
84
|
+
const match = (_this$items$find = this.items.find(getTypeMatcher(format, true))) != null ? _this$items$find : this.items.find(getTypeMatcher(format, false));
|
|
85
|
+
let text = '';
|
|
86
|
+
match == null ? void 0 : match.getAsString(t => {
|
|
87
|
+
text = t;
|
|
88
|
+
});
|
|
89
|
+
return text;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
setData(format, data) {
|
|
93
|
+
const matchIndex = this.items.findIndex(getTypeMatcher(format, true));
|
|
94
|
+
const item = new DataTransferItemStub(data, format);
|
|
95
|
+
|
|
96
|
+
if (matchIndex >= 0) {
|
|
97
|
+
this.items.splice(matchIndex, 1, item);
|
|
98
|
+
} else {
|
|
99
|
+
this.items.push(item);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
clearData(format) {
|
|
104
|
+
if (format) {
|
|
105
|
+
const matchIndex = this.items.findIndex(getTypeMatcher(format, true));
|
|
106
|
+
|
|
107
|
+
if (matchIndex >= 0) {
|
|
108
|
+
this.items.remove(matchIndex);
|
|
109
|
+
}
|
|
110
|
+
} else {
|
|
111
|
+
this.items.clear();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get types() {
|
|
116
|
+
const t = [];
|
|
117
|
+
|
|
118
|
+
if (this.files.length) {
|
|
119
|
+
t.push('Files');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
this.items.forEach(i => t.push(i.type));
|
|
123
|
+
Object.freeze(t);
|
|
124
|
+
return t;
|
|
125
|
+
}
|
|
126
|
+
/* istanbul ignore next */
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
setDragImage() {}
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function createDataTransfer(files = []) {
|
|
134
|
+
// Use real DataTransfer if available
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
136
|
+
const dt = typeof DataTransfer === 'undefined' ? new DataTransferStub() :
|
|
137
|
+
/* istanbul ignore next */
|
|
138
|
+
new DataTransfer();
|
|
139
|
+
Object.defineProperty(dt, 'files', {
|
|
140
|
+
get: () => (0, _FileList.createFileList)(files)
|
|
141
|
+
});
|
|
142
|
+
return dt;
|
|
143
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createFileList(files: File[]): FileList;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createFileList = createFileList;
|
|
7
|
+
|
|
8
|
+
// FileList can not be created per constructor.
|
|
9
|
+
function createFileList(files) {
|
|
10
|
+
const f = [...files];
|
|
11
|
+
Object.setPrototypeOf(f, FileList.prototype);
|
|
12
|
+
return f;
|
|
13
|
+
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export * from './click/isClickableInput';
|
|
2
|
+
export * from './dataTransfer/Blob';
|
|
3
|
+
export * from './dataTransfer/DataTransfer';
|
|
4
|
+
export * from './dataTransfer/FileList';
|
|
5
|
+
export * from './dataTransfer/Clipboard';
|
|
2
6
|
export * from './edit/buildTimeValue';
|
|
3
7
|
export * from './edit/calculateNewValue';
|
|
4
8
|
export * from './edit/editInputElement';
|
package/dist/utils/index.js
CHANGED
|
@@ -17,6 +17,58 @@ Object.keys(_isClickableInput).forEach(function (key) {
|
|
|
17
17
|
});
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
var _Blob = require("./dataTransfer/Blob");
|
|
21
|
+
|
|
22
|
+
Object.keys(_Blob).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _Blob[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _Blob[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _DataTransfer = require("./dataTransfer/DataTransfer");
|
|
34
|
+
|
|
35
|
+
Object.keys(_DataTransfer).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _DataTransfer[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _DataTransfer[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _FileList = require("./dataTransfer/FileList");
|
|
47
|
+
|
|
48
|
+
Object.keys(_FileList).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _FileList[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _FileList[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
var _Clipboard = require("./dataTransfer/Clipboard");
|
|
60
|
+
|
|
61
|
+
Object.keys(_Clipboard).forEach(function (key) {
|
|
62
|
+
if (key === "default" || key === "__esModule") return;
|
|
63
|
+
if (key in exports && exports[key] === _Clipboard[key]) return;
|
|
64
|
+
Object.defineProperty(exports, key, {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
get: function () {
|
|
67
|
+
return _Clipboard[key];
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
20
72
|
var _buildTimeValue = require("./edit/buildTimeValue");
|
|
21
73
|
|
|
22
74
|
Object.keys(_buildTimeValue).forEach(function (key) {
|