@bigbinary/neeto-image-uploader-frontend 2.0.0 → 2.0.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/dist/index.cjs.js +170 -1868
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +189 -1887
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.cjs.js
CHANGED
|
@@ -11,6 +11,7 @@ var Typography = require('@bigbinary/neetoui/Typography');
|
|
|
11
11
|
var ramda = require('ramda');
|
|
12
12
|
var reactI18next = require('react-i18next');
|
|
13
13
|
var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
|
|
14
|
+
var reactDropzone = require('react-dropzone');
|
|
14
15
|
var i18next = require('i18next');
|
|
15
16
|
var Toastr = require('@bigbinary/neetoui/Toastr');
|
|
16
17
|
var jsxRuntime = require('react/jsx-runtime');
|
|
@@ -73,7 +74,7 @@ function _toPropertyKey(arg) {
|
|
|
73
74
|
return _typeof$2(key) === "symbol" ? key : String(key);
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
function _defineProperty$
|
|
77
|
+
function _defineProperty$1(obj, key, value) {
|
|
77
78
|
key = _toPropertyKey(key);
|
|
78
79
|
if (key in obj) {
|
|
79
80
|
Object.defineProperty(obj, key, {
|
|
@@ -88,7 +89,7 @@ function _defineProperty$3(obj, key, value) {
|
|
|
88
89
|
return obj;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
function _objectWithoutPropertiesLoose
|
|
92
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
92
93
|
if (source == null) return {};
|
|
93
94
|
var target = {};
|
|
94
95
|
var sourceKeys = Object.keys(source);
|
|
@@ -101,9 +102,9 @@ function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
|
101
102
|
return target;
|
|
102
103
|
}
|
|
103
104
|
|
|
104
|
-
function _objectWithoutProperties$
|
|
105
|
+
function _objectWithoutProperties$1(source, excluded) {
|
|
105
106
|
if (source == null) return {};
|
|
106
|
-
var target = _objectWithoutPropertiesLoose
|
|
107
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
107
108
|
var key, i;
|
|
108
109
|
if (Object.getOwnPropertySymbols) {
|
|
109
110
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
@@ -138,11 +139,11 @@ var getAllowedTypes = function getAllowedTypes(uploadConfig) {
|
|
|
138
139
|
}), ramda.map(ramda.toUpper), ramda.join(", "))(uploadConfig.allowedImageTypes);
|
|
139
140
|
};
|
|
140
141
|
|
|
141
|
-
function _arrayWithHoles
|
|
142
|
+
function _arrayWithHoles(arr) {
|
|
142
143
|
if (Array.isArray(arr)) return arr;
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
function _iterableToArrayLimit
|
|
146
|
+
function _iterableToArrayLimit(r, l) {
|
|
146
147
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
147
148
|
if (null != t) {
|
|
148
149
|
var e,
|
|
@@ -170,1849 +171,29 @@ function _iterableToArrayLimit$2(r, l) {
|
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
|
|
173
|
-
function _arrayLikeToArray
|
|
174
|
+
function _arrayLikeToArray(arr, len) {
|
|
174
175
|
if (len == null || len > arr.length) len = arr.length;
|
|
175
176
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
176
177
|
return arr2;
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
function _unsupportedIterableToArray
|
|
180
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
180
181
|
if (!o) return;
|
|
181
|
-
if (typeof o === "string") return _arrayLikeToArray
|
|
182
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
182
183
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
183
184
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
184
185
|
if (n === "Map" || n === "Set") return Array.from(o);
|
|
185
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray
|
|
186
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
186
187
|
}
|
|
187
188
|
|
|
188
|
-
function _nonIterableRest
|
|
189
|
+
function _nonIterableRest() {
|
|
189
190
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
190
191
|
}
|
|
191
192
|
|
|
192
|
-
function _slicedToArray
|
|
193
|
-
return _arrayWithHoles
|
|
193
|
+
function _slicedToArray(arr, i) {
|
|
194
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
194
195
|
}
|
|
195
196
|
|
|
196
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
197
|
-
|
|
198
|
-
function getDefaultExportFromCjs (x) {
|
|
199
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
function getAugmentedNamespace(n) {
|
|
203
|
-
if (n.__esModule) return n;
|
|
204
|
-
var f = n.default;
|
|
205
|
-
if (typeof f == "function") {
|
|
206
|
-
var a = function a () {
|
|
207
|
-
if (this instanceof a) {
|
|
208
|
-
return Reflect.construct(f, arguments, this.constructor);
|
|
209
|
-
}
|
|
210
|
-
return f.apply(this, arguments);
|
|
211
|
-
};
|
|
212
|
-
a.prototype = f.prototype;
|
|
213
|
-
} else a = {};
|
|
214
|
-
Object.defineProperty(a, '__esModule', {value: true});
|
|
215
|
-
Object.keys(n).forEach(function (k) {
|
|
216
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
217
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
218
|
-
enumerable: true,
|
|
219
|
-
get: function () {
|
|
220
|
-
return n[k];
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
return a;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
var propTypes = {exports: {}};
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
231
|
-
*
|
|
232
|
-
* This source code is licensed under the MIT license found in the
|
|
233
|
-
* LICENSE file in the root directory of this source tree.
|
|
234
|
-
*/
|
|
235
|
-
|
|
236
|
-
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
237
|
-
|
|
238
|
-
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
242
|
-
*
|
|
243
|
-
* This source code is licensed under the MIT license found in the
|
|
244
|
-
* LICENSE file in the root directory of this source tree.
|
|
245
|
-
*/
|
|
246
|
-
|
|
247
|
-
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
248
|
-
|
|
249
|
-
function emptyFunction() {}
|
|
250
|
-
function emptyFunctionWithReset() {}
|
|
251
|
-
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
252
|
-
|
|
253
|
-
var factoryWithThrowingShims = function() {
|
|
254
|
-
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
255
|
-
if (secret === ReactPropTypesSecret) {
|
|
256
|
-
// It is still safe when called from React.
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
var err = new Error(
|
|
260
|
-
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
261
|
-
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
262
|
-
'Read more at http://fb.me/use-check-prop-types'
|
|
263
|
-
);
|
|
264
|
-
err.name = 'Invariant Violation';
|
|
265
|
-
throw err;
|
|
266
|
-
} shim.isRequired = shim;
|
|
267
|
-
function getShim() {
|
|
268
|
-
return shim;
|
|
269
|
-
} // Important!
|
|
270
|
-
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
271
|
-
var ReactPropTypes = {
|
|
272
|
-
array: shim,
|
|
273
|
-
bigint: shim,
|
|
274
|
-
bool: shim,
|
|
275
|
-
func: shim,
|
|
276
|
-
number: shim,
|
|
277
|
-
object: shim,
|
|
278
|
-
string: shim,
|
|
279
|
-
symbol: shim,
|
|
280
|
-
|
|
281
|
-
any: shim,
|
|
282
|
-
arrayOf: getShim,
|
|
283
|
-
element: shim,
|
|
284
|
-
elementType: shim,
|
|
285
|
-
instanceOf: getShim,
|
|
286
|
-
node: shim,
|
|
287
|
-
objectOf: getShim,
|
|
288
|
-
oneOf: getShim,
|
|
289
|
-
oneOfType: getShim,
|
|
290
|
-
shape: getShim,
|
|
291
|
-
exact: getShim,
|
|
292
|
-
|
|
293
|
-
checkPropTypes: emptyFunctionWithReset,
|
|
294
|
-
resetWarningCache: emptyFunction
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
298
|
-
|
|
299
|
-
return ReactPropTypes;
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
304
|
-
*
|
|
305
|
-
* This source code is licensed under the MIT license found in the
|
|
306
|
-
* LICENSE file in the root directory of this source tree.
|
|
307
|
-
*/
|
|
308
|
-
|
|
309
|
-
{
|
|
310
|
-
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
311
|
-
// http://fb.me/prop-types-in-prod
|
|
312
|
-
propTypes.exports = factoryWithThrowingShims();
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
var propTypesExports = propTypes.exports;
|
|
316
|
-
var PropTypes = /*@__PURE__*/getDefaultExportFromCjs(propTypesExports);
|
|
317
|
-
|
|
318
|
-
/******************************************************************************
|
|
319
|
-
Copyright (c) Microsoft Corporation.
|
|
320
|
-
|
|
321
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
322
|
-
purpose with or without fee is hereby granted.
|
|
323
|
-
|
|
324
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
325
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
326
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
327
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
328
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
329
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
330
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
331
|
-
***************************************************************************** */
|
|
332
|
-
|
|
333
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
334
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
335
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
336
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
337
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
338
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
339
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function __generator(thisArg, body) {
|
|
344
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
345
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
346
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
347
|
-
function step(op) {
|
|
348
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
349
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
350
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
351
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
352
|
-
switch (op[0]) {
|
|
353
|
-
case 0: case 1: t = op; break;
|
|
354
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
355
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
356
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
357
|
-
default:
|
|
358
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
359
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
360
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
361
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
362
|
-
if (t[2]) _.ops.pop();
|
|
363
|
-
_.trys.pop(); continue;
|
|
364
|
-
}
|
|
365
|
-
op = body.call(thisArg, _);
|
|
366
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
367
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
function __read(o, n) {
|
|
372
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
373
|
-
if (!m) return o;
|
|
374
|
-
var i = m.call(o), r, ar = [], e;
|
|
375
|
-
try {
|
|
376
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
377
|
-
}
|
|
378
|
-
catch (error) { e = { error: error }; }
|
|
379
|
-
finally {
|
|
380
|
-
try {
|
|
381
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
382
|
-
}
|
|
383
|
-
finally { if (e) throw e.error; }
|
|
384
|
-
}
|
|
385
|
-
return ar;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
function __spreadArray(to, from, pack) {
|
|
389
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
390
|
-
if (ar || !(i in from)) {
|
|
391
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
392
|
-
ar[i] = from[i];
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
var COMMON_MIME_TYPES = new Map([
|
|
399
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
|
400
|
-
['aac', 'audio/aac'],
|
|
401
|
-
['abw', 'application/x-abiword'],
|
|
402
|
-
['arc', 'application/x-freearc'],
|
|
403
|
-
['avif', 'image/avif'],
|
|
404
|
-
['avi', 'video/x-msvideo'],
|
|
405
|
-
['azw', 'application/vnd.amazon.ebook'],
|
|
406
|
-
['bin', 'application/octet-stream'],
|
|
407
|
-
['bmp', 'image/bmp'],
|
|
408
|
-
['bz', 'application/x-bzip'],
|
|
409
|
-
['bz2', 'application/x-bzip2'],
|
|
410
|
-
['cda', 'application/x-cdf'],
|
|
411
|
-
['csh', 'application/x-csh'],
|
|
412
|
-
['css', 'text/css'],
|
|
413
|
-
['csv', 'text/csv'],
|
|
414
|
-
['doc', 'application/msword'],
|
|
415
|
-
['docx', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'],
|
|
416
|
-
['eot', 'application/vnd.ms-fontobject'],
|
|
417
|
-
['epub', 'application/epub+zip'],
|
|
418
|
-
['gz', 'application/gzip'],
|
|
419
|
-
['gif', 'image/gif'],
|
|
420
|
-
['heic', 'image/heic'],
|
|
421
|
-
['heif', 'image/heif'],
|
|
422
|
-
['htm', 'text/html'],
|
|
423
|
-
['html', 'text/html'],
|
|
424
|
-
['ico', 'image/vnd.microsoft.icon'],
|
|
425
|
-
['ics', 'text/calendar'],
|
|
426
|
-
['jar', 'application/java-archive'],
|
|
427
|
-
['jpeg', 'image/jpeg'],
|
|
428
|
-
['jpg', 'image/jpeg'],
|
|
429
|
-
['js', 'text/javascript'],
|
|
430
|
-
['json', 'application/json'],
|
|
431
|
-
['jsonld', 'application/ld+json'],
|
|
432
|
-
['mid', 'audio/midi'],
|
|
433
|
-
['midi', 'audio/midi'],
|
|
434
|
-
['mjs', 'text/javascript'],
|
|
435
|
-
['mp3', 'audio/mpeg'],
|
|
436
|
-
['mp4', 'video/mp4'],
|
|
437
|
-
['mpeg', 'video/mpeg'],
|
|
438
|
-
['mpkg', 'application/vnd.apple.installer+xml'],
|
|
439
|
-
['odp', 'application/vnd.oasis.opendocument.presentation'],
|
|
440
|
-
['ods', 'application/vnd.oasis.opendocument.spreadsheet'],
|
|
441
|
-
['odt', 'application/vnd.oasis.opendocument.text'],
|
|
442
|
-
['oga', 'audio/ogg'],
|
|
443
|
-
['ogv', 'video/ogg'],
|
|
444
|
-
['ogx', 'application/ogg'],
|
|
445
|
-
['opus', 'audio/opus'],
|
|
446
|
-
['otf', 'font/otf'],
|
|
447
|
-
['png', 'image/png'],
|
|
448
|
-
['pdf', 'application/pdf'],
|
|
449
|
-
['php', 'application/x-httpd-php'],
|
|
450
|
-
['ppt', 'application/vnd.ms-powerpoint'],
|
|
451
|
-
['pptx', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'],
|
|
452
|
-
['rar', 'application/vnd.rar'],
|
|
453
|
-
['rtf', 'application/rtf'],
|
|
454
|
-
['sh', 'application/x-sh'],
|
|
455
|
-
['svg', 'image/svg+xml'],
|
|
456
|
-
['swf', 'application/x-shockwave-flash'],
|
|
457
|
-
['tar', 'application/x-tar'],
|
|
458
|
-
['tif', 'image/tiff'],
|
|
459
|
-
['tiff', 'image/tiff'],
|
|
460
|
-
['ts', 'video/mp2t'],
|
|
461
|
-
['ttf', 'font/ttf'],
|
|
462
|
-
['txt', 'text/plain'],
|
|
463
|
-
['vsd', 'application/vnd.visio'],
|
|
464
|
-
['wav', 'audio/wav'],
|
|
465
|
-
['weba', 'audio/webm'],
|
|
466
|
-
['webm', 'video/webm'],
|
|
467
|
-
['webp', 'image/webp'],
|
|
468
|
-
['woff', 'font/woff'],
|
|
469
|
-
['woff2', 'font/woff2'],
|
|
470
|
-
['xhtml', 'application/xhtml+xml'],
|
|
471
|
-
['xls', 'application/vnd.ms-excel'],
|
|
472
|
-
['xlsx', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'],
|
|
473
|
-
['xml', 'application/xml'],
|
|
474
|
-
['xul', 'application/vnd.mozilla.xul+xml'],
|
|
475
|
-
['zip', 'application/zip'],
|
|
476
|
-
['7z', 'application/x-7z-compressed'],
|
|
477
|
-
// Others
|
|
478
|
-
['mkv', 'video/x-matroska'],
|
|
479
|
-
['mov', 'video/quicktime'],
|
|
480
|
-
['msg', 'application/vnd.ms-outlook']
|
|
481
|
-
]);
|
|
482
|
-
function toFileWithPath(file, path) {
|
|
483
|
-
var f = withMimeType(file);
|
|
484
|
-
if (typeof f.path !== 'string') { // on electron, path is already set to the absolute path
|
|
485
|
-
var webkitRelativePath = file.webkitRelativePath;
|
|
486
|
-
Object.defineProperty(f, 'path', {
|
|
487
|
-
value: typeof path === 'string'
|
|
488
|
-
? path
|
|
489
|
-
// If <input webkitdirectory> is set,
|
|
490
|
-
// the File will have a {webkitRelativePath} property
|
|
491
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/webkitdirectory
|
|
492
|
-
: typeof webkitRelativePath === 'string' && webkitRelativePath.length > 0
|
|
493
|
-
? webkitRelativePath
|
|
494
|
-
: file.name,
|
|
495
|
-
writable: false,
|
|
496
|
-
configurable: false,
|
|
497
|
-
enumerable: true
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
return f;
|
|
501
|
-
}
|
|
502
|
-
function withMimeType(file) {
|
|
503
|
-
var name = file.name;
|
|
504
|
-
var hasExtension = name && name.lastIndexOf('.') !== -1;
|
|
505
|
-
if (hasExtension && !file.type) {
|
|
506
|
-
var ext = name.split('.')
|
|
507
|
-
.pop().toLowerCase();
|
|
508
|
-
var type = COMMON_MIME_TYPES.get(ext);
|
|
509
|
-
if (type) {
|
|
510
|
-
Object.defineProperty(file, 'type', {
|
|
511
|
-
value: type,
|
|
512
|
-
writable: false,
|
|
513
|
-
configurable: false,
|
|
514
|
-
enumerable: true
|
|
515
|
-
});
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
return file;
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
var FILES_TO_IGNORE = [
|
|
522
|
-
// Thumbnail cache files for macOS and Windows
|
|
523
|
-
'.DS_Store',
|
|
524
|
-
'Thumbs.db' // Windows
|
|
525
|
-
];
|
|
526
|
-
/**
|
|
527
|
-
* Convert a DragEvent's DataTrasfer object to a list of File objects
|
|
528
|
-
* NOTE: If some of the items are folders,
|
|
529
|
-
* everything will be flattened and placed in the same list but the paths will be kept as a {path} property.
|
|
530
|
-
*
|
|
531
|
-
* EXPERIMENTAL: A list of https://developer.mozilla.org/en-US/docs/Web/API/FileSystemHandle objects can also be passed as an arg
|
|
532
|
-
* and a list of File objects will be returned.
|
|
533
|
-
*
|
|
534
|
-
* @param evt
|
|
535
|
-
*/
|
|
536
|
-
function fromEvent(evt) {
|
|
537
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
538
|
-
return __generator(this, function (_a) {
|
|
539
|
-
if (isObject(evt) && isDataTransfer(evt.dataTransfer)) {
|
|
540
|
-
return [2 /*return*/, getDataTransferFiles(evt.dataTransfer, evt.type)];
|
|
541
|
-
}
|
|
542
|
-
else if (isChangeEvt(evt)) {
|
|
543
|
-
return [2 /*return*/, getInputFiles(evt)];
|
|
544
|
-
}
|
|
545
|
-
else if (Array.isArray(evt) && evt.every(function (item) { return 'getFile' in item && typeof item.getFile === 'function'; })) {
|
|
546
|
-
return [2 /*return*/, getFsHandleFiles(evt)];
|
|
547
|
-
}
|
|
548
|
-
return [2 /*return*/, []];
|
|
549
|
-
});
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
function isDataTransfer(value) {
|
|
553
|
-
return isObject(value);
|
|
554
|
-
}
|
|
555
|
-
function isChangeEvt(value) {
|
|
556
|
-
return isObject(value) && isObject(value.target);
|
|
557
|
-
}
|
|
558
|
-
function isObject(v) {
|
|
559
|
-
return typeof v === 'object' && v !== null;
|
|
560
|
-
}
|
|
561
|
-
function getInputFiles(evt) {
|
|
562
|
-
return fromList(evt.target.files).map(function (file) { return toFileWithPath(file); });
|
|
563
|
-
}
|
|
564
|
-
// Ee expect each handle to be https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileHandle
|
|
565
|
-
function getFsHandleFiles(handles) {
|
|
566
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
567
|
-
var files;
|
|
568
|
-
return __generator(this, function (_a) {
|
|
569
|
-
switch (_a.label) {
|
|
570
|
-
case 0: return [4 /*yield*/, Promise.all(handles.map(function (h) { return h.getFile(); }))];
|
|
571
|
-
case 1:
|
|
572
|
-
files = _a.sent();
|
|
573
|
-
return [2 /*return*/, files.map(function (file) { return toFileWithPath(file); })];
|
|
574
|
-
}
|
|
575
|
-
});
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
function getDataTransferFiles(dt, type) {
|
|
579
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
580
|
-
var items, files;
|
|
581
|
-
return __generator(this, function (_a) {
|
|
582
|
-
switch (_a.label) {
|
|
583
|
-
case 0:
|
|
584
|
-
if (!dt.items) return [3 /*break*/, 2];
|
|
585
|
-
items = fromList(dt.items)
|
|
586
|
-
.filter(function (item) { return item.kind === 'file'; });
|
|
587
|
-
// According to https://html.spec.whatwg.org/multipage/dnd.html#dndevents,
|
|
588
|
-
// only 'dragstart' and 'drop' has access to the data (source node)
|
|
589
|
-
if (type !== 'drop') {
|
|
590
|
-
return [2 /*return*/, items];
|
|
591
|
-
}
|
|
592
|
-
return [4 /*yield*/, Promise.all(items.map(toFilePromises))];
|
|
593
|
-
case 1:
|
|
594
|
-
files = _a.sent();
|
|
595
|
-
return [2 /*return*/, noIgnoredFiles(flatten(files))];
|
|
596
|
-
case 2: return [2 /*return*/, noIgnoredFiles(fromList(dt.files)
|
|
597
|
-
.map(function (file) { return toFileWithPath(file); }))];
|
|
598
|
-
}
|
|
599
|
-
});
|
|
600
|
-
});
|
|
601
|
-
}
|
|
602
|
-
function noIgnoredFiles(files) {
|
|
603
|
-
return files.filter(function (file) { return FILES_TO_IGNORE.indexOf(file.name) === -1; });
|
|
604
|
-
}
|
|
605
|
-
// IE11 does not support Array.from()
|
|
606
|
-
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from#Browser_compatibility
|
|
607
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/FileList
|
|
608
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItemList
|
|
609
|
-
function fromList(items) {
|
|
610
|
-
if (items === null) {
|
|
611
|
-
return [];
|
|
612
|
-
}
|
|
613
|
-
var files = [];
|
|
614
|
-
// tslint:disable: prefer-for-of
|
|
615
|
-
for (var i = 0; i < items.length; i++) {
|
|
616
|
-
var file = items[i];
|
|
617
|
-
files.push(file);
|
|
618
|
-
}
|
|
619
|
-
return files;
|
|
620
|
-
}
|
|
621
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/DataTransferItem
|
|
622
|
-
function toFilePromises(item) {
|
|
623
|
-
if (typeof item.webkitGetAsEntry !== 'function') {
|
|
624
|
-
return fromDataTransferItem(item);
|
|
625
|
-
}
|
|
626
|
-
var entry = item.webkitGetAsEntry();
|
|
627
|
-
// Safari supports dropping an image node from a different window and can be retrieved using
|
|
628
|
-
// the DataTransferItem.getAsFile() API
|
|
629
|
-
// NOTE: FileSystemEntry.file() throws if trying to get the file
|
|
630
|
-
if (entry && entry.isDirectory) {
|
|
631
|
-
return fromDirEntry(entry);
|
|
632
|
-
}
|
|
633
|
-
return fromDataTransferItem(item);
|
|
634
|
-
}
|
|
635
|
-
function flatten(items) {
|
|
636
|
-
return items.reduce(function (acc, files) { return __spreadArray(__spreadArray([], __read(acc), false), __read((Array.isArray(files) ? flatten(files) : [files])), false); }, []);
|
|
637
|
-
}
|
|
638
|
-
function fromDataTransferItem(item) {
|
|
639
|
-
var file = item.getAsFile();
|
|
640
|
-
if (!file) {
|
|
641
|
-
return Promise.reject("".concat(item, " is not a File"));
|
|
642
|
-
}
|
|
643
|
-
var fwp = toFileWithPath(file);
|
|
644
|
-
return Promise.resolve(fwp);
|
|
645
|
-
}
|
|
646
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemEntry
|
|
647
|
-
function fromEntry(entry) {
|
|
648
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
649
|
-
return __generator(this, function (_a) {
|
|
650
|
-
return [2 /*return*/, entry.isDirectory ? fromDirEntry(entry) : fromFileEntry(entry)];
|
|
651
|
-
});
|
|
652
|
-
});
|
|
653
|
-
}
|
|
654
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry
|
|
655
|
-
function fromDirEntry(entry) {
|
|
656
|
-
var reader = entry.createReader();
|
|
657
|
-
return new Promise(function (resolve, reject) {
|
|
658
|
-
var entries = [];
|
|
659
|
-
function readEntries() {
|
|
660
|
-
var _this = this;
|
|
661
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryEntry/createReader
|
|
662
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryReader/readEntries
|
|
663
|
-
reader.readEntries(function (batch) { return __awaiter(_this, void 0, void 0, function () {
|
|
664
|
-
var files, err_1, items;
|
|
665
|
-
return __generator(this, function (_a) {
|
|
666
|
-
switch (_a.label) {
|
|
667
|
-
case 0:
|
|
668
|
-
if (!!batch.length) return [3 /*break*/, 5];
|
|
669
|
-
_a.label = 1;
|
|
670
|
-
case 1:
|
|
671
|
-
_a.trys.push([1, 3, , 4]);
|
|
672
|
-
return [4 /*yield*/, Promise.all(entries)];
|
|
673
|
-
case 2:
|
|
674
|
-
files = _a.sent();
|
|
675
|
-
resolve(files);
|
|
676
|
-
return [3 /*break*/, 4];
|
|
677
|
-
case 3:
|
|
678
|
-
err_1 = _a.sent();
|
|
679
|
-
reject(err_1);
|
|
680
|
-
return [3 /*break*/, 4];
|
|
681
|
-
case 4: return [3 /*break*/, 6];
|
|
682
|
-
case 5:
|
|
683
|
-
items = Promise.all(batch.map(fromEntry));
|
|
684
|
-
entries.push(items);
|
|
685
|
-
// Continue reading
|
|
686
|
-
readEntries();
|
|
687
|
-
_a.label = 6;
|
|
688
|
-
case 6: return [2 /*return*/];
|
|
689
|
-
}
|
|
690
|
-
});
|
|
691
|
-
}); }, function (err) {
|
|
692
|
-
reject(err);
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
readEntries();
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/FileSystemFileEntry
|
|
699
|
-
function fromFileEntry(entry) {
|
|
700
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
701
|
-
return __generator(this, function (_a) {
|
|
702
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
703
|
-
entry.file(function (file) {
|
|
704
|
-
var fwp = toFileWithPath(file, entry.fullPath);
|
|
705
|
-
resolve(fwp);
|
|
706
|
-
}, function (err) {
|
|
707
|
-
reject(err);
|
|
708
|
-
});
|
|
709
|
-
})];
|
|
710
|
-
});
|
|
711
|
-
});
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
var _default$1 = function (file, acceptedFiles) {
|
|
715
|
-
if (file && acceptedFiles) {
|
|
716
|
-
var acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(',');
|
|
717
|
-
var fileName = file.name || '';
|
|
718
|
-
var mimeType = (file.type || '').toLowerCase();
|
|
719
|
-
var baseMimeType = mimeType.replace(/\/.*$/, '');
|
|
720
|
-
return acceptedFilesArray.some(function (type) {
|
|
721
|
-
var validType = type.trim().toLowerCase();
|
|
722
|
-
|
|
723
|
-
if (validType.charAt(0) === '.') {
|
|
724
|
-
return fileName.toLowerCase().endsWith(validType);
|
|
725
|
-
} else if (validType.endsWith('/*')) {
|
|
726
|
-
// This is something like a image/* mime type
|
|
727
|
-
return baseMimeType === validType.replace(/\/.*$/, '');
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
return mimeType === validType;
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
return true;
|
|
735
|
-
};
|
|
736
|
-
|
|
737
|
-
function _toConsumableArray$1(arr) { return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1(); }
|
|
738
|
-
|
|
739
|
-
function _nonIterableSpread$1() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
740
|
-
|
|
741
|
-
function _iterableToArray$1(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
742
|
-
|
|
743
|
-
function _arrayWithoutHoles$1(arr) { if (Array.isArray(arr)) return _arrayLikeToArray$1(arr); }
|
|
744
|
-
|
|
745
|
-
function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
746
|
-
|
|
747
|
-
function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$c(Object(source), !0).forEach(function (key) { _defineProperty$2(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
748
|
-
|
|
749
|
-
function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
750
|
-
|
|
751
|
-
function _slicedToArray$1(arr, i) { return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1(); }
|
|
752
|
-
|
|
753
|
-
function _nonIterableRest$1() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
754
|
-
|
|
755
|
-
function _unsupportedIterableToArray$1(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray$1(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray$1(o, minLen); }
|
|
756
|
-
|
|
757
|
-
function _arrayLikeToArray$1(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
758
|
-
|
|
759
|
-
function _iterableToArrayLimit$1(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
760
|
-
|
|
761
|
-
function _arrayWithHoles$1(arr) { if (Array.isArray(arr)) return arr; }
|
|
762
|
-
|
|
763
|
-
var FILE_INVALID_TYPE = "file-invalid-type";
|
|
764
|
-
var FILE_TOO_LARGE = "file-too-large";
|
|
765
|
-
var FILE_TOO_SMALL = "file-too-small";
|
|
766
|
-
var TOO_MANY_FILES = "too-many-files";
|
|
767
|
-
|
|
768
|
-
var getInvalidTypeRejectionErr = function getInvalidTypeRejectionErr(accept) {
|
|
769
|
-
accept = Array.isArray(accept) && accept.length === 1 ? accept[0] : accept;
|
|
770
|
-
var messageSuffix = Array.isArray(accept) ? "one of ".concat(accept.join(", ")) : accept;
|
|
771
|
-
return {
|
|
772
|
-
code: FILE_INVALID_TYPE,
|
|
773
|
-
message: "File type must be ".concat(messageSuffix)
|
|
774
|
-
};
|
|
775
|
-
};
|
|
776
|
-
var getTooLargeRejectionErr = function getTooLargeRejectionErr(maxSize) {
|
|
777
|
-
return {
|
|
778
|
-
code: FILE_TOO_LARGE,
|
|
779
|
-
message: "File is larger than ".concat(maxSize, " ").concat(maxSize === 1 ? "byte" : "bytes")
|
|
780
|
-
};
|
|
781
|
-
};
|
|
782
|
-
var getTooSmallRejectionErr = function getTooSmallRejectionErr(minSize) {
|
|
783
|
-
return {
|
|
784
|
-
code: FILE_TOO_SMALL,
|
|
785
|
-
message: "File is smaller than ".concat(minSize, " ").concat(minSize === 1 ? "byte" : "bytes")
|
|
786
|
-
};
|
|
787
|
-
};
|
|
788
|
-
var TOO_MANY_FILES_REJECTION = {
|
|
789
|
-
code: TOO_MANY_FILES,
|
|
790
|
-
message: "Too many files"
|
|
791
|
-
}; // Firefox versions prior to 53 return a bogus MIME type for every file drag, so dragovers with
|
|
792
|
-
// that MIME type will always be accepted
|
|
793
|
-
|
|
794
|
-
function fileAccepted(file, accept) {
|
|
795
|
-
var isAcceptable = file.type === "application/x-moz-file" || _default$1(file, accept);
|
|
796
|
-
return [isAcceptable, isAcceptable ? null : getInvalidTypeRejectionErr(accept)];
|
|
797
|
-
}
|
|
798
|
-
function fileMatchSize(file, minSize, maxSize) {
|
|
799
|
-
if (isDefined(file.size)) {
|
|
800
|
-
if (isDefined(minSize) && isDefined(maxSize)) {
|
|
801
|
-
if (file.size > maxSize) return [false, getTooLargeRejectionErr(maxSize)];
|
|
802
|
-
if (file.size < minSize) return [false, getTooSmallRejectionErr(minSize)];
|
|
803
|
-
} else if (isDefined(minSize) && file.size < minSize) return [false, getTooSmallRejectionErr(minSize)];else if (isDefined(maxSize) && file.size > maxSize) return [false, getTooLargeRejectionErr(maxSize)];
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
return [true, null];
|
|
807
|
-
}
|
|
808
|
-
|
|
809
|
-
function isDefined(value) {
|
|
810
|
-
return value !== undefined && value !== null;
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
*
|
|
814
|
-
* @param {object} options
|
|
815
|
-
* @param {File[]} options.files
|
|
816
|
-
* @param {string|string[]} [options.accept]
|
|
817
|
-
* @param {number} [options.minSize]
|
|
818
|
-
* @param {number} [options.maxSize]
|
|
819
|
-
* @param {boolean} [options.multiple]
|
|
820
|
-
* @param {number} [options.maxFiles]
|
|
821
|
-
* @param {(f: File) => FileError|FileError[]|null} [options.validator]
|
|
822
|
-
* @returns
|
|
823
|
-
*/
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
function allFilesAccepted(_ref) {
|
|
827
|
-
var files = _ref.files,
|
|
828
|
-
accept = _ref.accept,
|
|
829
|
-
minSize = _ref.minSize,
|
|
830
|
-
maxSize = _ref.maxSize,
|
|
831
|
-
multiple = _ref.multiple,
|
|
832
|
-
maxFiles = _ref.maxFiles,
|
|
833
|
-
validator = _ref.validator;
|
|
834
|
-
|
|
835
|
-
if (!multiple && files.length > 1 || multiple && maxFiles >= 1 && files.length > maxFiles) {
|
|
836
|
-
return false;
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
return files.every(function (file) {
|
|
840
|
-
var _fileAccepted = fileAccepted(file, accept),
|
|
841
|
-
_fileAccepted2 = _slicedToArray$1(_fileAccepted, 1),
|
|
842
|
-
accepted = _fileAccepted2[0];
|
|
843
|
-
|
|
844
|
-
var _fileMatchSize = fileMatchSize(file, minSize, maxSize),
|
|
845
|
-
_fileMatchSize2 = _slicedToArray$1(_fileMatchSize, 1),
|
|
846
|
-
sizeMatch = _fileMatchSize2[0];
|
|
847
|
-
|
|
848
|
-
var customErrors = validator ? validator(file) : null;
|
|
849
|
-
return accepted && sizeMatch && !customErrors;
|
|
850
|
-
});
|
|
851
|
-
} // React's synthetic events has event.isPropagationStopped,
|
|
852
|
-
// but to remain compatibility with other libs (Preact) fall back
|
|
853
|
-
// to check event.cancelBubble
|
|
854
|
-
|
|
855
|
-
function isPropagationStopped(event) {
|
|
856
|
-
if (typeof event.isPropagationStopped === "function") {
|
|
857
|
-
return event.isPropagationStopped();
|
|
858
|
-
} else if (typeof event.cancelBubble !== "undefined") {
|
|
859
|
-
return event.cancelBubble;
|
|
860
|
-
}
|
|
861
|
-
|
|
862
|
-
return false;
|
|
863
|
-
}
|
|
864
|
-
function isEvtWithFiles(event) {
|
|
865
|
-
if (!event.dataTransfer) {
|
|
866
|
-
return !!event.target && !!event.target.files;
|
|
867
|
-
} // https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/types
|
|
868
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API/Recommended_drag_types#file
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
return Array.prototype.some.call(event.dataTransfer.types, function (type) {
|
|
872
|
-
return type === "Files" || type === "application/x-moz-file";
|
|
873
|
-
});
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
function onDocumentDragOver(event) {
|
|
877
|
-
event.preventDefault();
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
function isIe(userAgent) {
|
|
881
|
-
return userAgent.indexOf("MSIE") !== -1 || userAgent.indexOf("Trident/") !== -1;
|
|
882
|
-
}
|
|
883
|
-
|
|
884
|
-
function isEdge(userAgent) {
|
|
885
|
-
return userAgent.indexOf("Edge/") !== -1;
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
function isIeOrEdge() {
|
|
889
|
-
var userAgent = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.navigator.userAgent;
|
|
890
|
-
return isIe(userAgent) || isEdge(userAgent);
|
|
891
|
-
}
|
|
892
|
-
/**
|
|
893
|
-
* This is intended to be used to compose event handlers
|
|
894
|
-
* They are executed in order until one of them calls `event.isPropagationStopped()`.
|
|
895
|
-
* Note that the check is done on the first invoke too,
|
|
896
|
-
* meaning that if propagation was stopped before invoking the fns,
|
|
897
|
-
* no handlers will be executed.
|
|
898
|
-
*
|
|
899
|
-
* @param {Function} fns the event hanlder functions
|
|
900
|
-
* @return {Function} the event handler to add to an element
|
|
901
|
-
*/
|
|
902
|
-
|
|
903
|
-
function composeEventHandlers() {
|
|
904
|
-
for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
905
|
-
fns[_key] = arguments[_key];
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
return function (event) {
|
|
909
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
910
|
-
args[_key2 - 1] = arguments[_key2];
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
return fns.some(function (fn) {
|
|
914
|
-
if (!isPropagationStopped(event) && fn) {
|
|
915
|
-
fn.apply(void 0, [event].concat(args));
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
return isPropagationStopped(event);
|
|
919
|
-
});
|
|
920
|
-
};
|
|
921
|
-
}
|
|
922
|
-
/**
|
|
923
|
-
* canUseFileSystemAccessAPI checks if the [File System Access API](https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API)
|
|
924
|
-
* is supported by the browser.
|
|
925
|
-
* @returns {boolean}
|
|
926
|
-
*/
|
|
927
|
-
|
|
928
|
-
function canUseFileSystemAccessAPI() {
|
|
929
|
-
return "showOpenFilePicker" in window;
|
|
930
|
-
}
|
|
931
|
-
/**
|
|
932
|
-
* Convert the `{accept}` dropzone prop to the
|
|
933
|
-
* `{types}` option for https://developer.mozilla.org/en-US/docs/Web/API/window/showOpenFilePicker
|
|
934
|
-
*
|
|
935
|
-
* @param {AcceptProp} accept
|
|
936
|
-
* @returns {{accept: string[]}[]}
|
|
937
|
-
*/
|
|
938
|
-
|
|
939
|
-
function pickerOptionsFromAccept(accept) {
|
|
940
|
-
if (isDefined(accept)) {
|
|
941
|
-
var acceptForPicker = Object.entries(accept).filter(function (_ref2) {
|
|
942
|
-
var _ref3 = _slicedToArray$1(_ref2, 2),
|
|
943
|
-
mimeType = _ref3[0],
|
|
944
|
-
ext = _ref3[1];
|
|
945
|
-
|
|
946
|
-
var ok = true;
|
|
947
|
-
|
|
948
|
-
if (!isMIMEType(mimeType)) {
|
|
949
|
-
console.warn("Skipped \"".concat(mimeType, "\" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types."));
|
|
950
|
-
ok = false;
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
if (!Array.isArray(ext) || !ext.every(isExt)) {
|
|
954
|
-
console.warn("Skipped \"".concat(mimeType, "\" because an invalid file extension was provided."));
|
|
955
|
-
ok = false;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
return ok;
|
|
959
|
-
}).reduce(function (agg, _ref4) {
|
|
960
|
-
var _ref5 = _slicedToArray$1(_ref4, 2),
|
|
961
|
-
mimeType = _ref5[0],
|
|
962
|
-
ext = _ref5[1];
|
|
963
|
-
|
|
964
|
-
return _objectSpread$b(_objectSpread$b({}, agg), {}, _defineProperty$2({}, mimeType, ext));
|
|
965
|
-
}, {});
|
|
966
|
-
return [{
|
|
967
|
-
// description is required due to https://crbug.com/1264708
|
|
968
|
-
description: "Files",
|
|
969
|
-
accept: acceptForPicker
|
|
970
|
-
}];
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
return accept;
|
|
974
|
-
}
|
|
975
|
-
/**
|
|
976
|
-
* Convert the `{accept}` dropzone prop to an array of MIME types/extensions.
|
|
977
|
-
* @param {AcceptProp} accept
|
|
978
|
-
* @returns {string}
|
|
979
|
-
*/
|
|
980
|
-
|
|
981
|
-
function acceptPropAsAcceptAttr(accept) {
|
|
982
|
-
if (isDefined(accept)) {
|
|
983
|
-
return Object.entries(accept).reduce(function (a, _ref6) {
|
|
984
|
-
var _ref7 = _slicedToArray$1(_ref6, 2),
|
|
985
|
-
mimeType = _ref7[0],
|
|
986
|
-
ext = _ref7[1];
|
|
987
|
-
|
|
988
|
-
return [].concat(_toConsumableArray$1(a), [mimeType], _toConsumableArray$1(ext));
|
|
989
|
-
}, []) // Silently discard invalid entries as pickerOptionsFromAccept warns about these
|
|
990
|
-
.filter(function (v) {
|
|
991
|
-
return isMIMEType(v) || isExt(v);
|
|
992
|
-
}).join(",");
|
|
993
|
-
}
|
|
994
|
-
|
|
995
|
-
return undefined;
|
|
996
|
-
}
|
|
997
|
-
/**
|
|
998
|
-
* Check if v is an exception caused by aborting a request (e.g window.showOpenFilePicker()).
|
|
999
|
-
*
|
|
1000
|
-
* See https://developer.mozilla.org/en-US/docs/Web/API/DOMException.
|
|
1001
|
-
* @param {any} v
|
|
1002
|
-
* @returns {boolean} True if v is an abort exception.
|
|
1003
|
-
*/
|
|
1004
|
-
|
|
1005
|
-
function isAbort(v) {
|
|
1006
|
-
return v instanceof DOMException && (v.name === "AbortError" || v.code === v.ABORT_ERR);
|
|
1007
|
-
}
|
|
1008
|
-
/**
|
|
1009
|
-
* Check if v is a security error.
|
|
1010
|
-
*
|
|
1011
|
-
* See https://developer.mozilla.org/en-US/docs/Web/API/DOMException.
|
|
1012
|
-
* @param {any} v
|
|
1013
|
-
* @returns {boolean} True if v is a security error.
|
|
1014
|
-
*/
|
|
1015
|
-
|
|
1016
|
-
function isSecurityError(v) {
|
|
1017
|
-
return v instanceof DOMException && (v.name === "SecurityError" || v.code === v.SECURITY_ERR);
|
|
1018
|
-
}
|
|
1019
|
-
/**
|
|
1020
|
-
* Check if v is a MIME type string.
|
|
1021
|
-
*
|
|
1022
|
-
* See accepted format: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#unique_file_type_specifiers.
|
|
1023
|
-
*
|
|
1024
|
-
* @param {string} v
|
|
1025
|
-
*/
|
|
1026
|
-
|
|
1027
|
-
function isMIMEType(v) {
|
|
1028
|
-
return v === "audio/*" || v === "video/*" || v === "image/*" || v === "text/*" || /\w+\/[-+.\w]+/g.test(v);
|
|
1029
|
-
}
|
|
1030
|
-
/**
|
|
1031
|
-
* Check if v is a file extension.
|
|
1032
|
-
* @param {string} v
|
|
1033
|
-
*/
|
|
1034
|
-
|
|
1035
|
-
function isExt(v) {
|
|
1036
|
-
return /^.*\.[\w]+$/.test(v);
|
|
1037
|
-
}
|
|
1038
|
-
/**
|
|
1039
|
-
* @typedef {Object.<string, string[]>} AcceptProp
|
|
1040
|
-
*/
|
|
1041
|
-
|
|
1042
|
-
/**
|
|
1043
|
-
* @typedef {object} FileError
|
|
1044
|
-
* @property {string} message
|
|
1045
|
-
* @property {ErrorCode|string} code
|
|
1046
|
-
*/
|
|
1047
|
-
|
|
1048
|
-
/**
|
|
1049
|
-
* @typedef {"file-invalid-type"|"file-too-large"|"file-too-small"|"too-many-files"} ErrorCode
|
|
1050
|
-
*/
|
|
1051
|
-
|
|
1052
|
-
var _excluded$5 = ["children"],
|
|
1053
|
-
_excluded2 = ["open"],
|
|
1054
|
-
_excluded3 = ["refKey", "role", "onKeyDown", "onFocus", "onBlur", "onClick", "onDragEnter", "onDragOver", "onDragLeave", "onDrop"],
|
|
1055
|
-
_excluded4 = ["refKey", "onChange", "onClick"];
|
|
1056
|
-
|
|
1057
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
1058
|
-
|
|
1059
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
1060
|
-
|
|
1061
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
1062
|
-
|
|
1063
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
1064
|
-
|
|
1065
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
1066
|
-
|
|
1067
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
1068
|
-
|
|
1069
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
1070
|
-
|
|
1071
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
1072
|
-
|
|
1073
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
1074
|
-
|
|
1075
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
1076
|
-
|
|
1077
|
-
function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
1078
|
-
|
|
1079
|
-
function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$b(Object(source), !0).forEach(function (key) { _defineProperty$1(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1080
|
-
|
|
1081
|
-
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
1082
|
-
|
|
1083
|
-
function _objectWithoutProperties$1(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
1084
|
-
|
|
1085
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
1086
|
-
/**
|
|
1087
|
-
* Convenience wrapper component for the `useDropzone` hook
|
|
1088
|
-
*
|
|
1089
|
-
* ```jsx
|
|
1090
|
-
* <Dropzone>
|
|
1091
|
-
* {({getRootProps, getInputProps}) => (
|
|
1092
|
-
* <div {...getRootProps()}>
|
|
1093
|
-
* <input {...getInputProps()} />
|
|
1094
|
-
* <p>Drag 'n' drop some files here, or click to select files</p>
|
|
1095
|
-
* </div>
|
|
1096
|
-
* )}
|
|
1097
|
-
* </Dropzone>
|
|
1098
|
-
* ```
|
|
1099
|
-
*/
|
|
1100
|
-
|
|
1101
|
-
var Dropzone = /*#__PURE__*/require$$0.forwardRef(function (_ref, ref) {
|
|
1102
|
-
var children = _ref.children,
|
|
1103
|
-
params = _objectWithoutProperties$1(_ref, _excluded$5);
|
|
1104
|
-
|
|
1105
|
-
var _useDropzone = useDropzone(params),
|
|
1106
|
-
open = _useDropzone.open,
|
|
1107
|
-
props = _objectWithoutProperties$1(_useDropzone, _excluded2);
|
|
1108
|
-
|
|
1109
|
-
require$$0.useImperativeHandle(ref, function () {
|
|
1110
|
-
return {
|
|
1111
|
-
open: open
|
|
1112
|
-
};
|
|
1113
|
-
}, [open]); // TODO: Figure out why react-styleguidist cannot create docs if we don't return a jsx element
|
|
1114
|
-
|
|
1115
|
-
return /*#__PURE__*/require$$0__default["default"].createElement(require$$0.Fragment, null, children(_objectSpread$a(_objectSpread$a({}, props), {}, {
|
|
1116
|
-
open: open
|
|
1117
|
-
})));
|
|
1118
|
-
});
|
|
1119
|
-
Dropzone.displayName = "Dropzone"; // Add default props for react-docgen
|
|
1120
|
-
|
|
1121
|
-
var defaultProps = {
|
|
1122
|
-
disabled: false,
|
|
1123
|
-
getFilesFromEvent: fromEvent,
|
|
1124
|
-
maxSize: Infinity,
|
|
1125
|
-
minSize: 0,
|
|
1126
|
-
multiple: true,
|
|
1127
|
-
maxFiles: 0,
|
|
1128
|
-
preventDropOnDocument: true,
|
|
1129
|
-
noClick: false,
|
|
1130
|
-
noKeyboard: false,
|
|
1131
|
-
noDrag: false,
|
|
1132
|
-
noDragEventsBubbling: false,
|
|
1133
|
-
validator: null,
|
|
1134
|
-
useFsAccessApi: true,
|
|
1135
|
-
autoFocus: false
|
|
1136
|
-
};
|
|
1137
|
-
Dropzone.defaultProps = defaultProps;
|
|
1138
|
-
Dropzone.propTypes = {
|
|
1139
|
-
/**
|
|
1140
|
-
* Render function that exposes the dropzone state and prop getter fns
|
|
1141
|
-
*
|
|
1142
|
-
* @param {object} params
|
|
1143
|
-
* @param {Function} params.getRootProps Returns the props you should apply to the root drop container you render
|
|
1144
|
-
* @param {Function} params.getInputProps Returns the props you should apply to hidden file input you render
|
|
1145
|
-
* @param {Function} params.open Open the native file selection dialog
|
|
1146
|
-
* @param {boolean} params.isFocused Dropzone area is in focus
|
|
1147
|
-
* @param {boolean} params.isFileDialogActive File dialog is opened
|
|
1148
|
-
* @param {boolean} params.isDragActive Active drag is in progress
|
|
1149
|
-
* @param {boolean} params.isDragAccept Dragged files are accepted
|
|
1150
|
-
* @param {boolean} params.isDragReject Some dragged files are rejected
|
|
1151
|
-
* @param {File[]} params.acceptedFiles Accepted files
|
|
1152
|
-
* @param {FileRejection[]} params.fileRejections Rejected files and why they were rejected
|
|
1153
|
-
*/
|
|
1154
|
-
children: PropTypes.func,
|
|
1155
|
-
|
|
1156
|
-
/**
|
|
1157
|
-
* Set accepted file types.
|
|
1158
|
-
* Checkout https://developer.mozilla.org/en-US/docs/Web/API/window/showOpenFilePicker types option for more information.
|
|
1159
|
-
* Keep in mind that mime type determination is not reliable across platforms. CSV files,
|
|
1160
|
-
* for example, are reported as text/plain under macOS but as application/vnd.ms-excel under
|
|
1161
|
-
* Windows. In some cases there might not be a mime type set at all (https://github.com/react-dropzone/react-dropzone/issues/276).
|
|
1162
|
-
*/
|
|
1163
|
-
accept: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)),
|
|
1164
|
-
|
|
1165
|
-
/**
|
|
1166
|
-
* Allow drag 'n' drop (or selection from the file dialog) of multiple files
|
|
1167
|
-
*/
|
|
1168
|
-
multiple: PropTypes.bool,
|
|
1169
|
-
|
|
1170
|
-
/**
|
|
1171
|
-
* If false, allow dropped items to take over the current browser window
|
|
1172
|
-
*/
|
|
1173
|
-
preventDropOnDocument: PropTypes.bool,
|
|
1174
|
-
|
|
1175
|
-
/**
|
|
1176
|
-
* If true, disables click to open the native file selection dialog
|
|
1177
|
-
*/
|
|
1178
|
-
noClick: PropTypes.bool,
|
|
1179
|
-
|
|
1180
|
-
/**
|
|
1181
|
-
* If true, disables SPACE/ENTER to open the native file selection dialog.
|
|
1182
|
-
* Note that it also stops tracking the focus state.
|
|
1183
|
-
*/
|
|
1184
|
-
noKeyboard: PropTypes.bool,
|
|
1185
|
-
|
|
1186
|
-
/**
|
|
1187
|
-
* If true, disables drag 'n' drop
|
|
1188
|
-
*/
|
|
1189
|
-
noDrag: PropTypes.bool,
|
|
1190
|
-
|
|
1191
|
-
/**
|
|
1192
|
-
* If true, stops drag event propagation to parents
|
|
1193
|
-
*/
|
|
1194
|
-
noDragEventsBubbling: PropTypes.bool,
|
|
1195
|
-
|
|
1196
|
-
/**
|
|
1197
|
-
* Minimum file size (in bytes)
|
|
1198
|
-
*/
|
|
1199
|
-
minSize: PropTypes.number,
|
|
1200
|
-
|
|
1201
|
-
/**
|
|
1202
|
-
* Maximum file size (in bytes)
|
|
1203
|
-
*/
|
|
1204
|
-
maxSize: PropTypes.number,
|
|
1205
|
-
|
|
1206
|
-
/**
|
|
1207
|
-
* Maximum accepted number of files
|
|
1208
|
-
* The default value is 0 which means there is no limitation to how many files are accepted.
|
|
1209
|
-
*/
|
|
1210
|
-
maxFiles: PropTypes.number,
|
|
1211
|
-
|
|
1212
|
-
/**
|
|
1213
|
-
* Enable/disable the dropzone
|
|
1214
|
-
*/
|
|
1215
|
-
disabled: PropTypes.bool,
|
|
1216
|
-
|
|
1217
|
-
/**
|
|
1218
|
-
* Use this to provide a custom file aggregator
|
|
1219
|
-
*
|
|
1220
|
-
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
1221
|
-
*/
|
|
1222
|
-
getFilesFromEvent: PropTypes.func,
|
|
1223
|
-
|
|
1224
|
-
/**
|
|
1225
|
-
* Cb for when closing the file dialog with no selection
|
|
1226
|
-
*/
|
|
1227
|
-
onFileDialogCancel: PropTypes.func,
|
|
1228
|
-
|
|
1229
|
-
/**
|
|
1230
|
-
* Cb for when opening the file dialog
|
|
1231
|
-
*/
|
|
1232
|
-
onFileDialogOpen: PropTypes.func,
|
|
1233
|
-
|
|
1234
|
-
/**
|
|
1235
|
-
* Set to true to use the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
|
|
1236
|
-
* to open the file picker instead of using an `<input type="file">` click event.
|
|
1237
|
-
*/
|
|
1238
|
-
useFsAccessApi: PropTypes.bool,
|
|
1239
|
-
|
|
1240
|
-
/**
|
|
1241
|
-
* Set to true to focus the root element on render
|
|
1242
|
-
*/
|
|
1243
|
-
autoFocus: PropTypes.bool,
|
|
1244
|
-
|
|
1245
|
-
/**
|
|
1246
|
-
* Cb for when the `dragenter` event occurs.
|
|
1247
|
-
*
|
|
1248
|
-
* @param {DragEvent} event
|
|
1249
|
-
*/
|
|
1250
|
-
onDragEnter: PropTypes.func,
|
|
1251
|
-
|
|
1252
|
-
/**
|
|
1253
|
-
* Cb for when the `dragleave` event occurs
|
|
1254
|
-
*
|
|
1255
|
-
* @param {DragEvent} event
|
|
1256
|
-
*/
|
|
1257
|
-
onDragLeave: PropTypes.func,
|
|
1258
|
-
|
|
1259
|
-
/**
|
|
1260
|
-
* Cb for when the `dragover` event occurs
|
|
1261
|
-
*
|
|
1262
|
-
* @param {DragEvent} event
|
|
1263
|
-
*/
|
|
1264
|
-
onDragOver: PropTypes.func,
|
|
1265
|
-
|
|
1266
|
-
/**
|
|
1267
|
-
* Cb for when the `drop` event occurs.
|
|
1268
|
-
* Note that this callback is invoked after the `getFilesFromEvent` callback is done.
|
|
1269
|
-
*
|
|
1270
|
-
* Files are accepted or rejected based on the `accept`, `multiple`, `minSize` and `maxSize` props.
|
|
1271
|
-
* `accept` must be a valid [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml) according to [input element specification](https://www.w3.org/wiki/HTML/Elements/input/file) or a valid file extension.
|
|
1272
|
-
* If `multiple` is set to false and additional files are dropped,
|
|
1273
|
-
* all files besides the first will be rejected.
|
|
1274
|
-
* Any file which does not have a size in the [`minSize`, `maxSize`] range, will be rejected as well.
|
|
1275
|
-
*
|
|
1276
|
-
* Note that the `onDrop` callback will always be invoked regardless if the dropped files were accepted or rejected.
|
|
1277
|
-
* If you'd like to react to a specific scenario, use the `onDropAccepted`/`onDropRejected` props.
|
|
1278
|
-
*
|
|
1279
|
-
* `onDrop` will provide you with an array of [File](https://developer.mozilla.org/en-US/docs/Web/API/File) objects which you can then process and send to a server.
|
|
1280
|
-
* For example, with [SuperAgent](https://github.com/visionmedia/superagent) as a http/ajax library:
|
|
1281
|
-
*
|
|
1282
|
-
* ```js
|
|
1283
|
-
* function onDrop(acceptedFiles) {
|
|
1284
|
-
* const req = request.post('/upload')
|
|
1285
|
-
* acceptedFiles.forEach(file => {
|
|
1286
|
-
* req.attach(file.name, file)
|
|
1287
|
-
* })
|
|
1288
|
-
* req.end(callback)
|
|
1289
|
-
* }
|
|
1290
|
-
* ```
|
|
1291
|
-
*
|
|
1292
|
-
* @param {File[]} acceptedFiles
|
|
1293
|
-
* @param {FileRejection[]} fileRejections
|
|
1294
|
-
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
1295
|
-
*/
|
|
1296
|
-
onDrop: PropTypes.func,
|
|
1297
|
-
|
|
1298
|
-
/**
|
|
1299
|
-
* Cb for when the `drop` event occurs.
|
|
1300
|
-
* Note that if no files are accepted, this callback is not invoked.
|
|
1301
|
-
*
|
|
1302
|
-
* @param {File[]} files
|
|
1303
|
-
* @param {(DragEvent|Event)} event
|
|
1304
|
-
*/
|
|
1305
|
-
onDropAccepted: PropTypes.func,
|
|
1306
|
-
|
|
1307
|
-
/**
|
|
1308
|
-
* Cb for when the `drop` event occurs.
|
|
1309
|
-
* Note that if no files are rejected, this callback is not invoked.
|
|
1310
|
-
*
|
|
1311
|
-
* @param {FileRejection[]} fileRejections
|
|
1312
|
-
* @param {(DragEvent|Event)} event
|
|
1313
|
-
*/
|
|
1314
|
-
onDropRejected: PropTypes.func,
|
|
1315
|
-
|
|
1316
|
-
/**
|
|
1317
|
-
* Cb for when there's some error from any of the promises.
|
|
1318
|
-
*
|
|
1319
|
-
* @param {Error} error
|
|
1320
|
-
*/
|
|
1321
|
-
onError: PropTypes.func,
|
|
1322
|
-
|
|
1323
|
-
/**
|
|
1324
|
-
* Custom validation function. It must return null if there's no errors.
|
|
1325
|
-
* @param {File} file
|
|
1326
|
-
* @returns {FileError|FileError[]|null}
|
|
1327
|
-
*/
|
|
1328
|
-
validator: PropTypes.func
|
|
1329
|
-
};
|
|
1330
|
-
/**
|
|
1331
|
-
* A function that is invoked for the `dragenter`,
|
|
1332
|
-
* `dragover` and `dragleave` events.
|
|
1333
|
-
* It is not invoked if the items are not files (such as link, text, etc.).
|
|
1334
|
-
*
|
|
1335
|
-
* @callback dragCb
|
|
1336
|
-
* @param {DragEvent} event
|
|
1337
|
-
*/
|
|
1338
|
-
|
|
1339
|
-
/**
|
|
1340
|
-
* A function that is invoked for the `drop` or input change event.
|
|
1341
|
-
* It is not invoked if the items are not files (such as link, text, etc.).
|
|
1342
|
-
*
|
|
1343
|
-
* @callback dropCb
|
|
1344
|
-
* @param {File[]} acceptedFiles List of accepted files
|
|
1345
|
-
* @param {FileRejection[]} fileRejections List of rejected files and why they were rejected
|
|
1346
|
-
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
1347
|
-
*/
|
|
1348
|
-
|
|
1349
|
-
/**
|
|
1350
|
-
* A function that is invoked for the `drop` or input change event.
|
|
1351
|
-
* It is not invoked if the items are files (such as link, text, etc.).
|
|
1352
|
-
*
|
|
1353
|
-
* @callback dropAcceptedCb
|
|
1354
|
-
* @param {File[]} files List of accepted files that meet the given criteria
|
|
1355
|
-
* (`accept`, `multiple`, `minSize`, `maxSize`)
|
|
1356
|
-
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
1357
|
-
*/
|
|
1358
|
-
|
|
1359
|
-
/**
|
|
1360
|
-
* A function that is invoked for the `drop` or input change event.
|
|
1361
|
-
*
|
|
1362
|
-
* @callback dropRejectedCb
|
|
1363
|
-
* @param {File[]} files List of rejected files that do not meet the given criteria
|
|
1364
|
-
* (`accept`, `multiple`, `minSize`, `maxSize`)
|
|
1365
|
-
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
1366
|
-
*/
|
|
1367
|
-
|
|
1368
|
-
/**
|
|
1369
|
-
* A function that is used aggregate files,
|
|
1370
|
-
* in a asynchronous fashion, from drag or input change events.
|
|
1371
|
-
*
|
|
1372
|
-
* @callback getFilesFromEvent
|
|
1373
|
-
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
1374
|
-
* @returns {(File[]|Promise<File[]>)}
|
|
1375
|
-
*/
|
|
1376
|
-
|
|
1377
|
-
/**
|
|
1378
|
-
* An object with the current dropzone state.
|
|
1379
|
-
*
|
|
1380
|
-
* @typedef {object} DropzoneState
|
|
1381
|
-
* @property {boolean} isFocused Dropzone area is in focus
|
|
1382
|
-
* @property {boolean} isFileDialogActive File dialog is opened
|
|
1383
|
-
* @property {boolean} isDragActive Active drag is in progress
|
|
1384
|
-
* @property {boolean} isDragAccept Dragged files are accepted
|
|
1385
|
-
* @property {boolean} isDragReject Some dragged files are rejected
|
|
1386
|
-
* @property {File[]} acceptedFiles Accepted files
|
|
1387
|
-
* @property {FileRejection[]} fileRejections Rejected files and why they were rejected
|
|
1388
|
-
*/
|
|
1389
|
-
|
|
1390
|
-
/**
|
|
1391
|
-
* An object with the dropzone methods.
|
|
1392
|
-
*
|
|
1393
|
-
* @typedef {object} DropzoneMethods
|
|
1394
|
-
* @property {Function} getRootProps Returns the props you should apply to the root drop container you render
|
|
1395
|
-
* @property {Function} getInputProps Returns the props you should apply to hidden file input you render
|
|
1396
|
-
* @property {Function} open Open the native file selection dialog
|
|
1397
|
-
*/
|
|
1398
|
-
|
|
1399
|
-
var initialState = {
|
|
1400
|
-
isFocused: false,
|
|
1401
|
-
isFileDialogActive: false,
|
|
1402
|
-
isDragActive: false,
|
|
1403
|
-
isDragAccept: false,
|
|
1404
|
-
isDragReject: false,
|
|
1405
|
-
acceptedFiles: [],
|
|
1406
|
-
fileRejections: []
|
|
1407
|
-
};
|
|
1408
|
-
/**
|
|
1409
|
-
* A React hook that creates a drag 'n' drop area.
|
|
1410
|
-
*
|
|
1411
|
-
* ```jsx
|
|
1412
|
-
* function MyDropzone(props) {
|
|
1413
|
-
* const {getRootProps, getInputProps} = useDropzone({
|
|
1414
|
-
* onDrop: acceptedFiles => {
|
|
1415
|
-
* // do something with the File objects, e.g. upload to some server
|
|
1416
|
-
* }
|
|
1417
|
-
* });
|
|
1418
|
-
* return (
|
|
1419
|
-
* <div {...getRootProps()}>
|
|
1420
|
-
* <input {...getInputProps()} />
|
|
1421
|
-
* <p>Drag and drop some files here, or click to select files</p>
|
|
1422
|
-
* </div>
|
|
1423
|
-
* )
|
|
1424
|
-
* }
|
|
1425
|
-
* ```
|
|
1426
|
-
*
|
|
1427
|
-
* @function useDropzone
|
|
1428
|
-
*
|
|
1429
|
-
* @param {object} props
|
|
1430
|
-
* @param {import("./utils").AcceptProp} [props.accept] Set accepted file types.
|
|
1431
|
-
* Checkout https://developer.mozilla.org/en-US/docs/Web/API/window/showOpenFilePicker types option for more information.
|
|
1432
|
-
* Keep in mind that mime type determination is not reliable across platforms. CSV files,
|
|
1433
|
-
* for example, are reported as text/plain under macOS but as application/vnd.ms-excel under
|
|
1434
|
-
* Windows. In some cases there might not be a mime type set at all (https://github.com/react-dropzone/react-dropzone/issues/276).
|
|
1435
|
-
* @param {boolean} [props.multiple=true] Allow drag 'n' drop (or selection from the file dialog) of multiple files
|
|
1436
|
-
* @param {boolean} [props.preventDropOnDocument=true] If false, allow dropped items to take over the current browser window
|
|
1437
|
-
* @param {boolean} [props.noClick=false] If true, disables click to open the native file selection dialog
|
|
1438
|
-
* @param {boolean} [props.noKeyboard=false] If true, disables SPACE/ENTER to open the native file selection dialog.
|
|
1439
|
-
* Note that it also stops tracking the focus state.
|
|
1440
|
-
* @param {boolean} [props.noDrag=false] If true, disables drag 'n' drop
|
|
1441
|
-
* @param {boolean} [props.noDragEventsBubbling=false] If true, stops drag event propagation to parents
|
|
1442
|
-
* @param {number} [props.minSize=0] Minimum file size (in bytes)
|
|
1443
|
-
* @param {number} [props.maxSize=Infinity] Maximum file size (in bytes)
|
|
1444
|
-
* @param {boolean} [props.disabled=false] Enable/disable the dropzone
|
|
1445
|
-
* @param {getFilesFromEvent} [props.getFilesFromEvent] Use this to provide a custom file aggregator
|
|
1446
|
-
* @param {Function} [props.onFileDialogCancel] Cb for when closing the file dialog with no selection
|
|
1447
|
-
* @param {boolean} [props.useFsAccessApi] Set to true to use the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
|
|
1448
|
-
* to open the file picker instead of using an `<input type="file">` click event.
|
|
1449
|
-
* @param {boolean} autoFocus Set to true to auto focus the root element.
|
|
1450
|
-
* @param {Function} [props.onFileDialogOpen] Cb for when opening the file dialog
|
|
1451
|
-
* @param {dragCb} [props.onDragEnter] Cb for when the `dragenter` event occurs.
|
|
1452
|
-
* @param {dragCb} [props.onDragLeave] Cb for when the `dragleave` event occurs
|
|
1453
|
-
* @param {dragCb} [props.onDragOver] Cb for when the `dragover` event occurs
|
|
1454
|
-
* @param {dropCb} [props.onDrop] Cb for when the `drop` event occurs.
|
|
1455
|
-
* Note that this callback is invoked after the `getFilesFromEvent` callback is done.
|
|
1456
|
-
*
|
|
1457
|
-
* Files are accepted or rejected based on the `accept`, `multiple`, `minSize` and `maxSize` props.
|
|
1458
|
-
* `accept` must be an object with keys as a valid [MIME type](http://www.iana.org/assignments/media-types/media-types.xhtml) according to [input element specification](https://www.w3.org/wiki/HTML/Elements/input/file) and the value an array of file extensions (optional).
|
|
1459
|
-
* If `multiple` is set to false and additional files are dropped,
|
|
1460
|
-
* all files besides the first will be rejected.
|
|
1461
|
-
* Any file which does not have a size in the [`minSize`, `maxSize`] range, will be rejected as well.
|
|
1462
|
-
*
|
|
1463
|
-
* Note that the `onDrop` callback will always be invoked regardless if the dropped files were accepted or rejected.
|
|
1464
|
-
* If you'd like to react to a specific scenario, use the `onDropAccepted`/`onDropRejected` props.
|
|
1465
|
-
*
|
|
1466
|
-
* `onDrop` will provide you with an array of [File](https://developer.mozilla.org/en-US/docs/Web/API/File) objects which you can then process and send to a server.
|
|
1467
|
-
* For example, with [SuperAgent](https://github.com/visionmedia/superagent) as a http/ajax library:
|
|
1468
|
-
*
|
|
1469
|
-
* ```js
|
|
1470
|
-
* function onDrop(acceptedFiles) {
|
|
1471
|
-
* const req = request.post('/upload')
|
|
1472
|
-
* acceptedFiles.forEach(file => {
|
|
1473
|
-
* req.attach(file.name, file)
|
|
1474
|
-
* })
|
|
1475
|
-
* req.end(callback)
|
|
1476
|
-
* }
|
|
1477
|
-
* ```
|
|
1478
|
-
* @param {dropAcceptedCb} [props.onDropAccepted]
|
|
1479
|
-
* @param {dropRejectedCb} [props.onDropRejected]
|
|
1480
|
-
* @param {(error: Error) => void} [props.onError]
|
|
1481
|
-
*
|
|
1482
|
-
* @returns {DropzoneState & DropzoneMethods}
|
|
1483
|
-
*/
|
|
1484
|
-
|
|
1485
|
-
function useDropzone() {
|
|
1486
|
-
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1487
|
-
|
|
1488
|
-
var _defaultProps$props = _objectSpread$a(_objectSpread$a({}, defaultProps), props),
|
|
1489
|
-
accept = _defaultProps$props.accept,
|
|
1490
|
-
disabled = _defaultProps$props.disabled,
|
|
1491
|
-
getFilesFromEvent = _defaultProps$props.getFilesFromEvent,
|
|
1492
|
-
maxSize = _defaultProps$props.maxSize,
|
|
1493
|
-
minSize = _defaultProps$props.minSize,
|
|
1494
|
-
multiple = _defaultProps$props.multiple,
|
|
1495
|
-
maxFiles = _defaultProps$props.maxFiles,
|
|
1496
|
-
onDragEnter = _defaultProps$props.onDragEnter,
|
|
1497
|
-
onDragLeave = _defaultProps$props.onDragLeave,
|
|
1498
|
-
onDragOver = _defaultProps$props.onDragOver,
|
|
1499
|
-
onDrop = _defaultProps$props.onDrop,
|
|
1500
|
-
onDropAccepted = _defaultProps$props.onDropAccepted,
|
|
1501
|
-
onDropRejected = _defaultProps$props.onDropRejected,
|
|
1502
|
-
onFileDialogCancel = _defaultProps$props.onFileDialogCancel,
|
|
1503
|
-
onFileDialogOpen = _defaultProps$props.onFileDialogOpen,
|
|
1504
|
-
useFsAccessApi = _defaultProps$props.useFsAccessApi,
|
|
1505
|
-
autoFocus = _defaultProps$props.autoFocus,
|
|
1506
|
-
preventDropOnDocument = _defaultProps$props.preventDropOnDocument,
|
|
1507
|
-
noClick = _defaultProps$props.noClick,
|
|
1508
|
-
noKeyboard = _defaultProps$props.noKeyboard,
|
|
1509
|
-
noDrag = _defaultProps$props.noDrag,
|
|
1510
|
-
noDragEventsBubbling = _defaultProps$props.noDragEventsBubbling,
|
|
1511
|
-
onError = _defaultProps$props.onError,
|
|
1512
|
-
validator = _defaultProps$props.validator;
|
|
1513
|
-
|
|
1514
|
-
var acceptAttr = require$$0.useMemo(function () {
|
|
1515
|
-
return acceptPropAsAcceptAttr(accept);
|
|
1516
|
-
}, [accept]);
|
|
1517
|
-
var pickerTypes = require$$0.useMemo(function () {
|
|
1518
|
-
return pickerOptionsFromAccept(accept);
|
|
1519
|
-
}, [accept]);
|
|
1520
|
-
var onFileDialogOpenCb = require$$0.useMemo(function () {
|
|
1521
|
-
return typeof onFileDialogOpen === "function" ? onFileDialogOpen : noop;
|
|
1522
|
-
}, [onFileDialogOpen]);
|
|
1523
|
-
var onFileDialogCancelCb = require$$0.useMemo(function () {
|
|
1524
|
-
return typeof onFileDialogCancel === "function" ? onFileDialogCancel : noop;
|
|
1525
|
-
}, [onFileDialogCancel]);
|
|
1526
|
-
/**
|
|
1527
|
-
* @constant
|
|
1528
|
-
* @type {React.MutableRefObject<HTMLElement>}
|
|
1529
|
-
*/
|
|
1530
|
-
|
|
1531
|
-
var rootRef = require$$0.useRef(null);
|
|
1532
|
-
var inputRef = require$$0.useRef(null);
|
|
1533
|
-
|
|
1534
|
-
var _useReducer = require$$0.useReducer(reducer, initialState),
|
|
1535
|
-
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
1536
|
-
state = _useReducer2[0],
|
|
1537
|
-
dispatch = _useReducer2[1];
|
|
1538
|
-
|
|
1539
|
-
var isFocused = state.isFocused,
|
|
1540
|
-
isFileDialogActive = state.isFileDialogActive;
|
|
1541
|
-
var fsAccessApiWorksRef = require$$0.useRef(typeof window !== "undefined" && window.isSecureContext && useFsAccessApi && canUseFileSystemAccessAPI()); // Update file dialog active state when the window is focused on
|
|
1542
|
-
|
|
1543
|
-
var onWindowFocus = function onWindowFocus() {
|
|
1544
|
-
// Execute the timeout only if the file dialog is opened in the browser
|
|
1545
|
-
if (!fsAccessApiWorksRef.current && isFileDialogActive) {
|
|
1546
|
-
setTimeout(function () {
|
|
1547
|
-
if (inputRef.current) {
|
|
1548
|
-
var files = inputRef.current.files;
|
|
1549
|
-
|
|
1550
|
-
if (!files.length) {
|
|
1551
|
-
dispatch({
|
|
1552
|
-
type: "closeDialog"
|
|
1553
|
-
});
|
|
1554
|
-
onFileDialogCancelCb();
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
}, 300);
|
|
1558
|
-
}
|
|
1559
|
-
};
|
|
1560
|
-
|
|
1561
|
-
require$$0.useEffect(function () {
|
|
1562
|
-
window.addEventListener("focus", onWindowFocus, false);
|
|
1563
|
-
return function () {
|
|
1564
|
-
window.removeEventListener("focus", onWindowFocus, false);
|
|
1565
|
-
};
|
|
1566
|
-
}, [inputRef, isFileDialogActive, onFileDialogCancelCb, fsAccessApiWorksRef]);
|
|
1567
|
-
var dragTargetsRef = require$$0.useRef([]);
|
|
1568
|
-
|
|
1569
|
-
var onDocumentDrop = function onDocumentDrop(event) {
|
|
1570
|
-
if (rootRef.current && rootRef.current.contains(event.target)) {
|
|
1571
|
-
// If we intercepted an event for our instance, let it propagate down to the instance's onDrop handler
|
|
1572
|
-
return;
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
|
-
event.preventDefault();
|
|
1576
|
-
dragTargetsRef.current = [];
|
|
1577
|
-
};
|
|
1578
|
-
|
|
1579
|
-
require$$0.useEffect(function () {
|
|
1580
|
-
if (preventDropOnDocument) {
|
|
1581
|
-
document.addEventListener("dragover", onDocumentDragOver, false);
|
|
1582
|
-
document.addEventListener("drop", onDocumentDrop, false);
|
|
1583
|
-
}
|
|
1584
|
-
|
|
1585
|
-
return function () {
|
|
1586
|
-
if (preventDropOnDocument) {
|
|
1587
|
-
document.removeEventListener("dragover", onDocumentDragOver);
|
|
1588
|
-
document.removeEventListener("drop", onDocumentDrop);
|
|
1589
|
-
}
|
|
1590
|
-
};
|
|
1591
|
-
}, [rootRef, preventDropOnDocument]); // Auto focus the root when autoFocus is true
|
|
1592
|
-
|
|
1593
|
-
require$$0.useEffect(function () {
|
|
1594
|
-
if (!disabled && autoFocus && rootRef.current) {
|
|
1595
|
-
rootRef.current.focus();
|
|
1596
|
-
}
|
|
1597
|
-
|
|
1598
|
-
return function () {};
|
|
1599
|
-
}, [rootRef, autoFocus, disabled]);
|
|
1600
|
-
var onErrCb = require$$0.useCallback(function (e) {
|
|
1601
|
-
if (onError) {
|
|
1602
|
-
onError(e);
|
|
1603
|
-
} else {
|
|
1604
|
-
// Let the user know something's gone wrong if they haven't provided the onError cb.
|
|
1605
|
-
console.error(e);
|
|
1606
|
-
}
|
|
1607
|
-
}, [onError]);
|
|
1608
|
-
var onDragEnterCb = require$$0.useCallback(function (event) {
|
|
1609
|
-
event.preventDefault(); // Persist here because we need the event later after getFilesFromEvent() is done
|
|
1610
|
-
|
|
1611
|
-
event.persist();
|
|
1612
|
-
stopPropagation(event);
|
|
1613
|
-
dragTargetsRef.current = [].concat(_toConsumableArray(dragTargetsRef.current), [event.target]);
|
|
1614
|
-
|
|
1615
|
-
if (isEvtWithFiles(event)) {
|
|
1616
|
-
Promise.resolve(getFilesFromEvent(event)).then(function (files) {
|
|
1617
|
-
if (isPropagationStopped(event) && !noDragEventsBubbling) {
|
|
1618
|
-
return;
|
|
1619
|
-
}
|
|
1620
|
-
|
|
1621
|
-
var fileCount = files.length;
|
|
1622
|
-
var isDragAccept = fileCount > 0 && allFilesAccepted({
|
|
1623
|
-
files: files,
|
|
1624
|
-
accept: acceptAttr,
|
|
1625
|
-
minSize: minSize,
|
|
1626
|
-
maxSize: maxSize,
|
|
1627
|
-
multiple: multiple,
|
|
1628
|
-
maxFiles: maxFiles,
|
|
1629
|
-
validator: validator
|
|
1630
|
-
});
|
|
1631
|
-
var isDragReject = fileCount > 0 && !isDragAccept;
|
|
1632
|
-
dispatch({
|
|
1633
|
-
isDragAccept: isDragAccept,
|
|
1634
|
-
isDragReject: isDragReject,
|
|
1635
|
-
isDragActive: true,
|
|
1636
|
-
type: "setDraggedFiles"
|
|
1637
|
-
});
|
|
1638
|
-
|
|
1639
|
-
if (onDragEnter) {
|
|
1640
|
-
onDragEnter(event);
|
|
1641
|
-
}
|
|
1642
|
-
}).catch(function (e) {
|
|
1643
|
-
return onErrCb(e);
|
|
1644
|
-
});
|
|
1645
|
-
}
|
|
1646
|
-
}, [getFilesFromEvent, onDragEnter, onErrCb, noDragEventsBubbling, acceptAttr, minSize, maxSize, multiple, maxFiles, validator]);
|
|
1647
|
-
var onDragOverCb = require$$0.useCallback(function (event) {
|
|
1648
|
-
event.preventDefault();
|
|
1649
|
-
event.persist();
|
|
1650
|
-
stopPropagation(event);
|
|
1651
|
-
var hasFiles = isEvtWithFiles(event);
|
|
1652
|
-
|
|
1653
|
-
if (hasFiles && event.dataTransfer) {
|
|
1654
|
-
try {
|
|
1655
|
-
event.dataTransfer.dropEffect = "copy";
|
|
1656
|
-
} catch (_unused) {}
|
|
1657
|
-
/* eslint-disable-line no-empty */
|
|
1658
|
-
|
|
1659
|
-
}
|
|
1660
|
-
|
|
1661
|
-
if (hasFiles && onDragOver) {
|
|
1662
|
-
onDragOver(event);
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
return false;
|
|
1666
|
-
}, [onDragOver, noDragEventsBubbling]);
|
|
1667
|
-
var onDragLeaveCb = require$$0.useCallback(function (event) {
|
|
1668
|
-
event.preventDefault();
|
|
1669
|
-
event.persist();
|
|
1670
|
-
stopPropagation(event); // Only deactivate once the dropzone and all children have been left
|
|
1671
|
-
|
|
1672
|
-
var targets = dragTargetsRef.current.filter(function (target) {
|
|
1673
|
-
return rootRef.current && rootRef.current.contains(target);
|
|
1674
|
-
}); // Make sure to remove a target present multiple times only once
|
|
1675
|
-
// (Firefox may fire dragenter/dragleave multiple times on the same element)
|
|
1676
|
-
|
|
1677
|
-
var targetIdx = targets.indexOf(event.target);
|
|
1678
|
-
|
|
1679
|
-
if (targetIdx !== -1) {
|
|
1680
|
-
targets.splice(targetIdx, 1);
|
|
1681
|
-
}
|
|
1682
|
-
|
|
1683
|
-
dragTargetsRef.current = targets;
|
|
1684
|
-
|
|
1685
|
-
if (targets.length > 0) {
|
|
1686
|
-
return;
|
|
1687
|
-
}
|
|
1688
|
-
|
|
1689
|
-
dispatch({
|
|
1690
|
-
type: "setDraggedFiles",
|
|
1691
|
-
isDragActive: false,
|
|
1692
|
-
isDragAccept: false,
|
|
1693
|
-
isDragReject: false
|
|
1694
|
-
});
|
|
1695
|
-
|
|
1696
|
-
if (isEvtWithFiles(event) && onDragLeave) {
|
|
1697
|
-
onDragLeave(event);
|
|
1698
|
-
}
|
|
1699
|
-
}, [rootRef, onDragLeave, noDragEventsBubbling]);
|
|
1700
|
-
var setFiles = require$$0.useCallback(function (files, event) {
|
|
1701
|
-
var acceptedFiles = [];
|
|
1702
|
-
var fileRejections = [];
|
|
1703
|
-
files.forEach(function (file) {
|
|
1704
|
-
var _fileAccepted = fileAccepted(file, acceptAttr),
|
|
1705
|
-
_fileAccepted2 = _slicedToArray(_fileAccepted, 2),
|
|
1706
|
-
accepted = _fileAccepted2[0],
|
|
1707
|
-
acceptError = _fileAccepted2[1];
|
|
1708
|
-
|
|
1709
|
-
var _fileMatchSize = fileMatchSize(file, minSize, maxSize),
|
|
1710
|
-
_fileMatchSize2 = _slicedToArray(_fileMatchSize, 2),
|
|
1711
|
-
sizeMatch = _fileMatchSize2[0],
|
|
1712
|
-
sizeError = _fileMatchSize2[1];
|
|
1713
|
-
|
|
1714
|
-
var customErrors = validator ? validator(file) : null;
|
|
1715
|
-
|
|
1716
|
-
if (accepted && sizeMatch && !customErrors) {
|
|
1717
|
-
acceptedFiles.push(file);
|
|
1718
|
-
} else {
|
|
1719
|
-
var errors = [acceptError, sizeError];
|
|
1720
|
-
|
|
1721
|
-
if (customErrors) {
|
|
1722
|
-
errors = errors.concat(customErrors);
|
|
1723
|
-
}
|
|
1724
|
-
|
|
1725
|
-
fileRejections.push({
|
|
1726
|
-
file: file,
|
|
1727
|
-
errors: errors.filter(function (e) {
|
|
1728
|
-
return e;
|
|
1729
|
-
})
|
|
1730
|
-
});
|
|
1731
|
-
}
|
|
1732
|
-
});
|
|
1733
|
-
|
|
1734
|
-
if (!multiple && acceptedFiles.length > 1 || multiple && maxFiles >= 1 && acceptedFiles.length > maxFiles) {
|
|
1735
|
-
// Reject everything and empty accepted files
|
|
1736
|
-
acceptedFiles.forEach(function (file) {
|
|
1737
|
-
fileRejections.push({
|
|
1738
|
-
file: file,
|
|
1739
|
-
errors: [TOO_MANY_FILES_REJECTION]
|
|
1740
|
-
});
|
|
1741
|
-
});
|
|
1742
|
-
acceptedFiles.splice(0);
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
|
-
dispatch({
|
|
1746
|
-
acceptedFiles: acceptedFiles,
|
|
1747
|
-
fileRejections: fileRejections,
|
|
1748
|
-
type: "setFiles"
|
|
1749
|
-
});
|
|
1750
|
-
|
|
1751
|
-
if (onDrop) {
|
|
1752
|
-
onDrop(acceptedFiles, fileRejections, event);
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
|
-
if (fileRejections.length > 0 && onDropRejected) {
|
|
1756
|
-
onDropRejected(fileRejections, event);
|
|
1757
|
-
}
|
|
1758
|
-
|
|
1759
|
-
if (acceptedFiles.length > 0 && onDropAccepted) {
|
|
1760
|
-
onDropAccepted(acceptedFiles, event);
|
|
1761
|
-
}
|
|
1762
|
-
}, [dispatch, multiple, acceptAttr, minSize, maxSize, maxFiles, onDrop, onDropAccepted, onDropRejected, validator]);
|
|
1763
|
-
var onDropCb = require$$0.useCallback(function (event) {
|
|
1764
|
-
event.preventDefault(); // Persist here because we need the event later after getFilesFromEvent() is done
|
|
1765
|
-
|
|
1766
|
-
event.persist();
|
|
1767
|
-
stopPropagation(event);
|
|
1768
|
-
dragTargetsRef.current = [];
|
|
1769
|
-
|
|
1770
|
-
if (isEvtWithFiles(event)) {
|
|
1771
|
-
Promise.resolve(getFilesFromEvent(event)).then(function (files) {
|
|
1772
|
-
if (isPropagationStopped(event) && !noDragEventsBubbling) {
|
|
1773
|
-
return;
|
|
1774
|
-
}
|
|
1775
|
-
|
|
1776
|
-
setFiles(files, event);
|
|
1777
|
-
}).catch(function (e) {
|
|
1778
|
-
return onErrCb(e);
|
|
1779
|
-
});
|
|
1780
|
-
}
|
|
1781
|
-
|
|
1782
|
-
dispatch({
|
|
1783
|
-
type: "reset"
|
|
1784
|
-
});
|
|
1785
|
-
}, [getFilesFromEvent, setFiles, onErrCb, noDragEventsBubbling]); // Fn for opening the file dialog programmatically
|
|
1786
|
-
|
|
1787
|
-
var openFileDialog = require$$0.useCallback(function () {
|
|
1788
|
-
// No point to use FS access APIs if context is not secure
|
|
1789
|
-
// https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts#feature_detection
|
|
1790
|
-
if (fsAccessApiWorksRef.current) {
|
|
1791
|
-
dispatch({
|
|
1792
|
-
type: "openDialog"
|
|
1793
|
-
});
|
|
1794
|
-
onFileDialogOpenCb(); // https://developer.mozilla.org/en-US/docs/Web/API/window/showOpenFilePicker
|
|
1795
|
-
|
|
1796
|
-
var opts = {
|
|
1797
|
-
multiple: multiple,
|
|
1798
|
-
types: pickerTypes
|
|
1799
|
-
};
|
|
1800
|
-
window.showOpenFilePicker(opts).then(function (handles) {
|
|
1801
|
-
return getFilesFromEvent(handles);
|
|
1802
|
-
}).then(function (files) {
|
|
1803
|
-
setFiles(files, null);
|
|
1804
|
-
dispatch({
|
|
1805
|
-
type: "closeDialog"
|
|
1806
|
-
});
|
|
1807
|
-
}).catch(function (e) {
|
|
1808
|
-
// AbortError means the user canceled
|
|
1809
|
-
if (isAbort(e)) {
|
|
1810
|
-
onFileDialogCancelCb(e);
|
|
1811
|
-
dispatch({
|
|
1812
|
-
type: "closeDialog"
|
|
1813
|
-
});
|
|
1814
|
-
} else if (isSecurityError(e)) {
|
|
1815
|
-
fsAccessApiWorksRef.current = false; // CORS, so cannot use this API
|
|
1816
|
-
// Try using the input
|
|
1817
|
-
|
|
1818
|
-
if (inputRef.current) {
|
|
1819
|
-
inputRef.current.value = null;
|
|
1820
|
-
inputRef.current.click();
|
|
1821
|
-
} else {
|
|
1822
|
-
onErrCb(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."));
|
|
1823
|
-
}
|
|
1824
|
-
} else {
|
|
1825
|
-
onErrCb(e);
|
|
1826
|
-
}
|
|
1827
|
-
});
|
|
1828
|
-
return;
|
|
1829
|
-
}
|
|
1830
|
-
|
|
1831
|
-
if (inputRef.current) {
|
|
1832
|
-
dispatch({
|
|
1833
|
-
type: "openDialog"
|
|
1834
|
-
});
|
|
1835
|
-
onFileDialogOpenCb();
|
|
1836
|
-
inputRef.current.value = null;
|
|
1837
|
-
inputRef.current.click();
|
|
1838
|
-
}
|
|
1839
|
-
}, [dispatch, onFileDialogOpenCb, onFileDialogCancelCb, useFsAccessApi, setFiles, onErrCb, pickerTypes, multiple]); // Cb to open the file dialog when SPACE/ENTER occurs on the dropzone
|
|
1840
|
-
|
|
1841
|
-
var onKeyDownCb = require$$0.useCallback(function (event) {
|
|
1842
|
-
// Ignore keyboard events bubbling up the DOM tree
|
|
1843
|
-
if (!rootRef.current || !rootRef.current.isEqualNode(event.target)) {
|
|
1844
|
-
return;
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
if (event.key === " " || event.key === "Enter" || event.keyCode === 32 || event.keyCode === 13) {
|
|
1848
|
-
event.preventDefault();
|
|
1849
|
-
openFileDialog();
|
|
1850
|
-
}
|
|
1851
|
-
}, [rootRef, openFileDialog]); // Update focus state for the dropzone
|
|
1852
|
-
|
|
1853
|
-
var onFocusCb = require$$0.useCallback(function () {
|
|
1854
|
-
dispatch({
|
|
1855
|
-
type: "focus"
|
|
1856
|
-
});
|
|
1857
|
-
}, []);
|
|
1858
|
-
var onBlurCb = require$$0.useCallback(function () {
|
|
1859
|
-
dispatch({
|
|
1860
|
-
type: "blur"
|
|
1861
|
-
});
|
|
1862
|
-
}, []); // Cb to open the file dialog when click occurs on the dropzone
|
|
1863
|
-
|
|
1864
|
-
var onClickCb = require$$0.useCallback(function () {
|
|
1865
|
-
if (noClick) {
|
|
1866
|
-
return;
|
|
1867
|
-
} // In IE11/Edge the file-browser dialog is blocking, therefore, use setTimeout()
|
|
1868
|
-
// to ensure React can handle state changes
|
|
1869
|
-
// See: https://github.com/react-dropzone/react-dropzone/issues/450
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
if (isIeOrEdge()) {
|
|
1873
|
-
setTimeout(openFileDialog, 0);
|
|
1874
|
-
} else {
|
|
1875
|
-
openFileDialog();
|
|
1876
|
-
}
|
|
1877
|
-
}, [noClick, openFileDialog]);
|
|
1878
|
-
|
|
1879
|
-
var composeHandler = function composeHandler(fn) {
|
|
1880
|
-
return disabled ? null : fn;
|
|
1881
|
-
};
|
|
1882
|
-
|
|
1883
|
-
var composeKeyboardHandler = function composeKeyboardHandler(fn) {
|
|
1884
|
-
return noKeyboard ? null : composeHandler(fn);
|
|
1885
|
-
};
|
|
1886
|
-
|
|
1887
|
-
var composeDragHandler = function composeDragHandler(fn) {
|
|
1888
|
-
return noDrag ? null : composeHandler(fn);
|
|
1889
|
-
};
|
|
1890
|
-
|
|
1891
|
-
var stopPropagation = function stopPropagation(event) {
|
|
1892
|
-
if (noDragEventsBubbling) {
|
|
1893
|
-
event.stopPropagation();
|
|
1894
|
-
}
|
|
1895
|
-
};
|
|
1896
|
-
|
|
1897
|
-
var getRootProps = require$$0.useMemo(function () {
|
|
1898
|
-
return function () {
|
|
1899
|
-
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1900
|
-
_ref2$refKey = _ref2.refKey,
|
|
1901
|
-
refKey = _ref2$refKey === void 0 ? "ref" : _ref2$refKey,
|
|
1902
|
-
role = _ref2.role,
|
|
1903
|
-
onKeyDown = _ref2.onKeyDown,
|
|
1904
|
-
onFocus = _ref2.onFocus,
|
|
1905
|
-
onBlur = _ref2.onBlur,
|
|
1906
|
-
onClick = _ref2.onClick,
|
|
1907
|
-
onDragEnter = _ref2.onDragEnter,
|
|
1908
|
-
onDragOver = _ref2.onDragOver,
|
|
1909
|
-
onDragLeave = _ref2.onDragLeave,
|
|
1910
|
-
onDrop = _ref2.onDrop,
|
|
1911
|
-
rest = _objectWithoutProperties$1(_ref2, _excluded3);
|
|
1912
|
-
|
|
1913
|
-
return _objectSpread$a(_objectSpread$a(_defineProperty$1({
|
|
1914
|
-
onKeyDown: composeKeyboardHandler(composeEventHandlers(onKeyDown, onKeyDownCb)),
|
|
1915
|
-
onFocus: composeKeyboardHandler(composeEventHandlers(onFocus, onFocusCb)),
|
|
1916
|
-
onBlur: composeKeyboardHandler(composeEventHandlers(onBlur, onBlurCb)),
|
|
1917
|
-
onClick: composeHandler(composeEventHandlers(onClick, onClickCb)),
|
|
1918
|
-
onDragEnter: composeDragHandler(composeEventHandlers(onDragEnter, onDragEnterCb)),
|
|
1919
|
-
onDragOver: composeDragHandler(composeEventHandlers(onDragOver, onDragOverCb)),
|
|
1920
|
-
onDragLeave: composeDragHandler(composeEventHandlers(onDragLeave, onDragLeaveCb)),
|
|
1921
|
-
onDrop: composeDragHandler(composeEventHandlers(onDrop, onDropCb)),
|
|
1922
|
-
role: typeof role === "string" && role !== "" ? role : "presentation"
|
|
1923
|
-
}, refKey, rootRef), !disabled && !noKeyboard ? {
|
|
1924
|
-
tabIndex: 0
|
|
1925
|
-
} : {}), rest);
|
|
1926
|
-
};
|
|
1927
|
-
}, [rootRef, onKeyDownCb, onFocusCb, onBlurCb, onClickCb, onDragEnterCb, onDragOverCb, onDragLeaveCb, onDropCb, noKeyboard, noDrag, disabled]);
|
|
1928
|
-
var onInputElementClick = require$$0.useCallback(function (event) {
|
|
1929
|
-
event.stopPropagation();
|
|
1930
|
-
}, []);
|
|
1931
|
-
var getInputProps = require$$0.useMemo(function () {
|
|
1932
|
-
return function () {
|
|
1933
|
-
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
1934
|
-
_ref3$refKey = _ref3.refKey,
|
|
1935
|
-
refKey = _ref3$refKey === void 0 ? "ref" : _ref3$refKey,
|
|
1936
|
-
onChange = _ref3.onChange,
|
|
1937
|
-
onClick = _ref3.onClick,
|
|
1938
|
-
rest = _objectWithoutProperties$1(_ref3, _excluded4);
|
|
1939
|
-
|
|
1940
|
-
var inputProps = _defineProperty$1({
|
|
1941
|
-
accept: acceptAttr,
|
|
1942
|
-
multiple: multiple,
|
|
1943
|
-
type: "file",
|
|
1944
|
-
style: {
|
|
1945
|
-
display: "none"
|
|
1946
|
-
},
|
|
1947
|
-
onChange: composeHandler(composeEventHandlers(onChange, onDropCb)),
|
|
1948
|
-
onClick: composeHandler(composeEventHandlers(onClick, onInputElementClick)),
|
|
1949
|
-
tabIndex: -1
|
|
1950
|
-
}, refKey, inputRef);
|
|
1951
|
-
|
|
1952
|
-
return _objectSpread$a(_objectSpread$a({}, inputProps), rest);
|
|
1953
|
-
};
|
|
1954
|
-
}, [inputRef, accept, multiple, onDropCb, disabled]);
|
|
1955
|
-
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
1956
|
-
isFocused: isFocused && !disabled,
|
|
1957
|
-
getRootProps: getRootProps,
|
|
1958
|
-
getInputProps: getInputProps,
|
|
1959
|
-
rootRef: rootRef,
|
|
1960
|
-
inputRef: inputRef,
|
|
1961
|
-
open: composeHandler(openFileDialog)
|
|
1962
|
-
});
|
|
1963
|
-
}
|
|
1964
|
-
/**
|
|
1965
|
-
* @param {DropzoneState} state
|
|
1966
|
-
* @param {{type: string} & DropzoneState} action
|
|
1967
|
-
* @returns {DropzoneState}
|
|
1968
|
-
*/
|
|
1969
|
-
|
|
1970
|
-
function reducer(state, action) {
|
|
1971
|
-
/* istanbul ignore next */
|
|
1972
|
-
switch (action.type) {
|
|
1973
|
-
case "focus":
|
|
1974
|
-
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
1975
|
-
isFocused: true
|
|
1976
|
-
});
|
|
1977
|
-
|
|
1978
|
-
case "blur":
|
|
1979
|
-
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
1980
|
-
isFocused: false
|
|
1981
|
-
});
|
|
1982
|
-
|
|
1983
|
-
case "openDialog":
|
|
1984
|
-
return _objectSpread$a(_objectSpread$a({}, initialState), {}, {
|
|
1985
|
-
isFileDialogActive: true
|
|
1986
|
-
});
|
|
1987
|
-
|
|
1988
|
-
case "closeDialog":
|
|
1989
|
-
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
1990
|
-
isFileDialogActive: false
|
|
1991
|
-
});
|
|
1992
|
-
|
|
1993
|
-
case "setDraggedFiles":
|
|
1994
|
-
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
1995
|
-
isDragActive: action.isDragActive,
|
|
1996
|
-
isDragAccept: action.isDragAccept,
|
|
1997
|
-
isDragReject: action.isDragReject
|
|
1998
|
-
});
|
|
1999
|
-
|
|
2000
|
-
case "setFiles":
|
|
2001
|
-
return _objectSpread$a(_objectSpread$a({}, state), {}, {
|
|
2002
|
-
acceptedFiles: action.acceptedFiles,
|
|
2003
|
-
fileRejections: action.fileRejections
|
|
2004
|
-
});
|
|
2005
|
-
|
|
2006
|
-
case "reset":
|
|
2007
|
-
return _objectSpread$a({}, initialState);
|
|
2008
|
-
|
|
2009
|
-
default:
|
|
2010
|
-
return state;
|
|
2011
|
-
}
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
function noop() {}
|
|
2015
|
-
|
|
2016
197
|
var DROPZONE_ROOT_DIV_CLASSNAME = "neeto-ui-border-primary-600 hover:neeto-ui-bg-gray-100 neeto-ui-rounded-lg flex h-full w-full flex-col items-center justify-center gap-3 border border-dashed p-5 transition-all duration-300 ease-in-out";
|
|
2017
198
|
var FILE_ERRORS = {
|
|
2018
199
|
"file-invalid-type": i18next.t("neetoImageUploader.imageUpload.fileTypeError"),
|
|
@@ -2037,10 +218,10 @@ var useUploadDropzone = function useUploadDropzone(_ref) {
|
|
|
2037
218
|
} : _ref$uploadConfig,
|
|
2038
219
|
_onDrop = _ref.onDrop;
|
|
2039
220
|
var _useState = require$$0.useState(0),
|
|
2040
|
-
_useState2 = _slicedToArray
|
|
221
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2041
222
|
uploadProgress = _useState2[0],
|
|
2042
223
|
setUploadProgress = _useState2[1];
|
|
2043
|
-
var _useDropzone = useDropzone({
|
|
224
|
+
var _useDropzone = reactDropzone.useDropzone({
|
|
2044
225
|
onDrop: function onDrop(acceptedFiles) {
|
|
2045
226
|
return _onDrop(acceptedFiles[0], setUploadProgress);
|
|
2046
227
|
},
|
|
@@ -2083,7 +264,7 @@ var ProgressBar = function ProgressBar(_ref) {
|
|
|
2083
264
|
};
|
|
2084
265
|
|
|
2085
266
|
function ownKeys$a(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2086
|
-
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
267
|
+
function _objectSpread$9(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$a(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$a(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2087
268
|
var ImageDirectUpload = function ImageDirectUpload(_ref) {
|
|
2088
269
|
var _ref$uploadConfig = _ref.uploadConfig,
|
|
2089
270
|
uploadConfig = _ref$uploadConfig === void 0 ? DEFAULT_UPLOAD_CONFIG : _ref$uploadConfig,
|
|
@@ -2161,28 +342,28 @@ var ImageDirectUpload = function ImageDirectUpload(_ref) {
|
|
|
2161
342
|
|
|
2162
343
|
var _excluded$4 = ["className"];
|
|
2163
344
|
function ownKeys$9(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2164
|
-
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
345
|
+
function _objectSpread$8(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$9(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$9(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2165
346
|
var ImagePlaceholder = function ImagePlaceholder(_ref) {
|
|
2166
347
|
var _ref$className = _ref.className,
|
|
2167
348
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
2168
|
-
props = _objectWithoutProperties$
|
|
349
|
+
props = _objectWithoutProperties$1(_ref, _excluded$4);
|
|
2169
350
|
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread$8({
|
|
2170
|
-
className: classnames__default["default"]("neeto-ui-bg-gray-200", _defineProperty$
|
|
351
|
+
className: classnames__default["default"]("neeto-ui-bg-gray-200", _defineProperty$1({}, className, className))
|
|
2171
352
|
}, props));
|
|
2172
353
|
};
|
|
2173
354
|
|
|
2174
355
|
var _excluded$3 = ["src", "className", "fallback"];
|
|
2175
356
|
function ownKeys$8(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2176
|
-
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
357
|
+
function _objectSpread$7(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$8(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$8(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2177
358
|
var ImageWithFallback = function ImageWithFallback(_ref) {
|
|
2178
359
|
var src = _ref.src,
|
|
2179
360
|
_ref$className = _ref.className,
|
|
2180
361
|
className = _ref$className === void 0 ? "h-full w-full" : _ref$className,
|
|
2181
362
|
_ref$fallback = _ref.fallback,
|
|
2182
363
|
Fallback = _ref$fallback === void 0 ? ImagePlaceholder : _ref$fallback,
|
|
2183
|
-
props = _objectWithoutProperties$
|
|
364
|
+
props = _objectWithoutProperties$1(_ref, _excluded$3);
|
|
2184
365
|
var _useState = require$$0.useState(false),
|
|
2185
|
-
_useState2 = _slicedToArray
|
|
366
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2186
367
|
isLoaded = _useState2[0],
|
|
2187
368
|
setIsLoaded = _useState2[1];
|
|
2188
369
|
require$$0.useEffect(function () {
|
|
@@ -2906,7 +1087,7 @@ var isItemsCenter = function isItemsCenter(_ref4) {
|
|
|
2906
1087
|
|
|
2907
1088
|
var _excluded$2 = ["src", "className", "imageFallbackProps", "onDrop", "isDisabled", "onRemove"];
|
|
2908
1089
|
function ownKeys$6(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2909
|
-
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
1090
|
+
function _objectSpread$6(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$6(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$6(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2910
1091
|
var BasicImageUploader = function BasicImageUploader(_ref) {
|
|
2911
1092
|
var _ref$src = _ref.src,
|
|
2912
1093
|
src = _ref$src === void 0 ? "" : _ref$src,
|
|
@@ -2923,7 +1104,7 @@ var BasicImageUploader = function BasicImageUploader(_ref) {
|
|
|
2923
1104
|
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
2924
1105
|
_ref$onRemove = _ref.onRemove,
|
|
2925
1106
|
onRemove = _ref$onRemove === void 0 ? neetoCist.noop : _ref$onRemove,
|
|
2926
|
-
props = _objectWithoutProperties$
|
|
1107
|
+
props = _objectWithoutProperties$1(_ref, _excluded$2);
|
|
2927
1108
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2928
1109
|
className: classnames__default["default"](className, {
|
|
2929
1110
|
"cursor-pointer": true,
|
|
@@ -2981,7 +1162,7 @@ var ASSETS_STALE_TIME = 900000; // 15 mins
|
|
|
2981
1162
|
var UNSPLASH_STALE_TIME = 900000;
|
|
2982
1163
|
|
|
2983
1164
|
function ownKeys$5(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
2984
|
-
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
1165
|
+
function _objectSpread$5(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$5(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$5(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
2985
1166
|
var useCreateBlob = function useCreateBlob(options) {
|
|
2986
1167
|
return reactUtils.useMutationWithInvalidation(directUploadsApi.create, _objectSpread$5({
|
|
2987
1168
|
keysToInvalidate: [QUERY_KEYS.ASSETS_LIST]
|
|
@@ -3019,6 +1200,37 @@ function _asyncToGenerator(fn) {
|
|
|
3019
1200
|
};
|
|
3020
1201
|
}
|
|
3021
1202
|
|
|
1203
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
1204
|
+
|
|
1205
|
+
function getDefaultExportFromCjs (x) {
|
|
1206
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
function getAugmentedNamespace(n) {
|
|
1210
|
+
if (n.__esModule) return n;
|
|
1211
|
+
var f = n.default;
|
|
1212
|
+
if (typeof f == "function") {
|
|
1213
|
+
var a = function a () {
|
|
1214
|
+
if (this instanceof a) {
|
|
1215
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
1216
|
+
}
|
|
1217
|
+
return f.apply(this, arguments);
|
|
1218
|
+
};
|
|
1219
|
+
a.prototype = f.prototype;
|
|
1220
|
+
} else a = {};
|
|
1221
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
1222
|
+
Object.keys(n).forEach(function (k) {
|
|
1223
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
1224
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
1225
|
+
enumerable: true,
|
|
1226
|
+
get: function () {
|
|
1227
|
+
return n[k];
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
});
|
|
1231
|
+
return a;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
3022
1234
|
var regeneratorRuntime$1 = {exports: {}};
|
|
3023
1235
|
|
|
3024
1236
|
var _typeof = {exports: {}};
|
|
@@ -3534,7 +1746,7 @@ var developmentApi = {
|
|
|
3534
1746
|
};
|
|
3535
1747
|
|
|
3536
1748
|
function ownKeys$4(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3537
|
-
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
1749
|
+
function _objectSpread$4(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$4(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$4(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3538
1750
|
var useCropImage = function useCropImage(options) {
|
|
3539
1751
|
return reactQuery.useMutation(_objectSpread$4({
|
|
3540
1752
|
mutationFn: developmentApi.cropImage
|
|
@@ -3677,11 +1889,11 @@ var Controls = function Controls(_ref) {
|
|
|
3677
1889
|
return cropHeight * (((_imageRef$current3 = imageRef.current) === null || _imageRef$current3 === void 0 ? void 0 : _imageRef$current3.naturalWidth) / ((_imageRef$current4 = imageRef.current) === null || _imageRef$current4 === void 0 ? void 0 : _imageRef$current4.width));
|
|
3678
1890
|
};
|
|
3679
1891
|
var _useState = require$$0.useState(getActualCropHeight(crop.height)),
|
|
3680
|
-
_useState2 = _slicedToArray
|
|
1892
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3681
1893
|
height = _useState2[0],
|
|
3682
1894
|
setHeight = _useState2[1];
|
|
3683
1895
|
var _useState3 = require$$0.useState(getActualCropWidth(crop.width)),
|
|
3684
|
-
_useState4 = _slicedToArray
|
|
1896
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
3685
1897
|
width = _useState4[0],
|
|
3686
1898
|
setWidth = _useState4[1];
|
|
3687
1899
|
var _useImageControls = useImageControls({
|
|
@@ -3788,22 +2000,22 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
3788
2000
|
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
3789
2001
|
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
3790
2002
|
var _useState = require$$0.useState(true),
|
|
3791
|
-
_useState2 = _slicedToArray
|
|
2003
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3792
2004
|
isAspectRatioLocked = _useState2[0],
|
|
3793
2005
|
setIsAspectRatioLocked = _useState2[1];
|
|
3794
2006
|
var _useState3 = require$$0.useState(false),
|
|
3795
|
-
_useState4 = _slicedToArray
|
|
2007
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
3796
2008
|
isFullImage = _useState4[0],
|
|
3797
2009
|
setIsFullImage = _useState4[1];
|
|
3798
2010
|
var _useState5 = require$$0.useState({
|
|
3799
2011
|
width: (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) || 16,
|
|
3800
2012
|
height: (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.height) || 9
|
|
3801
2013
|
}),
|
|
3802
|
-
_useState6 = _slicedToArray
|
|
2014
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
3803
2015
|
aspectRatio = _useState6[0],
|
|
3804
2016
|
setAspectRatio = _useState6[1];
|
|
3805
2017
|
var _useState7 = require$$0.useState(DEFAULT_CROP_CONFIG),
|
|
3806
|
-
_useState8 = _slicedToArray
|
|
2018
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
3807
2019
|
crop = _useState8[0],
|
|
3808
2020
|
setCrop = _useState8[1];
|
|
3809
2021
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -3921,7 +2133,7 @@ var imagesApi = {
|
|
|
3921
2133
|
};
|
|
3922
2134
|
|
|
3923
2135
|
function ownKeys$3(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3924
|
-
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
2136
|
+
function _objectSpread$3(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$3(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$3(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
3925
2137
|
var useFetchAssets = function useFetchAssets(_ref) {
|
|
3926
2138
|
var searchTerm = _ref.searchTerm,
|
|
3927
2139
|
url = _ref.url,
|
|
@@ -3955,6 +2167,96 @@ var useFetchAssets = function useFetchAssets(_ref) {
|
|
|
3955
2167
|
|
|
3956
2168
|
var lib = {};
|
|
3957
2169
|
|
|
2170
|
+
var propTypes = {exports: {}};
|
|
2171
|
+
|
|
2172
|
+
/**
|
|
2173
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2174
|
+
*
|
|
2175
|
+
* This source code is licensed under the MIT license found in the
|
|
2176
|
+
* LICENSE file in the root directory of this source tree.
|
|
2177
|
+
*/
|
|
2178
|
+
|
|
2179
|
+
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
2180
|
+
|
|
2181
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
2182
|
+
|
|
2183
|
+
/**
|
|
2184
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2185
|
+
*
|
|
2186
|
+
* This source code is licensed under the MIT license found in the
|
|
2187
|
+
* LICENSE file in the root directory of this source tree.
|
|
2188
|
+
*/
|
|
2189
|
+
|
|
2190
|
+
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
2191
|
+
|
|
2192
|
+
function emptyFunction() {}
|
|
2193
|
+
function emptyFunctionWithReset() {}
|
|
2194
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
2195
|
+
|
|
2196
|
+
var factoryWithThrowingShims = function() {
|
|
2197
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
2198
|
+
if (secret === ReactPropTypesSecret) {
|
|
2199
|
+
// It is still safe when called from React.
|
|
2200
|
+
return;
|
|
2201
|
+
}
|
|
2202
|
+
var err = new Error(
|
|
2203
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
2204
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
2205
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
2206
|
+
);
|
|
2207
|
+
err.name = 'Invariant Violation';
|
|
2208
|
+
throw err;
|
|
2209
|
+
} shim.isRequired = shim;
|
|
2210
|
+
function getShim() {
|
|
2211
|
+
return shim;
|
|
2212
|
+
} // Important!
|
|
2213
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
2214
|
+
var ReactPropTypes = {
|
|
2215
|
+
array: shim,
|
|
2216
|
+
bigint: shim,
|
|
2217
|
+
bool: shim,
|
|
2218
|
+
func: shim,
|
|
2219
|
+
number: shim,
|
|
2220
|
+
object: shim,
|
|
2221
|
+
string: shim,
|
|
2222
|
+
symbol: shim,
|
|
2223
|
+
|
|
2224
|
+
any: shim,
|
|
2225
|
+
arrayOf: getShim,
|
|
2226
|
+
element: shim,
|
|
2227
|
+
elementType: shim,
|
|
2228
|
+
instanceOf: getShim,
|
|
2229
|
+
node: shim,
|
|
2230
|
+
objectOf: getShim,
|
|
2231
|
+
oneOf: getShim,
|
|
2232
|
+
oneOfType: getShim,
|
|
2233
|
+
shape: getShim,
|
|
2234
|
+
exact: getShim,
|
|
2235
|
+
|
|
2236
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
2237
|
+
resetWarningCache: emptyFunction
|
|
2238
|
+
};
|
|
2239
|
+
|
|
2240
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
2241
|
+
|
|
2242
|
+
return ReactPropTypes;
|
|
2243
|
+
};
|
|
2244
|
+
|
|
2245
|
+
/**
|
|
2246
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2247
|
+
*
|
|
2248
|
+
* This source code is licensed under the MIT license found in the
|
|
2249
|
+
* LICENSE file in the root directory of this source tree.
|
|
2250
|
+
*/
|
|
2251
|
+
|
|
2252
|
+
{
|
|
2253
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
2254
|
+
// http://fb.me/prop-types-in-prod
|
|
2255
|
+
propTypes.exports = factoryWithThrowingShims();
|
|
2256
|
+
}
|
|
2257
|
+
|
|
2258
|
+
var propTypesExports = propTypes.exports;
|
|
2259
|
+
|
|
3958
2260
|
var _extends = Object.assign || function (target) {
|
|
3959
2261
|
for (var i = 1; i < arguments.length; i++) {
|
|
3960
2262
|
var source = arguments[i];
|
|
@@ -4844,7 +3146,7 @@ var unsplashApi = {
|
|
|
4844
3146
|
};
|
|
4845
3147
|
|
|
4846
3148
|
function ownKeys$2(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4847
|
-
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
3149
|
+
function _objectSpread$2(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$2(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$2(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4848
3150
|
var UNSPLASH_LIST = QUERY_KEYS.UNSPLASH_LIST;
|
|
4849
3151
|
var useFetchUnsplashImages = function useFetchUnsplashImages(_ref) {
|
|
4850
3152
|
var query = _ref.query;
|
|
@@ -5020,7 +3322,7 @@ var ImageLibrary = function ImageLibrary(_ref) {
|
|
|
5020
3322
|
setIsUploading = _ref.setIsUploading,
|
|
5021
3323
|
setActiveTab = _ref.setActiveTab;
|
|
5022
3324
|
var _useState = require$$0.useState(""),
|
|
5023
|
-
_useState2 = _slicedToArray
|
|
3325
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5024
3326
|
query = _useState2[0],
|
|
5025
3327
|
setQuery = _useState2[1];
|
|
5026
3328
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -5059,7 +3361,7 @@ var ImageLibrary = function ImageLibrary(_ref) {
|
|
|
5059
3361
|
|
|
5060
3362
|
var _excluded$1 = ["key"];
|
|
5061
3363
|
function ownKeys$1(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5062
|
-
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
3364
|
+
function _objectSpread$1(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$1(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$1(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5063
3365
|
var Modal = function Modal(_ref) {
|
|
5064
3366
|
var isOpen = _ref.isOpen,
|
|
5065
3367
|
_ref$onClose = _ref.onClose,
|
|
@@ -5071,15 +3373,15 @@ var Modal = function Modal(_ref) {
|
|
|
5071
3373
|
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
5072
3374
|
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
5073
3375
|
var _useState = require$$0.useState(TABS[0].key),
|
|
5074
|
-
_useState2 = _slicedToArray
|
|
3376
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5075
3377
|
activeTab = _useState2[0],
|
|
5076
3378
|
setActiveTab = _useState2[1];
|
|
5077
3379
|
var _useState3 = require$$0.useState({}),
|
|
5078
|
-
_useState4 = _slicedToArray
|
|
3380
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
5079
3381
|
selectedImage = _useState4[0],
|
|
5080
3382
|
setSelectedImage = _useState4[1];
|
|
5081
3383
|
var _useState5 = require$$0.useState(false),
|
|
5082
|
-
_useState6 = _slicedToArray
|
|
3384
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
5083
3385
|
isUploading = _useState6[0],
|
|
5084
3386
|
setIsUploading = _useState6[1];
|
|
5085
3387
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -5199,7 +3501,7 @@ var Modal = function Modal(_ref) {
|
|
|
5199
3501
|
className: "flex gap-2",
|
|
5200
3502
|
children: options.map(function (_ref2) {
|
|
5201
3503
|
var key = _ref2.key,
|
|
5202
|
-
otherProps = _objectWithoutProperties$
|
|
3504
|
+
otherProps = _objectWithoutProperties$1(_ref2, _excluded$1);
|
|
5203
3505
|
return /*#__PURE__*/require$$0.createElement(Button__default["default"], _objectSpread$1(_objectSpread$1({}, otherProps), {}, {
|
|
5204
3506
|
key: key,
|
|
5205
3507
|
size: "small"
|
|
@@ -5234,7 +3536,7 @@ var Modal = function Modal(_ref) {
|
|
|
5234
3536
|
|
|
5235
3537
|
var _excluded = ["key", "label"];
|
|
5236
3538
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
5237
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty$
|
|
3539
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty$1(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5238
3540
|
var Menu = Dropdown__default["default"].Menu,
|
|
5239
3541
|
MenuItem = Dropdown__default["default"].MenuItem;
|
|
5240
3542
|
var ImageUploader = function ImageUploader(_ref) {
|
|
@@ -5249,13 +3551,13 @@ var ImageUploader = function ImageUploader(_ref) {
|
|
|
5249
3551
|
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
5250
3552
|
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
5251
3553
|
var _useState = require$$0.useState(false),
|
|
5252
|
-
_useState2 = _slicedToArray
|
|
3554
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5253
3555
|
isAssetLibraryOpen = _useState2[0],
|
|
5254
3556
|
setIsAssetLibraryOpen = _useState2[1];
|
|
5255
3557
|
var _useState3 = require$$0.useState({
|
|
5256
3558
|
url: src
|
|
5257
3559
|
}),
|
|
5258
|
-
_useState4 = _slicedToArray
|
|
3560
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
5259
3561
|
image = _useState4[0],
|
|
5260
3562
|
setImage = _useState4[1];
|
|
5261
3563
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -5355,7 +3657,7 @@ var ImageUploader = function ImageUploader(_ref) {
|
|
|
5355
3657
|
children: options.map(function (_ref2) {
|
|
5356
3658
|
var key = _ref2.key,
|
|
5357
3659
|
label = _ref2.label,
|
|
5358
|
-
otherProps = _objectWithoutProperties$
|
|
3660
|
+
otherProps = _objectWithoutProperties$1(_ref2, _excluded);
|
|
5359
3661
|
return /*#__PURE__*/require$$0.createElement(MenuItem.Button, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
5360
3662
|
key: key
|
|
5361
3663
|
}), label);
|
|
@@ -5381,11 +3683,11 @@ var ImageUploader = function ImageUploader(_ref) {
|
|
|
5381
3683
|
|
|
5382
3684
|
var useImageUpload = function useImageUpload() {
|
|
5383
3685
|
var _useState = require$$0.useState(0),
|
|
5384
|
-
_useState2 = _slicedToArray
|
|
3686
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5385
3687
|
uploadProgress = _useState2[0],
|
|
5386
3688
|
setUploadProgress = _useState2[1];
|
|
5387
3689
|
var _useState3 = require$$0.useState(false),
|
|
5388
|
-
_useState4 = _slicedToArray
|
|
3690
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
5389
3691
|
isUploading = _useState4[0],
|
|
5390
3692
|
setIsUploading = _useState4[1];
|
|
5391
3693
|
var authenticationEndpoint = "".concat(window.location.origin, "/neeto_image_uploader_engine/imagekit/auth");
|
|
@@ -5526,11 +3828,11 @@ var useProfileImageUpload = function useProfileImageUpload(_ref) {
|
|
|
5526
3828
|
var _ref$uploadConfig = _ref.uploadConfig,
|
|
5527
3829
|
uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig;
|
|
5528
3830
|
var _useState = require$$0.useState(0),
|
|
5529
|
-
_useState2 = _slicedToArray
|
|
3831
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5530
3832
|
uploadProgress = _useState2[0],
|
|
5531
3833
|
setUploadProgress = _useState2[1];
|
|
5532
3834
|
var _useState3 = require$$0.useState(false),
|
|
5533
|
-
_useState4 = _slicedToArray
|
|
3835
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
5534
3836
|
isUploading = _useState4[0],
|
|
5535
3837
|
setIsUploading = _useState4[1];
|
|
5536
3838
|
var authenticationEndpoint = "".concat(window.location.origin, "/neeto_image_uploader_engine/imagekit/auth");
|