@atlaskit/media-picker 64.2.0 → 64.2.1
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/CHANGELOG.md +6 -0
- package/dist/cjs/components/browser/browser.js +13 -48
- package/dist/cjs/components/browser/index.js +0 -33
- package/dist/cjs/components/clipboard/clipboard.js +7 -36
- package/dist/cjs/components/clipboard/index.js +0 -32
- package/dist/cjs/components/component.js +2 -16
- package/dist/cjs/components/dropzone/dropzone.js +17 -79
- package/dist/cjs/components/dropzone/index.js +2 -36
- package/dist/cjs/components/localUploadReact.js +21 -75
- package/dist/cjs/components/media-picker-analytics-error-boundary.js +3 -20
- package/dist/cjs/config.js +0 -5
- package/dist/cjs/domain/preview.js +0 -2
- package/dist/cjs/index.js +0 -4
- package/dist/cjs/service/types.js +0 -2
- package/dist/cjs/service/uploadServiceImpl.js +9 -58
- package/dist/cjs/util/analytics.js +1 -6
- package/dist/cjs/util/appendTimestamp.js +0 -3
- package/dist/cjs/util/eventEmitter.js +0 -8
- package/dist/cjs/util/getPreviewFromBlob.js +0 -15
- package/dist/cjs/util/getPreviewFromImage.js +0 -13
- package/dist/cjs/util/ufoExperiences.js +1 -21
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/browser/browser.js +6 -25
- package/dist/es2019/components/browser/index.js +1 -15
- package/dist/es2019/components/clipboard/clipboard.js +4 -23
- package/dist/es2019/components/clipboard/index.js +1 -11
- package/dist/es2019/components/component.js +0 -5
- package/dist/es2019/components/dropzone/dropzone.js +21 -54
- package/dist/es2019/components/dropzone/index.js +3 -15
- package/dist/es2019/components/localUploadReact.js +0 -19
- package/dist/es2019/components/media-picker-analytics-error-boundary.js +0 -2
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/service/types.js +0 -1
- package/dist/es2019/service/uploadServiceImpl.js +2 -35
- package/dist/es2019/util/analytics.js +4 -2
- package/dist/es2019/util/appendTimestamp.js +0 -1
- package/dist/es2019/util/eventEmitter.js +0 -9
- package/dist/es2019/util/getPreviewFromBlob.js +0 -3
- package/dist/es2019/util/getPreviewFromImage.js +0 -1
- package/dist/es2019/util/ufoExperiences.js +3 -8
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/browser/browser.js +13 -40
- package/dist/esm/components/browser/index.js +1 -27
- package/dist/esm/components/clipboard/clipboard.js +7 -29
- package/dist/esm/components/clipboard/index.js +1 -25
- package/dist/esm/components/component.js +2 -10
- package/dist/esm/components/dropzone/dropzone.js +17 -77
- package/dist/esm/components/dropzone/index.js +3 -31
- package/dist/esm/components/localUploadReact.js +21 -69
- package/dist/esm/components/media-picker-analytics-error-boundary.js +3 -14
- package/dist/esm/index.js +1 -0
- package/dist/esm/service/types.js +0 -1
- package/dist/esm/service/uploadServiceImpl.js +9 -46
- package/dist/esm/util/analytics.js +4 -2
- package/dist/esm/util/appendTimestamp.js +0 -1
- package/dist/esm/util/eventEmitter.js +0 -3
- package/dist/esm/util/getPreviewFromBlob.js +0 -8
- package/dist/esm/util/getPreviewFromImage.js +0 -8
- package/dist/esm/util/ufoExperiences.js +1 -11
- package/dist/esm/version.json +1 -1
- package/package.json +6 -4
|
@@ -7,97 +7,73 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
-
|
|
11
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
|
|
13
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
-
|
|
15
12
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
16
13
|
import { ANALYTICS_MEDIA_CHANNEL, getMediaFeatureFlag, withMediaAnalyticsContext } from '@atlaskit/media-common';
|
|
17
14
|
import { isWebkitSupported } from '@atlaskit/media-ui/browser';
|
|
18
15
|
import { getFilesFromItems, getFilesFromFileSystemEntries } from 'flat-files';
|
|
19
16
|
import { LocalUploadComponentReact } from '../localUploadReact';
|
|
20
17
|
import { getPackageAttributes, LOGGED_FEATURE_FLAGS } from '../../util/analytics';
|
|
21
|
-
|
|
22
18
|
function dragContainsFiles(event) {
|
|
23
19
|
if (!event.dataTransfer) {
|
|
24
20
|
return false;
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
var types = event.dataTransfer.types;
|
|
28
23
|
return Array.from(types).indexOf('Files') > -1;
|
|
29
24
|
}
|
|
30
|
-
|
|
31
25
|
var COMPONENT_NAME = 'dropzone';
|
|
32
26
|
export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
33
27
|
_inherits(DropzoneBase, _LocalUploadComponent);
|
|
34
|
-
|
|
35
28
|
var _super = _createSuper(DropzoneBase);
|
|
36
|
-
|
|
37
29
|
function DropzoneBase(props) {
|
|
38
30
|
var _this;
|
|
39
|
-
|
|
40
31
|
_classCallCheck(this, DropzoneBase);
|
|
41
|
-
|
|
42
32
|
_this = _super.call(this, props, COMPONENT_NAME);
|
|
43
|
-
|
|
44
33
|
_defineProperty(_assertThisInitialized(_this), "uiActive", false);
|
|
45
|
-
|
|
46
34
|
_defineProperty(_assertThisInitialized(_this), "addContainerListeners", function () {
|
|
47
35
|
var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.getContainer();
|
|
48
36
|
container.addEventListener('dragover', _this.onDragOver, false);
|
|
49
37
|
container.addEventListener('dragleave', _this.onDragLeave, false);
|
|
50
38
|
container.addEventListener('drop', _this.onFileDropped);
|
|
51
39
|
});
|
|
52
|
-
|
|
53
40
|
_defineProperty(_assertThisInitialized(_this), "removeContainerListeners", function () {
|
|
54
41
|
var container = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _this.getContainer();
|
|
55
42
|
container.removeEventListener('dragover', _this.onDragOver, false);
|
|
56
43
|
container.removeEventListener('dragleave', _this.onDragLeave, false);
|
|
57
44
|
container.removeEventListener('drop', _this.onFileDropped);
|
|
58
45
|
});
|
|
59
|
-
|
|
60
46
|
_defineProperty(_assertThisInitialized(_this), "onDragOver", function (event) {
|
|
61
47
|
event.preventDefault();
|
|
62
|
-
|
|
63
48
|
if (event.dataTransfer && dragContainsFiles(event)) {
|
|
64
49
|
var dataTransfer = event.dataTransfer;
|
|
65
50
|
var allowed;
|
|
66
|
-
|
|
67
51
|
try {
|
|
68
52
|
allowed = dataTransfer.effectAllowed;
|
|
69
53
|
} catch (e) {} // the error is expected in IE11
|
|
70
54
|
|
|
71
|
-
|
|
72
55
|
dataTransfer.dropEffect = 'move' === allowed || 'linkMove' === allowed ? 'move' : 'copy';
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
56
|
+
var length = _this.getDraggedItemsLength(dataTransfer);
|
|
57
|
+
// [EDM-1636]: needed in order to make multiple dropzones in the page to work
|
|
77
58
|
event.stopPropagation();
|
|
78
|
-
|
|
79
59
|
_this.emitDragOver({
|
|
80
60
|
length: length
|
|
81
61
|
});
|
|
82
62
|
}
|
|
83
63
|
});
|
|
84
|
-
|
|
85
64
|
_defineProperty(_assertThisInitialized(_this), "onDragLeave", function (e) {
|
|
86
65
|
if (e.dataTransfer) {
|
|
87
66
|
e.preventDefault();
|
|
88
67
|
var length = 0;
|
|
89
|
-
|
|
90
68
|
if (dragContainsFiles(e)) {
|
|
91
69
|
var dataTransfer = e.dataTransfer;
|
|
92
70
|
length = _this.getDraggedItemsLength(dataTransfer);
|
|
93
71
|
}
|
|
94
|
-
|
|
95
72
|
_this.emitDragLeave({
|
|
96
73
|
length: length
|
|
97
74
|
});
|
|
98
75
|
}
|
|
99
76
|
});
|
|
100
|
-
|
|
101
77
|
_defineProperty(_assertThisInitialized(_this), "onFileDropped", /*#__PURE__*/function () {
|
|
102
78
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(dragEvent) {
|
|
103
79
|
var flattenedDirectoryFiles, files;
|
|
@@ -109,45 +85,33 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
109
85
|
_context.next = 2;
|
|
110
86
|
break;
|
|
111
87
|
}
|
|
112
|
-
|
|
113
88
|
return _context.abrupt("return");
|
|
114
|
-
|
|
115
89
|
case 2:
|
|
116
90
|
dragEvent.preventDefault();
|
|
117
91
|
dragEvent.stopPropagation();
|
|
92
|
+
|
|
118
93
|
/*
|
|
119
94
|
* Only enable support for folders if (1) the browser is supported (2) feature flag is enabled
|
|
120
95
|
* The file flattening library used to add support for Folders uses a function called webkitEntry.
|
|
121
96
|
* Some browser types are not supported https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitEntries
|
|
122
97
|
*/
|
|
123
|
-
|
|
124
98
|
if (!(isWebkitSupported() && getMediaFeatureFlag('folderUploads', _this.props.featureFlags))) {
|
|
125
99
|
_context.next = 13;
|
|
126
100
|
break;
|
|
127
101
|
}
|
|
128
|
-
|
|
129
102
|
_this.fireAnalyticsForFolders(dragEvent.dataTransfer.items);
|
|
130
|
-
|
|
131
103
|
_context.next = 8;
|
|
132
104
|
return _this.getFilesFromDragEvent(dragEvent.dataTransfer.items);
|
|
133
|
-
|
|
134
105
|
case 8:
|
|
135
106
|
flattenedDirectoryFiles = _context.sent;
|
|
136
|
-
|
|
137
107
|
_this.onDropFolders(flattenedDirectoryFiles.length);
|
|
138
|
-
|
|
139
108
|
_this.uploadService.addFiles(flattenedDirectoryFiles);
|
|
140
|
-
|
|
141
109
|
_context.next = 16;
|
|
142
110
|
break;
|
|
143
|
-
|
|
144
111
|
case 13:
|
|
145
112
|
_this.onDrop(dragEvent);
|
|
146
|
-
|
|
147
113
|
files = Array.from(dragEvent.dataTransfer.files);
|
|
148
|
-
|
|
149
114
|
_this.uploadService.addFiles(files);
|
|
150
|
-
|
|
151
115
|
case 16:
|
|
152
116
|
case "end":
|
|
153
117
|
return _context.stop();
|
|
@@ -155,32 +119,30 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
155
119
|
}
|
|
156
120
|
}, _callee);
|
|
157
121
|
}));
|
|
158
|
-
|
|
159
122
|
return function (_x) {
|
|
160
123
|
return _ref.apply(this, arguments);
|
|
161
124
|
};
|
|
162
125
|
}());
|
|
163
|
-
|
|
164
126
|
_defineProperty(_assertThisInitialized(_this), "fireAnalyticsForFolders", function (items) {
|
|
165
127
|
//convert DataTransferItemList into an array of DataTransferItem(s)
|
|
166
|
-
var toArray = Array.from(items);
|
|
128
|
+
var toArray = Array.from(items);
|
|
167
129
|
|
|
130
|
+
//function to check if a file entry is a folder
|
|
168
131
|
var hasFolder = function hasFolder(item) {
|
|
169
132
|
var _item$webkitGetAsEntr;
|
|
170
|
-
|
|
171
133
|
return (_item$webkitGetAsEntr = item.webkitGetAsEntry()) === null || _item$webkitGetAsEntr === void 0 ? void 0 : _item$webkitGetAsEntr.isDirectory;
|
|
172
|
-
};
|
|
173
|
-
|
|
134
|
+
};
|
|
174
135
|
|
|
136
|
+
//how many folders are in a single drag and drop event
|
|
175
137
|
var folderCount = toArray.filter(function (item) {
|
|
176
138
|
return hasFolder(item);
|
|
177
|
-
}).length;
|
|
139
|
+
}).length;
|
|
178
140
|
|
|
141
|
+
// fires analytic events if number of folders is more than 0
|
|
179
142
|
if (folderCount > 0) {
|
|
180
143
|
_this.fireAnalyticsEvent('folderDroppedInto', folderCount);
|
|
181
144
|
}
|
|
182
145
|
});
|
|
183
|
-
|
|
184
146
|
_defineProperty(_assertThisInitialized(_this), "getFilesFromDragEvent", /*#__PURE__*/function () {
|
|
185
147
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(dragEventItemList) {
|
|
186
148
|
var items, fileSystemEntries, files;
|
|
@@ -189,19 +151,15 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
189
151
|
switch (_context2.prev = _context2.next) {
|
|
190
152
|
case 0:
|
|
191
153
|
items = dragEventItemList; //If items consist of directory or directories, flatten it to grab the files only. Else, just get the files
|
|
192
|
-
|
|
193
154
|
_context2.next = 3;
|
|
194
155
|
return getFilesFromItems(items);
|
|
195
|
-
|
|
196
156
|
case 3:
|
|
197
157
|
fileSystemEntries = _context2.sent;
|
|
198
158
|
_context2.next = 6;
|
|
199
159
|
return getFilesFromFileSystemEntries(fileSystemEntries);
|
|
200
|
-
|
|
201
160
|
case 6:
|
|
202
161
|
files = _context2.sent;
|
|
203
162
|
return _context2.abrupt("return", _this.filterFilesAgainstBlacklist(files));
|
|
204
|
-
|
|
205
163
|
case 8:
|
|
206
164
|
case "end":
|
|
207
165
|
return _context2.stop();
|
|
@@ -209,52 +167,42 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
209
167
|
}
|
|
210
168
|
}, _callee2);
|
|
211
169
|
}));
|
|
212
|
-
|
|
213
170
|
return function (_x2) {
|
|
214
171
|
return _ref2.apply(this, arguments);
|
|
215
172
|
};
|
|
216
173
|
}());
|
|
217
|
-
|
|
218
174
|
_defineProperty(_assertThisInitialized(_this), "filterFilesAgainstBlacklist", function (files) {
|
|
219
175
|
// We don't want these files in our final File list
|
|
220
|
-
var blacklist = ['.DS_Store', 'thumbs.db', 'desktop.ini'];
|
|
176
|
+
var blacklist = ['.DS_Store', 'thumbs.db', 'desktop.ini'];
|
|
221
177
|
|
|
178
|
+
// Filter Files using our defined blacklist
|
|
222
179
|
return files.filter(function (file) {
|
|
223
180
|
return !blacklist.includes(file.name);
|
|
224
181
|
});
|
|
225
182
|
});
|
|
226
|
-
|
|
227
183
|
_defineProperty(_assertThisInitialized(_this), "onDropFolders", function (fileCount) {
|
|
228
184
|
if (fileCount > 0) {
|
|
229
185
|
_this.sendAnalyticsAndEmitDragLeave(fileCount);
|
|
230
186
|
}
|
|
231
187
|
});
|
|
232
|
-
|
|
233
188
|
_defineProperty(_assertThisInitialized(_this), "onDrop", function (e) {
|
|
234
189
|
if (e.dataTransfer && dragContainsFiles(e)) {
|
|
235
190
|
var dataTransfer = e.dataTransfer;
|
|
236
|
-
|
|
237
191
|
var fileCount = _this.getDraggedItemsLength(dataTransfer);
|
|
238
|
-
|
|
239
192
|
_this.sendAnalyticsAndEmitDragLeave(fileCount);
|
|
240
193
|
}
|
|
241
194
|
});
|
|
242
|
-
|
|
243
195
|
_defineProperty(_assertThisInitialized(_this), "sendAnalyticsAndEmitDragLeave", function (fileCount) {
|
|
244
196
|
_this.fireAnalyticsEvent('droppedInto', fileCount);
|
|
245
|
-
|
|
246
197
|
if (_this.props.onDrop) {
|
|
247
198
|
_this.props.onDrop();
|
|
248
199
|
}
|
|
249
|
-
|
|
250
200
|
_this.emitDragLeave({
|
|
251
201
|
length: fileCount
|
|
252
202
|
});
|
|
253
203
|
});
|
|
254
|
-
|
|
255
204
|
return _this;
|
|
256
205
|
}
|
|
257
|
-
|
|
258
206
|
_createClass(DropzoneBase, [{
|
|
259
207
|
key: "getContainer",
|
|
260
208
|
value: function getContainer() {
|
|
@@ -266,7 +214,6 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
266
214
|
value: function componentDidMount() {
|
|
267
215
|
var onCancelFn = this.props.onCancelFn;
|
|
268
216
|
this.addContainerListeners(this.getContainer());
|
|
269
|
-
|
|
270
217
|
if (onCancelFn) {
|
|
271
218
|
onCancelFn(this.cancel);
|
|
272
219
|
}
|
|
@@ -281,7 +228,6 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
281
228
|
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
282
229
|
var newContainer = nextProps.config.container;
|
|
283
230
|
var oldContainer = this.props.config.container;
|
|
284
|
-
|
|
285
231
|
if (newContainer !== oldContainer) {
|
|
286
232
|
this.removeContainerListeners(oldContainer);
|
|
287
233
|
this.addContainerListeners(newContainer);
|
|
@@ -289,7 +235,8 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
289
235
|
}
|
|
290
236
|
}, {
|
|
291
237
|
key: "getDraggedItemsLength",
|
|
292
|
-
value:
|
|
238
|
+
value:
|
|
239
|
+
// Cross-browser way of getting dragged items length, we prioritize "items" if present
|
|
293
240
|
// https://www.w3.org/TR/html51/editing.html#the-datatransfer-interface
|
|
294
241
|
// This method is used on 'dragover' and we have no way to retrieve FileSystemFileEntry,
|
|
295
242
|
// which contains info about if the dropped item is a file or directory. That info is only
|
|
@@ -300,12 +247,12 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
300
247
|
return items.filter(function (i) {
|
|
301
248
|
return i.kind === 'file';
|
|
302
249
|
}).length;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
|
|
250
|
+
}
|
|
251
|
+
// This is required for IE11
|
|
306
252
|
return dataTransfer.files.length;
|
|
307
|
-
}
|
|
253
|
+
}
|
|
308
254
|
|
|
255
|
+
// Similar to the onDrop event, but for folders.
|
|
309
256
|
}, {
|
|
310
257
|
key: "emitDragOver",
|
|
311
258
|
value: function emitDragOver(payload) {
|
|
@@ -313,7 +260,6 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
313
260
|
var onDragEnter = this.props.onDragEnter;
|
|
314
261
|
this.uiActive = true;
|
|
315
262
|
this.fireAnalyticsEvent('draggedInto', payload.length);
|
|
316
|
-
|
|
317
263
|
if (onDragEnter) {
|
|
318
264
|
onDragEnter(payload);
|
|
319
265
|
}
|
|
@@ -323,20 +269,16 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
323
269
|
key: "emitDragLeave",
|
|
324
270
|
value: function emitDragLeave(payload) {
|
|
325
271
|
var _this2 = this;
|
|
326
|
-
|
|
327
272
|
if (this.uiActive) {
|
|
328
273
|
this.uiActive = false;
|
|
329
274
|
/*
|
|
330
275
|
when drag over child elements, container will issue dragleave and then dragover immediately.
|
|
331
276
|
The 50ms timeout will prevent from issuing that "false" dragleave event
|
|
332
277
|
*/
|
|
333
|
-
|
|
334
278
|
window.setTimeout(function () {
|
|
335
279
|
if (!_this2.uiActive) {
|
|
336
280
|
var onDragLeave = _this2.props.onDragLeave;
|
|
337
|
-
|
|
338
281
|
_this2.fireAnalyticsEvent('draggedOut', payload.length);
|
|
339
|
-
|
|
340
282
|
if (onDragLeave) {
|
|
341
283
|
onDragLeave(payload);
|
|
342
284
|
}
|
|
@@ -348,7 +290,6 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
348
290
|
key: "fireAnalyticsEvent",
|
|
349
291
|
value: function fireAnalyticsEvent(action, fileCount) {
|
|
350
292
|
var createAnalyticsEvent = this.props.createAnalyticsEvent;
|
|
351
|
-
|
|
352
293
|
if (createAnalyticsEvent) {
|
|
353
294
|
var _payload = {
|
|
354
295
|
eventType: 'ui',
|
|
@@ -368,7 +309,6 @@ export var DropzoneBase = /*#__PURE__*/function (_LocalUploadComponent) {
|
|
|
368
309
|
return null;
|
|
369
310
|
}
|
|
370
311
|
}]);
|
|
371
|
-
|
|
372
312
|
return DropzoneBase;
|
|
373
313
|
}(LocalUploadComponentReact);
|
|
374
314
|
export default DropzoneBase;
|
|
@@ -8,42 +8,30 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
8
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
10
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
|
-
|
|
12
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
13
|
-
|
|
14
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
15
|
-
|
|
16
13
|
import React from 'react';
|
|
17
14
|
export var DropzoneLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
18
15
|
_inherits(DropzoneLoader, _React$PureComponent);
|
|
19
|
-
|
|
20
16
|
var _super = _createSuper(DropzoneLoader);
|
|
21
|
-
|
|
22
17
|
function DropzoneLoader() {
|
|
23
18
|
var _this;
|
|
24
|
-
|
|
25
19
|
_classCallCheck(this, DropzoneLoader);
|
|
26
|
-
|
|
27
20
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
28
21
|
args[_key] = arguments[_key];
|
|
29
22
|
}
|
|
30
|
-
|
|
31
23
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
32
|
-
|
|
33
24
|
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
34
25
|
Dropzone: DropzoneLoader.Dropzone,
|
|
35
26
|
MediaPickerErrorBoundary: DropzoneLoader.MediaPickerErrorBoundary
|
|
36
27
|
});
|
|
37
|
-
|
|
38
28
|
return _this;
|
|
39
29
|
}
|
|
40
|
-
|
|
41
30
|
_createClass(DropzoneLoader, [{
|
|
42
31
|
key: "UNSAFE_componentWillMount",
|
|
43
32
|
value: function () {
|
|
44
33
|
var _UNSAFE_componentWillMount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
45
34
|
var _yield$Promise$all, _yield$Promise$all2, mediaClient, dropzoneModule, mediaPickerErrorBoundaryModule;
|
|
46
|
-
|
|
47
35
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
48
36
|
while (1) {
|
|
49
37
|
switch (_context.prev = _context.next) {
|
|
@@ -52,17 +40,9 @@ export var DropzoneLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
52
40
|
_context.next = 16;
|
|
53
41
|
break;
|
|
54
42
|
}
|
|
55
|
-
|
|
56
43
|
_context.prev = 1;
|
|
57
44
|
_context.next = 4;
|
|
58
|
-
return Promise.all([import(
|
|
59
|
-
/* webpackChunkName: "@atlaskit-internal_media-client" */
|
|
60
|
-
'@atlaskit/media-client'), import(
|
|
61
|
-
/* webpackChunkName: "@atlaskit-internal_media-dropzone" */
|
|
62
|
-
'./dropzone'), import(
|
|
63
|
-
/* webpackChunkName: "@atlaskit-internal_media-picker-error-boundary" */
|
|
64
|
-
'../media-picker-analytics-error-boundary')]);
|
|
65
|
-
|
|
45
|
+
return Promise.all([import( /* webpackChunkName: "@atlaskit-internal_media-client" */'@atlaskit/media-client'), import( /* webpackChunkName: "@atlaskit-internal_media-dropzone" */'./dropzone'), import( /* webpackChunkName: "@atlaskit-internal_media-picker-error-boundary" */'../media-picker-analytics-error-boundary')]);
|
|
66
46
|
case 4:
|
|
67
47
|
_yield$Promise$all = _context.sent;
|
|
68
48
|
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 3);
|
|
@@ -77,11 +57,9 @@ export var DropzoneLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
77
57
|
});
|
|
78
58
|
_context.next = 16;
|
|
79
59
|
break;
|
|
80
|
-
|
|
81
60
|
case 14:
|
|
82
61
|
_context.prev = 14;
|
|
83
62
|
_context.t0 = _context["catch"](1);
|
|
84
|
-
|
|
85
63
|
case 16:
|
|
86
64
|
case "end":
|
|
87
65
|
return _context.stop();
|
|
@@ -89,29 +67,23 @@ export var DropzoneLoader = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
89
67
|
}
|
|
90
68
|
}, _callee, this, [[1, 14]]);
|
|
91
69
|
}));
|
|
92
|
-
|
|
93
70
|
function UNSAFE_componentWillMount() {
|
|
94
71
|
return _UNSAFE_componentWillMount.apply(this, arguments);
|
|
95
72
|
}
|
|
96
|
-
|
|
97
73
|
return UNSAFE_componentWillMount;
|
|
98
74
|
}()
|
|
99
75
|
}, {
|
|
100
76
|
key: "render",
|
|
101
77
|
value: function render() {
|
|
102
78
|
var _this$state = this.state,
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
79
|
+
Dropzone = _this$state.Dropzone,
|
|
80
|
+
MediaPickerErrorBoundary = _this$state.MediaPickerErrorBoundary;
|
|
106
81
|
if (!Dropzone || !MediaPickerErrorBoundary) {
|
|
107
82
|
return null;
|
|
108
83
|
}
|
|
109
|
-
|
|
110
84
|
return /*#__PURE__*/React.createElement(MediaPickerErrorBoundary, null, /*#__PURE__*/React.createElement(Dropzone, this.props));
|
|
111
85
|
}
|
|
112
86
|
}]);
|
|
113
|
-
|
|
114
87
|
return DropzoneLoader;
|
|
115
88
|
}(React.PureComponent);
|
|
116
|
-
|
|
117
89
|
_defineProperty(DropzoneLoader, "displayName", 'AsyncDropzone');
|
|
@@ -7,11 +7,8 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
7
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
8
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
10
|
-
|
|
11
10
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
|
-
|
|
13
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
14
|
-
|
|
15
12
|
import { Component } from 'react';
|
|
16
13
|
import { start, end } from 'perf-marks';
|
|
17
14
|
import { getMediaClientErrorReason } from '@atlaskit/media-client';
|
|
@@ -22,27 +19,20 @@ import { getRequestMetadata } from '../util/analytics';
|
|
|
22
19
|
import { startMediaUploadUfoExperience, succeedMediaUploadUfoExperience, failMediaUploadUfoExperience } from '../util/ufoExperiences';
|
|
23
20
|
export var LocalUploadComponentReact = /*#__PURE__*/function (_Component) {
|
|
24
21
|
_inherits(LocalUploadComponentReact, _Component);
|
|
25
|
-
|
|
26
22
|
var _super = _createSuper(LocalUploadComponentReact);
|
|
27
|
-
|
|
28
23
|
function LocalUploadComponentReact(props, componentName) {
|
|
29
24
|
var _this;
|
|
30
|
-
|
|
31
25
|
_classCallCheck(this, LocalUploadComponentReact);
|
|
32
|
-
|
|
33
26
|
_this = _super.call(this, props);
|
|
34
|
-
|
|
35
27
|
_defineProperty(_assertThisInitialized(_this), "uploadComponent", new UploadComponent());
|
|
36
|
-
|
|
37
28
|
_defineProperty(_assertThisInitialized(_this), "fireCommencedEvent", function (payload) {
|
|
38
29
|
var files = payload.files,
|
|
39
|
-
|
|
30
|
+
traceContext = payload.traceContext;
|
|
40
31
|
files.forEach(function (_ref) {
|
|
41
32
|
var fileId = _ref.id,
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
fileSize = _ref.size,
|
|
34
|
+
fileMimetype = _ref.type;
|
|
44
35
|
start("MediaPicker.fireUpload.".concat(fileId));
|
|
45
|
-
|
|
46
36
|
_this.createAndFireAnalyticsEvent({
|
|
47
37
|
eventType: 'operational',
|
|
48
38
|
action: 'commenced',
|
|
@@ -59,22 +49,18 @@ export var LocalUploadComponentReact = /*#__PURE__*/function (_Component) {
|
|
|
59
49
|
traceContext: traceContext
|
|
60
50
|
}
|
|
61
51
|
});
|
|
62
|
-
|
|
63
52
|
startMediaUploadUfoExperience(fileId, _this.componentName);
|
|
64
53
|
});
|
|
65
54
|
});
|
|
66
|
-
|
|
67
55
|
_defineProperty(_assertThisInitialized(_this), "fireUploadSucceeded", function (payload) {
|
|
68
56
|
var _payload$file = payload.file,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
57
|
+
fileId = _payload$file.id,
|
|
58
|
+
fileSize = _payload$file.size,
|
|
59
|
+
fileMimetype = _payload$file.type,
|
|
60
|
+
traceContext = payload.traceContext;
|
|
74
61
|
var _end = end("MediaPicker.fireUpload.".concat(fileId)),
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
62
|
+
_end$duration = _end.duration,
|
|
63
|
+
uploadDurationMsec = _end$duration === void 0 ? -1 : _end$duration;
|
|
78
64
|
_this.createAndFireAnalyticsEvent({
|
|
79
65
|
eventType: 'operational',
|
|
80
66
|
action: 'succeeded',
|
|
@@ -93,25 +79,21 @@ export var LocalUploadComponentReact = /*#__PURE__*/function (_Component) {
|
|
|
93
79
|
traceContext: traceContext
|
|
94
80
|
}
|
|
95
81
|
});
|
|
96
|
-
|
|
97
82
|
succeedMediaUploadUfoExperience(fileId, {
|
|
98
83
|
fileId: fileId,
|
|
99
84
|
fileSize: fileSize,
|
|
100
85
|
fileMimetype: fileMimetype
|
|
101
86
|
});
|
|
102
87
|
});
|
|
103
|
-
|
|
104
88
|
_defineProperty(_assertThisInitialized(_this), "fireUploadFailed", /*#__PURE__*/function () {
|
|
105
89
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload) {
|
|
106
90
|
var fileId, _payload$error, errorName, rawError, traceContext, _end2, _end2$duration, uploadDurationMsec;
|
|
107
|
-
|
|
108
91
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
109
92
|
while (1) {
|
|
110
93
|
switch (_context.prev = _context.next) {
|
|
111
94
|
case 0:
|
|
112
95
|
fileId = payload.fileId, _payload$error = payload.error, errorName = _payload$error.name, rawError = _payload$error.rawError, traceContext = payload.traceContext;
|
|
113
96
|
_end2 = end("MediaPicker.fireUpload.".concat(fileId)), _end2$duration = _end2.duration, uploadDurationMsec = _end2$duration === void 0 ? -1 : _end2$duration;
|
|
114
|
-
|
|
115
97
|
_this.createAndFireAnalyticsEvent({
|
|
116
98
|
eventType: 'operational',
|
|
117
99
|
action: 'failed',
|
|
@@ -131,7 +113,6 @@ export var LocalUploadComponentReact = /*#__PURE__*/function (_Component) {
|
|
|
131
113
|
traceContext: traceContext
|
|
132
114
|
}
|
|
133
115
|
});
|
|
134
|
-
|
|
135
116
|
failMediaUploadUfoExperience(fileId, {
|
|
136
117
|
failReason: errorName,
|
|
137
118
|
error: !!rawError ? getMediaClientErrorReason(rawError) : 'unknown',
|
|
@@ -141,7 +122,6 @@ export var LocalUploadComponentReact = /*#__PURE__*/function (_Component) {
|
|
|
141
122
|
},
|
|
142
123
|
uploadDurationMsec: uploadDurationMsec
|
|
143
124
|
});
|
|
144
|
-
|
|
145
125
|
case 4:
|
|
146
126
|
case "end":
|
|
147
127
|
return _context.stop();
|
|
@@ -149,106 +129,78 @@ export var LocalUploadComponentReact = /*#__PURE__*/function (_Component) {
|
|
|
149
129
|
}
|
|
150
130
|
}, _callee);
|
|
151
131
|
}));
|
|
152
|
-
|
|
153
132
|
return function (_x) {
|
|
154
133
|
return _ref2.apply(this, arguments);
|
|
155
134
|
};
|
|
156
135
|
}());
|
|
157
|
-
|
|
158
136
|
_defineProperty(_assertThisInitialized(_this), "createAndFireAnalyticsEvent", function (payload) {
|
|
159
137
|
var createAnalyticsEvent = _this.props.createAnalyticsEvent;
|
|
160
|
-
|
|
161
138
|
if (createAnalyticsEvent) {
|
|
162
139
|
createAnalyticsEvent(payload).fire(ANALYTICS_MEDIA_CHANNEL);
|
|
163
140
|
}
|
|
164
141
|
});
|
|
165
|
-
|
|
166
142
|
_defineProperty(_assertThisInitialized(_this), "cancel", function (uniqueIdentifier) {
|
|
167
143
|
_this.uploadService.cancel(uniqueIdentifier);
|
|
168
144
|
});
|
|
169
|
-
|
|
170
145
|
_defineProperty(_assertThisInitialized(_this), "onFilesAdded", function (_ref3) {
|
|
171
146
|
var files = _ref3.files,
|
|
172
|
-
|
|
173
|
-
|
|
147
|
+
traceContext = _ref3.traceContext;
|
|
174
148
|
_this.uploadComponent.emitUploadsStart(files, traceContext);
|
|
175
149
|
});
|
|
176
|
-
|
|
177
150
|
_defineProperty(_assertThisInitialized(_this), "onFilePreviewUpdate", function (_ref4) {
|
|
178
151
|
var file = _ref4.file,
|
|
179
|
-
|
|
180
|
-
|
|
152
|
+
preview = _ref4.preview;
|
|
181
153
|
_this.uploadComponent.emitUploadPreviewUpdate(file, preview);
|
|
182
154
|
});
|
|
183
|
-
|
|
184
155
|
_defineProperty(_assertThisInitialized(_this), "onFileConverting", function (_ref5) {
|
|
185
156
|
var file = _ref5.file,
|
|
186
|
-
|
|
187
|
-
|
|
157
|
+
traceContext = _ref5.traceContext;
|
|
188
158
|
_this.uploadComponent.emitUploadEnd(file, traceContext);
|
|
189
159
|
});
|
|
190
|
-
|
|
191
160
|
_defineProperty(_assertThisInitialized(_this), "onUploadError", function (_ref6) {
|
|
192
161
|
var fileId = _ref6.fileId,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
162
|
+
error = _ref6.error,
|
|
163
|
+
traceContext = _ref6.traceContext;
|
|
196
164
|
_this.uploadComponent.emitUploadError(fileId, error, traceContext);
|
|
197
165
|
});
|
|
198
|
-
|
|
199
166
|
_this.componentName = componentName;
|
|
200
167
|
var _this$props = _this.props,
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
168
|
+
mediaClient = _this$props.mediaClient,
|
|
169
|
+
config = _this$props.config,
|
|
170
|
+
onUploadsStart = _this$props.onUploadsStart,
|
|
171
|
+
onPreviewUpdate = _this$props.onPreviewUpdate,
|
|
172
|
+
onEnd = _this$props.onEnd,
|
|
173
|
+
onError = _this$props.onError;
|
|
207
174
|
var tenantUploadParams = config.uploadParams;
|
|
208
175
|
var _config$shouldCopyFil = config.shouldCopyFileToRecents,
|
|
209
|
-
|
|
210
|
-
|
|
176
|
+
shouldCopyFileToRecents = _config$shouldCopyFil === void 0 ? true : _config$shouldCopyFil;
|
|
211
177
|
_this.uploadComponent.on('uploads-start', _this.fireCommencedEvent);
|
|
212
|
-
|
|
213
178
|
_this.uploadComponent.on('upload-end', _this.fireUploadSucceeded);
|
|
214
|
-
|
|
215
179
|
_this.uploadComponent.on('upload-error', _this.fireUploadFailed);
|
|
216
|
-
|
|
217
180
|
if (onUploadsStart) {
|
|
218
181
|
_this.uploadComponent.on('uploads-start', onUploadsStart);
|
|
219
182
|
}
|
|
220
|
-
|
|
221
183
|
if (onPreviewUpdate) {
|
|
222
184
|
_this.uploadComponent.on('upload-preview-update', onPreviewUpdate);
|
|
223
185
|
}
|
|
224
|
-
|
|
225
186
|
if (onEnd) {
|
|
226
187
|
_this.uploadComponent.on('upload-end', onEnd);
|
|
227
188
|
}
|
|
228
|
-
|
|
229
189
|
if (onError) {
|
|
230
190
|
_this.uploadComponent.on('upload-error', onError);
|
|
231
191
|
}
|
|
232
|
-
|
|
233
192
|
_this.uploadService = new UploadServiceImpl(mediaClient, tenantUploadParams, shouldCopyFileToRecents);
|
|
234
|
-
|
|
235
193
|
_this.uploadService.on('files-added', _this.onFilesAdded);
|
|
236
|
-
|
|
237
194
|
_this.uploadService.on('file-preview-update', _this.onFilePreviewUpdate);
|
|
238
|
-
|
|
239
195
|
_this.uploadService.on('file-converting', _this.onFileConverting);
|
|
240
|
-
|
|
241
196
|
_this.uploadService.on('file-upload-error', _this.onUploadError);
|
|
242
|
-
|
|
243
197
|
return _this;
|
|
244
198
|
}
|
|
245
|
-
|
|
246
199
|
_createClass(LocalUploadComponentReact, [{
|
|
247
200
|
key: "setUploadParams",
|
|
248
201
|
value: function setUploadParams(uploadParams) {
|
|
249
202
|
this.uploadService.setUploadParams(uploadParams);
|
|
250
203
|
}
|
|
251
204
|
}]);
|
|
252
|
-
|
|
253
205
|
return LocalUploadComponentReact;
|
|
254
206
|
}(Component);
|