@bigbinary/neeto-image-uploader-frontend 2.0.0 → 2.0.2
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 +185 -1878
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +198 -1894
- package/dist/index.js.map +1 -1
- package/package.json +19 -16
package/dist/index.cjs.js
CHANGED
|
@@ -5,15 +5,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var require$$0 = require('react');
|
|
6
6
|
var classnames = require('classnames');
|
|
7
7
|
var neetoCist = require('@bigbinary/neeto-cist');
|
|
8
|
-
var
|
|
8
|
+
var Delete = require('@bigbinary/neeto-icons/Delete');
|
|
9
9
|
var Button = require('@bigbinary/neetoui/Button');
|
|
10
10
|
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');
|
|
18
|
+
var MenuHorizontal = require('@bigbinary/neeto-icons/MenuHorizontal');
|
|
17
19
|
var Dropdown = require('@bigbinary/neetoui/Dropdown');
|
|
18
20
|
var NeetoUIModal = require('@bigbinary/neetoui/Modal');
|
|
19
21
|
var Tab = require('@bigbinary/neetoui/Tab');
|
|
@@ -22,6 +24,7 @@ var reactQuery = require('@tanstack/react-query');
|
|
|
22
24
|
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
23
25
|
var axios = require('axios');
|
|
24
26
|
var activestorage = require('@rails/activestorage');
|
|
27
|
+
var LeftArrow = require('@bigbinary/neeto-icons/LeftArrow');
|
|
25
28
|
var utils = require('@bigbinary/neeto-commons-frontend/utils');
|
|
26
29
|
var Input = require('@bigbinary/neetoui/Input');
|
|
27
30
|
var Switch = require('@bigbinary/neetoui/Switch');
|
|
@@ -30,15 +33,18 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
30
33
|
|
|
31
34
|
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
32
35
|
var classnames__default = /*#__PURE__*/_interopDefaultLegacy(classnames);
|
|
36
|
+
var Delete__default = /*#__PURE__*/_interopDefaultLegacy(Delete);
|
|
33
37
|
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
34
38
|
var Typography__default = /*#__PURE__*/_interopDefaultLegacy(Typography);
|
|
35
39
|
var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
|
|
36
40
|
var Toastr__default = /*#__PURE__*/_interopDefaultLegacy(Toastr);
|
|
41
|
+
var MenuHorizontal__default = /*#__PURE__*/_interopDefaultLegacy(MenuHorizontal);
|
|
37
42
|
var Dropdown__default = /*#__PURE__*/_interopDefaultLegacy(Dropdown);
|
|
38
43
|
var NeetoUIModal__default = /*#__PURE__*/_interopDefaultLegacy(NeetoUIModal);
|
|
39
44
|
var Tab__default = /*#__PURE__*/_interopDefaultLegacy(Tab);
|
|
40
45
|
var Spinner__default = /*#__PURE__*/_interopDefaultLegacy(Spinner);
|
|
41
46
|
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
47
|
+
var LeftArrow__default = /*#__PURE__*/_interopDefaultLegacy(LeftArrow);
|
|
42
48
|
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
|
|
43
49
|
var Switch__default = /*#__PURE__*/_interopDefaultLegacy(Switch);
|
|
44
50
|
|
|
@@ -73,7 +79,7 @@ function _toPropertyKey(arg) {
|
|
|
73
79
|
return _typeof$2(key) === "symbol" ? key : String(key);
|
|
74
80
|
}
|
|
75
81
|
|
|
76
|
-
function _defineProperty$
|
|
82
|
+
function _defineProperty$1(obj, key, value) {
|
|
77
83
|
key = _toPropertyKey(key);
|
|
78
84
|
if (key in obj) {
|
|
79
85
|
Object.defineProperty(obj, key, {
|
|
@@ -88,7 +94,7 @@ function _defineProperty$3(obj, key, value) {
|
|
|
88
94
|
return obj;
|
|
89
95
|
}
|
|
90
96
|
|
|
91
|
-
function _objectWithoutPropertiesLoose
|
|
97
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
92
98
|
if (source == null) return {};
|
|
93
99
|
var target = {};
|
|
94
100
|
var sourceKeys = Object.keys(source);
|
|
@@ -101,9 +107,9 @@ function _objectWithoutPropertiesLoose$1(source, excluded) {
|
|
|
101
107
|
return target;
|
|
102
108
|
}
|
|
103
109
|
|
|
104
|
-
function _objectWithoutProperties$
|
|
110
|
+
function _objectWithoutProperties$1(source, excluded) {
|
|
105
111
|
if (source == null) return {};
|
|
106
|
-
var target = _objectWithoutPropertiesLoose
|
|
112
|
+
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
107
113
|
var key, i;
|
|
108
114
|
if (Object.getOwnPropertySymbols) {
|
|
109
115
|
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
@@ -138,11 +144,11 @@ var getAllowedTypes = function getAllowedTypes(uploadConfig) {
|
|
|
138
144
|
}), ramda.map(ramda.toUpper), ramda.join(", "))(uploadConfig.allowedImageTypes);
|
|
139
145
|
};
|
|
140
146
|
|
|
141
|
-
function _arrayWithHoles
|
|
147
|
+
function _arrayWithHoles(arr) {
|
|
142
148
|
if (Array.isArray(arr)) return arr;
|
|
143
149
|
}
|
|
144
150
|
|
|
145
|
-
function _iterableToArrayLimit
|
|
151
|
+
function _iterableToArrayLimit(r, l) {
|
|
146
152
|
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
147
153
|
if (null != t) {
|
|
148
154
|
var e,
|
|
@@ -170,1849 +176,29 @@ function _iterableToArrayLimit$2(r, l) {
|
|
|
170
176
|
}
|
|
171
177
|
}
|
|
172
178
|
|
|
173
|
-
function _arrayLikeToArray
|
|
179
|
+
function _arrayLikeToArray(arr, len) {
|
|
174
180
|
if (len == null || len > arr.length) len = arr.length;
|
|
175
181
|
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
176
182
|
return arr2;
|
|
177
183
|
}
|
|
178
184
|
|
|
179
|
-
function _unsupportedIterableToArray
|
|
185
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
180
186
|
if (!o) return;
|
|
181
|
-
if (typeof o === "string") return _arrayLikeToArray
|
|
187
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
182
188
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
183
189
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
184
190
|
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
|
|
191
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
186
192
|
}
|
|
187
193
|
|
|
188
|
-
function _nonIterableRest
|
|
194
|
+
function _nonIterableRest() {
|
|
189
195
|
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
196
|
}
|
|
191
197
|
|
|
192
|
-
function _slicedToArray
|
|
193
|
-
return _arrayWithHoles
|
|
198
|
+
function _slicedToArray(arr, i) {
|
|
199
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
194
200
|
}
|
|
195
201
|
|
|
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
202
|
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
203
|
var FILE_ERRORS = {
|
|
2018
204
|
"file-invalid-type": i18next.t("neetoImageUploader.imageUpload.fileTypeError"),
|
|
@@ -2037,10 +223,10 @@ var useUploadDropzone = function useUploadDropzone(_ref) {
|
|
|
2037
223
|
} : _ref$uploadConfig,
|
|
2038
224
|
_onDrop = _ref.onDrop;
|
|
2039
225
|
var _useState = require$$0.useState(0),
|
|
2040
|
-
_useState2 = _slicedToArray
|
|
226
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2041
227
|
uploadProgress = _useState2[0],
|
|
2042
228
|
setUploadProgress = _useState2[1];
|
|
2043
|
-
var _useDropzone = useDropzone({
|
|
229
|
+
var _useDropzone = reactDropzone.useDropzone({
|
|
2044
230
|
onDrop: function onDrop(acceptedFiles) {
|
|
2045
231
|
return _onDrop(acceptedFiles[0], setUploadProgress);
|
|
2046
232
|
},
|
|
@@ -2083,7 +269,7 @@ var ProgressBar = function ProgressBar(_ref) {
|
|
|
2083
269
|
};
|
|
2084
270
|
|
|
2085
271
|
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$
|
|
272
|
+
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
273
|
var ImageDirectUpload = function ImageDirectUpload(_ref) {
|
|
2088
274
|
var _ref$uploadConfig = _ref.uploadConfig,
|
|
2089
275
|
uploadConfig = _ref$uploadConfig === void 0 ? DEFAULT_UPLOAD_CONFIG : _ref$uploadConfig,
|
|
@@ -2117,9 +303,9 @@ var ImageDirectUpload = function ImageDirectUpload(_ref) {
|
|
|
2117
303
|
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
2118
304
|
i18nKey: "neetoImageUploader.imageUpload.dragAndDropOrBrowseFile",
|
|
2119
305
|
components: {
|
|
2120
|
-
span: /*#__PURE__*/jsxRuntime.jsx("
|
|
2121
|
-
|
|
2122
|
-
|
|
306
|
+
span: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
307
|
+
"data-cy": "neeto-image-uploader-browse-text",
|
|
308
|
+
style: "link"
|
|
2123
309
|
})
|
|
2124
310
|
}
|
|
2125
311
|
})
|
|
@@ -2133,9 +319,9 @@ var ImageDirectUpload = function ImageDirectUpload(_ref) {
|
|
|
2133
319
|
children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
|
|
2134
320
|
i18nKey: "neetoImageUploader.imageUpload.selectImagefromImageLibrary",
|
|
2135
321
|
components: {
|
|
2136
|
-
span: /*#__PURE__*/jsxRuntime.jsx("
|
|
2137
|
-
|
|
2138
|
-
|
|
322
|
+
span: /*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
323
|
+
"data-cy": "open-asset-library-button",
|
|
324
|
+
style: "link"
|
|
2139
325
|
})
|
|
2140
326
|
}
|
|
2141
327
|
})
|
|
@@ -2161,28 +347,28 @@ var ImageDirectUpload = function ImageDirectUpload(_ref) {
|
|
|
2161
347
|
|
|
2162
348
|
var _excluded$4 = ["className"];
|
|
2163
349
|
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$
|
|
350
|
+
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
351
|
var ImagePlaceholder = function ImagePlaceholder(_ref) {
|
|
2166
352
|
var _ref$className = _ref.className,
|
|
2167
353
|
className = _ref$className === void 0 ? "" : _ref$className,
|
|
2168
|
-
props = _objectWithoutProperties$
|
|
354
|
+
props = _objectWithoutProperties$1(_ref, _excluded$4);
|
|
2169
355
|
return /*#__PURE__*/jsxRuntime.jsx("div", _objectSpread$8({
|
|
2170
|
-
className: classnames__default["default"]("neeto-ui-bg-gray-200", _defineProperty$
|
|
356
|
+
className: classnames__default["default"]("neeto-ui-bg-gray-200", _defineProperty$1({}, className, className))
|
|
2171
357
|
}, props));
|
|
2172
358
|
};
|
|
2173
359
|
|
|
2174
360
|
var _excluded$3 = ["src", "className", "fallback"];
|
|
2175
361
|
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$
|
|
362
|
+
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
363
|
var ImageWithFallback = function ImageWithFallback(_ref) {
|
|
2178
364
|
var src = _ref.src,
|
|
2179
365
|
_ref$className = _ref.className,
|
|
2180
366
|
className = _ref$className === void 0 ? "h-full w-full" : _ref$className,
|
|
2181
367
|
_ref$fallback = _ref.fallback,
|
|
2182
368
|
Fallback = _ref$fallback === void 0 ? ImagePlaceholder : _ref$fallback,
|
|
2183
|
-
props = _objectWithoutProperties$
|
|
369
|
+
props = _objectWithoutProperties$1(_ref, _excluded$3);
|
|
2184
370
|
var _useState = require$$0.useState(false),
|
|
2185
|
-
_useState2 = _slicedToArray
|
|
371
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
2186
372
|
isLoaded = _useState2[0],
|
|
2187
373
|
setIsLoaded = _useState2[1];
|
|
2188
374
|
require$$0.useEffect(function () {
|
|
@@ -2906,7 +1092,7 @@ var isItemsCenter = function isItemsCenter(_ref4) {
|
|
|
2906
1092
|
|
|
2907
1093
|
var _excluded$2 = ["src", "className", "imageFallbackProps", "onDrop", "isDisabled", "onRemove"];
|
|
2908
1094
|
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$
|
|
1095
|
+
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
1096
|
var BasicImageUploader = function BasicImageUploader(_ref) {
|
|
2911
1097
|
var _ref$src = _ref.src,
|
|
2912
1098
|
src = _ref$src === void 0 ? "" : _ref$src,
|
|
@@ -2923,7 +1109,7 @@ var BasicImageUploader = function BasicImageUploader(_ref) {
|
|
|
2923
1109
|
isDisabled = _ref$isDisabled === void 0 ? false : _ref$isDisabled,
|
|
2924
1110
|
_ref$onRemove = _ref.onRemove,
|
|
2925
1111
|
onRemove = _ref$onRemove === void 0 ? neetoCist.noop : _ref$onRemove,
|
|
2926
|
-
props = _objectWithoutProperties$
|
|
1112
|
+
props = _objectWithoutProperties$1(_ref, _excluded$2);
|
|
2927
1113
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
2928
1114
|
className: classnames__default["default"](className, {
|
|
2929
1115
|
"cursor-pointer": true,
|
|
@@ -2940,7 +1126,7 @@ var BasicImageUploader = function BasicImageUploader(_ref) {
|
|
|
2940
1126
|
className: "absolute right-3 top-3",
|
|
2941
1127
|
"data-cy": "basic-image-uploader-remove-button",
|
|
2942
1128
|
disabled: isDisabled,
|
|
2943
|
-
icon:
|
|
1129
|
+
icon: Delete__default["default"],
|
|
2944
1130
|
size: "small",
|
|
2945
1131
|
onClick: onRemove
|
|
2946
1132
|
})]
|
|
@@ -2981,7 +1167,7 @@ var ASSETS_STALE_TIME = 900000; // 15 mins
|
|
|
2981
1167
|
var UNSPLASH_STALE_TIME = 900000;
|
|
2982
1168
|
|
|
2983
1169
|
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$
|
|
1170
|
+
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
1171
|
var useCreateBlob = function useCreateBlob(options) {
|
|
2986
1172
|
return reactUtils.useMutationWithInvalidation(directUploadsApi.create, _objectSpread$5({
|
|
2987
1173
|
keysToInvalidate: [QUERY_KEYS.ASSETS_LIST]
|
|
@@ -3019,6 +1205,37 @@ function _asyncToGenerator(fn) {
|
|
|
3019
1205
|
};
|
|
3020
1206
|
}
|
|
3021
1207
|
|
|
1208
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
1209
|
+
|
|
1210
|
+
function getDefaultExportFromCjs (x) {
|
|
1211
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1214
|
+
function getAugmentedNamespace(n) {
|
|
1215
|
+
if (n.__esModule) return n;
|
|
1216
|
+
var f = n.default;
|
|
1217
|
+
if (typeof f == "function") {
|
|
1218
|
+
var a = function a () {
|
|
1219
|
+
if (this instanceof a) {
|
|
1220
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
1221
|
+
}
|
|
1222
|
+
return f.apply(this, arguments);
|
|
1223
|
+
};
|
|
1224
|
+
a.prototype = f.prototype;
|
|
1225
|
+
} else a = {};
|
|
1226
|
+
Object.defineProperty(a, '__esModule', {value: true});
|
|
1227
|
+
Object.keys(n).forEach(function (k) {
|
|
1228
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
1229
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
1230
|
+
enumerable: true,
|
|
1231
|
+
get: function () {
|
|
1232
|
+
return n[k];
|
|
1233
|
+
}
|
|
1234
|
+
});
|
|
1235
|
+
});
|
|
1236
|
+
return a;
|
|
1237
|
+
}
|
|
1238
|
+
|
|
3022
1239
|
var regeneratorRuntime$1 = {exports: {}};
|
|
3023
1240
|
|
|
3024
1241
|
var _typeof = {exports: {}};
|
|
@@ -3534,7 +1751,7 @@ var developmentApi = {
|
|
|
3534
1751
|
};
|
|
3535
1752
|
|
|
3536
1753
|
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$
|
|
1754
|
+
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
1755
|
var useCropImage = function useCropImage(options) {
|
|
3539
1756
|
return reactQuery.useMutation(_objectSpread$4({
|
|
3540
1757
|
mutationFn: developmentApi.cropImage
|
|
@@ -3677,11 +1894,11 @@ var Controls = function Controls(_ref) {
|
|
|
3677
1894
|
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
1895
|
};
|
|
3679
1896
|
var _useState = require$$0.useState(getActualCropHeight(crop.height)),
|
|
3680
|
-
_useState2 = _slicedToArray
|
|
1897
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3681
1898
|
height = _useState2[0],
|
|
3682
1899
|
setHeight = _useState2[1];
|
|
3683
1900
|
var _useState3 = require$$0.useState(getActualCropWidth(crop.width)),
|
|
3684
|
-
_useState4 = _slicedToArray
|
|
1901
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
3685
1902
|
width = _useState4[0],
|
|
3686
1903
|
setWidth = _useState4[1];
|
|
3687
1904
|
var _useImageControls = useImageControls({
|
|
@@ -3788,22 +2005,22 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
3788
2005
|
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
3789
2006
|
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
3790
2007
|
var _useState = require$$0.useState(true),
|
|
3791
|
-
_useState2 = _slicedToArray
|
|
2008
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
3792
2009
|
isAspectRatioLocked = _useState2[0],
|
|
3793
2010
|
setIsAspectRatioLocked = _useState2[1];
|
|
3794
2011
|
var _useState3 = require$$0.useState(false),
|
|
3795
|
-
_useState4 = _slicedToArray
|
|
2012
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
3796
2013
|
isFullImage = _useState4[0],
|
|
3797
2014
|
setIsFullImage = _useState4[1];
|
|
3798
2015
|
var _useState5 = require$$0.useState({
|
|
3799
2016
|
width: (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.width) || 16,
|
|
3800
2017
|
height: (fixedAspectRatio === null || fixedAspectRatio === void 0 ? void 0 : fixedAspectRatio.height) || 9
|
|
3801
2018
|
}),
|
|
3802
|
-
_useState6 = _slicedToArray
|
|
2019
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
3803
2020
|
aspectRatio = _useState6[0],
|
|
3804
2021
|
setAspectRatio = _useState6[1];
|
|
3805
2022
|
var _useState7 = require$$0.useState(DEFAULT_CROP_CONFIG),
|
|
3806
|
-
_useState8 = _slicedToArray
|
|
2023
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
3807
2024
|
crop = _useState8[0],
|
|
3808
2025
|
setCrop = _useState8[1];
|
|
3809
2026
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -3851,7 +2068,7 @@ var ImageEditor = function ImageEditor(_ref) {
|
|
|
3851
2068
|
children: [/*#__PURE__*/jsxRuntime.jsx(Button__default["default"], {
|
|
3852
2069
|
className: "self-start",
|
|
3853
2070
|
"data-cy": "image-editor-back-button",
|
|
3854
|
-
icon:
|
|
2071
|
+
icon: LeftArrow__default["default"],
|
|
3855
2072
|
iconPosition: "left",
|
|
3856
2073
|
style: "text",
|
|
3857
2074
|
onClick: handleReset
|
|
@@ -3921,7 +2138,7 @@ var imagesApi = {
|
|
|
3921
2138
|
};
|
|
3922
2139
|
|
|
3923
2140
|
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$
|
|
2141
|
+
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
2142
|
var useFetchAssets = function useFetchAssets(_ref) {
|
|
3926
2143
|
var searchTerm = _ref.searchTerm,
|
|
3927
2144
|
url = _ref.url,
|
|
@@ -3955,6 +2172,96 @@ var useFetchAssets = function useFetchAssets(_ref) {
|
|
|
3955
2172
|
|
|
3956
2173
|
var lib = {};
|
|
3957
2174
|
|
|
2175
|
+
var propTypes = {exports: {}};
|
|
2176
|
+
|
|
2177
|
+
/**
|
|
2178
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2179
|
+
*
|
|
2180
|
+
* This source code is licensed under the MIT license found in the
|
|
2181
|
+
* LICENSE file in the root directory of this source tree.
|
|
2182
|
+
*/
|
|
2183
|
+
|
|
2184
|
+
var ReactPropTypesSecret$1 = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
|
|
2185
|
+
|
|
2186
|
+
var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
2187
|
+
|
|
2188
|
+
/**
|
|
2189
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2190
|
+
*
|
|
2191
|
+
* This source code is licensed under the MIT license found in the
|
|
2192
|
+
* LICENSE file in the root directory of this source tree.
|
|
2193
|
+
*/
|
|
2194
|
+
|
|
2195
|
+
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
2196
|
+
|
|
2197
|
+
function emptyFunction() {}
|
|
2198
|
+
function emptyFunctionWithReset() {}
|
|
2199
|
+
emptyFunctionWithReset.resetWarningCache = emptyFunction;
|
|
2200
|
+
|
|
2201
|
+
var factoryWithThrowingShims = function() {
|
|
2202
|
+
function shim(props, propName, componentName, location, propFullName, secret) {
|
|
2203
|
+
if (secret === ReactPropTypesSecret) {
|
|
2204
|
+
// It is still safe when called from React.
|
|
2205
|
+
return;
|
|
2206
|
+
}
|
|
2207
|
+
var err = new Error(
|
|
2208
|
+
'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
|
|
2209
|
+
'Use PropTypes.checkPropTypes() to call them. ' +
|
|
2210
|
+
'Read more at http://fb.me/use-check-prop-types'
|
|
2211
|
+
);
|
|
2212
|
+
err.name = 'Invariant Violation';
|
|
2213
|
+
throw err;
|
|
2214
|
+
} shim.isRequired = shim;
|
|
2215
|
+
function getShim() {
|
|
2216
|
+
return shim;
|
|
2217
|
+
} // Important!
|
|
2218
|
+
// Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
|
|
2219
|
+
var ReactPropTypes = {
|
|
2220
|
+
array: shim,
|
|
2221
|
+
bigint: shim,
|
|
2222
|
+
bool: shim,
|
|
2223
|
+
func: shim,
|
|
2224
|
+
number: shim,
|
|
2225
|
+
object: shim,
|
|
2226
|
+
string: shim,
|
|
2227
|
+
symbol: shim,
|
|
2228
|
+
|
|
2229
|
+
any: shim,
|
|
2230
|
+
arrayOf: getShim,
|
|
2231
|
+
element: shim,
|
|
2232
|
+
elementType: shim,
|
|
2233
|
+
instanceOf: getShim,
|
|
2234
|
+
node: shim,
|
|
2235
|
+
objectOf: getShim,
|
|
2236
|
+
oneOf: getShim,
|
|
2237
|
+
oneOfType: getShim,
|
|
2238
|
+
shape: getShim,
|
|
2239
|
+
exact: getShim,
|
|
2240
|
+
|
|
2241
|
+
checkPropTypes: emptyFunctionWithReset,
|
|
2242
|
+
resetWarningCache: emptyFunction
|
|
2243
|
+
};
|
|
2244
|
+
|
|
2245
|
+
ReactPropTypes.PropTypes = ReactPropTypes;
|
|
2246
|
+
|
|
2247
|
+
return ReactPropTypes;
|
|
2248
|
+
};
|
|
2249
|
+
|
|
2250
|
+
/**
|
|
2251
|
+
* Copyright (c) 2013-present, Facebook, Inc.
|
|
2252
|
+
*
|
|
2253
|
+
* This source code is licensed under the MIT license found in the
|
|
2254
|
+
* LICENSE file in the root directory of this source tree.
|
|
2255
|
+
*/
|
|
2256
|
+
|
|
2257
|
+
{
|
|
2258
|
+
// By explicitly using `prop-types` you are opting into new production behavior.
|
|
2259
|
+
// http://fb.me/prop-types-in-prod
|
|
2260
|
+
propTypes.exports = factoryWithThrowingShims();
|
|
2261
|
+
}
|
|
2262
|
+
|
|
2263
|
+
var propTypesExports = propTypes.exports;
|
|
2264
|
+
|
|
3958
2265
|
var _extends = Object.assign || function (target) {
|
|
3959
2266
|
for (var i = 1; i < arguments.length; i++) {
|
|
3960
2267
|
var source = arguments[i];
|
|
@@ -4844,7 +3151,7 @@ var unsplashApi = {
|
|
|
4844
3151
|
};
|
|
4845
3152
|
|
|
4846
3153
|
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$
|
|
3154
|
+
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
3155
|
var UNSPLASH_LIST = QUERY_KEYS.UNSPLASH_LIST;
|
|
4849
3156
|
var useFetchUnsplashImages = function useFetchUnsplashImages(_ref) {
|
|
4850
3157
|
var query = _ref.query;
|
|
@@ -5020,7 +3327,7 @@ var ImageLibrary = function ImageLibrary(_ref) {
|
|
|
5020
3327
|
setIsUploading = _ref.setIsUploading,
|
|
5021
3328
|
setActiveTab = _ref.setActiveTab;
|
|
5022
3329
|
var _useState = require$$0.useState(""),
|
|
5023
|
-
_useState2 = _slicedToArray
|
|
3330
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5024
3331
|
query = _useState2[0],
|
|
5025
3332
|
setQuery = _useState2[1];
|
|
5026
3333
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -5059,7 +3366,7 @@ var ImageLibrary = function ImageLibrary(_ref) {
|
|
|
5059
3366
|
|
|
5060
3367
|
var _excluded$1 = ["key"];
|
|
5061
3368
|
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$
|
|
3369
|
+
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
3370
|
var Modal = function Modal(_ref) {
|
|
5064
3371
|
var isOpen = _ref.isOpen,
|
|
5065
3372
|
_ref$onClose = _ref.onClose,
|
|
@@ -5071,15 +3378,15 @@ var Modal = function Modal(_ref) {
|
|
|
5071
3378
|
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
5072
3379
|
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
5073
3380
|
var _useState = require$$0.useState(TABS[0].key),
|
|
5074
|
-
_useState2 = _slicedToArray
|
|
3381
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5075
3382
|
activeTab = _useState2[0],
|
|
5076
3383
|
setActiveTab = _useState2[1];
|
|
5077
3384
|
var _useState3 = require$$0.useState({}),
|
|
5078
|
-
_useState4 = _slicedToArray
|
|
3385
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
5079
3386
|
selectedImage = _useState4[0],
|
|
5080
3387
|
setSelectedImage = _useState4[1];
|
|
5081
3388
|
var _useState5 = require$$0.useState(false),
|
|
5082
|
-
_useState6 = _slicedToArray
|
|
3389
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
5083
3390
|
isUploading = _useState6[0],
|
|
5084
3391
|
setIsUploading = _useState6[1];
|
|
5085
3392
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -5199,7 +3506,7 @@ var Modal = function Modal(_ref) {
|
|
|
5199
3506
|
className: "flex gap-2",
|
|
5200
3507
|
children: options.map(function (_ref2) {
|
|
5201
3508
|
var key = _ref2.key,
|
|
5202
|
-
otherProps = _objectWithoutProperties$
|
|
3509
|
+
otherProps = _objectWithoutProperties$1(_ref2, _excluded$1);
|
|
5203
3510
|
return /*#__PURE__*/require$$0.createElement(Button__default["default"], _objectSpread$1(_objectSpread$1({}, otherProps), {}, {
|
|
5204
3511
|
key: key,
|
|
5205
3512
|
size: "small"
|
|
@@ -5234,7 +3541,7 @@ var Modal = function Modal(_ref) {
|
|
|
5234
3541
|
|
|
5235
3542
|
var _excluded = ["key", "label"];
|
|
5236
3543
|
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$
|
|
3544
|
+
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
3545
|
var Menu = Dropdown__default["default"].Menu,
|
|
5239
3546
|
MenuItem = Dropdown__default["default"].MenuItem;
|
|
5240
3547
|
var ImageUploader = function ImageUploader(_ref) {
|
|
@@ -5249,13 +3556,13 @@ var ImageUploader = function ImageUploader(_ref) {
|
|
|
5249
3556
|
_ref$fixedAspectRatio = _ref.fixedAspectRatio,
|
|
5250
3557
|
fixedAspectRatio = _ref$fixedAspectRatio === void 0 ? {} : _ref$fixedAspectRatio;
|
|
5251
3558
|
var _useState = require$$0.useState(false),
|
|
5252
|
-
_useState2 = _slicedToArray
|
|
3559
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5253
3560
|
isAssetLibraryOpen = _useState2[0],
|
|
5254
3561
|
setIsAssetLibraryOpen = _useState2[1];
|
|
5255
3562
|
var _useState3 = require$$0.useState({
|
|
5256
3563
|
url: src
|
|
5257
3564
|
}),
|
|
5258
|
-
_useState4 = _slicedToArray
|
|
3565
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
5259
3566
|
image = _useState4[0],
|
|
5260
3567
|
setImage = _useState4[1];
|
|
5261
3568
|
var _useTranslation = reactI18next.useTranslation(),
|
|
@@ -5350,12 +3657,12 @@ var ImageUploader = function ImageUploader(_ref) {
|
|
|
5350
3657
|
},
|
|
5351
3658
|
buttonSize: "small",
|
|
5352
3659
|
buttonStyle: "primary",
|
|
5353
|
-
icon:
|
|
3660
|
+
icon: MenuHorizontal__default["default"],
|
|
5354
3661
|
children: /*#__PURE__*/jsxRuntime.jsx(Menu, {
|
|
5355
3662
|
children: options.map(function (_ref2) {
|
|
5356
3663
|
var key = _ref2.key,
|
|
5357
3664
|
label = _ref2.label,
|
|
5358
|
-
otherProps = _objectWithoutProperties$
|
|
3665
|
+
otherProps = _objectWithoutProperties$1(_ref2, _excluded);
|
|
5359
3666
|
return /*#__PURE__*/require$$0.createElement(MenuItem.Button, _objectSpread(_objectSpread({}, otherProps), {}, {
|
|
5360
3667
|
key: key
|
|
5361
3668
|
}), label);
|
|
@@ -5381,11 +3688,11 @@ var ImageUploader = function ImageUploader(_ref) {
|
|
|
5381
3688
|
|
|
5382
3689
|
var useImageUpload = function useImageUpload() {
|
|
5383
3690
|
var _useState = require$$0.useState(0),
|
|
5384
|
-
_useState2 = _slicedToArray
|
|
3691
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5385
3692
|
uploadProgress = _useState2[0],
|
|
5386
3693
|
setUploadProgress = _useState2[1];
|
|
5387
3694
|
var _useState3 = require$$0.useState(false),
|
|
5388
|
-
_useState4 = _slicedToArray
|
|
3695
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
5389
3696
|
isUploading = _useState4[0],
|
|
5390
3697
|
setIsUploading = _useState4[1];
|
|
5391
3698
|
var authenticationEndpoint = "".concat(window.location.origin, "/neeto_image_uploader_engine/imagekit/auth");
|
|
@@ -5526,11 +3833,11 @@ var useProfileImageUpload = function useProfileImageUpload(_ref) {
|
|
|
5526
3833
|
var _ref$uploadConfig = _ref.uploadConfig,
|
|
5527
3834
|
uploadConfig = _ref$uploadConfig === void 0 ? {} : _ref$uploadConfig;
|
|
5528
3835
|
var _useState = require$$0.useState(0),
|
|
5529
|
-
_useState2 = _slicedToArray
|
|
3836
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
5530
3837
|
uploadProgress = _useState2[0],
|
|
5531
3838
|
setUploadProgress = _useState2[1];
|
|
5532
3839
|
var _useState3 = require$$0.useState(false),
|
|
5533
|
-
_useState4 = _slicedToArray
|
|
3840
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
5534
3841
|
isUploading = _useState4[0],
|
|
5535
3842
|
setIsUploading = _useState4[1];
|
|
5536
3843
|
var authenticationEndpoint = "".concat(window.location.origin, "/neeto_image_uploader_engine/imagekit/auth");
|