@m4l/components 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,6 +14,7 @@ import { R as RHFDateTime } from "../hook-form/RHFDateTime.js";
14
14
  import "@mui/x-date-pickers";
15
15
  import { R as RHFTextField } from "../hook-form/RHFTextField/index.js";
16
16
  import "../../lodash.js";
17
+ import "react-dropzone";
17
18
  import "../../react-lazy-load-image-component.js";
18
19
  import "../Image/index.js";
19
20
  import "../hook-form/RHFUpload.js";
@@ -2,7 +2,7 @@ import { styled as styled$1, FormHelperText } from "@mui/material";
2
2
  import { useCallback } from "react";
3
3
  import { useFormContext, Controller } from "react-hook-form";
4
4
  import { i as isString_1 } from "../../lodash.js";
5
- import { u as useDropzone } from "../../node_modules.js";
5
+ import { useDropzone } from "react-dropzone";
6
6
  import { styled, alpha } from "@mui/material/styles";
7
7
  import { I as Image } from "../Image/index.js";
8
8
  import { useEnvironment, useModuleDictionary } from "@m4l/core";
package/index.js CHANGED
@@ -57,13 +57,14 @@ import "react/jsx-runtime";
57
57
  import "@m4l/core";
58
58
  import "react-hook-form";
59
59
  import "./node_modules.js";
60
- import "prop-types";
61
60
  import "@mui/material/styles";
62
61
  import "@mui/x-date-pickers";
63
62
  import "./lodash.js";
64
63
  import "./commonjs.js";
65
64
  import "react-dom";
65
+ import "prop-types";
66
66
  import "clsx";
67
+ import "react-dropzone";
67
68
  import "./react-lazy-load-image-component.js";
68
69
  import "react-router-dom";
69
70
  import "@mui/lab";
package/node_modules.js CHANGED
@@ -1,7 +1,4 @@
1
1
  import { get, set, appendErrors } from "react-hook-form";
2
- import { useMemo, useRef, useReducer, useEffect, useCallback, forwardRef, useImperativeHandle } from "react";
3
- import PropTypes from "prop-types";
4
- import { jsx, Fragment } from "react/jsx-runtime";
5
2
  var e = function(i, e2, t2) {
6
3
  if (i && "reportValidity" in i) {
7
4
  var f2 = get(t2, e2);
@@ -54,1307 +51,4 @@ var o = function(o2, n, a) {
54
51
  }
55
52
  };
56
53
  };
57
- function __awaiter(thisArg, _arguments, P, generator) {
58
- function adopt(value) {
59
- return value instanceof P ? value : new P(function(resolve) {
60
- resolve(value);
61
- });
62
- }
63
- return new (P || (P = Promise))(function(resolve, reject) {
64
- function fulfilled(value) {
65
- try {
66
- step(generator.next(value));
67
- } catch (e2) {
68
- reject(e2);
69
- }
70
- }
71
- function rejected(value) {
72
- try {
73
- step(generator["throw"](value));
74
- } catch (e2) {
75
- reject(e2);
76
- }
77
- }
78
- function step(result) {
79
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
80
- }
81
- step((generator = generator.apply(thisArg, _arguments || [])).next());
82
- });
83
- }
84
- function __generator(thisArg, body) {
85
- var _ = { label: 0, sent: function() {
86
- if (t2[0] & 1)
87
- throw t2[1];
88
- return t2[1];
89
- }, trys: [], ops: [] }, f2, y, t2, g;
90
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
91
- return this;
92
- }), g;
93
- function verb(n) {
94
- return function(v) {
95
- return step([n, v]);
96
- };
97
- }
98
- function step(op) {
99
- if (f2)
100
- throw new TypeError("Generator is already executing.");
101
- while (_)
102
- try {
103
- if (f2 = 1, y && (t2 = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t2 = y["return"]) && t2.call(y), 0) : y.next) && !(t2 = t2.call(y, op[1])).done)
104
- return t2;
105
- if (y = 0, t2)
106
- op = [op[0] & 2, t2.value];
107
- switch (op[0]) {
108
- case 0:
109
- case 1:
110
- t2 = op;
111
- break;
112
- case 4:
113
- _.label++;
114
- return { value: op[1], done: false };
115
- case 5:
116
- _.label++;
117
- y = op[1];
118
- op = [0];
119
- continue;
120
- case 7:
121
- op = _.ops.pop();
122
- _.trys.pop();
123
- continue;
124
- default:
125
- if (!(t2 = _.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
126
- _ = 0;
127
- continue;
128
- }
129
- if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
130
- _.label = op[1];
131
- break;
132
- }
133
- if (op[0] === 6 && _.label < t2[1]) {
134
- _.label = t2[1];
135
- t2 = op;
136
- break;
137
- }
138
- if (t2 && _.label < t2[2]) {
139
- _.label = t2[2];
140
- _.ops.push(op);
141
- break;
142
- }
143
- if (t2[2])
144
- _.ops.pop();
145
- _.trys.pop();
146
- continue;
147
- }
148
- op = body.call(thisArg, _);
149
- } catch (e2) {
150
- op = [6, e2];
151
- y = 0;
152
- } finally {
153
- f2 = t2 = 0;
154
- }
155
- if (op[0] & 5)
156
- throw op[1];
157
- return { value: op[0] ? op[1] : void 0, done: true };
158
- }
159
- }
160
- function __read(o2, n) {
161
- var m = typeof Symbol === "function" && o2[Symbol.iterator];
162
- if (!m)
163
- return o2;
164
- var i = m.call(o2), r, ar = [], e2;
165
- try {
166
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
167
- ar.push(r.value);
168
- } catch (error) {
169
- e2 = { error };
170
- } finally {
171
- try {
172
- if (r && !r.done && (m = i["return"]))
173
- m.call(i);
174
- } finally {
175
- if (e2)
176
- throw e2.error;
177
- }
178
- }
179
- return ar;
180
- }
181
- function __spreadArray(to, from, pack) {
182
- if (pack || arguments.length === 2)
183
- for (var i = 0, l = from.length, ar; i < l; i++) {
184
- if (ar || !(i in from)) {
185
- if (!ar)
186
- ar = Array.prototype.slice.call(from, 0, i);
187
- ar[i] = from[i];
188
- }
189
- }
190
- return to.concat(ar || Array.prototype.slice.call(from));
191
- }
192
- var COMMON_MIME_TYPES = /* @__PURE__ */ new Map([
193
- ["aac", "audio/aac"],
194
- ["abw", "application/x-abiword"],
195
- ["arc", "application/x-freearc"],
196
- ["avif", "image/avif"],
197
- ["avi", "video/x-msvideo"],
198
- ["azw", "application/vnd.amazon.ebook"],
199
- ["bin", "application/octet-stream"],
200
- ["bmp", "image/bmp"],
201
- ["bz", "application/x-bzip"],
202
- ["bz2", "application/x-bzip2"],
203
- ["cda", "application/x-cdf"],
204
- ["csh", "application/x-csh"],
205
- ["css", "text/css"],
206
- ["csv", "text/csv"],
207
- ["doc", "application/msword"],
208
- ["docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
209
- ["eot", "application/vnd.ms-fontobject"],
210
- ["epub", "application/epub+zip"],
211
- ["gz", "application/gzip"],
212
- ["gif", "image/gif"],
213
- ["heic", "image/heic"],
214
- ["heif", "image/heif"],
215
- ["htm", "text/html"],
216
- ["html", "text/html"],
217
- ["ico", "image/vnd.microsoft.icon"],
218
- ["ics", "text/calendar"],
219
- ["jar", "application/java-archive"],
220
- ["jpeg", "image/jpeg"],
221
- ["jpg", "image/jpeg"],
222
- ["js", "text/javascript"],
223
- ["json", "application/json"],
224
- ["jsonld", "application/ld+json"],
225
- ["mid", "audio/midi"],
226
- ["midi", "audio/midi"],
227
- ["mjs", "text/javascript"],
228
- ["mp3", "audio/mpeg"],
229
- ["mp4", "video/mp4"],
230
- ["mpeg", "video/mpeg"],
231
- ["mpkg", "application/vnd.apple.installer+xml"],
232
- ["odp", "application/vnd.oasis.opendocument.presentation"],
233
- ["ods", "application/vnd.oasis.opendocument.spreadsheet"],
234
- ["odt", "application/vnd.oasis.opendocument.text"],
235
- ["oga", "audio/ogg"],
236
- ["ogv", "video/ogg"],
237
- ["ogx", "application/ogg"],
238
- ["opus", "audio/opus"],
239
- ["otf", "font/otf"],
240
- ["png", "image/png"],
241
- ["pdf", "application/pdf"],
242
- ["php", "application/x-httpd-php"],
243
- ["ppt", "application/vnd.ms-powerpoint"],
244
- ["pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"],
245
- ["rar", "application/vnd.rar"],
246
- ["rtf", "application/rtf"],
247
- ["sh", "application/x-sh"],
248
- ["svg", "image/svg+xml"],
249
- ["swf", "application/x-shockwave-flash"],
250
- ["tar", "application/x-tar"],
251
- ["tif", "image/tiff"],
252
- ["tiff", "image/tiff"],
253
- ["ts", "video/mp2t"],
254
- ["ttf", "font/ttf"],
255
- ["txt", "text/plain"],
256
- ["vsd", "application/vnd.visio"],
257
- ["wav", "audio/wav"],
258
- ["weba", "audio/webm"],
259
- ["webm", "video/webm"],
260
- ["webp", "image/webp"],
261
- ["woff", "font/woff"],
262
- ["woff2", "font/woff2"],
263
- ["xhtml", "application/xhtml+xml"],
264
- ["xls", "application/vnd.ms-excel"],
265
- ["xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
266
- ["xml", "application/xml"],
267
- ["xul", "application/vnd.mozilla.xul+xml"],
268
- ["zip", "application/zip"],
269
- ["7z", "application/x-7z-compressed"],
270
- ["mkv", "video/x-matroska"],
271
- ["mov", "video/quicktime"],
272
- ["msg", "application/vnd.ms-outlook"]
273
- ]);
274
- function toFileWithPath(file, path) {
275
- var f2 = withMimeType(file);
276
- if (typeof f2.path !== "string") {
277
- var webkitRelativePath = file.webkitRelativePath;
278
- Object.defineProperty(f2, "path", {
279
- value: typeof path === "string" ? path : typeof webkitRelativePath === "string" && webkitRelativePath.length > 0 ? webkitRelativePath : file.name,
280
- writable: false,
281
- configurable: false,
282
- enumerable: true
283
- });
284
- }
285
- return f2;
286
- }
287
- function withMimeType(file) {
288
- var name = file.name;
289
- var hasExtension = name && name.lastIndexOf(".") !== -1;
290
- if (hasExtension && !file.type) {
291
- var ext = name.split(".").pop().toLowerCase();
292
- var type = COMMON_MIME_TYPES.get(ext);
293
- if (type) {
294
- Object.defineProperty(file, "type", {
295
- value: type,
296
- writable: false,
297
- configurable: false,
298
- enumerable: true
299
- });
300
- }
301
- }
302
- return file;
303
- }
304
- var FILES_TO_IGNORE = [
305
- ".DS_Store",
306
- "Thumbs.db"
307
- ];
308
- function fromEvent(evt) {
309
- return __awaiter(this, void 0, void 0, function() {
310
- return __generator(this, function(_a) {
311
- if (isObject(evt) && isDataTransfer(evt.dataTransfer)) {
312
- return [2, getDataTransferFiles(evt.dataTransfer, evt.type)];
313
- } else if (isChangeEvt(evt)) {
314
- return [2, getInputFiles(evt)];
315
- } else if (Array.isArray(evt) && evt.every(function(item) {
316
- return "getFile" in item && typeof item.getFile === "function";
317
- })) {
318
- return [2, getFsHandleFiles(evt)];
319
- }
320
- return [2, []];
321
- });
322
- });
323
- }
324
- function isDataTransfer(value) {
325
- return isObject(value);
326
- }
327
- function isChangeEvt(value) {
328
- return isObject(value) && isObject(value.target);
329
- }
330
- function isObject(v) {
331
- return typeof v === "object" && v !== null;
332
- }
333
- function getInputFiles(evt) {
334
- return fromList(evt.target.files).map(function(file) {
335
- return toFileWithPath(file);
336
- });
337
- }
338
- function getFsHandleFiles(handles) {
339
- return __awaiter(this, void 0, void 0, function() {
340
- var files;
341
- return __generator(this, function(_a) {
342
- switch (_a.label) {
343
- case 0:
344
- return [4, Promise.all(handles.map(function(h) {
345
- return h.getFile();
346
- }))];
347
- case 1:
348
- files = _a.sent();
349
- return [2, files.map(function(file) {
350
- return toFileWithPath(file);
351
- })];
352
- }
353
- });
354
- });
355
- }
356
- function getDataTransferFiles(dt, type) {
357
- return __awaiter(this, void 0, void 0, function() {
358
- var items, files;
359
- return __generator(this, function(_a) {
360
- switch (_a.label) {
361
- case 0:
362
- if (!dt.items)
363
- return [3, 2];
364
- items = fromList(dt.items).filter(function(item) {
365
- return item.kind === "file";
366
- });
367
- if (type !== "drop") {
368
- return [2, items];
369
- }
370
- return [4, Promise.all(items.map(toFilePromises))];
371
- case 1:
372
- files = _a.sent();
373
- return [2, noIgnoredFiles(flatten(files))];
374
- case 2:
375
- return [2, noIgnoredFiles(fromList(dt.files).map(function(file) {
376
- return toFileWithPath(file);
377
- }))];
378
- }
379
- });
380
- });
381
- }
382
- function noIgnoredFiles(files) {
383
- return files.filter(function(file) {
384
- return FILES_TO_IGNORE.indexOf(file.name) === -1;
385
- });
386
- }
387
- function fromList(items) {
388
- if (items === null) {
389
- return [];
390
- }
391
- var files = [];
392
- for (var i = 0; i < items.length; i++) {
393
- var file = items[i];
394
- files.push(file);
395
- }
396
- return files;
397
- }
398
- function toFilePromises(item) {
399
- if (typeof item.webkitGetAsEntry !== "function") {
400
- return fromDataTransferItem(item);
401
- }
402
- var entry = item.webkitGetAsEntry();
403
- if (entry && entry.isDirectory) {
404
- return fromDirEntry(entry);
405
- }
406
- return fromDataTransferItem(item);
407
- }
408
- function flatten(items) {
409
- return items.reduce(function(acc, files) {
410
- return __spreadArray(__spreadArray([], __read(acc), false), __read(Array.isArray(files) ? flatten(files) : [files]), false);
411
- }, []);
412
- }
413
- function fromDataTransferItem(item) {
414
- var file = item.getAsFile();
415
- if (!file) {
416
- return Promise.reject("".concat(item, " is not a File"));
417
- }
418
- var fwp = toFileWithPath(file);
419
- return Promise.resolve(fwp);
420
- }
421
- function fromEntry(entry) {
422
- return __awaiter(this, void 0, void 0, function() {
423
- return __generator(this, function(_a) {
424
- return [2, entry.isDirectory ? fromDirEntry(entry) : fromFileEntry(entry)];
425
- });
426
- });
427
- }
428
- function fromDirEntry(entry) {
429
- var reader = entry.createReader();
430
- return new Promise(function(resolve, reject) {
431
- var entries = [];
432
- function readEntries() {
433
- var _this = this;
434
- reader.readEntries(function(batch) {
435
- return __awaiter(_this, void 0, void 0, function() {
436
- var files, err_1, items;
437
- return __generator(this, function(_a) {
438
- switch (_a.label) {
439
- case 0:
440
- if (!!batch.length)
441
- return [3, 5];
442
- _a.label = 1;
443
- case 1:
444
- _a.trys.push([1, 3, , 4]);
445
- return [4, Promise.all(entries)];
446
- case 2:
447
- files = _a.sent();
448
- resolve(files);
449
- return [3, 4];
450
- case 3:
451
- err_1 = _a.sent();
452
- reject(err_1);
453
- return [3, 4];
454
- case 4:
455
- return [3, 6];
456
- case 5:
457
- items = Promise.all(batch.map(fromEntry));
458
- entries.push(items);
459
- readEntries();
460
- _a.label = 6;
461
- case 6:
462
- return [2];
463
- }
464
- });
465
- });
466
- }, function(err) {
467
- reject(err);
468
- });
469
- }
470
- readEntries();
471
- });
472
- }
473
- function fromFileEntry(entry) {
474
- return __awaiter(this, void 0, void 0, function() {
475
- return __generator(this, function(_a) {
476
- return [2, new Promise(function(resolve, reject) {
477
- entry.file(function(file) {
478
- var fwp = toFileWithPath(file, entry.fullPath);
479
- resolve(fwp);
480
- }, function(err) {
481
- reject(err);
482
- });
483
- })];
484
- });
485
- });
486
- }
487
- var _default = function(file, acceptedFiles) {
488
- if (file && acceptedFiles) {
489
- var acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(",");
490
- var fileName = file.name || "";
491
- var mimeType = (file.type || "").toLowerCase();
492
- var baseMimeType = mimeType.replace(/\/.*$/, "");
493
- return acceptedFilesArray.some(function(type) {
494
- var validType = type.trim().toLowerCase();
495
- if (validType.charAt(0) === ".") {
496
- return fileName.toLowerCase().endsWith(validType);
497
- } else if (validType.endsWith("/*")) {
498
- return baseMimeType === validType.replace(/\/.*$/, "");
499
- }
500
- return mimeType === validType;
501
- });
502
- }
503
- return true;
504
- };
505
- function _toConsumableArray$1(arr) {
506
- return _arrayWithoutHoles$1(arr) || _iterableToArray$1(arr) || _unsupportedIterableToArray$1(arr) || _nonIterableSpread$1();
507
- }
508
- function _nonIterableSpread$1() {
509
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
510
- }
511
- function _iterableToArray$1(iter) {
512
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
513
- return Array.from(iter);
514
- }
515
- function _arrayWithoutHoles$1(arr) {
516
- if (Array.isArray(arr))
517
- return _arrayLikeToArray$1(arr);
518
- }
519
- function ownKeys$1(object, enumerableOnly) {
520
- var keys = Object.keys(object);
521
- if (Object.getOwnPropertySymbols) {
522
- var symbols = Object.getOwnPropertySymbols(object);
523
- enumerableOnly && (symbols = symbols.filter(function(sym) {
524
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
525
- })), keys.push.apply(keys, symbols);
526
- }
527
- return keys;
528
- }
529
- function _objectSpread$1(target) {
530
- for (var i = 1; i < arguments.length; i++) {
531
- var source = null != arguments[i] ? arguments[i] : {};
532
- i % 2 ? ownKeys$1(Object(source), true).forEach(function(key) {
533
- _defineProperty$1(target, key, source[key]);
534
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function(key) {
535
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
536
- });
537
- }
538
- return target;
539
- }
540
- function _defineProperty$1(obj, key, value) {
541
- if (key in obj) {
542
- Object.defineProperty(obj, key, { value, enumerable: true, configurable: true, writable: true });
543
- } else {
544
- obj[key] = value;
545
- }
546
- return obj;
547
- }
548
- function _slicedToArray$1(arr, i) {
549
- return _arrayWithHoles$1(arr) || _iterableToArrayLimit$1(arr, i) || _unsupportedIterableToArray$1(arr, i) || _nonIterableRest$1();
550
- }
551
- function _nonIterableRest$1() {
552
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
553
- }
554
- function _unsupportedIterableToArray$1(o2, minLen) {
555
- if (!o2)
556
- return;
557
- if (typeof o2 === "string")
558
- return _arrayLikeToArray$1(o2, minLen);
559
- var n = Object.prototype.toString.call(o2).slice(8, -1);
560
- if (n === "Object" && o2.constructor)
561
- n = o2.constructor.name;
562
- if (n === "Map" || n === "Set")
563
- return Array.from(o2);
564
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
565
- return _arrayLikeToArray$1(o2, minLen);
566
- }
567
- function _arrayLikeToArray$1(arr, len) {
568
- if (len == null || len > arr.length)
569
- len = arr.length;
570
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
571
- arr2[i] = arr[i];
572
- }
573
- return arr2;
574
- }
575
- function _iterableToArrayLimit$1(arr, i) {
576
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
577
- if (_i == null)
578
- return;
579
- var _arr = [];
580
- var _n = true;
581
- var _d = false;
582
- var _s, _e;
583
- try {
584
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
585
- _arr.push(_s.value);
586
- if (i && _arr.length === i)
587
- break;
588
- }
589
- } catch (err) {
590
- _d = true;
591
- _e = err;
592
- } finally {
593
- try {
594
- if (!_n && _i["return"] != null)
595
- _i["return"]();
596
- } finally {
597
- if (_d)
598
- throw _e;
599
- }
600
- }
601
- return _arr;
602
- }
603
- function _arrayWithHoles$1(arr) {
604
- if (Array.isArray(arr))
605
- return arr;
606
- }
607
- var FILE_INVALID_TYPE = "file-invalid-type";
608
- var FILE_TOO_LARGE = "file-too-large";
609
- var FILE_TOO_SMALL = "file-too-small";
610
- var TOO_MANY_FILES = "too-many-files";
611
- var getInvalidTypeRejectionErr = function getInvalidTypeRejectionErr2(accept) {
612
- accept = Array.isArray(accept) && accept.length === 1 ? accept[0] : accept;
613
- var messageSuffix = Array.isArray(accept) ? "one of ".concat(accept.join(", ")) : accept;
614
- return {
615
- code: FILE_INVALID_TYPE,
616
- message: "File type must be ".concat(messageSuffix)
617
- };
618
- };
619
- var getTooLargeRejectionErr = function getTooLargeRejectionErr2(maxSize) {
620
- return {
621
- code: FILE_TOO_LARGE,
622
- message: "File is larger than ".concat(maxSize, " ").concat(maxSize === 1 ? "byte" : "bytes")
623
- };
624
- };
625
- var getTooSmallRejectionErr = function getTooSmallRejectionErr2(minSize) {
626
- return {
627
- code: FILE_TOO_SMALL,
628
- message: "File is smaller than ".concat(minSize, " ").concat(minSize === 1 ? "byte" : "bytes")
629
- };
630
- };
631
- var TOO_MANY_FILES_REJECTION = {
632
- code: TOO_MANY_FILES,
633
- message: "Too many files"
634
- };
635
- function fileAccepted(file, accept) {
636
- var isAcceptable = file.type === "application/x-moz-file" || _default(file, accept);
637
- return [isAcceptable, isAcceptable ? null : getInvalidTypeRejectionErr(accept)];
638
- }
639
- function fileMatchSize(file, minSize, maxSize) {
640
- if (isDefined(file.size)) {
641
- if (isDefined(minSize) && isDefined(maxSize)) {
642
- if (file.size > maxSize)
643
- return [false, getTooLargeRejectionErr(maxSize)];
644
- if (file.size < minSize)
645
- return [false, getTooSmallRejectionErr(minSize)];
646
- } else if (isDefined(minSize) && file.size < minSize)
647
- return [false, getTooSmallRejectionErr(minSize)];
648
- else if (isDefined(maxSize) && file.size > maxSize)
649
- return [false, getTooLargeRejectionErr(maxSize)];
650
- }
651
- return [true, null];
652
- }
653
- function isDefined(value) {
654
- return value !== void 0 && value !== null;
655
- }
656
- function allFilesAccepted(_ref) {
657
- var files = _ref.files, accept = _ref.accept, minSize = _ref.minSize, maxSize = _ref.maxSize, multiple = _ref.multiple, maxFiles = _ref.maxFiles, validator = _ref.validator;
658
- if (!multiple && files.length > 1 || multiple && maxFiles >= 1 && files.length > maxFiles) {
659
- return false;
660
- }
661
- return files.every(function(file) {
662
- var _fileAccepted = fileAccepted(file, accept), _fileAccepted2 = _slicedToArray$1(_fileAccepted, 1), accepted = _fileAccepted2[0];
663
- var _fileMatchSize = fileMatchSize(file, minSize, maxSize), _fileMatchSize2 = _slicedToArray$1(_fileMatchSize, 1), sizeMatch = _fileMatchSize2[0];
664
- var customErrors = validator ? validator(file) : null;
665
- return accepted && sizeMatch && !customErrors;
666
- });
667
- }
668
- function isPropagationStopped(event) {
669
- if (typeof event.isPropagationStopped === "function") {
670
- return event.isPropagationStopped();
671
- } else if (typeof event.cancelBubble !== "undefined") {
672
- return event.cancelBubble;
673
- }
674
- return false;
675
- }
676
- function isEvtWithFiles(event) {
677
- if (!event.dataTransfer) {
678
- return !!event.target && !!event.target.files;
679
- }
680
- return Array.prototype.some.call(event.dataTransfer.types, function(type) {
681
- return type === "Files" || type === "application/x-moz-file";
682
- });
683
- }
684
- function onDocumentDragOver(event) {
685
- event.preventDefault();
686
- }
687
- function isIe(userAgent) {
688
- return userAgent.indexOf("MSIE") !== -1 || userAgent.indexOf("Trident/") !== -1;
689
- }
690
- function isEdge(userAgent) {
691
- return userAgent.indexOf("Edge/") !== -1;
692
- }
693
- function isIeOrEdge() {
694
- var userAgent = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.navigator.userAgent;
695
- return isIe(userAgent) || isEdge(userAgent);
696
- }
697
- function composeEventHandlers() {
698
- for (var _len = arguments.length, fns = new Array(_len), _key = 0; _key < _len; _key++) {
699
- fns[_key] = arguments[_key];
700
- }
701
- return function(event) {
702
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
703
- args[_key2 - 1] = arguments[_key2];
704
- }
705
- return fns.some(function(fn) {
706
- if (!isPropagationStopped(event) && fn) {
707
- fn.apply(void 0, [event].concat(args));
708
- }
709
- return isPropagationStopped(event);
710
- });
711
- };
712
- }
713
- function canUseFileSystemAccessAPI() {
714
- return "showOpenFilePicker" in window;
715
- }
716
- function pickerOptionsFromAccept(accept) {
717
- if (isDefined(accept)) {
718
- var acceptForPicker = Object.entries(accept).filter(function(_ref2) {
719
- var _ref3 = _slicedToArray$1(_ref2, 2), mimeType = _ref3[0], ext = _ref3[1];
720
- var ok = true;
721
- if (!isMIMEType(mimeType)) {
722
- 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.'));
723
- ok = false;
724
- }
725
- if (!Array.isArray(ext) || !ext.every(isExt)) {
726
- console.warn('Skipped "'.concat(mimeType, '" because an invalid file extension was provided.'));
727
- ok = false;
728
- }
729
- return ok;
730
- }).reduce(function(agg, _ref4) {
731
- var _ref5 = _slicedToArray$1(_ref4, 2), mimeType = _ref5[0], ext = _ref5[1];
732
- return _objectSpread$1(_objectSpread$1({}, agg), {}, _defineProperty$1({}, mimeType, ext));
733
- }, {});
734
- return [{
735
- accept: acceptForPicker
736
- }];
737
- }
738
- return accept;
739
- }
740
- function acceptPropAsAcceptAttr(accept) {
741
- if (isDefined(accept)) {
742
- return Object.entries(accept).reduce(function(a, _ref6) {
743
- var _ref7 = _slicedToArray$1(_ref6, 2), mimeType = _ref7[0], ext = _ref7[1];
744
- return [].concat(_toConsumableArray$1(a), [mimeType], _toConsumableArray$1(ext));
745
- }, []).filter(function(v) {
746
- return isMIMEType(v) || isExt(v);
747
- }).join(",");
748
- }
749
- return void 0;
750
- }
751
- function isAbort(v) {
752
- return v instanceof DOMException && (v.name === "AbortError" || v.code === v.ABORT_ERR);
753
- }
754
- function isSecurityError(v) {
755
- return v instanceof DOMException && (v.name === "SecurityError" || v.code === v.SECURITY_ERR);
756
- }
757
- function isMIMEType(v) {
758
- return v === "audio/*" || v === "video/*" || v === "image/*" || v === "text/*" || /\w+\/[-+.\w]+/g.test(v);
759
- }
760
- function isExt(v) {
761
- return /^.*\.[\w]+$/.test(v);
762
- }
763
- var _excluded = ["children"], _excluded2 = ["open"], _excluded3 = ["refKey", "role", "onKeyDown", "onFocus", "onBlur", "onClick", "onDragEnter", "onDragOver", "onDragLeave", "onDrop"], _excluded4 = ["refKey", "onChange", "onClick"];
764
- function _toConsumableArray(arr) {
765
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
766
- }
767
- function _nonIterableSpread() {
768
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
769
- }
770
- function _iterableToArray(iter) {
771
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null)
772
- return Array.from(iter);
773
- }
774
- function _arrayWithoutHoles(arr) {
775
- if (Array.isArray(arr))
776
- return _arrayLikeToArray(arr);
777
- }
778
- function _slicedToArray(arr, i) {
779
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
780
- }
781
- function _nonIterableRest() {
782
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
783
- }
784
- function _unsupportedIterableToArray(o2, minLen) {
785
- if (!o2)
786
- return;
787
- if (typeof o2 === "string")
788
- return _arrayLikeToArray(o2, minLen);
789
- var n = Object.prototype.toString.call(o2).slice(8, -1);
790
- if (n === "Object" && o2.constructor)
791
- n = o2.constructor.name;
792
- if (n === "Map" || n === "Set")
793
- return Array.from(o2);
794
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
795
- return _arrayLikeToArray(o2, minLen);
796
- }
797
- function _arrayLikeToArray(arr, len) {
798
- if (len == null || len > arr.length)
799
- len = arr.length;
800
- for (var i = 0, arr2 = new Array(len); i < len; i++) {
801
- arr2[i] = arr[i];
802
- }
803
- return arr2;
804
- }
805
- function _iterableToArrayLimit(arr, i) {
806
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
807
- if (_i == null)
808
- return;
809
- var _arr = [];
810
- var _n = true;
811
- var _d = false;
812
- var _s, _e;
813
- try {
814
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
815
- _arr.push(_s.value);
816
- if (i && _arr.length === i)
817
- break;
818
- }
819
- } catch (err) {
820
- _d = true;
821
- _e = err;
822
- } finally {
823
- try {
824
- if (!_n && _i["return"] != null)
825
- _i["return"]();
826
- } finally {
827
- if (_d)
828
- throw _e;
829
- }
830
- }
831
- return _arr;
832
- }
833
- function _arrayWithHoles(arr) {
834
- if (Array.isArray(arr))
835
- return arr;
836
- }
837
- function ownKeys(object, enumerableOnly) {
838
- var keys = Object.keys(object);
839
- if (Object.getOwnPropertySymbols) {
840
- var symbols = Object.getOwnPropertySymbols(object);
841
- enumerableOnly && (symbols = symbols.filter(function(sym) {
842
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
843
- })), keys.push.apply(keys, symbols);
844
- }
845
- return keys;
846
- }
847
- function _objectSpread(target) {
848
- for (var i = 1; i < arguments.length; i++) {
849
- var source = null != arguments[i] ? arguments[i] : {};
850
- i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
851
- _defineProperty(target, key, source[key]);
852
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
853
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
854
- });
855
- }
856
- return target;
857
- }
858
- function _defineProperty(obj, key, value) {
859
- if (key in obj) {
860
- Object.defineProperty(obj, key, {
861
- value,
862
- enumerable: true,
863
- configurable: true,
864
- writable: true
865
- });
866
- } else {
867
- obj[key] = value;
868
- }
869
- return obj;
870
- }
871
- function _objectWithoutProperties(source, excluded) {
872
- if (source == null)
873
- return {};
874
- var target = _objectWithoutPropertiesLoose(source, excluded);
875
- var key, i;
876
- if (Object.getOwnPropertySymbols) {
877
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
878
- for (i = 0; i < sourceSymbolKeys.length; i++) {
879
- key = sourceSymbolKeys[i];
880
- if (excluded.indexOf(key) >= 0)
881
- continue;
882
- if (!Object.prototype.propertyIsEnumerable.call(source, key))
883
- continue;
884
- target[key] = source[key];
885
- }
886
- }
887
- return target;
888
- }
889
- function _objectWithoutPropertiesLoose(source, excluded) {
890
- if (source == null)
891
- return {};
892
- var target = {};
893
- var sourceKeys = Object.keys(source);
894
- var key, i;
895
- for (i = 0; i < sourceKeys.length; i++) {
896
- key = sourceKeys[i];
897
- if (excluded.indexOf(key) >= 0)
898
- continue;
899
- target[key] = source[key];
900
- }
901
- return target;
902
- }
903
- var Dropzone = /* @__PURE__ */ forwardRef(function(_ref, ref) {
904
- var children = _ref.children, params = _objectWithoutProperties(_ref, _excluded);
905
- var _useDropzone = useDropzone(params), open = _useDropzone.open, props = _objectWithoutProperties(_useDropzone, _excluded2);
906
- useImperativeHandle(ref, function() {
907
- return {
908
- open
909
- };
910
- }, [open]);
911
- return /* @__PURE__ */ jsx(Fragment, {
912
- children: children(_objectSpread(_objectSpread({}, props), {}, {
913
- open
914
- }))
915
- });
916
- });
917
- Dropzone.displayName = "Dropzone";
918
- var defaultProps = {
919
- disabled: false,
920
- getFilesFromEvent: fromEvent,
921
- maxSize: Infinity,
922
- minSize: 0,
923
- multiple: true,
924
- maxFiles: 0,
925
- preventDropOnDocument: true,
926
- noClick: false,
927
- noKeyboard: false,
928
- noDrag: false,
929
- noDragEventsBubbling: false,
930
- validator: null,
931
- useFsAccessApi: true,
932
- autoFocus: false
933
- };
934
- Dropzone.defaultProps = defaultProps;
935
- Dropzone.propTypes = {
936
- children: PropTypes.func,
937
- accept: PropTypes.objectOf(PropTypes.arrayOf(PropTypes.string)),
938
- multiple: PropTypes.bool,
939
- preventDropOnDocument: PropTypes.bool,
940
- noClick: PropTypes.bool,
941
- noKeyboard: PropTypes.bool,
942
- noDrag: PropTypes.bool,
943
- noDragEventsBubbling: PropTypes.bool,
944
- minSize: PropTypes.number,
945
- maxSize: PropTypes.number,
946
- maxFiles: PropTypes.number,
947
- disabled: PropTypes.bool,
948
- getFilesFromEvent: PropTypes.func,
949
- onFileDialogCancel: PropTypes.func,
950
- onFileDialogOpen: PropTypes.func,
951
- useFsAccessApi: PropTypes.bool,
952
- autoFocus: PropTypes.bool,
953
- onDragEnter: PropTypes.func,
954
- onDragLeave: PropTypes.func,
955
- onDragOver: PropTypes.func,
956
- onDrop: PropTypes.func,
957
- onDropAccepted: PropTypes.func,
958
- onDropRejected: PropTypes.func,
959
- onError: PropTypes.func,
960
- validator: PropTypes.func
961
- };
962
- var initialState = {
963
- isFocused: false,
964
- isFileDialogActive: false,
965
- isDragActive: false,
966
- isDragAccept: false,
967
- isDragReject: false,
968
- acceptedFiles: [],
969
- fileRejections: []
970
- };
971
- function useDropzone() {
972
- var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
973
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), accept = _defaultProps$props.accept, disabled = _defaultProps$props.disabled, getFilesFromEvent = _defaultProps$props.getFilesFromEvent, maxSize = _defaultProps$props.maxSize, minSize = _defaultProps$props.minSize, multiple = _defaultProps$props.multiple, maxFiles = _defaultProps$props.maxFiles, onDragEnter = _defaultProps$props.onDragEnter, onDragLeave = _defaultProps$props.onDragLeave, onDragOver = _defaultProps$props.onDragOver, onDrop = _defaultProps$props.onDrop, onDropAccepted = _defaultProps$props.onDropAccepted, onDropRejected = _defaultProps$props.onDropRejected, onFileDialogCancel = _defaultProps$props.onFileDialogCancel, onFileDialogOpen = _defaultProps$props.onFileDialogOpen, useFsAccessApi = _defaultProps$props.useFsAccessApi, autoFocus = _defaultProps$props.autoFocus, preventDropOnDocument = _defaultProps$props.preventDropOnDocument, noClick = _defaultProps$props.noClick, noKeyboard = _defaultProps$props.noKeyboard, noDrag = _defaultProps$props.noDrag, noDragEventsBubbling = _defaultProps$props.noDragEventsBubbling, onError = _defaultProps$props.onError, validator = _defaultProps$props.validator;
974
- var acceptAttr = useMemo(function() {
975
- return acceptPropAsAcceptAttr(accept);
976
- }, [accept]);
977
- var pickerTypes = useMemo(function() {
978
- return pickerOptionsFromAccept(accept);
979
- }, [accept]);
980
- var onFileDialogOpenCb = useMemo(function() {
981
- return typeof onFileDialogOpen === "function" ? onFileDialogOpen : noop;
982
- }, [onFileDialogOpen]);
983
- var onFileDialogCancelCb = useMemo(function() {
984
- return typeof onFileDialogCancel === "function" ? onFileDialogCancel : noop;
985
- }, [onFileDialogCancel]);
986
- var rootRef = useRef(null);
987
- var inputRef = useRef(null);
988
- var _useReducer = useReducer(reducer, initialState), _useReducer2 = _slicedToArray(_useReducer, 2), state = _useReducer2[0], dispatch = _useReducer2[1];
989
- var isFocused = state.isFocused, isFileDialogActive = state.isFileDialogActive;
990
- var fsAccessApiWorksRef = useRef(typeof window !== "undefined" && window.isSecureContext && useFsAccessApi && canUseFileSystemAccessAPI());
991
- var onWindowFocus = function onWindowFocus2() {
992
- if (!fsAccessApiWorksRef.current && isFileDialogActive) {
993
- setTimeout(function() {
994
- if (inputRef.current) {
995
- var files = inputRef.current.files;
996
- if (!files.length) {
997
- dispatch({
998
- type: "closeDialog"
999
- });
1000
- onFileDialogCancelCb();
1001
- }
1002
- }
1003
- }, 300);
1004
- }
1005
- };
1006
- useEffect(function() {
1007
- window.addEventListener("focus", onWindowFocus, false);
1008
- return function() {
1009
- window.removeEventListener("focus", onWindowFocus, false);
1010
- };
1011
- }, [inputRef, isFileDialogActive, onFileDialogCancelCb, fsAccessApiWorksRef]);
1012
- var dragTargetsRef = useRef([]);
1013
- var onDocumentDrop = function onDocumentDrop2(event) {
1014
- if (rootRef.current && rootRef.current.contains(event.target)) {
1015
- return;
1016
- }
1017
- event.preventDefault();
1018
- dragTargetsRef.current = [];
1019
- };
1020
- useEffect(function() {
1021
- if (preventDropOnDocument) {
1022
- document.addEventListener("dragover", onDocumentDragOver, false);
1023
- document.addEventListener("drop", onDocumentDrop, false);
1024
- }
1025
- return function() {
1026
- if (preventDropOnDocument) {
1027
- document.removeEventListener("dragover", onDocumentDragOver);
1028
- document.removeEventListener("drop", onDocumentDrop);
1029
- }
1030
- };
1031
- }, [rootRef, preventDropOnDocument]);
1032
- useEffect(function() {
1033
- if (!disabled && autoFocus && rootRef.current) {
1034
- rootRef.current.focus();
1035
- }
1036
- return function() {
1037
- };
1038
- }, [rootRef, autoFocus, disabled]);
1039
- var onErrCb = useCallback(function(e2) {
1040
- if (onError) {
1041
- onError(e2);
1042
- } else {
1043
- console.error(e2);
1044
- }
1045
- }, [onError]);
1046
- var onDragEnterCb = useCallback(function(event) {
1047
- event.preventDefault();
1048
- event.persist();
1049
- stopPropagation(event);
1050
- dragTargetsRef.current = [].concat(_toConsumableArray(dragTargetsRef.current), [event.target]);
1051
- if (isEvtWithFiles(event)) {
1052
- Promise.resolve(getFilesFromEvent(event)).then(function(files) {
1053
- if (isPropagationStopped(event) && !noDragEventsBubbling) {
1054
- return;
1055
- }
1056
- var fileCount = files.length;
1057
- var isDragAccept = fileCount > 0 && allFilesAccepted({
1058
- files,
1059
- accept: acceptAttr,
1060
- minSize,
1061
- maxSize,
1062
- multiple,
1063
- maxFiles,
1064
- validator
1065
- });
1066
- var isDragReject = fileCount > 0 && !isDragAccept;
1067
- dispatch({
1068
- isDragAccept,
1069
- isDragReject,
1070
- isDragActive: true,
1071
- type: "setDraggedFiles"
1072
- });
1073
- if (onDragEnter) {
1074
- onDragEnter(event);
1075
- }
1076
- }).catch(function(e2) {
1077
- return onErrCb(e2);
1078
- });
1079
- }
1080
- }, [getFilesFromEvent, onDragEnter, onErrCb, noDragEventsBubbling, acceptAttr, minSize, maxSize, multiple, maxFiles, validator]);
1081
- var onDragOverCb = useCallback(function(event) {
1082
- event.preventDefault();
1083
- event.persist();
1084
- stopPropagation(event);
1085
- var hasFiles = isEvtWithFiles(event);
1086
- if (hasFiles && event.dataTransfer) {
1087
- try {
1088
- event.dataTransfer.dropEffect = "copy";
1089
- } catch (_unused) {
1090
- }
1091
- }
1092
- if (hasFiles && onDragOver) {
1093
- onDragOver(event);
1094
- }
1095
- return false;
1096
- }, [onDragOver, noDragEventsBubbling]);
1097
- var onDragLeaveCb = useCallback(function(event) {
1098
- event.preventDefault();
1099
- event.persist();
1100
- stopPropagation(event);
1101
- var targets = dragTargetsRef.current.filter(function(target) {
1102
- return rootRef.current && rootRef.current.contains(target);
1103
- });
1104
- var targetIdx = targets.indexOf(event.target);
1105
- if (targetIdx !== -1) {
1106
- targets.splice(targetIdx, 1);
1107
- }
1108
- dragTargetsRef.current = targets;
1109
- if (targets.length > 0) {
1110
- return;
1111
- }
1112
- dispatch({
1113
- type: "setDraggedFiles",
1114
- isDragActive: false,
1115
- isDragAccept: false,
1116
- isDragReject: false
1117
- });
1118
- if (isEvtWithFiles(event) && onDragLeave) {
1119
- onDragLeave(event);
1120
- }
1121
- }, [rootRef, onDragLeave, noDragEventsBubbling]);
1122
- var setFiles = useCallback(function(files, event) {
1123
- var acceptedFiles = [];
1124
- var fileRejections = [];
1125
- files.forEach(function(file) {
1126
- var _fileAccepted = fileAccepted(file, acceptAttr), _fileAccepted2 = _slicedToArray(_fileAccepted, 2), accepted = _fileAccepted2[0], acceptError = _fileAccepted2[1];
1127
- var _fileMatchSize = fileMatchSize(file, minSize, maxSize), _fileMatchSize2 = _slicedToArray(_fileMatchSize, 2), sizeMatch = _fileMatchSize2[0], sizeError = _fileMatchSize2[1];
1128
- var customErrors = validator ? validator(file) : null;
1129
- if (accepted && sizeMatch && !customErrors) {
1130
- acceptedFiles.push(file);
1131
- } else {
1132
- var errors = [acceptError, sizeError];
1133
- if (customErrors) {
1134
- errors = errors.concat(customErrors);
1135
- }
1136
- fileRejections.push({
1137
- file,
1138
- errors: errors.filter(function(e2) {
1139
- return e2;
1140
- })
1141
- });
1142
- }
1143
- });
1144
- if (!multiple && acceptedFiles.length > 1 || multiple && maxFiles >= 1 && acceptedFiles.length > maxFiles) {
1145
- acceptedFiles.forEach(function(file) {
1146
- fileRejections.push({
1147
- file,
1148
- errors: [TOO_MANY_FILES_REJECTION]
1149
- });
1150
- });
1151
- acceptedFiles.splice(0);
1152
- }
1153
- dispatch({
1154
- acceptedFiles,
1155
- fileRejections,
1156
- type: "setFiles"
1157
- });
1158
- if (onDrop) {
1159
- onDrop(acceptedFiles, fileRejections, event);
1160
- }
1161
- if (fileRejections.length > 0 && onDropRejected) {
1162
- onDropRejected(fileRejections, event);
1163
- }
1164
- if (acceptedFiles.length > 0 && onDropAccepted) {
1165
- onDropAccepted(acceptedFiles, event);
1166
- }
1167
- }, [dispatch, multiple, acceptAttr, minSize, maxSize, maxFiles, onDrop, onDropAccepted, onDropRejected, validator]);
1168
- var onDropCb = useCallback(function(event) {
1169
- event.preventDefault();
1170
- event.persist();
1171
- stopPropagation(event);
1172
- dragTargetsRef.current = [];
1173
- if (isEvtWithFiles(event)) {
1174
- Promise.resolve(getFilesFromEvent(event)).then(function(files) {
1175
- if (isPropagationStopped(event) && !noDragEventsBubbling) {
1176
- return;
1177
- }
1178
- setFiles(files, event);
1179
- }).catch(function(e2) {
1180
- return onErrCb(e2);
1181
- });
1182
- }
1183
- dispatch({
1184
- type: "reset"
1185
- });
1186
- }, [getFilesFromEvent, setFiles, onErrCb, noDragEventsBubbling]);
1187
- var openFileDialog = useCallback(function() {
1188
- if (fsAccessApiWorksRef.current) {
1189
- dispatch({
1190
- type: "openDialog"
1191
- });
1192
- onFileDialogOpenCb();
1193
- var opts = {
1194
- multiple,
1195
- types: pickerTypes
1196
- };
1197
- window.showOpenFilePicker(opts).then(function(handles) {
1198
- return getFilesFromEvent(handles);
1199
- }).then(function(files) {
1200
- setFiles(files, null);
1201
- dispatch({
1202
- type: "closeDialog"
1203
- });
1204
- }).catch(function(e2) {
1205
- if (isAbort(e2)) {
1206
- onFileDialogCancelCb(e2);
1207
- dispatch({
1208
- type: "closeDialog"
1209
- });
1210
- } else if (isSecurityError(e2)) {
1211
- fsAccessApiWorksRef.current = false;
1212
- if (inputRef.current) {
1213
- inputRef.current.value = null;
1214
- inputRef.current.click();
1215
- } else {
1216
- 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."));
1217
- }
1218
- } else {
1219
- onErrCb(e2);
1220
- }
1221
- });
1222
- return;
1223
- }
1224
- if (inputRef.current) {
1225
- dispatch({
1226
- type: "openDialog"
1227
- });
1228
- onFileDialogOpenCb();
1229
- inputRef.current.value = null;
1230
- inputRef.current.click();
1231
- }
1232
- }, [dispatch, onFileDialogOpenCb, onFileDialogCancelCb, useFsAccessApi, setFiles, onErrCb, pickerTypes, multiple]);
1233
- var onKeyDownCb = useCallback(function(event) {
1234
- if (!rootRef.current || !rootRef.current.isEqualNode(event.target)) {
1235
- return;
1236
- }
1237
- if (event.key === " " || event.key === "Enter" || event.keyCode === 32 || event.keyCode === 13) {
1238
- event.preventDefault();
1239
- openFileDialog();
1240
- }
1241
- }, [rootRef, openFileDialog]);
1242
- var onFocusCb = useCallback(function() {
1243
- dispatch({
1244
- type: "focus"
1245
- });
1246
- }, []);
1247
- var onBlurCb = useCallback(function() {
1248
- dispatch({
1249
- type: "blur"
1250
- });
1251
- }, []);
1252
- var onClickCb = useCallback(function() {
1253
- if (noClick) {
1254
- return;
1255
- }
1256
- if (isIeOrEdge()) {
1257
- setTimeout(openFileDialog, 0);
1258
- } else {
1259
- openFileDialog();
1260
- }
1261
- }, [noClick, openFileDialog]);
1262
- var composeHandler = function composeHandler2(fn) {
1263
- return disabled ? null : fn;
1264
- };
1265
- var composeKeyboardHandler = function composeKeyboardHandler2(fn) {
1266
- return noKeyboard ? null : composeHandler(fn);
1267
- };
1268
- var composeDragHandler = function composeDragHandler2(fn) {
1269
- return noDrag ? null : composeHandler(fn);
1270
- };
1271
- var stopPropagation = function stopPropagation2(event) {
1272
- if (noDragEventsBubbling) {
1273
- event.stopPropagation();
1274
- }
1275
- };
1276
- var getRootProps = useMemo(function() {
1277
- return function() {
1278
- var _ref2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref2$refKey = _ref2.refKey, refKey = _ref2$refKey === void 0 ? "ref" : _ref2$refKey, role = _ref2.role, onKeyDown = _ref2.onKeyDown, onFocus = _ref2.onFocus, onBlur = _ref2.onBlur, onClick = _ref2.onClick, onDragEnter2 = _ref2.onDragEnter, onDragOver2 = _ref2.onDragOver, onDragLeave2 = _ref2.onDragLeave, onDrop2 = _ref2.onDrop, rest = _objectWithoutProperties(_ref2, _excluded3);
1279
- return _objectSpread(_objectSpread(_defineProperty({
1280
- onKeyDown: composeKeyboardHandler(composeEventHandlers(onKeyDown, onKeyDownCb)),
1281
- onFocus: composeKeyboardHandler(composeEventHandlers(onFocus, onFocusCb)),
1282
- onBlur: composeKeyboardHandler(composeEventHandlers(onBlur, onBlurCb)),
1283
- onClick: composeHandler(composeEventHandlers(onClick, onClickCb)),
1284
- onDragEnter: composeDragHandler(composeEventHandlers(onDragEnter2, onDragEnterCb)),
1285
- onDragOver: composeDragHandler(composeEventHandlers(onDragOver2, onDragOverCb)),
1286
- onDragLeave: composeDragHandler(composeEventHandlers(onDragLeave2, onDragLeaveCb)),
1287
- onDrop: composeDragHandler(composeEventHandlers(onDrop2, onDropCb)),
1288
- role: typeof role === "string" && role !== "" ? role : "presentation"
1289
- }, refKey, rootRef), !disabled && !noKeyboard ? {
1290
- tabIndex: 0
1291
- } : {}), rest);
1292
- };
1293
- }, [rootRef, onKeyDownCb, onFocusCb, onBlurCb, onClickCb, onDragEnterCb, onDragOverCb, onDragLeaveCb, onDropCb, noKeyboard, noDrag, disabled]);
1294
- var onInputElementClick = useCallback(function(event) {
1295
- event.stopPropagation();
1296
- }, []);
1297
- var getInputProps = useMemo(function() {
1298
- return function() {
1299
- var _ref3 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref3$refKey = _ref3.refKey, refKey = _ref3$refKey === void 0 ? "ref" : _ref3$refKey, onChange = _ref3.onChange, onClick = _ref3.onClick, rest = _objectWithoutProperties(_ref3, _excluded4);
1300
- var inputProps = _defineProperty({
1301
- accept: acceptAttr,
1302
- multiple,
1303
- type: "file",
1304
- style: {
1305
- display: "none"
1306
- },
1307
- onChange: composeHandler(composeEventHandlers(onChange, onDropCb)),
1308
- onClick: composeHandler(composeEventHandlers(onClick, onInputElementClick)),
1309
- tabIndex: -1
1310
- }, refKey, inputRef);
1311
- return _objectSpread(_objectSpread({}, inputProps), rest);
1312
- };
1313
- }, [inputRef, accept, multiple, onDropCb, disabled]);
1314
- return _objectSpread(_objectSpread({}, state), {}, {
1315
- isFocused: isFocused && !disabled,
1316
- getRootProps,
1317
- getInputProps,
1318
- rootRef,
1319
- inputRef,
1320
- open: composeHandler(openFileDialog)
1321
- });
1322
- }
1323
- function reducer(state, action) {
1324
- switch (action.type) {
1325
- case "focus":
1326
- return _objectSpread(_objectSpread({}, state), {}, {
1327
- isFocused: true
1328
- });
1329
- case "blur":
1330
- return _objectSpread(_objectSpread({}, state), {}, {
1331
- isFocused: false
1332
- });
1333
- case "openDialog":
1334
- return _objectSpread(_objectSpread({}, initialState), {}, {
1335
- isFileDialogActive: true
1336
- });
1337
- case "closeDialog":
1338
- return _objectSpread(_objectSpread({}, state), {}, {
1339
- isFileDialogActive: false
1340
- });
1341
- case "setDraggedFiles":
1342
- return _objectSpread(_objectSpread({}, state), {}, {
1343
- isDragActive: action.isDragActive,
1344
- isDragAccept: action.isDragAccept,
1345
- isDragReject: action.isDragReject
1346
- });
1347
- case "setFiles":
1348
- return _objectSpread(_objectSpread({}, state), {}, {
1349
- acceptedFiles: action.acceptedFiles,
1350
- fileRejections: action.fileRejections
1351
- });
1352
- case "reset":
1353
- return _objectSpread({}, initialState);
1354
- default:
1355
- return state;
1356
- }
1357
- }
1358
- function noop() {
1359
- }
1360
- export { o, useDropzone as u };
54
+ export { o };
package/package.json CHANGED
@@ -1,15 +1,22 @@
1
1
  {
2
2
  "name": "@m4l/components",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "UNLICENSED",
5
5
  "dependencies": {
6
6
  "@m4l/core": "*",
7
7
  "@m4l/graphics": "*",
8
+ "react-helmet-async": "^1.3.0",
9
+ "react-hook-form": "^7.33.1",
10
+ "react-router-dom": "^6.3.0",
11
+ "yup": "^0.32.11"
12
+ },
13
+ "peerDependencies": {
8
14
  "@mui/lab": "^5.0.0-alpha.89",
9
- "@mui/material": "^5.8.7",
10
- "@mui/system": "^5.10.3",
15
+ "@mui/material": "^5.10.4",
16
+ "@types/react": "^17.0.0 || ^18.0.0",
17
+ "@types/react-dom": "^17.0.0 || ^18.0.0",
11
18
  "framer-motion": "^6.5.0",
12
- "react": "^17.0.0 || 18.x",
19
+ "react-dom": "^17.0.0 || ^18.0.0",
13
20
  "react-dropzone": "^14.2.2",
14
21
  "react-helmet-async": "^1.3.0",
15
22
  "react-hook-form": "^7.33.1",
package/vendor.js CHANGED
@@ -12,6 +12,7 @@ import "./components/hook-form/RHFDateTime.js";
12
12
  import "@mui/x-date-pickers";
13
13
  import "./components/hook-form/RHFTextField/index.js";
14
14
  import "./lodash.js";
15
+ import "react-dropzone";
15
16
  import { styled } from "@mui/material/styles";
16
17
  import "./react-lazy-load-image-component.js";
17
18
  import "./components/Image/index.js";