@cfx-dev/ui-components 0.0.19 → 0.0.21
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/Combination-Dp_plIQU.js +793 -0
- package/dist/{Icons-B26SczGZ.js → Icons-BlBKvJD8.js} +40 -98
- package/dist/{Rail-BCY3h7eP.js → Rail-CCuyJpf6.js} +11 -11
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/assets/InputDropzone.css +1 -0
- package/dist/assets/ItemPreview.css +1 -0
- package/dist/assets/Table.css +1 -0
- package/dist/components/BackdropPortal/BackdropPortal.d.ts +1 -0
- package/dist/components/BackdropPortal/BackdropPortal.js +9 -7
- package/dist/components/Badge/Badge.d.ts +2 -2
- package/dist/components/Button/Button.d.ts +2 -1
- package/dist/components/Button/Button.js +27 -25
- package/dist/components/Button/ButtonBar.d.ts +0 -1
- package/dist/components/Button/LinkButton.js +13 -13
- package/dist/components/Flyout/Flyout.d.ts +1 -0
- package/dist/components/Flyout/Flyout.js +28 -27
- package/dist/components/Input/Input.js +1 -1
- package/dist/components/Input/RichInput.js +2 -2
- package/dist/components/InputDropzone/InputDropzone.d.ts +14 -0
- package/dist/components/InputDropzone/InputDropzone.js +1103 -0
- package/dist/components/InputDropzone/ItemPreview.d.ts +8 -0
- package/dist/components/InputDropzone/ItemPreview.js +24 -0
- package/dist/components/Layout/Scrollable/Rail.js +3 -3
- package/dist/components/Layout/Scrollable/Scrollable.js +2 -2
- package/dist/components/Layout/Scrollable/VirtualScrollable.js +3 -4
- package/dist/components/Modal/Modal.d.ts +0 -2
- package/dist/components/Modal/Modal.js +3 -3
- package/dist/components/NavList/NavList.js +5 -5
- package/dist/components/OnScreenSensor.js +6 -6
- package/dist/components/Overlay/Overlay.d.ts +1 -0
- package/dist/components/Overlay/Overlay.js +16 -15
- package/dist/components/Select/Select.js +652 -663
- package/dist/components/Shroud/Shroud.js +20 -19
- package/dist/components/Switch/Switch.js +1 -1
- package/dist/components/Table/Table.d.ts +17 -0
- package/dist/components/Table/Table.js +61 -0
- package/dist/components/Tabular/Tabular.d.ts +1 -1
- package/dist/components/Text/Text.types.d.ts +0 -1
- package/dist/components/Title/Title.d.ts +1 -0
- package/dist/components/Title/Title.js +26 -25
- package/dist/{extends-Dk_bSU3E.js → extends-hS2Bh-Yp.js} +1 -2
- package/dist/{index-C75OpfGQ.js → index-2hJuj4UN.js} +2018 -2526
- package/dist/index-DQMInta3.js +663 -0
- package/dist/index.esm-BkynlSN6.js +72 -0
- package/dist/main.d.ts +17 -26
- package/dist/main.js +145 -122
- package/dist/{medium-Dc7QRuE0.js → medium-JVtzoF2c.js} +3 -3
- package/dist/style-guide/Colours/DarkThemeSwatches.d.ts +2 -0
- package/dist/style-guide/Colours/DarkThemeSwatches.js +110 -0
- package/dist/style-guide/Colours/LightThemeSwatches.d.ts +2 -0
- package/dist/style-guide/Colours/LightThemeSwatches.js +105 -0
- package/dist/style-guide/Colours/Swatches.d.ts +6 -0
- package/dist/style-guide/Colours/Swatches.js +48 -0
- package/dist/style-guide/Icons/IconDisplayGrid.d.ts +2 -0
- package/dist/style-guide/Icons/IconDisplayGrid.js +42 -0
- package/dist/style-guide/Icons/Icons.js +7 -0
- package/dist/tslib.es6-CBKHJX9H.js +151 -0
- package/dist/utils/functional.js +19 -6
- package/dist/utils/hooks.d.ts +2 -1
- package/dist/utils/hooks.js +77 -10
- package/dist/utils/links.js +1128 -12
- package/dist/utils/math.js +8 -3
- package/dist/utils/mergeRefs.d.ts +1 -1
- package/dist/utils/mergeRefs.js +2 -2
- package/dist/utils/outlet.js +19 -4
- package/dist/utils/string.js +42 -7
- package/package.json +7 -13
- package/dist/Combination-Dj-a6dCZ.js +0 -1462
- package/dist/components/Icons.js +0 -6
- package/dist/functional-C0pE183N.js +0 -30
- package/dist/hooks-GAujvL7d.js +0 -86
- package/dist/links-CgOD-Vfj.js +0 -1142
- package/dist/math-i2ceybzU.js +0 -16
- package/dist/outlet-B11a3Kgw.js +0 -27
- package/dist/string-NVxCUbqk.js +0 -54
- package/dist/tslib.es6-Dd_EkEfR.js +0 -48
- /package/dist/{components → style-guide/Icons}/Icons.d.ts +0 -0
|
@@ -0,0 +1,1103 @@
|
|
|
1
|
+
import { jsxs as he, jsx as N } from "react/jsx-runtime";
|
|
2
|
+
import er, { useMemo as L, useRef as te, useReducer as br, useEffect as De, useCallback as D, forwardRef as hr, useImperativeHandle as Dr, Fragment as Ar } from "react";
|
|
3
|
+
import { P as l } from "../../index-DQMInta3.js";
|
|
4
|
+
import { a as M, b as $, c as We, d as Be } from "../../tslib.es6-CBKHJX9H.js";
|
|
5
|
+
import { F as wr } from "../../Icons-BlBKvJD8.js";
|
|
6
|
+
import { Icon as _r } from "../Icon/Icon.js";
|
|
7
|
+
import { clsx as Fr } from "../../utils/clsx.js";
|
|
8
|
+
import { ItemPreview as Or } from "./ItemPreview.js";
|
|
9
|
+
import '../../assets/InputDropzone.css';var xr = /* @__PURE__ */ new Map([
|
|
10
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
|
11
|
+
["aac", "audio/aac"],
|
|
12
|
+
["abw", "application/x-abiword"],
|
|
13
|
+
["arc", "application/x-freearc"],
|
|
14
|
+
["avif", "image/avif"],
|
|
15
|
+
["avi", "video/x-msvideo"],
|
|
16
|
+
["azw", "application/vnd.amazon.ebook"],
|
|
17
|
+
["bin", "application/octet-stream"],
|
|
18
|
+
["bmp", "image/bmp"],
|
|
19
|
+
["bz", "application/x-bzip"],
|
|
20
|
+
["bz2", "application/x-bzip2"],
|
|
21
|
+
["cda", "application/x-cdf"],
|
|
22
|
+
["csh", "application/x-csh"],
|
|
23
|
+
["css", "text/css"],
|
|
24
|
+
["csv", "text/csv"],
|
|
25
|
+
["doc", "application/msword"],
|
|
26
|
+
["docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document"],
|
|
27
|
+
["eot", "application/vnd.ms-fontobject"],
|
|
28
|
+
["epub", "application/epub+zip"],
|
|
29
|
+
["gz", "application/gzip"],
|
|
30
|
+
["gif", "image/gif"],
|
|
31
|
+
["heic", "image/heic"],
|
|
32
|
+
["heif", "image/heif"],
|
|
33
|
+
["htm", "text/html"],
|
|
34
|
+
["html", "text/html"],
|
|
35
|
+
["ico", "image/vnd.microsoft.icon"],
|
|
36
|
+
["ics", "text/calendar"],
|
|
37
|
+
["jar", "application/java-archive"],
|
|
38
|
+
["jpeg", "image/jpeg"],
|
|
39
|
+
["jpg", "image/jpeg"],
|
|
40
|
+
["js", "text/javascript"],
|
|
41
|
+
["json", "application/json"],
|
|
42
|
+
["jsonld", "application/ld+json"],
|
|
43
|
+
["mid", "audio/midi"],
|
|
44
|
+
["midi", "audio/midi"],
|
|
45
|
+
["mjs", "text/javascript"],
|
|
46
|
+
["mp3", "audio/mpeg"],
|
|
47
|
+
["mp4", "video/mp4"],
|
|
48
|
+
["mpeg", "video/mpeg"],
|
|
49
|
+
["mpkg", "application/vnd.apple.installer+xml"],
|
|
50
|
+
["odp", "application/vnd.oasis.opendocument.presentation"],
|
|
51
|
+
["ods", "application/vnd.oasis.opendocument.spreadsheet"],
|
|
52
|
+
["odt", "application/vnd.oasis.opendocument.text"],
|
|
53
|
+
["oga", "audio/ogg"],
|
|
54
|
+
["ogv", "video/ogg"],
|
|
55
|
+
["ogx", "application/ogg"],
|
|
56
|
+
["opus", "audio/opus"],
|
|
57
|
+
["otf", "font/otf"],
|
|
58
|
+
["png", "image/png"],
|
|
59
|
+
["pdf", "application/pdf"],
|
|
60
|
+
["php", "application/x-httpd-php"],
|
|
61
|
+
["ppt", "application/vnd.ms-powerpoint"],
|
|
62
|
+
["pptx", "application/vnd.openxmlformats-officedocument.presentationml.presentation"],
|
|
63
|
+
["rar", "application/vnd.rar"],
|
|
64
|
+
["rtf", "application/rtf"],
|
|
65
|
+
["sh", "application/x-sh"],
|
|
66
|
+
["svg", "image/svg+xml"],
|
|
67
|
+
["swf", "application/x-shockwave-flash"],
|
|
68
|
+
["tar", "application/x-tar"],
|
|
69
|
+
["tif", "image/tiff"],
|
|
70
|
+
["tiff", "image/tiff"],
|
|
71
|
+
["ts", "video/mp2t"],
|
|
72
|
+
["ttf", "font/ttf"],
|
|
73
|
+
["txt", "text/plain"],
|
|
74
|
+
["vsd", "application/vnd.visio"],
|
|
75
|
+
["wav", "audio/wav"],
|
|
76
|
+
["weba", "audio/webm"],
|
|
77
|
+
["webm", "video/webm"],
|
|
78
|
+
["webp", "image/webp"],
|
|
79
|
+
["woff", "font/woff"],
|
|
80
|
+
["woff2", "font/woff2"],
|
|
81
|
+
["xhtml", "application/xhtml+xml"],
|
|
82
|
+
["xls", "application/vnd.ms-excel"],
|
|
83
|
+
["xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],
|
|
84
|
+
["xml", "application/xml"],
|
|
85
|
+
["xul", "application/vnd.mozilla.xul+xml"],
|
|
86
|
+
["zip", "application/zip"],
|
|
87
|
+
["7z", "application/x-7z-compressed"],
|
|
88
|
+
// Others
|
|
89
|
+
["mkv", "video/x-matroska"],
|
|
90
|
+
["mov", "video/quicktime"],
|
|
91
|
+
["msg", "application/vnd.ms-outlook"]
|
|
92
|
+
]);
|
|
93
|
+
function Y(e, r) {
|
|
94
|
+
var t = Er(e);
|
|
95
|
+
if (typeof t.path != "string") {
|
|
96
|
+
var n = e.webkitRelativePath;
|
|
97
|
+
Object.defineProperty(t, "path", {
|
|
98
|
+
value: typeof r == "string" ? r : typeof n == "string" && n.length > 0 ? n : e.name,
|
|
99
|
+
writable: !1,
|
|
100
|
+
configurable: !1,
|
|
101
|
+
enumerable: !0
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return t;
|
|
105
|
+
}
|
|
106
|
+
function Er(e) {
|
|
107
|
+
var r = e.name, t = r && r.lastIndexOf(".") !== -1;
|
|
108
|
+
if (t && !e.type) {
|
|
109
|
+
var n = r.split(".").pop().toLowerCase(), i = xr.get(n);
|
|
110
|
+
i && Object.defineProperty(e, "type", {
|
|
111
|
+
value: i,
|
|
112
|
+
writable: !1,
|
|
113
|
+
configurable: !1,
|
|
114
|
+
enumerable: !0
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return e;
|
|
118
|
+
}
|
|
119
|
+
var jr = [
|
|
120
|
+
// Thumbnail cache files for macOS and Windows
|
|
121
|
+
".DS_Store",
|
|
122
|
+
"Thumbs.db"
|
|
123
|
+
// Windows
|
|
124
|
+
];
|
|
125
|
+
function Pr(e) {
|
|
126
|
+
return M(this, void 0, void 0, function() {
|
|
127
|
+
return $(this, function(r) {
|
|
128
|
+
return oe(e) && Tr(e.dataTransfer) ? [2, Rr(e.dataTransfer, e.type)] : Ir(e) ? [2, Sr(e)] : Array.isArray(e) && e.every(function(t) {
|
|
129
|
+
return "getFile" in t && typeof t.getFile == "function";
|
|
130
|
+
}) ? [2, Cr(e)] : [2, []];
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function Tr(e) {
|
|
135
|
+
return oe(e);
|
|
136
|
+
}
|
|
137
|
+
function Ir(e) {
|
|
138
|
+
return oe(e) && oe(e.target);
|
|
139
|
+
}
|
|
140
|
+
function oe(e) {
|
|
141
|
+
return typeof e == "object" && e !== null;
|
|
142
|
+
}
|
|
143
|
+
function Sr(e) {
|
|
144
|
+
return we(e.target.files).map(function(r) {
|
|
145
|
+
return Y(r);
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
function Cr(e) {
|
|
149
|
+
return M(this, void 0, void 0, function() {
|
|
150
|
+
var r;
|
|
151
|
+
return $(this, function(t) {
|
|
152
|
+
switch (t.label) {
|
|
153
|
+
case 0:
|
|
154
|
+
return [4, Promise.all(e.map(function(n) {
|
|
155
|
+
return n.getFile();
|
|
156
|
+
}))];
|
|
157
|
+
case 1:
|
|
158
|
+
return r = t.sent(), [2, r.map(function(n) {
|
|
159
|
+
return Y(n);
|
|
160
|
+
})];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function Rr(e, r) {
|
|
166
|
+
return M(this, void 0, void 0, function() {
|
|
167
|
+
var t, n;
|
|
168
|
+
return $(this, function(i) {
|
|
169
|
+
switch (i.label) {
|
|
170
|
+
case 0:
|
|
171
|
+
return e.items ? (t = we(e.items).filter(function(a) {
|
|
172
|
+
return a.kind === "file";
|
|
173
|
+
}), r !== "drop" ? [2, t] : [4, Promise.all(t.map(kr))]) : [3, 2];
|
|
174
|
+
case 1:
|
|
175
|
+
return n = i.sent(), [2, Ne(rr(n))];
|
|
176
|
+
case 2:
|
|
177
|
+
return [2, Ne(we(e.files).map(function(a) {
|
|
178
|
+
return Y(a);
|
|
179
|
+
}))];
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function Ne(e) {
|
|
185
|
+
return e.filter(function(r) {
|
|
186
|
+
return jr.indexOf(r.name) === -1;
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
function we(e) {
|
|
190
|
+
if (e === null)
|
|
191
|
+
return [];
|
|
192
|
+
for (var r = [], t = 0; t < e.length; t++) {
|
|
193
|
+
var n = e[t];
|
|
194
|
+
r.push(n);
|
|
195
|
+
}
|
|
196
|
+
return r;
|
|
197
|
+
}
|
|
198
|
+
function kr(e) {
|
|
199
|
+
if (typeof e.webkitGetAsEntry != "function")
|
|
200
|
+
return Ue(e);
|
|
201
|
+
var r = e.webkitGetAsEntry();
|
|
202
|
+
return r && r.isDirectory ? tr(r) : Ue(e);
|
|
203
|
+
}
|
|
204
|
+
function rr(e) {
|
|
205
|
+
return e.reduce(function(r, t) {
|
|
206
|
+
return We(We([], Be(r), !1), Be(Array.isArray(t) ? rr(t) : [t]), !1);
|
|
207
|
+
}, []);
|
|
208
|
+
}
|
|
209
|
+
function Ue(e) {
|
|
210
|
+
var r = e.getAsFile();
|
|
211
|
+
if (!r)
|
|
212
|
+
return Promise.reject("".concat(e, " is not a File"));
|
|
213
|
+
var t = Y(r);
|
|
214
|
+
return Promise.resolve(t);
|
|
215
|
+
}
|
|
216
|
+
function zr(e) {
|
|
217
|
+
return M(this, void 0, void 0, function() {
|
|
218
|
+
return $(this, function(r) {
|
|
219
|
+
return [2, e.isDirectory ? tr(e) : Lr(e)];
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function tr(e) {
|
|
224
|
+
var r = e.createReader();
|
|
225
|
+
return new Promise(function(t, n) {
|
|
226
|
+
var i = [];
|
|
227
|
+
function a() {
|
|
228
|
+
var s = this;
|
|
229
|
+
r.readEntries(function(u) {
|
|
230
|
+
return M(s, void 0, void 0, function() {
|
|
231
|
+
var d, A, w;
|
|
232
|
+
return $(this, function(v) {
|
|
233
|
+
switch (v.label) {
|
|
234
|
+
case 0:
|
|
235
|
+
if (u.length) return [3, 5];
|
|
236
|
+
v.label = 1;
|
|
237
|
+
case 1:
|
|
238
|
+
return v.trys.push([1, 3, , 4]), [4, Promise.all(i)];
|
|
239
|
+
case 2:
|
|
240
|
+
return d = v.sent(), t(d), [3, 4];
|
|
241
|
+
case 3:
|
|
242
|
+
return A = v.sent(), n(A), [3, 4];
|
|
243
|
+
case 4:
|
|
244
|
+
return [3, 6];
|
|
245
|
+
case 5:
|
|
246
|
+
w = Promise.all(u.map(zr)), i.push(w), a(), v.label = 6;
|
|
247
|
+
case 6:
|
|
248
|
+
return [
|
|
249
|
+
2
|
|
250
|
+
/*return*/
|
|
251
|
+
];
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
}, function(u) {
|
|
256
|
+
n(u);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
a();
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function Lr(e) {
|
|
263
|
+
return M(this, void 0, void 0, function() {
|
|
264
|
+
return $(this, function(r) {
|
|
265
|
+
return [2, new Promise(function(t, n) {
|
|
266
|
+
e.file(function(i) {
|
|
267
|
+
var a = Y(i, e.fullPath);
|
|
268
|
+
t(a);
|
|
269
|
+
}, function(i) {
|
|
270
|
+
n(i);
|
|
271
|
+
});
|
|
272
|
+
})];
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
var Mr = function(e, r) {
|
|
277
|
+
if (e && r) {
|
|
278
|
+
var t = Array.isArray(r) ? r : r.split(","), n = e.name || "", i = (e.type || "").toLowerCase(), a = i.replace(/\/.*$/, "");
|
|
279
|
+
return t.some(function(s) {
|
|
280
|
+
var u = s.trim().toLowerCase();
|
|
281
|
+
return u.charAt(0) === "." ? n.toLowerCase().endsWith(u) : u.endsWith("/*") ? a === u.replace(/\/.*$/, "") : i === u;
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
return !0;
|
|
285
|
+
};
|
|
286
|
+
function Ye(e) {
|
|
287
|
+
return Hr(e) || Kr(e) || or(e) || $r();
|
|
288
|
+
}
|
|
289
|
+
function $r() {
|
|
290
|
+
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
291
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
292
|
+
}
|
|
293
|
+
function Kr(e) {
|
|
294
|
+
if (typeof Symbol < "u" && e[Symbol.iterator] != null || e["@@iterator"] != null) return Array.from(e);
|
|
295
|
+
}
|
|
296
|
+
function Hr(e) {
|
|
297
|
+
if (Array.isArray(e)) return _e(e);
|
|
298
|
+
}
|
|
299
|
+
function Ge(e, r) {
|
|
300
|
+
var t = Object.keys(e);
|
|
301
|
+
if (Object.getOwnPropertySymbols) {
|
|
302
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
303
|
+
r && (n = n.filter(function(i) {
|
|
304
|
+
return Object.getOwnPropertyDescriptor(e, i).enumerable;
|
|
305
|
+
})), t.push.apply(t, n);
|
|
306
|
+
}
|
|
307
|
+
return t;
|
|
308
|
+
}
|
|
309
|
+
function qe(e) {
|
|
310
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
311
|
+
var t = arguments[r] != null ? arguments[r] : {};
|
|
312
|
+
r % 2 ? Ge(Object(t), !0).forEach(function(n) {
|
|
313
|
+
nr(e, n, t[n]);
|
|
314
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : Ge(Object(t)).forEach(function(n) {
|
|
315
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return e;
|
|
319
|
+
}
|
|
320
|
+
function nr(e, r, t) {
|
|
321
|
+
return r in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e;
|
|
322
|
+
}
|
|
323
|
+
function U(e, r) {
|
|
324
|
+
return Nr(e) || Br(e, r) || or(e, r) || Wr();
|
|
325
|
+
}
|
|
326
|
+
function Wr() {
|
|
327
|
+
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
328
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
329
|
+
}
|
|
330
|
+
function or(e, r) {
|
|
331
|
+
if (e) {
|
|
332
|
+
if (typeof e == "string") return _e(e, r);
|
|
333
|
+
var t = Object.prototype.toString.call(e).slice(8, -1);
|
|
334
|
+
if (t === "Object" && e.constructor && (t = e.constructor.name), t === "Map" || t === "Set") return Array.from(e);
|
|
335
|
+
if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)) return _e(e, r);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
function _e(e, r) {
|
|
339
|
+
(r == null || r > e.length) && (r = e.length);
|
|
340
|
+
for (var t = 0, n = new Array(r); t < r; t++)
|
|
341
|
+
n[t] = e[t];
|
|
342
|
+
return n;
|
|
343
|
+
}
|
|
344
|
+
function Br(e, r) {
|
|
345
|
+
var t = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
|
|
346
|
+
if (t != null) {
|
|
347
|
+
var n = [], i = !0, a = !1, s, u;
|
|
348
|
+
try {
|
|
349
|
+
for (t = t.call(e); !(i = (s = t.next()).done) && (n.push(s.value), !(r && n.length === r)); i = !0)
|
|
350
|
+
;
|
|
351
|
+
} catch (d) {
|
|
352
|
+
a = !0, u = d;
|
|
353
|
+
} finally {
|
|
354
|
+
try {
|
|
355
|
+
!i && t.return != null && t.return();
|
|
356
|
+
} finally {
|
|
357
|
+
if (a) throw u;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
return n;
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
function Nr(e) {
|
|
364
|
+
if (Array.isArray(e)) return e;
|
|
365
|
+
}
|
|
366
|
+
var Ur = "file-invalid-type", Yr = "file-too-large", Gr = "file-too-small", qr = "too-many-files", Jr = function(r) {
|
|
367
|
+
r = Array.isArray(r) && r.length === 1 ? r[0] : r;
|
|
368
|
+
var t = Array.isArray(r) ? "one of ".concat(r.join(", ")) : r;
|
|
369
|
+
return {
|
|
370
|
+
code: Ur,
|
|
371
|
+
message: "File type must be ".concat(t)
|
|
372
|
+
};
|
|
373
|
+
}, Je = function(r) {
|
|
374
|
+
return {
|
|
375
|
+
code: Yr,
|
|
376
|
+
message: "File is larger than ".concat(r, " ").concat(r === 1 ? "byte" : "bytes")
|
|
377
|
+
};
|
|
378
|
+
}, Ve = function(r) {
|
|
379
|
+
return {
|
|
380
|
+
code: Gr,
|
|
381
|
+
message: "File is smaller than ".concat(r, " ").concat(r === 1 ? "byte" : "bytes")
|
|
382
|
+
};
|
|
383
|
+
}, Vr = {
|
|
384
|
+
code: qr,
|
|
385
|
+
message: "Too many files"
|
|
386
|
+
};
|
|
387
|
+
function ir(e, r) {
|
|
388
|
+
var t = e.type === "application/x-moz-file" || Mr(e, r);
|
|
389
|
+
return [t, t ? null : Jr(r)];
|
|
390
|
+
}
|
|
391
|
+
function ar(e, r, t) {
|
|
392
|
+
if (S(e.size))
|
|
393
|
+
if (S(r) && S(t)) {
|
|
394
|
+
if (e.size > t) return [!1, Je(t)];
|
|
395
|
+
if (e.size < r) return [!1, Ve(r)];
|
|
396
|
+
} else {
|
|
397
|
+
if (S(r) && e.size < r) return [!1, Ve(r)];
|
|
398
|
+
if (S(t) && e.size > t) return [!1, Je(t)];
|
|
399
|
+
}
|
|
400
|
+
return [!0, null];
|
|
401
|
+
}
|
|
402
|
+
function S(e) {
|
|
403
|
+
return e != null;
|
|
404
|
+
}
|
|
405
|
+
function Qr(e) {
|
|
406
|
+
var r = e.files, t = e.accept, n = e.minSize, i = e.maxSize, a = e.multiple, s = e.maxFiles, u = e.validator;
|
|
407
|
+
return !a && r.length > 1 || a && s >= 1 && r.length > s ? !1 : r.every(function(d) {
|
|
408
|
+
var A = ir(d, t), w = U(A, 1), v = w[0], x = ar(d, n, i), E = U(x, 1), j = E[0], P = u ? u(d) : null;
|
|
409
|
+
return v && j && !P;
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
function ie(e) {
|
|
413
|
+
return typeof e.isPropagationStopped == "function" ? e.isPropagationStopped() : typeof e.cancelBubble < "u" ? e.cancelBubble : !1;
|
|
414
|
+
}
|
|
415
|
+
function ne(e) {
|
|
416
|
+
return e.dataTransfer ? Array.prototype.some.call(e.dataTransfer.types, function(r) {
|
|
417
|
+
return r === "Files" || r === "application/x-moz-file";
|
|
418
|
+
}) : !!e.target && !!e.target.files;
|
|
419
|
+
}
|
|
420
|
+
function Qe(e) {
|
|
421
|
+
e.preventDefault();
|
|
422
|
+
}
|
|
423
|
+
function Xr(e) {
|
|
424
|
+
return e.indexOf("MSIE") !== -1 || e.indexOf("Trident/") !== -1;
|
|
425
|
+
}
|
|
426
|
+
function Zr(e) {
|
|
427
|
+
return e.indexOf("Edge/") !== -1;
|
|
428
|
+
}
|
|
429
|
+
function et() {
|
|
430
|
+
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.navigator.userAgent;
|
|
431
|
+
return Xr(e) || Zr(e);
|
|
432
|
+
}
|
|
433
|
+
function _() {
|
|
434
|
+
for (var e = arguments.length, r = new Array(e), t = 0; t < e; t++)
|
|
435
|
+
r[t] = arguments[t];
|
|
436
|
+
return function(n) {
|
|
437
|
+
for (var i = arguments.length, a = new Array(i > 1 ? i - 1 : 0), s = 1; s < i; s++)
|
|
438
|
+
a[s - 1] = arguments[s];
|
|
439
|
+
return r.some(function(u) {
|
|
440
|
+
return !ie(n) && u && u.apply(void 0, [n].concat(a)), ie(n);
|
|
441
|
+
});
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function rt() {
|
|
445
|
+
return "showOpenFilePicker" in window;
|
|
446
|
+
}
|
|
447
|
+
function tt(e) {
|
|
448
|
+
if (S(e)) {
|
|
449
|
+
var r = Object.entries(e).filter(function(t) {
|
|
450
|
+
var n = U(t, 2), i = n[0], a = n[1], s = !0;
|
|
451
|
+
return cr(i) || (console.warn('Skipped "'.concat(i, '" 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.')), s = !1), (!Array.isArray(a) || !a.every(ur)) && (console.warn('Skipped "'.concat(i, '" because an invalid file extension was provided.')), s = !1), s;
|
|
452
|
+
}).reduce(function(t, n) {
|
|
453
|
+
var i = U(n, 2), a = i[0], s = i[1];
|
|
454
|
+
return qe(qe({}, t), {}, nr({}, a, s));
|
|
455
|
+
}, {});
|
|
456
|
+
return [{
|
|
457
|
+
// description is required due to https://crbug.com/1264708
|
|
458
|
+
description: "Files",
|
|
459
|
+
accept: r
|
|
460
|
+
}];
|
|
461
|
+
}
|
|
462
|
+
return e;
|
|
463
|
+
}
|
|
464
|
+
function nt(e) {
|
|
465
|
+
if (S(e))
|
|
466
|
+
return Object.entries(e).reduce(function(r, t) {
|
|
467
|
+
var n = U(t, 2), i = n[0], a = n[1];
|
|
468
|
+
return [].concat(Ye(r), [i], Ye(a));
|
|
469
|
+
}, []).filter(function(r) {
|
|
470
|
+
return cr(r) || ur(r);
|
|
471
|
+
}).join(",");
|
|
472
|
+
}
|
|
473
|
+
function ot(e) {
|
|
474
|
+
return e instanceof DOMException && (e.name === "AbortError" || e.code === e.ABORT_ERR);
|
|
475
|
+
}
|
|
476
|
+
function it(e) {
|
|
477
|
+
return e instanceof DOMException && (e.name === "SecurityError" || e.code === e.SECURITY_ERR);
|
|
478
|
+
}
|
|
479
|
+
function cr(e) {
|
|
480
|
+
return e === "audio/*" || e === "video/*" || e === "image/*" || e === "text/*" || /\w+\/[-+.\w]+/g.test(e);
|
|
481
|
+
}
|
|
482
|
+
function ur(e) {
|
|
483
|
+
return /^.*\.[\w]+$/.test(e);
|
|
484
|
+
}
|
|
485
|
+
var at = ["children"], ct = ["open"], ut = ["refKey", "role", "onKeyDown", "onFocus", "onBlur", "onClick", "onDragEnter", "onDragOver", "onDragLeave", "onDrop"], st = ["refKey", "onChange", "onClick"];
|
|
486
|
+
function lt(e) {
|
|
487
|
+
return dt(e) || pt(e) || sr(e) || ft();
|
|
488
|
+
}
|
|
489
|
+
function ft() {
|
|
490
|
+
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
491
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
492
|
+
}
|
|
493
|
+
function pt(e) {
|
|
494
|
+
if (typeof Symbol < "u" && e[Symbol.iterator] != null || e["@@iterator"] != null) return Array.from(e);
|
|
495
|
+
}
|
|
496
|
+
function dt(e) {
|
|
497
|
+
if (Array.isArray(e)) return Fe(e);
|
|
498
|
+
}
|
|
499
|
+
function Ae(e, r) {
|
|
500
|
+
return vt(e) || gt(e, r) || sr(e, r) || mt();
|
|
501
|
+
}
|
|
502
|
+
function mt() {
|
|
503
|
+
throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
504
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
505
|
+
}
|
|
506
|
+
function sr(e, r) {
|
|
507
|
+
if (e) {
|
|
508
|
+
if (typeof e == "string") return Fe(e, r);
|
|
509
|
+
var t = Object.prototype.toString.call(e).slice(8, -1);
|
|
510
|
+
if (t === "Object" && e.constructor && (t = e.constructor.name), t === "Map" || t === "Set") return Array.from(e);
|
|
511
|
+
if (t === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)) return Fe(e, r);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
function Fe(e, r) {
|
|
515
|
+
(r == null || r > e.length) && (r = e.length);
|
|
516
|
+
for (var t = 0, n = new Array(r); t < r; t++)
|
|
517
|
+
n[t] = e[t];
|
|
518
|
+
return n;
|
|
519
|
+
}
|
|
520
|
+
function gt(e, r) {
|
|
521
|
+
var t = e == null ? null : typeof Symbol < "u" && e[Symbol.iterator] || e["@@iterator"];
|
|
522
|
+
if (t != null) {
|
|
523
|
+
var n = [], i = !0, a = !1, s, u;
|
|
524
|
+
try {
|
|
525
|
+
for (t = t.call(e); !(i = (s = t.next()).done) && (n.push(s.value), !(r && n.length === r)); i = !0)
|
|
526
|
+
;
|
|
527
|
+
} catch (d) {
|
|
528
|
+
a = !0, u = d;
|
|
529
|
+
} finally {
|
|
530
|
+
try {
|
|
531
|
+
!i && t.return != null && t.return();
|
|
532
|
+
} finally {
|
|
533
|
+
if (a) throw u;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
return n;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
function vt(e) {
|
|
540
|
+
if (Array.isArray(e)) return e;
|
|
541
|
+
}
|
|
542
|
+
function Xe(e, r) {
|
|
543
|
+
var t = Object.keys(e);
|
|
544
|
+
if (Object.getOwnPropertySymbols) {
|
|
545
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
546
|
+
r && (n = n.filter(function(i) {
|
|
547
|
+
return Object.getOwnPropertyDescriptor(e, i).enumerable;
|
|
548
|
+
})), t.push.apply(t, n);
|
|
549
|
+
}
|
|
550
|
+
return t;
|
|
551
|
+
}
|
|
552
|
+
function f(e) {
|
|
553
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
554
|
+
var t = arguments[r] != null ? arguments[r] : {};
|
|
555
|
+
r % 2 ? Xe(Object(t), !0).forEach(function(n) {
|
|
556
|
+
Oe(e, n, t[n]);
|
|
557
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : Xe(Object(t)).forEach(function(n) {
|
|
558
|
+
Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(t, n));
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
return e;
|
|
562
|
+
}
|
|
563
|
+
function Oe(e, r, t) {
|
|
564
|
+
return r in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e;
|
|
565
|
+
}
|
|
566
|
+
function ae(e, r) {
|
|
567
|
+
if (e == null) return {};
|
|
568
|
+
var t = yt(e, r), n, i;
|
|
569
|
+
if (Object.getOwnPropertySymbols) {
|
|
570
|
+
var a = Object.getOwnPropertySymbols(e);
|
|
571
|
+
for (i = 0; i < a.length; i++)
|
|
572
|
+
n = a[i], !(r.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (t[n] = e[n]);
|
|
573
|
+
}
|
|
574
|
+
return t;
|
|
575
|
+
}
|
|
576
|
+
function yt(e, r) {
|
|
577
|
+
if (e == null) return {};
|
|
578
|
+
var t = {}, n = Object.keys(e), i, a;
|
|
579
|
+
for (a = 0; a < n.length; a++)
|
|
580
|
+
i = n[a], !(r.indexOf(i) >= 0) && (t[i] = e[i]);
|
|
581
|
+
return t;
|
|
582
|
+
}
|
|
583
|
+
var Ee = /* @__PURE__ */ hr(function(e, r) {
|
|
584
|
+
var t = e.children, n = ae(e, at), i = fr(n), a = i.open, s = ae(i, ct);
|
|
585
|
+
return Dr(r, function() {
|
|
586
|
+
return {
|
|
587
|
+
open: a
|
|
588
|
+
};
|
|
589
|
+
}, [a]), /* @__PURE__ */ er.createElement(Ar, null, t(f(f({}, s), {}, {
|
|
590
|
+
open: a
|
|
591
|
+
})));
|
|
592
|
+
});
|
|
593
|
+
Ee.displayName = "Dropzone";
|
|
594
|
+
var lr = {
|
|
595
|
+
disabled: !1,
|
|
596
|
+
getFilesFromEvent: Pr,
|
|
597
|
+
maxSize: 1 / 0,
|
|
598
|
+
minSize: 0,
|
|
599
|
+
multiple: !0,
|
|
600
|
+
maxFiles: 0,
|
|
601
|
+
preventDropOnDocument: !0,
|
|
602
|
+
noClick: !1,
|
|
603
|
+
noKeyboard: !1,
|
|
604
|
+
noDrag: !1,
|
|
605
|
+
noDragEventsBubbling: !1,
|
|
606
|
+
validator: null,
|
|
607
|
+
useFsAccessApi: !0,
|
|
608
|
+
autoFocus: !1
|
|
609
|
+
};
|
|
610
|
+
Ee.defaultProps = lr;
|
|
611
|
+
Ee.propTypes = {
|
|
612
|
+
/**
|
|
613
|
+
* Render function that exposes the dropzone state and prop getter fns
|
|
614
|
+
*
|
|
615
|
+
* @param {object} params
|
|
616
|
+
* @param {Function} params.getRootProps Returns the props you should apply to the root drop container you render
|
|
617
|
+
* @param {Function} params.getInputProps Returns the props you should apply to hidden file input you render
|
|
618
|
+
* @param {Function} params.open Open the native file selection dialog
|
|
619
|
+
* @param {boolean} params.isFocused Dropzone area is in focus
|
|
620
|
+
* @param {boolean} params.isFileDialogActive File dialog is opened
|
|
621
|
+
* @param {boolean} params.isDragActive Active drag is in progress
|
|
622
|
+
* @param {boolean} params.isDragAccept Dragged files are accepted
|
|
623
|
+
* @param {boolean} params.isDragReject Some dragged files are rejected
|
|
624
|
+
* @param {File[]} params.acceptedFiles Accepted files
|
|
625
|
+
* @param {FileRejection[]} params.fileRejections Rejected files and why they were rejected
|
|
626
|
+
*/
|
|
627
|
+
children: l.func,
|
|
628
|
+
/**
|
|
629
|
+
* Set accepted file types.
|
|
630
|
+
* Checkout https://developer.mozilla.org/en-US/docs/Web/API/window/showOpenFilePicker types option for more information.
|
|
631
|
+
* Keep in mind that mime type determination is not reliable across platforms. CSV files,
|
|
632
|
+
* for example, are reported as text/plain under macOS but as application/vnd.ms-excel under
|
|
633
|
+
* Windows. In some cases there might not be a mime type set at all (https://github.com/react-dropzone/react-dropzone/issues/276).
|
|
634
|
+
*/
|
|
635
|
+
accept: l.objectOf(l.arrayOf(l.string)),
|
|
636
|
+
/**
|
|
637
|
+
* Allow drag 'n' drop (or selection from the file dialog) of multiple files
|
|
638
|
+
*/
|
|
639
|
+
multiple: l.bool,
|
|
640
|
+
/**
|
|
641
|
+
* If false, allow dropped items to take over the current browser window
|
|
642
|
+
*/
|
|
643
|
+
preventDropOnDocument: l.bool,
|
|
644
|
+
/**
|
|
645
|
+
* If true, disables click to open the native file selection dialog
|
|
646
|
+
*/
|
|
647
|
+
noClick: l.bool,
|
|
648
|
+
/**
|
|
649
|
+
* If true, disables SPACE/ENTER to open the native file selection dialog.
|
|
650
|
+
* Note that it also stops tracking the focus state.
|
|
651
|
+
*/
|
|
652
|
+
noKeyboard: l.bool,
|
|
653
|
+
/**
|
|
654
|
+
* If true, disables drag 'n' drop
|
|
655
|
+
*/
|
|
656
|
+
noDrag: l.bool,
|
|
657
|
+
/**
|
|
658
|
+
* If true, stops drag event propagation to parents
|
|
659
|
+
*/
|
|
660
|
+
noDragEventsBubbling: l.bool,
|
|
661
|
+
/**
|
|
662
|
+
* Minimum file size (in bytes)
|
|
663
|
+
*/
|
|
664
|
+
minSize: l.number,
|
|
665
|
+
/**
|
|
666
|
+
* Maximum file size (in bytes)
|
|
667
|
+
*/
|
|
668
|
+
maxSize: l.number,
|
|
669
|
+
/**
|
|
670
|
+
* Maximum accepted number of files
|
|
671
|
+
* The default value is 0 which means there is no limitation to how many files are accepted.
|
|
672
|
+
*/
|
|
673
|
+
maxFiles: l.number,
|
|
674
|
+
/**
|
|
675
|
+
* Enable/disable the dropzone
|
|
676
|
+
*/
|
|
677
|
+
disabled: l.bool,
|
|
678
|
+
/**
|
|
679
|
+
* Use this to provide a custom file aggregator
|
|
680
|
+
*
|
|
681
|
+
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
682
|
+
*/
|
|
683
|
+
getFilesFromEvent: l.func,
|
|
684
|
+
/**
|
|
685
|
+
* Cb for when closing the file dialog with no selection
|
|
686
|
+
*/
|
|
687
|
+
onFileDialogCancel: l.func,
|
|
688
|
+
/**
|
|
689
|
+
* Cb for when opening the file dialog
|
|
690
|
+
*/
|
|
691
|
+
onFileDialogOpen: l.func,
|
|
692
|
+
/**
|
|
693
|
+
* Set to true to use the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API
|
|
694
|
+
* to open the file picker instead of using an `<input type="file">` click event.
|
|
695
|
+
*/
|
|
696
|
+
useFsAccessApi: l.bool,
|
|
697
|
+
/**
|
|
698
|
+
* Set to true to focus the root element on render
|
|
699
|
+
*/
|
|
700
|
+
autoFocus: l.bool,
|
|
701
|
+
/**
|
|
702
|
+
* Cb for when the `dragenter` event occurs.
|
|
703
|
+
*
|
|
704
|
+
* @param {DragEvent} event
|
|
705
|
+
*/
|
|
706
|
+
onDragEnter: l.func,
|
|
707
|
+
/**
|
|
708
|
+
* Cb for when the `dragleave` event occurs
|
|
709
|
+
*
|
|
710
|
+
* @param {DragEvent} event
|
|
711
|
+
*/
|
|
712
|
+
onDragLeave: l.func,
|
|
713
|
+
/**
|
|
714
|
+
* Cb for when the `dragover` event occurs
|
|
715
|
+
*
|
|
716
|
+
* @param {DragEvent} event
|
|
717
|
+
*/
|
|
718
|
+
onDragOver: l.func,
|
|
719
|
+
/**
|
|
720
|
+
* Cb for when the `drop` event occurs.
|
|
721
|
+
* Note that this callback is invoked after the `getFilesFromEvent` callback is done.
|
|
722
|
+
*
|
|
723
|
+
* Files are accepted or rejected based on the `accept`, `multiple`, `minSize` and `maxSize` props.
|
|
724
|
+
* `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.
|
|
725
|
+
* If `multiple` is set to false and additional files are dropped,
|
|
726
|
+
* all files besides the first will be rejected.
|
|
727
|
+
* Any file which does not have a size in the [`minSize`, `maxSize`] range, will be rejected as well.
|
|
728
|
+
*
|
|
729
|
+
* Note that the `onDrop` callback will always be invoked regardless if the dropped files were accepted or rejected.
|
|
730
|
+
* If you'd like to react to a specific scenario, use the `onDropAccepted`/`onDropRejected` props.
|
|
731
|
+
*
|
|
732
|
+
* `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.
|
|
733
|
+
* For example, with [SuperAgent](https://github.com/visionmedia/superagent) as a http/ajax library:
|
|
734
|
+
*
|
|
735
|
+
* ```js
|
|
736
|
+
* function onDrop(acceptedFiles) {
|
|
737
|
+
* const req = request.post('/upload')
|
|
738
|
+
* acceptedFiles.forEach(file => {
|
|
739
|
+
* req.attach(file.name, file)
|
|
740
|
+
* })
|
|
741
|
+
* req.end(callback)
|
|
742
|
+
* }
|
|
743
|
+
* ```
|
|
744
|
+
*
|
|
745
|
+
* @param {File[]} acceptedFiles
|
|
746
|
+
* @param {FileRejection[]} fileRejections
|
|
747
|
+
* @param {(DragEvent|Event)} event A drag event or input change event (if files were selected via the file dialog)
|
|
748
|
+
*/
|
|
749
|
+
onDrop: l.func,
|
|
750
|
+
/**
|
|
751
|
+
* Cb for when the `drop` event occurs.
|
|
752
|
+
* Note that if no files are accepted, this callback is not invoked.
|
|
753
|
+
*
|
|
754
|
+
* @param {File[]} files
|
|
755
|
+
* @param {(DragEvent|Event)} event
|
|
756
|
+
*/
|
|
757
|
+
onDropAccepted: l.func,
|
|
758
|
+
/**
|
|
759
|
+
* Cb for when the `drop` event occurs.
|
|
760
|
+
* Note that if no files are rejected, this callback is not invoked.
|
|
761
|
+
*
|
|
762
|
+
* @param {FileRejection[]} fileRejections
|
|
763
|
+
* @param {(DragEvent|Event)} event
|
|
764
|
+
*/
|
|
765
|
+
onDropRejected: l.func,
|
|
766
|
+
/**
|
|
767
|
+
* Cb for when there's some error from any of the promises.
|
|
768
|
+
*
|
|
769
|
+
* @param {Error} error
|
|
770
|
+
*/
|
|
771
|
+
onError: l.func,
|
|
772
|
+
/**
|
|
773
|
+
* Custom validation function. It must return null if there's no errors.
|
|
774
|
+
* @param {File} file
|
|
775
|
+
* @returns {FileError|FileError[]|null}
|
|
776
|
+
*/
|
|
777
|
+
validator: l.func
|
|
778
|
+
};
|
|
779
|
+
var xe = {
|
|
780
|
+
isFocused: !1,
|
|
781
|
+
isFileDialogActive: !1,
|
|
782
|
+
isDragActive: !1,
|
|
783
|
+
isDragAccept: !1,
|
|
784
|
+
isDragReject: !1,
|
|
785
|
+
acceptedFiles: [],
|
|
786
|
+
fileRejections: []
|
|
787
|
+
};
|
|
788
|
+
function fr() {
|
|
789
|
+
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, r = f(f({}, lr), e), t = r.accept, n = r.disabled, i = r.getFilesFromEvent, a = r.maxSize, s = r.minSize, u = r.multiple, d = r.maxFiles, A = r.onDragEnter, w = r.onDragLeave, v = r.onDragOver, x = r.onDrop, E = r.onDropAccepted, j = r.onDropRejected, P = r.onFileDialogCancel, K = r.onFileDialogOpen, G = r.useFsAccessApi, q = r.autoFocus, O = r.preventDropOnDocument, je = r.noClick, ce = r.noKeyboard, Pe = r.noDrag, T = r.noDragEventsBubbling, ue = r.onError, H = r.validator, W = L(function() {
|
|
790
|
+
return nt(t);
|
|
791
|
+
}, [t]), Te = L(function() {
|
|
792
|
+
return tt(t);
|
|
793
|
+
}, [t]), se = L(function() {
|
|
794
|
+
return typeof K == "function" ? K : Ze;
|
|
795
|
+
}, [K]), J = L(function() {
|
|
796
|
+
return typeof P == "function" ? P : Ze;
|
|
797
|
+
}, [P]), g = te(null), h = te(null), pr = br(bt, xe), Ie = Ae(pr, 2), le = Ie[0], y = Ie[1], dr = le.isFocused, Se = le.isFileDialogActive, V = te(typeof window < "u" && window.isSecureContext && G && rt()), Ce = function() {
|
|
798
|
+
!V.current && Se && setTimeout(function() {
|
|
799
|
+
if (h.current) {
|
|
800
|
+
var c = h.current.files;
|
|
801
|
+
c.length || (y({
|
|
802
|
+
type: "closeDialog"
|
|
803
|
+
}), J());
|
|
804
|
+
}
|
|
805
|
+
}, 300);
|
|
806
|
+
};
|
|
807
|
+
De(function() {
|
|
808
|
+
return window.addEventListener("focus", Ce, !1), function() {
|
|
809
|
+
window.removeEventListener("focus", Ce, !1);
|
|
810
|
+
};
|
|
811
|
+
}, [h, Se, J, V]);
|
|
812
|
+
var C = te([]), Re = function(c) {
|
|
813
|
+
g.current && g.current.contains(c.target) || (c.preventDefault(), C.current = []);
|
|
814
|
+
};
|
|
815
|
+
De(function() {
|
|
816
|
+
return O && (document.addEventListener("dragover", Qe, !1), document.addEventListener("drop", Re, !1)), function() {
|
|
817
|
+
O && (document.removeEventListener("dragover", Qe), document.removeEventListener("drop", Re));
|
|
818
|
+
};
|
|
819
|
+
}, [g, O]), De(function() {
|
|
820
|
+
return !n && q && g.current && g.current.focus(), function() {
|
|
821
|
+
};
|
|
822
|
+
}, [g, q, n]);
|
|
823
|
+
var I = D(function(o) {
|
|
824
|
+
ue ? ue(o) : console.error(o);
|
|
825
|
+
}, [ue]), ke = D(function(o) {
|
|
826
|
+
o.preventDefault(), o.persist(), ee(o), C.current = [].concat(lt(C.current), [o.target]), ne(o) && Promise.resolve(i(o)).then(function(c) {
|
|
827
|
+
if (!(ie(o) && !T)) {
|
|
828
|
+
var p = c.length, m = p > 0 && Qr({
|
|
829
|
+
files: c,
|
|
830
|
+
accept: W,
|
|
831
|
+
minSize: s,
|
|
832
|
+
maxSize: a,
|
|
833
|
+
multiple: u,
|
|
834
|
+
maxFiles: d,
|
|
835
|
+
validator: H
|
|
836
|
+
}), b = p > 0 && !m;
|
|
837
|
+
y({
|
|
838
|
+
isDragAccept: m,
|
|
839
|
+
isDragReject: b,
|
|
840
|
+
isDragActive: !0,
|
|
841
|
+
type: "setDraggedFiles"
|
|
842
|
+
}), A && A(o);
|
|
843
|
+
}
|
|
844
|
+
}).catch(function(c) {
|
|
845
|
+
return I(c);
|
|
846
|
+
});
|
|
847
|
+
}, [i, A, I, T, W, s, a, u, d, H]), ze = D(function(o) {
|
|
848
|
+
o.preventDefault(), o.persist(), ee(o);
|
|
849
|
+
var c = ne(o);
|
|
850
|
+
if (c && o.dataTransfer)
|
|
851
|
+
try {
|
|
852
|
+
o.dataTransfer.dropEffect = "copy";
|
|
853
|
+
} catch {
|
|
854
|
+
}
|
|
855
|
+
return c && v && v(o), !1;
|
|
856
|
+
}, [v, T]), Le = D(function(o) {
|
|
857
|
+
o.preventDefault(), o.persist(), ee(o);
|
|
858
|
+
var c = C.current.filter(function(m) {
|
|
859
|
+
return g.current && g.current.contains(m);
|
|
860
|
+
}), p = c.indexOf(o.target);
|
|
861
|
+
p !== -1 && c.splice(p, 1), C.current = c, !(c.length > 0) && (y({
|
|
862
|
+
type: "setDraggedFiles",
|
|
863
|
+
isDragActive: !1,
|
|
864
|
+
isDragAccept: !1,
|
|
865
|
+
isDragReject: !1
|
|
866
|
+
}), ne(o) && w && w(o));
|
|
867
|
+
}, [g, w, T]), Q = D(function(o, c) {
|
|
868
|
+
var p = [], m = [];
|
|
869
|
+
o.forEach(function(b) {
|
|
870
|
+
var B = ir(b, W), z = Ae(B, 2), pe = z[0], de = z[1], me = ar(b, s, a), re = Ae(me, 2), ge = re[0], ve = re[1], ye = H ? H(b) : null;
|
|
871
|
+
if (pe && ge && !ye)
|
|
872
|
+
p.push(b);
|
|
873
|
+
else {
|
|
874
|
+
var be = [de, ve];
|
|
875
|
+
ye && (be = be.concat(ye)), m.push({
|
|
876
|
+
file: b,
|
|
877
|
+
errors: be.filter(function(yr) {
|
|
878
|
+
return yr;
|
|
879
|
+
})
|
|
880
|
+
});
|
|
881
|
+
}
|
|
882
|
+
}), (!u && p.length > 1 || u && d >= 1 && p.length > d) && (p.forEach(function(b) {
|
|
883
|
+
m.push({
|
|
884
|
+
file: b,
|
|
885
|
+
errors: [Vr]
|
|
886
|
+
});
|
|
887
|
+
}), p.splice(0)), y({
|
|
888
|
+
acceptedFiles: p,
|
|
889
|
+
fileRejections: m,
|
|
890
|
+
type: "setFiles"
|
|
891
|
+
}), x && x(p, m, c), m.length > 0 && j && j(m, c), p.length > 0 && E && E(p, c);
|
|
892
|
+
}, [y, u, W, s, a, d, x, E, j, H]), X = D(function(o) {
|
|
893
|
+
o.preventDefault(), o.persist(), ee(o), C.current = [], ne(o) && Promise.resolve(i(o)).then(function(c) {
|
|
894
|
+
ie(o) && !T || Q(c, o);
|
|
895
|
+
}).catch(function(c) {
|
|
896
|
+
return I(c);
|
|
897
|
+
}), y({
|
|
898
|
+
type: "reset"
|
|
899
|
+
});
|
|
900
|
+
}, [i, Q, I, T]), R = D(function() {
|
|
901
|
+
if (V.current) {
|
|
902
|
+
y({
|
|
903
|
+
type: "openDialog"
|
|
904
|
+
}), se();
|
|
905
|
+
var o = {
|
|
906
|
+
multiple: u,
|
|
907
|
+
types: Te
|
|
908
|
+
};
|
|
909
|
+
window.showOpenFilePicker(o).then(function(c) {
|
|
910
|
+
return i(c);
|
|
911
|
+
}).then(function(c) {
|
|
912
|
+
Q(c, null), y({
|
|
913
|
+
type: "closeDialog"
|
|
914
|
+
});
|
|
915
|
+
}).catch(function(c) {
|
|
916
|
+
ot(c) ? (J(c), y({
|
|
917
|
+
type: "closeDialog"
|
|
918
|
+
})) : it(c) ? (V.current = !1, h.current ? (h.current.value = null, h.current.click()) : I(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."))) : I(c);
|
|
919
|
+
});
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
h.current && (y({
|
|
923
|
+
type: "openDialog"
|
|
924
|
+
}), se(), h.current.value = null, h.current.click());
|
|
925
|
+
}, [y, se, J, G, Q, I, Te, u]), Me = D(function(o) {
|
|
926
|
+
!g.current || !g.current.isEqualNode(o.target) || (o.key === " " || o.key === "Enter" || o.keyCode === 32 || o.keyCode === 13) && (o.preventDefault(), R());
|
|
927
|
+
}, [g, R]), $e = D(function() {
|
|
928
|
+
y({
|
|
929
|
+
type: "focus"
|
|
930
|
+
});
|
|
931
|
+
}, []), Ke = D(function() {
|
|
932
|
+
y({
|
|
933
|
+
type: "blur"
|
|
934
|
+
});
|
|
935
|
+
}, []), He = D(function() {
|
|
936
|
+
je || (et() ? setTimeout(R, 0) : R());
|
|
937
|
+
}, [je, R]), k = function(c) {
|
|
938
|
+
return n ? null : c;
|
|
939
|
+
}, fe = function(c) {
|
|
940
|
+
return ce ? null : k(c);
|
|
941
|
+
}, Z = function(c) {
|
|
942
|
+
return Pe ? null : k(c);
|
|
943
|
+
}, ee = function(c) {
|
|
944
|
+
T && c.stopPropagation();
|
|
945
|
+
}, mr = L(function() {
|
|
946
|
+
return function() {
|
|
947
|
+
var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, c = o.refKey, p = c === void 0 ? "ref" : c, m = o.role, b = o.onKeyDown, B = o.onFocus, z = o.onBlur, pe = o.onClick, de = o.onDragEnter, me = o.onDragOver, re = o.onDragLeave, ge = o.onDrop, ve = ae(o, ut);
|
|
948
|
+
return f(f(Oe({
|
|
949
|
+
onKeyDown: fe(_(b, Me)),
|
|
950
|
+
onFocus: fe(_(B, $e)),
|
|
951
|
+
onBlur: fe(_(z, Ke)),
|
|
952
|
+
onClick: k(_(pe, He)),
|
|
953
|
+
onDragEnter: Z(_(de, ke)),
|
|
954
|
+
onDragOver: Z(_(me, ze)),
|
|
955
|
+
onDragLeave: Z(_(re, Le)),
|
|
956
|
+
onDrop: Z(_(ge, X)),
|
|
957
|
+
role: typeof m == "string" && m !== "" ? m : "presentation"
|
|
958
|
+
}, p, g), !n && !ce ? {
|
|
959
|
+
tabIndex: 0
|
|
960
|
+
} : {}), ve);
|
|
961
|
+
};
|
|
962
|
+
}, [g, Me, $e, Ke, He, ke, ze, Le, X, ce, Pe, n]), gr = D(function(o) {
|
|
963
|
+
o.stopPropagation();
|
|
964
|
+
}, []), vr = L(function() {
|
|
965
|
+
return function() {
|
|
966
|
+
var o = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, c = o.refKey, p = c === void 0 ? "ref" : c, m = o.onChange, b = o.onClick, B = ae(o, st), z = Oe({
|
|
967
|
+
accept: W,
|
|
968
|
+
multiple: u,
|
|
969
|
+
type: "file",
|
|
970
|
+
style: {
|
|
971
|
+
display: "none"
|
|
972
|
+
},
|
|
973
|
+
onChange: k(_(m, X)),
|
|
974
|
+
onClick: k(_(b, gr)),
|
|
975
|
+
tabIndex: -1
|
|
976
|
+
}, p, h);
|
|
977
|
+
return f(f({}, z), B);
|
|
978
|
+
};
|
|
979
|
+
}, [h, t, u, X, n]);
|
|
980
|
+
return f(f({}, le), {}, {
|
|
981
|
+
isFocused: dr && !n,
|
|
982
|
+
getRootProps: mr,
|
|
983
|
+
getInputProps: vr,
|
|
984
|
+
rootRef: g,
|
|
985
|
+
inputRef: h,
|
|
986
|
+
open: k(R)
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
function bt(e, r) {
|
|
990
|
+
switch (r.type) {
|
|
991
|
+
case "focus":
|
|
992
|
+
return f(f({}, e), {}, {
|
|
993
|
+
isFocused: !0
|
|
994
|
+
});
|
|
995
|
+
case "blur":
|
|
996
|
+
return f(f({}, e), {}, {
|
|
997
|
+
isFocused: !1
|
|
998
|
+
});
|
|
999
|
+
case "openDialog":
|
|
1000
|
+
return f(f({}, xe), {}, {
|
|
1001
|
+
isFileDialogActive: !0
|
|
1002
|
+
});
|
|
1003
|
+
case "closeDialog":
|
|
1004
|
+
return f(f({}, e), {}, {
|
|
1005
|
+
isFileDialogActive: !1
|
|
1006
|
+
});
|
|
1007
|
+
case "setDraggedFiles":
|
|
1008
|
+
return f(f({}, e), {}, {
|
|
1009
|
+
isDragActive: r.isDragActive,
|
|
1010
|
+
isDragAccept: r.isDragAccept,
|
|
1011
|
+
isDragReject: r.isDragReject
|
|
1012
|
+
});
|
|
1013
|
+
case "setFiles":
|
|
1014
|
+
return f(f({}, e), {}, {
|
|
1015
|
+
acceptedFiles: r.acceptedFiles,
|
|
1016
|
+
fileRejections: r.fileRejections
|
|
1017
|
+
});
|
|
1018
|
+
case "reset":
|
|
1019
|
+
return f({}, xe);
|
|
1020
|
+
default:
|
|
1021
|
+
return e;
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
function Ze() {
|
|
1025
|
+
}
|
|
1026
|
+
const ht = "_root_1kc1u_1", Dt = "_dropzone_1kc1u_1", At = "_text_1kc1u_21", wt = "_disabled_1kc1u_30", _t = "_focused_1kc1u_41", Ft = "_dragActive_1kc1u_41", Ot = "_linkText_1kc1u_47", F = {
|
|
1027
|
+
root: ht,
|
|
1028
|
+
dropzone: Dt,
|
|
1029
|
+
text: At,
|
|
1030
|
+
disabled: wt,
|
|
1031
|
+
focused: _t,
|
|
1032
|
+
dragActive: Ft,
|
|
1033
|
+
linkText: Ot
|
|
1034
|
+
};
|
|
1035
|
+
function Rt(e) {
|
|
1036
|
+
const {
|
|
1037
|
+
value: r,
|
|
1038
|
+
onChange: t,
|
|
1039
|
+
text: n,
|
|
1040
|
+
linkText: i,
|
|
1041
|
+
removeItemAriaLabel: a = "",
|
|
1042
|
+
rootAriaLabel: s = "",
|
|
1043
|
+
onRemoveFile: u,
|
|
1044
|
+
...d
|
|
1045
|
+
} = e, {
|
|
1046
|
+
isFocused: A,
|
|
1047
|
+
isDragActive: w,
|
|
1048
|
+
isDragAccept: v,
|
|
1049
|
+
isDragReject: x,
|
|
1050
|
+
isFileDialogActive: E,
|
|
1051
|
+
acceptedFiles: j,
|
|
1052
|
+
getRootProps: P,
|
|
1053
|
+
getInputProps: K
|
|
1054
|
+
} = fr(d), G = er.useCallback((O) => {
|
|
1055
|
+
u && u(O);
|
|
1056
|
+
}, [u]), q = Fr(F.dropzone, {
|
|
1057
|
+
[F.disabled]: d.disabled,
|
|
1058
|
+
[F.focused]: A,
|
|
1059
|
+
[F.dragActive]: w,
|
|
1060
|
+
[F.dragAccept]: v,
|
|
1061
|
+
[F.dragReject]: x,
|
|
1062
|
+
[F.fileDialogActive]: E
|
|
1063
|
+
});
|
|
1064
|
+
return /* @__PURE__ */ he("section", { className: F.root, children: [
|
|
1065
|
+
/* @__PURE__ */ he(
|
|
1066
|
+
"div",
|
|
1067
|
+
{
|
|
1068
|
+
className: q,
|
|
1069
|
+
...P({
|
|
1070
|
+
"aria-label": s
|
|
1071
|
+
}),
|
|
1072
|
+
children: [
|
|
1073
|
+
/* @__PURE__ */ N(
|
|
1074
|
+
"input",
|
|
1075
|
+
{
|
|
1076
|
+
...K({
|
|
1077
|
+
value: r,
|
|
1078
|
+
onChange: t
|
|
1079
|
+
})
|
|
1080
|
+
}
|
|
1081
|
+
),
|
|
1082
|
+
/* @__PURE__ */ N(_r, { size: "xxlarge", children: /* @__PURE__ */ N(wr, {}) }),
|
|
1083
|
+
/* @__PURE__ */ he("span", { className: F.text, children: [
|
|
1084
|
+
i ? `${n} ` : n,
|
|
1085
|
+
!!i && /* @__PURE__ */ N("span", { className: F.linkText, children: i })
|
|
1086
|
+
] })
|
|
1087
|
+
]
|
|
1088
|
+
}
|
|
1089
|
+
),
|
|
1090
|
+
j.map((O) => /* @__PURE__ */ N(
|
|
1091
|
+
Or,
|
|
1092
|
+
{
|
|
1093
|
+
removeAriaLabel: a,
|
|
1094
|
+
file: O,
|
|
1095
|
+
onRemoveFile: G
|
|
1096
|
+
},
|
|
1097
|
+
O.path
|
|
1098
|
+
))
|
|
1099
|
+
] });
|
|
1100
|
+
}
|
|
1101
|
+
export {
|
|
1102
|
+
Rt as InputDropzone
|
|
1103
|
+
};
|