@availity/mui-file-selector 1.7.0 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/index.d.mts +32 -7
- package/dist/index.d.ts +32 -7
- package/dist/index.js +168 -1163
- package/dist/index.mjs +180 -1201
- package/package.json +2 -1
- package/src/lib/Dropzone.tsx +63 -1
- package/src/lib/Dropzone2.tsx +60 -2
- package/src/lib/ErrorAlert.tsx +1 -0
- package/src/lib/FileSelector.tsx +19 -1
- package/src/lib/FileSelector2.tsx +8 -1
- package/src/lib/FileTypesMessage.tsx +14 -0
- package/src/lib/HeaderMessage.tsx +8 -3
package/dist/index.js
CHANGED
|
@@ -34,9 +34,6 @@ var __objRest = (source, exclude) => {
|
|
|
34
34
|
}
|
|
35
35
|
return target;
|
|
36
36
|
};
|
|
37
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
38
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
39
|
-
};
|
|
40
37
|
var __export = (target, all) => {
|
|
41
38
|
for (var name in all)
|
|
42
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -79,135 +76,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
79
76
|
});
|
|
80
77
|
};
|
|
81
78
|
|
|
82
|
-
// ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
|
|
83
|
-
var require_use_sync_external_store_shim_production = __commonJS({
|
|
84
|
-
"../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js"(exports2) {
|
|
85
|
-
"use strict";
|
|
86
|
-
var React6 = require("react");
|
|
87
|
-
function is(x, y) {
|
|
88
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
89
|
-
}
|
|
90
|
-
var objectIs = "function" === typeof Object.is ? Object.is : is;
|
|
91
|
-
var useState7 = React6.useState;
|
|
92
|
-
var useEffect4 = React6.useEffect;
|
|
93
|
-
var useLayoutEffect = React6.useLayoutEffect;
|
|
94
|
-
var useDebugValue = React6.useDebugValue;
|
|
95
|
-
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
96
|
-
var value = getSnapshot(), _useState = useState7({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
|
|
97
|
-
useLayoutEffect(
|
|
98
|
-
function() {
|
|
99
|
-
inst.value = value;
|
|
100
|
-
inst.getSnapshot = getSnapshot;
|
|
101
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
102
|
-
},
|
|
103
|
-
[subscribe, value, getSnapshot]
|
|
104
|
-
);
|
|
105
|
-
useEffect4(
|
|
106
|
-
function() {
|
|
107
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
108
|
-
return subscribe(function() {
|
|
109
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
[subscribe]
|
|
113
|
-
);
|
|
114
|
-
useDebugValue(value);
|
|
115
|
-
return value;
|
|
116
|
-
}
|
|
117
|
-
function checkIfSnapshotChanged(inst) {
|
|
118
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
119
|
-
inst = inst.value;
|
|
120
|
-
try {
|
|
121
|
-
var nextValue = latestGetSnapshot();
|
|
122
|
-
return !objectIs(inst, nextValue);
|
|
123
|
-
} catch (error) {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function useSyncExternalStore$12(subscribe, getSnapshot) {
|
|
128
|
-
return getSnapshot();
|
|
129
|
-
}
|
|
130
|
-
var shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$12 : useSyncExternalStore$2;
|
|
131
|
-
exports2.useSyncExternalStore = void 0 !== React6.useSyncExternalStore ? React6.useSyncExternalStore : shim;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
|
|
136
|
-
var require_use_sync_external_store_shim_development = __commonJS({
|
|
137
|
-
"../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports2) {
|
|
138
|
-
"use strict";
|
|
139
|
-
"production" !== process.env.NODE_ENV && function() {
|
|
140
|
-
function is(x, y) {
|
|
141
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
142
|
-
}
|
|
143
|
-
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
144
|
-
didWarnOld18Alpha || void 0 === React6.startTransition || (didWarnOld18Alpha = true, console.error(
|
|
145
|
-
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
146
|
-
));
|
|
147
|
-
var value = getSnapshot();
|
|
148
|
-
if (!didWarnUncachedGetSnapshot) {
|
|
149
|
-
var cachedValue = getSnapshot();
|
|
150
|
-
objectIs(value, cachedValue) || (console.error(
|
|
151
|
-
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
152
|
-
), didWarnUncachedGetSnapshot = true);
|
|
153
|
-
}
|
|
154
|
-
cachedValue = useState7({
|
|
155
|
-
inst: { value, getSnapshot }
|
|
156
|
-
});
|
|
157
|
-
var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
|
|
158
|
-
useLayoutEffect(
|
|
159
|
-
function() {
|
|
160
|
-
inst.value = value;
|
|
161
|
-
inst.getSnapshot = getSnapshot;
|
|
162
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
163
|
-
},
|
|
164
|
-
[subscribe, value, getSnapshot]
|
|
165
|
-
);
|
|
166
|
-
useEffect4(
|
|
167
|
-
function() {
|
|
168
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
169
|
-
return subscribe(function() {
|
|
170
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
[subscribe]
|
|
174
|
-
);
|
|
175
|
-
useDebugValue(value);
|
|
176
|
-
return value;
|
|
177
|
-
}
|
|
178
|
-
function checkIfSnapshotChanged(inst) {
|
|
179
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
180
|
-
inst = inst.value;
|
|
181
|
-
try {
|
|
182
|
-
var nextValue = latestGetSnapshot();
|
|
183
|
-
return !objectIs(inst, nextValue);
|
|
184
|
-
} catch (error) {
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function useSyncExternalStore$12(subscribe, getSnapshot) {
|
|
189
|
-
return getSnapshot();
|
|
190
|
-
}
|
|
191
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
192
|
-
var React6 = require("react"), objectIs = "function" === typeof Object.is ? Object.is : is, useState7 = React6.useState, useEffect4 = React6.useEffect, useLayoutEffect = React6.useLayoutEffect, useDebugValue = React6.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$12 : useSyncExternalStore$2;
|
|
193
|
-
exports2.useSyncExternalStore = void 0 !== React6.useSyncExternalStore ? React6.useSyncExternalStore : shim;
|
|
194
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
195
|
-
}();
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
// ../../node_modules/use-sync-external-store/shim/index.js
|
|
200
|
-
var require_shim = __commonJS({
|
|
201
|
-
"../../node_modules/use-sync-external-store/shim/index.js"(exports2, module2) {
|
|
202
|
-
"use strict";
|
|
203
|
-
if (process.env.NODE_ENV === "production") {
|
|
204
|
-
module2.exports = require_use_sync_external_store_shim_production();
|
|
205
|
-
} else {
|
|
206
|
-
module2.exports = require_use_sync_external_store_shim_development();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
|
|
211
79
|
// src/index.ts
|
|
212
80
|
var index_exports = {};
|
|
213
81
|
__export(index_exports, {
|
|
@@ -240,7 +108,7 @@ var import_styles = require("@mui/material/styles");
|
|
|
240
108
|
var import_react_dropzone = require("react-dropzone");
|
|
241
109
|
var import_react_hook_form2 = require("react-hook-form");
|
|
242
110
|
var import_mui_divider = require("@availity/mui-divider");
|
|
243
|
-
var
|
|
111
|
+
var import_mui_icon2 = require("@availity/mui-icon");
|
|
244
112
|
var import_mui_layout = require("@availity/mui-layout");
|
|
245
113
|
var import_mui_typography = require("@availity/mui-typography");
|
|
246
114
|
|
|
@@ -298,6 +166,55 @@ var FilePickerBtn = (_a) => {
|
|
|
298
166
|
] });
|
|
299
167
|
};
|
|
300
168
|
|
|
169
|
+
// src/lib/util.ts
|
|
170
|
+
var import_mui_icon = require("@availity/mui-icon");
|
|
171
|
+
function formatBytes(bytes, decimals = 2) {
|
|
172
|
+
if (!+bytes) return "0 Bytes";
|
|
173
|
+
const k = 1024;
|
|
174
|
+
const dm = decimals < 0 ? 0 : decimals;
|
|
175
|
+
const sizes = ["Bytes", "KB", "MB", "GB"];
|
|
176
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
177
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
178
|
+
}
|
|
179
|
+
var FILE_EXT_ICONS = {
|
|
180
|
+
png: import_mui_icon.FileImageIcon,
|
|
181
|
+
jpg: import_mui_icon.FileImageIcon,
|
|
182
|
+
jpeg: import_mui_icon.FileImageIcon,
|
|
183
|
+
gif: import_mui_icon.FileImageIcon,
|
|
184
|
+
csv: import_mui_icon.FileCsvIcon,
|
|
185
|
+
ppt: import_mui_icon.FilePowerpointIcon,
|
|
186
|
+
pptx: import_mui_icon.FilePowerpointIcon,
|
|
187
|
+
xls: import_mui_icon.FileExcelIcon,
|
|
188
|
+
xlsx: import_mui_icon.FileExcelIcon,
|
|
189
|
+
doc: import_mui_icon.FileWordIcon,
|
|
190
|
+
docx: import_mui_icon.FileWordIcon,
|
|
191
|
+
txt: import_mui_icon.FileLinesIcon,
|
|
192
|
+
text: import_mui_icon.FileLinesIcon,
|
|
193
|
+
zip: import_mui_icon.FileArchiveIcon,
|
|
194
|
+
"7zip": import_mui_icon.FileArchiveIcon,
|
|
195
|
+
xml: import_mui_icon.FileCodeIcon,
|
|
196
|
+
html: import_mui_icon.FileCodeIcon,
|
|
197
|
+
pdf: import_mui_icon.FilePdfIcon
|
|
198
|
+
};
|
|
199
|
+
var isValidKey = (key) => key ? key in FILE_EXT_ICONS : false;
|
|
200
|
+
var getFileExtension = (fileName) => {
|
|
201
|
+
var _a;
|
|
202
|
+
return ((_a = fileName.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
|
|
203
|
+
};
|
|
204
|
+
var getFileExtIcon = (fileName) => {
|
|
205
|
+
const ext = getFileExtension(fileName);
|
|
206
|
+
return isValidKey(ext) ? FILE_EXT_ICONS[ext] : import_mui_icon.FileIcon;
|
|
207
|
+
};
|
|
208
|
+
var dedupeErrors = (errors) => {
|
|
209
|
+
const dedupedErrors = errors.reduce((acc, error) => {
|
|
210
|
+
if (!acc.find((err) => err.code === error.code)) {
|
|
211
|
+
acc.push(error);
|
|
212
|
+
}
|
|
213
|
+
return acc;
|
|
214
|
+
}, []);
|
|
215
|
+
return dedupedErrors;
|
|
216
|
+
};
|
|
217
|
+
|
|
301
218
|
// src/lib/Dropzone.tsx
|
|
302
219
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
303
220
|
var outerBoxStyles = {
|
|
@@ -337,6 +254,7 @@ var Dropzone = ({
|
|
|
337
254
|
enableDropArea = true,
|
|
338
255
|
maxFiles,
|
|
339
256
|
maxSize,
|
|
257
|
+
maxTotalSize,
|
|
340
258
|
multiple,
|
|
341
259
|
name,
|
|
342
260
|
onChange,
|
|
@@ -389,7 +307,48 @@ var Dropzone = ({
|
|
|
389
307
|
}
|
|
390
308
|
setTotalSize((prev) => prev + newSize);
|
|
391
309
|
const previous = (_a2 = watch(name)) != null ? _a2 : [];
|
|
392
|
-
|
|
310
|
+
if (maxTotalSize) {
|
|
311
|
+
const currentTotalSize = previous.reduce((sum, file) => sum + file.size, 0);
|
|
312
|
+
let newSize2 = 0;
|
|
313
|
+
const availableSize = Math.max(0, maxTotalSize - currentTotalSize);
|
|
314
|
+
let sizeCounter = 0;
|
|
315
|
+
const cutoffIndex = acceptedFiles.findIndex((file) => {
|
|
316
|
+
sizeCounter += file.size;
|
|
317
|
+
return sizeCounter > availableSize;
|
|
318
|
+
});
|
|
319
|
+
if (cutoffIndex !== -1) {
|
|
320
|
+
const filesToAdd2 = acceptedFiles.slice(0, cutoffIndex === 0 ? 0 : cutoffIndex);
|
|
321
|
+
fileRejections.push({
|
|
322
|
+
file: acceptedFiles[cutoffIndex],
|
|
323
|
+
errors: [
|
|
324
|
+
{
|
|
325
|
+
code: "upload-too-large",
|
|
326
|
+
message: `Total upload size exceeds the limit of ${formatBytes(maxTotalSize)}.`
|
|
327
|
+
}
|
|
328
|
+
],
|
|
329
|
+
id: counter.increment()
|
|
330
|
+
});
|
|
331
|
+
acceptedFiles = filesToAdd2;
|
|
332
|
+
}
|
|
333
|
+
newSize2 = acceptedFiles.reduce((sum, file) => sum + file.size, 0);
|
|
334
|
+
setTotalSize((prev) => prev + newSize2);
|
|
335
|
+
}
|
|
336
|
+
const remainingSlots = maxFiles ? Math.max(0, maxFiles - previous.length) : acceptedFiles.length;
|
|
337
|
+
const filesToAdd = acceptedFiles.slice(0, remainingSlots);
|
|
338
|
+
setValue(name, previous.concat(filesToAdd));
|
|
339
|
+
if (maxFiles && acceptedFiles.length > remainingSlots) {
|
|
340
|
+
fileRejections.push({
|
|
341
|
+
file: acceptedFiles[remainingSlots],
|
|
342
|
+
// Use the first excess file
|
|
343
|
+
errors: [
|
|
344
|
+
{
|
|
345
|
+
code: "too-many-files",
|
|
346
|
+
message: `Too many files. You may only upload ${maxFiles} file(s).`
|
|
347
|
+
}
|
|
348
|
+
],
|
|
349
|
+
id: counter.increment()
|
|
350
|
+
});
|
|
351
|
+
}
|
|
393
352
|
if (fileRejections.length > 0) {
|
|
394
353
|
const TOO_MANY_FILES_CODE = "too-many-files";
|
|
395
354
|
let hasTooManyFiles = false;
|
|
@@ -449,7 +408,7 @@ var Dropzone = ({
|
|
|
449
408
|
};
|
|
450
409
|
const hasFiles = getFieldValue().length > 0;
|
|
451
410
|
return enableDropArea ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DropzoneContainer, __spreadProps(__spreadValues({ sx: outerBoxStyles }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_layout.Box, { sx: innerBoxStyles, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_layout.Stack, { spacing: 2, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
452
|
-
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
411
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_icon2.CloudUploadIcon, { fontSize: "xlarge", color: "secondary" }),
|
|
453
412
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_typography.Typography, { variant: "subtitle2", fontWeight: "700", children: "Drag and Drop Files Here" }),
|
|
454
413
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_divider.Divider, { flexItem: true, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_typography.Typography, { variant: "subtitle2", children: "OR" }) }),
|
|
455
414
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
@@ -475,7 +434,7 @@ var Dropzone = ({
|
|
|
475
434
|
onClick: handleOnClick,
|
|
476
435
|
inputProps,
|
|
477
436
|
onChange: handleOnChange,
|
|
478
|
-
startIcon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
437
|
+
startIcon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_mui_icon2.PlusIcon, {}),
|
|
479
438
|
children: hasFiles ? "Add More Files" : "Add File(s)"
|
|
480
439
|
}
|
|
481
440
|
);
|
|
@@ -490,57 +449,6 @@ var import_mui_icon3 = require("@availity/mui-icon");
|
|
|
490
449
|
var import_mui_layout2 = require("@availity/mui-layout");
|
|
491
450
|
var import_mui_typography2 = require("@availity/mui-typography");
|
|
492
451
|
var import_upload_core = __toESM(require("@availity/upload-core"));
|
|
493
|
-
|
|
494
|
-
// src/lib/util.ts
|
|
495
|
-
var import_mui_icon2 = require("@availity/mui-icon");
|
|
496
|
-
function formatBytes(bytes, decimals = 2) {
|
|
497
|
-
if (!+bytes) return "0 Bytes";
|
|
498
|
-
const k = 1024;
|
|
499
|
-
const dm = decimals < 0 ? 0 : decimals;
|
|
500
|
-
const sizes = ["Bytes", "KB", "MB", "GB"];
|
|
501
|
-
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
502
|
-
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
|
|
503
|
-
}
|
|
504
|
-
var FILE_EXT_ICONS = {
|
|
505
|
-
png: import_mui_icon2.FileImageIcon,
|
|
506
|
-
jpg: import_mui_icon2.FileImageIcon,
|
|
507
|
-
jpeg: import_mui_icon2.FileImageIcon,
|
|
508
|
-
gif: import_mui_icon2.FileImageIcon,
|
|
509
|
-
csv: import_mui_icon2.FileCsvIcon,
|
|
510
|
-
ppt: import_mui_icon2.FilePowerpointIcon,
|
|
511
|
-
pptx: import_mui_icon2.FilePowerpointIcon,
|
|
512
|
-
xls: import_mui_icon2.FileExcelIcon,
|
|
513
|
-
xlsx: import_mui_icon2.FileExcelIcon,
|
|
514
|
-
doc: import_mui_icon2.FileWordIcon,
|
|
515
|
-
docx: import_mui_icon2.FileWordIcon,
|
|
516
|
-
txt: import_mui_icon2.FileLinesIcon,
|
|
517
|
-
text: import_mui_icon2.FileLinesIcon,
|
|
518
|
-
zip: import_mui_icon2.FileArchiveIcon,
|
|
519
|
-
"7zip": import_mui_icon2.FileArchiveIcon,
|
|
520
|
-
xml: import_mui_icon2.FileCodeIcon,
|
|
521
|
-
html: import_mui_icon2.FileCodeIcon,
|
|
522
|
-
pdf: import_mui_icon2.FilePdfIcon
|
|
523
|
-
};
|
|
524
|
-
var isValidKey = (key) => key ? key in FILE_EXT_ICONS : false;
|
|
525
|
-
var getFileExtension = (fileName) => {
|
|
526
|
-
var _a;
|
|
527
|
-
return ((_a = fileName.split(".").pop()) == null ? void 0 : _a.toLowerCase()) || "";
|
|
528
|
-
};
|
|
529
|
-
var getFileExtIcon = (fileName) => {
|
|
530
|
-
const ext = getFileExtension(fileName);
|
|
531
|
-
return isValidKey(ext) ? FILE_EXT_ICONS[ext] : import_mui_icon2.FileIcon;
|
|
532
|
-
};
|
|
533
|
-
var dedupeErrors = (errors) => {
|
|
534
|
-
const dedupedErrors = errors.reduce((acc, error) => {
|
|
535
|
-
if (!acc.find((err) => err.code === error.code)) {
|
|
536
|
-
acc.push(error);
|
|
537
|
-
}
|
|
538
|
-
return acc;
|
|
539
|
-
}, []);
|
|
540
|
-
return dedupedErrors;
|
|
541
|
-
};
|
|
542
|
-
|
|
543
|
-
// src/lib/Dropzone2.tsx
|
|
544
452
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
545
453
|
var counter2 = createCounter();
|
|
546
454
|
function startUpload(file, options) {
|
|
@@ -562,6 +470,7 @@ var Dropzone2 = ({
|
|
|
562
470
|
enableDropArea = true,
|
|
563
471
|
maxFiles,
|
|
564
472
|
maxSize,
|
|
473
|
+
maxTotalSize,
|
|
565
474
|
multiple,
|
|
566
475
|
name,
|
|
567
476
|
onChange,
|
|
@@ -616,8 +525,50 @@ var Dropzone2 = ({
|
|
|
616
525
|
}
|
|
617
526
|
setTotalSize((prev) => prev + newSize);
|
|
618
527
|
const previous = (_a2 = watch(name)) != null ? _a2 : [];
|
|
619
|
-
|
|
528
|
+
if (maxTotalSize) {
|
|
529
|
+
const currentTotalSize = previous.reduce((sum, upload) => sum + upload.file.size, 0);
|
|
530
|
+
console.log({ previous });
|
|
531
|
+
let newSize2 = 0;
|
|
532
|
+
const availableSize = Math.max(0, maxTotalSize - currentTotalSize);
|
|
533
|
+
let sizeCounter = 0;
|
|
534
|
+
const cutoffIndex = acceptedFiles.findIndex((file) => {
|
|
535
|
+
sizeCounter += file.size;
|
|
536
|
+
return sizeCounter > availableSize;
|
|
537
|
+
});
|
|
538
|
+
if (cutoffIndex !== -1) {
|
|
539
|
+
const filesToAdd2 = acceptedFiles.slice(0, cutoffIndex === 0 ? 0 : cutoffIndex);
|
|
540
|
+
fileRejections.push({
|
|
541
|
+
file: acceptedFiles[cutoffIndex],
|
|
542
|
+
errors: [
|
|
543
|
+
{
|
|
544
|
+
code: "upload-too-large",
|
|
545
|
+
message: `Total upload size exceeds the limit of ${formatBytes(maxTotalSize)}.`
|
|
546
|
+
}
|
|
547
|
+
],
|
|
548
|
+
id: counter2.increment()
|
|
549
|
+
});
|
|
550
|
+
acceptedFiles = filesToAdd2;
|
|
551
|
+
}
|
|
552
|
+
newSize2 = acceptedFiles.reduce((sum, file) => sum + file.size, 0);
|
|
553
|
+
setTotalSize((prev) => prev + newSize2);
|
|
554
|
+
}
|
|
555
|
+
const remainingSlots = maxFiles ? Math.max(0, maxFiles - previous.length) : acceptedFiles.length;
|
|
556
|
+
const filesToAdd = acceptedFiles.slice(0, remainingSlots);
|
|
557
|
+
const uploads = filesToAdd.map((file) => startUpload(file, uploadOptions));
|
|
620
558
|
setValue(name, previous.concat(yield Promise.all(uploads)));
|
|
559
|
+
if (maxFiles && acceptedFiles.length > remainingSlots) {
|
|
560
|
+
fileRejections.push({
|
|
561
|
+
file: acceptedFiles[remainingSlots],
|
|
562
|
+
// Use the first excess file
|
|
563
|
+
errors: [
|
|
564
|
+
{
|
|
565
|
+
code: "too-many-files",
|
|
566
|
+
message: `Too many files. You may only upload ${maxFiles} file(s).`
|
|
567
|
+
}
|
|
568
|
+
],
|
|
569
|
+
id: counter2.increment()
|
|
570
|
+
});
|
|
571
|
+
}
|
|
621
572
|
if (fileRejections.length > 0) {
|
|
622
573
|
const TOO_MANY_FILES_CODE = "too-many-files";
|
|
623
574
|
let hasTooManyFiles = false;
|
|
@@ -714,6 +665,7 @@ var import_mui_list = require("@availity/mui-list");
|
|
|
714
665
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
715
666
|
var codes = {
|
|
716
667
|
"file-too-large": "File exceeds maximum size",
|
|
668
|
+
"upload-too-large": "File causes maximum total upload size to be exceeded",
|
|
717
669
|
"file-invalid-type": "File has an invalid type",
|
|
718
670
|
"file-too-small": "File is smaller than minimum size",
|
|
719
671
|
"too-many-file": "Too many files",
|
|
@@ -1045,952 +997,8 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
|
1045
997
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_progress.LinearProgress, { value: statePercentage, "aria-label": `${upload.file.name}-progress` });
|
|
1046
998
|
};
|
|
1047
999
|
|
|
1048
|
-
// ../../node_modules/@tanstack/query-core/build/lib/subscribable.mjs
|
|
1049
|
-
var Subscribable = class {
|
|
1050
|
-
constructor() {
|
|
1051
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
1052
|
-
this.subscribe = this.subscribe.bind(this);
|
|
1053
|
-
}
|
|
1054
|
-
subscribe(listener) {
|
|
1055
|
-
const identity = {
|
|
1056
|
-
listener
|
|
1057
|
-
};
|
|
1058
|
-
this.listeners.add(identity);
|
|
1059
|
-
this.onSubscribe();
|
|
1060
|
-
return () => {
|
|
1061
|
-
this.listeners.delete(identity);
|
|
1062
|
-
this.onUnsubscribe();
|
|
1063
|
-
};
|
|
1064
|
-
}
|
|
1065
|
-
hasListeners() {
|
|
1066
|
-
return this.listeners.size > 0;
|
|
1067
|
-
}
|
|
1068
|
-
onSubscribe() {
|
|
1069
|
-
}
|
|
1070
|
-
onUnsubscribe() {
|
|
1071
|
-
}
|
|
1072
|
-
};
|
|
1073
|
-
|
|
1074
|
-
// ../../node_modules/@tanstack/query-core/build/lib/utils.mjs
|
|
1075
|
-
var isServer = typeof window === "undefined" || "Deno" in window;
|
|
1076
|
-
function noop() {
|
|
1077
|
-
return void 0;
|
|
1078
|
-
}
|
|
1079
|
-
function isValidTimeout(value) {
|
|
1080
|
-
return typeof value === "number" && value >= 0 && value !== Infinity;
|
|
1081
|
-
}
|
|
1082
|
-
function timeUntilStale(updatedAt, staleTime) {
|
|
1083
|
-
return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
|
|
1084
|
-
}
|
|
1085
|
-
function parseQueryArgs(arg1, arg2, arg3) {
|
|
1086
|
-
if (!isQueryKey(arg1)) {
|
|
1087
|
-
return arg1;
|
|
1088
|
-
}
|
|
1089
|
-
if (typeof arg2 === "function") {
|
|
1090
|
-
return __spreadProps(__spreadValues({}, arg3), {
|
|
1091
|
-
queryKey: arg1,
|
|
1092
|
-
queryFn: arg2
|
|
1093
|
-
});
|
|
1094
|
-
}
|
|
1095
|
-
return __spreadProps(__spreadValues({}, arg2), {
|
|
1096
|
-
queryKey: arg1
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
function replaceEqualDeep(a, b) {
|
|
1100
|
-
if (a === b) {
|
|
1101
|
-
return a;
|
|
1102
|
-
}
|
|
1103
|
-
const array = isPlainArray(a) && isPlainArray(b);
|
|
1104
|
-
if (array || isPlainObject(a) && isPlainObject(b)) {
|
|
1105
|
-
const aSize = array ? a.length : Object.keys(a).length;
|
|
1106
|
-
const bItems = array ? b : Object.keys(b);
|
|
1107
|
-
const bSize = bItems.length;
|
|
1108
|
-
const copy = array ? [] : {};
|
|
1109
|
-
let equalItems = 0;
|
|
1110
|
-
for (let i = 0; i < bSize; i++) {
|
|
1111
|
-
const key = array ? i : bItems[i];
|
|
1112
|
-
copy[key] = replaceEqualDeep(a[key], b[key]);
|
|
1113
|
-
if (copy[key] === a[key]) {
|
|
1114
|
-
equalItems++;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
return aSize === bSize && equalItems === aSize ? a : copy;
|
|
1118
|
-
}
|
|
1119
|
-
return b;
|
|
1120
|
-
}
|
|
1121
|
-
function shallowEqualObjects(a, b) {
|
|
1122
|
-
if (a && !b || b && !a) {
|
|
1123
|
-
return false;
|
|
1124
|
-
}
|
|
1125
|
-
for (const key in a) {
|
|
1126
|
-
if (a[key] !== b[key]) {
|
|
1127
|
-
return false;
|
|
1128
|
-
}
|
|
1129
|
-
}
|
|
1130
|
-
return true;
|
|
1131
|
-
}
|
|
1132
|
-
function isPlainArray(value) {
|
|
1133
|
-
return Array.isArray(value) && value.length === Object.keys(value).length;
|
|
1134
|
-
}
|
|
1135
|
-
function isPlainObject(o) {
|
|
1136
|
-
if (!hasObjectPrototype(o)) {
|
|
1137
|
-
return false;
|
|
1138
|
-
}
|
|
1139
|
-
const ctor = o.constructor;
|
|
1140
|
-
if (typeof ctor === "undefined") {
|
|
1141
|
-
return true;
|
|
1142
|
-
}
|
|
1143
|
-
const prot = ctor.prototype;
|
|
1144
|
-
if (!hasObjectPrototype(prot)) {
|
|
1145
|
-
return false;
|
|
1146
|
-
}
|
|
1147
|
-
if (!prot.hasOwnProperty("isPrototypeOf")) {
|
|
1148
|
-
return false;
|
|
1149
|
-
}
|
|
1150
|
-
return true;
|
|
1151
|
-
}
|
|
1152
|
-
function hasObjectPrototype(o) {
|
|
1153
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
1154
|
-
}
|
|
1155
|
-
function isQueryKey(value) {
|
|
1156
|
-
return Array.isArray(value);
|
|
1157
|
-
}
|
|
1158
|
-
function sleep(timeout) {
|
|
1159
|
-
return new Promise((resolve) => {
|
|
1160
|
-
setTimeout(resolve, timeout);
|
|
1161
|
-
});
|
|
1162
|
-
}
|
|
1163
|
-
function scheduleMicrotask(callback) {
|
|
1164
|
-
sleep(0).then(callback);
|
|
1165
|
-
}
|
|
1166
|
-
function replaceData(prevData, data, options) {
|
|
1167
|
-
if (options.isDataEqual != null && options.isDataEqual(prevData, data)) {
|
|
1168
|
-
return prevData;
|
|
1169
|
-
} else if (typeof options.structuralSharing === "function") {
|
|
1170
|
-
return options.structuralSharing(prevData, data);
|
|
1171
|
-
} else if (options.structuralSharing !== false) {
|
|
1172
|
-
return replaceEqualDeep(prevData, data);
|
|
1173
|
-
}
|
|
1174
|
-
return data;
|
|
1175
|
-
}
|
|
1176
|
-
|
|
1177
|
-
// ../../node_modules/@tanstack/query-core/build/lib/focusManager.mjs
|
|
1178
|
-
var FocusManager = class extends Subscribable {
|
|
1179
|
-
constructor() {
|
|
1180
|
-
super();
|
|
1181
|
-
this.setup = (onFocus) => {
|
|
1182
|
-
if (!isServer && window.addEventListener) {
|
|
1183
|
-
const listener = () => onFocus();
|
|
1184
|
-
window.addEventListener("visibilitychange", listener, false);
|
|
1185
|
-
window.addEventListener("focus", listener, false);
|
|
1186
|
-
return () => {
|
|
1187
|
-
window.removeEventListener("visibilitychange", listener);
|
|
1188
|
-
window.removeEventListener("focus", listener);
|
|
1189
|
-
};
|
|
1190
|
-
}
|
|
1191
|
-
return;
|
|
1192
|
-
};
|
|
1193
|
-
}
|
|
1194
|
-
onSubscribe() {
|
|
1195
|
-
if (!this.cleanup) {
|
|
1196
|
-
this.setEventListener(this.setup);
|
|
1197
|
-
}
|
|
1198
|
-
}
|
|
1199
|
-
onUnsubscribe() {
|
|
1200
|
-
if (!this.hasListeners()) {
|
|
1201
|
-
var _this$cleanup;
|
|
1202
|
-
(_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
|
|
1203
|
-
this.cleanup = void 0;
|
|
1204
|
-
}
|
|
1205
|
-
}
|
|
1206
|
-
setEventListener(setup) {
|
|
1207
|
-
var _this$cleanup2;
|
|
1208
|
-
this.setup = setup;
|
|
1209
|
-
(_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
|
|
1210
|
-
this.cleanup = setup((focused) => {
|
|
1211
|
-
if (typeof focused === "boolean") {
|
|
1212
|
-
this.setFocused(focused);
|
|
1213
|
-
} else {
|
|
1214
|
-
this.onFocus();
|
|
1215
|
-
}
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
setFocused(focused) {
|
|
1219
|
-
const changed = this.focused !== focused;
|
|
1220
|
-
if (changed) {
|
|
1221
|
-
this.focused = focused;
|
|
1222
|
-
this.onFocus();
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
onFocus() {
|
|
1226
|
-
this.listeners.forEach(({
|
|
1227
|
-
listener
|
|
1228
|
-
}) => {
|
|
1229
|
-
listener();
|
|
1230
|
-
});
|
|
1231
|
-
}
|
|
1232
|
-
isFocused() {
|
|
1233
|
-
if (typeof this.focused === "boolean") {
|
|
1234
|
-
return this.focused;
|
|
1235
|
-
}
|
|
1236
|
-
if (typeof document === "undefined") {
|
|
1237
|
-
return true;
|
|
1238
|
-
}
|
|
1239
|
-
return [void 0, "visible", "prerender"].includes(document.visibilityState);
|
|
1240
|
-
}
|
|
1241
|
-
};
|
|
1242
|
-
var focusManager = new FocusManager();
|
|
1243
|
-
|
|
1244
|
-
// ../../node_modules/@tanstack/query-core/build/lib/onlineManager.mjs
|
|
1245
|
-
var onlineEvents = ["online", "offline"];
|
|
1246
|
-
var OnlineManager = class extends Subscribable {
|
|
1247
|
-
constructor() {
|
|
1248
|
-
super();
|
|
1249
|
-
this.setup = (onOnline) => {
|
|
1250
|
-
if (!isServer && window.addEventListener) {
|
|
1251
|
-
const listener = () => onOnline();
|
|
1252
|
-
onlineEvents.forEach((event) => {
|
|
1253
|
-
window.addEventListener(event, listener, false);
|
|
1254
|
-
});
|
|
1255
|
-
return () => {
|
|
1256
|
-
onlineEvents.forEach((event) => {
|
|
1257
|
-
window.removeEventListener(event, listener);
|
|
1258
|
-
});
|
|
1259
|
-
};
|
|
1260
|
-
}
|
|
1261
|
-
return;
|
|
1262
|
-
};
|
|
1263
|
-
}
|
|
1264
|
-
onSubscribe() {
|
|
1265
|
-
if (!this.cleanup) {
|
|
1266
|
-
this.setEventListener(this.setup);
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
onUnsubscribe() {
|
|
1270
|
-
if (!this.hasListeners()) {
|
|
1271
|
-
var _this$cleanup;
|
|
1272
|
-
(_this$cleanup = this.cleanup) == null ? void 0 : _this$cleanup.call(this);
|
|
1273
|
-
this.cleanup = void 0;
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
setEventListener(setup) {
|
|
1277
|
-
var _this$cleanup2;
|
|
1278
|
-
this.setup = setup;
|
|
1279
|
-
(_this$cleanup2 = this.cleanup) == null ? void 0 : _this$cleanup2.call(this);
|
|
1280
|
-
this.cleanup = setup((online) => {
|
|
1281
|
-
if (typeof online === "boolean") {
|
|
1282
|
-
this.setOnline(online);
|
|
1283
|
-
} else {
|
|
1284
|
-
this.onOnline();
|
|
1285
|
-
}
|
|
1286
|
-
});
|
|
1287
|
-
}
|
|
1288
|
-
setOnline(online) {
|
|
1289
|
-
const changed = this.online !== online;
|
|
1290
|
-
if (changed) {
|
|
1291
|
-
this.online = online;
|
|
1292
|
-
this.onOnline();
|
|
1293
|
-
}
|
|
1294
|
-
}
|
|
1295
|
-
onOnline() {
|
|
1296
|
-
this.listeners.forEach(({
|
|
1297
|
-
listener
|
|
1298
|
-
}) => {
|
|
1299
|
-
listener();
|
|
1300
|
-
});
|
|
1301
|
-
}
|
|
1302
|
-
isOnline() {
|
|
1303
|
-
if (typeof this.online === "boolean") {
|
|
1304
|
-
return this.online;
|
|
1305
|
-
}
|
|
1306
|
-
if (typeof navigator === "undefined" || typeof navigator.onLine === "undefined") {
|
|
1307
|
-
return true;
|
|
1308
|
-
}
|
|
1309
|
-
return navigator.onLine;
|
|
1310
|
-
}
|
|
1311
|
-
};
|
|
1312
|
-
var onlineManager = new OnlineManager();
|
|
1313
|
-
|
|
1314
|
-
// ../../node_modules/@tanstack/query-core/build/lib/retryer.mjs
|
|
1315
|
-
function canFetch(networkMode) {
|
|
1316
|
-
return (networkMode != null ? networkMode : "online") === "online" ? onlineManager.isOnline() : true;
|
|
1317
|
-
}
|
|
1318
|
-
var CancelledError = class {
|
|
1319
|
-
constructor(options) {
|
|
1320
|
-
this.revert = options == null ? void 0 : options.revert;
|
|
1321
|
-
this.silent = options == null ? void 0 : options.silent;
|
|
1322
|
-
}
|
|
1323
|
-
};
|
|
1324
|
-
function isCancelledError(value) {
|
|
1325
|
-
return value instanceof CancelledError;
|
|
1326
|
-
}
|
|
1327
|
-
|
|
1328
|
-
// ../../node_modules/@tanstack/query-core/build/lib/notifyManager.mjs
|
|
1329
|
-
function createNotifyManager() {
|
|
1330
|
-
let queue = [];
|
|
1331
|
-
let transactions = 0;
|
|
1332
|
-
let notifyFn = (callback) => {
|
|
1333
|
-
callback();
|
|
1334
|
-
};
|
|
1335
|
-
let batchNotifyFn = (callback) => {
|
|
1336
|
-
callback();
|
|
1337
|
-
};
|
|
1338
|
-
const batch = (callback) => {
|
|
1339
|
-
let result;
|
|
1340
|
-
transactions++;
|
|
1341
|
-
try {
|
|
1342
|
-
result = callback();
|
|
1343
|
-
} finally {
|
|
1344
|
-
transactions--;
|
|
1345
|
-
if (!transactions) {
|
|
1346
|
-
flush();
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
return result;
|
|
1350
|
-
};
|
|
1351
|
-
const schedule = (callback) => {
|
|
1352
|
-
if (transactions) {
|
|
1353
|
-
queue.push(callback);
|
|
1354
|
-
} else {
|
|
1355
|
-
scheduleMicrotask(() => {
|
|
1356
|
-
notifyFn(callback);
|
|
1357
|
-
});
|
|
1358
|
-
}
|
|
1359
|
-
};
|
|
1360
|
-
const batchCalls = (callback) => {
|
|
1361
|
-
return (...args) => {
|
|
1362
|
-
schedule(() => {
|
|
1363
|
-
callback(...args);
|
|
1364
|
-
});
|
|
1365
|
-
};
|
|
1366
|
-
};
|
|
1367
|
-
const flush = () => {
|
|
1368
|
-
const originalQueue = queue;
|
|
1369
|
-
queue = [];
|
|
1370
|
-
if (originalQueue.length) {
|
|
1371
|
-
scheduleMicrotask(() => {
|
|
1372
|
-
batchNotifyFn(() => {
|
|
1373
|
-
originalQueue.forEach((callback) => {
|
|
1374
|
-
notifyFn(callback);
|
|
1375
|
-
});
|
|
1376
|
-
});
|
|
1377
|
-
});
|
|
1378
|
-
}
|
|
1379
|
-
};
|
|
1380
|
-
const setNotifyFunction = (fn) => {
|
|
1381
|
-
notifyFn = fn;
|
|
1382
|
-
};
|
|
1383
|
-
const setBatchNotifyFunction = (fn) => {
|
|
1384
|
-
batchNotifyFn = fn;
|
|
1385
|
-
};
|
|
1386
|
-
return {
|
|
1387
|
-
batch,
|
|
1388
|
-
batchCalls,
|
|
1389
|
-
schedule,
|
|
1390
|
-
setNotifyFunction,
|
|
1391
|
-
setBatchNotifyFunction
|
|
1392
|
-
};
|
|
1393
|
-
}
|
|
1394
|
-
var notifyManager = createNotifyManager();
|
|
1395
|
-
|
|
1396
|
-
// ../../node_modules/@tanstack/query-core/build/lib/queryObserver.mjs
|
|
1397
|
-
var QueryObserver = class extends Subscribable {
|
|
1398
|
-
constructor(client, options) {
|
|
1399
|
-
super();
|
|
1400
|
-
this.client = client;
|
|
1401
|
-
this.options = options;
|
|
1402
|
-
this.trackedProps = /* @__PURE__ */ new Set();
|
|
1403
|
-
this.selectError = null;
|
|
1404
|
-
this.bindMethods();
|
|
1405
|
-
this.setOptions(options);
|
|
1406
|
-
}
|
|
1407
|
-
bindMethods() {
|
|
1408
|
-
this.remove = this.remove.bind(this);
|
|
1409
|
-
this.refetch = this.refetch.bind(this);
|
|
1410
|
-
}
|
|
1411
|
-
onSubscribe() {
|
|
1412
|
-
if (this.listeners.size === 1) {
|
|
1413
|
-
this.currentQuery.addObserver(this);
|
|
1414
|
-
if (shouldFetchOnMount(this.currentQuery, this.options)) {
|
|
1415
|
-
this.executeFetch();
|
|
1416
|
-
}
|
|
1417
|
-
this.updateTimers();
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
onUnsubscribe() {
|
|
1421
|
-
if (!this.hasListeners()) {
|
|
1422
|
-
this.destroy();
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
shouldFetchOnReconnect() {
|
|
1426
|
-
return shouldFetchOn(this.currentQuery, this.options, this.options.refetchOnReconnect);
|
|
1427
|
-
}
|
|
1428
|
-
shouldFetchOnWindowFocus() {
|
|
1429
|
-
return shouldFetchOn(this.currentQuery, this.options, this.options.refetchOnWindowFocus);
|
|
1430
|
-
}
|
|
1431
|
-
destroy() {
|
|
1432
|
-
this.listeners = /* @__PURE__ */ new Set();
|
|
1433
|
-
this.clearStaleTimeout();
|
|
1434
|
-
this.clearRefetchInterval();
|
|
1435
|
-
this.currentQuery.removeObserver(this);
|
|
1436
|
-
}
|
|
1437
|
-
setOptions(options, notifyOptions) {
|
|
1438
|
-
const prevOptions = this.options;
|
|
1439
|
-
const prevQuery = this.currentQuery;
|
|
1440
|
-
this.options = this.client.defaultQueryOptions(options);
|
|
1441
|
-
if (process.env.NODE_ENV !== "production" && typeof (options == null ? void 0 : options.isDataEqual) !== "undefined") {
|
|
1442
|
-
this.client.getLogger().error("The isDataEqual option has been deprecated and will be removed in the next major version. You can achieve the same functionality by passing a function as the structuralSharing option");
|
|
1443
|
-
}
|
|
1444
|
-
if (!shallowEqualObjects(prevOptions, this.options)) {
|
|
1445
|
-
this.client.getQueryCache().notify({
|
|
1446
|
-
type: "observerOptionsUpdated",
|
|
1447
|
-
query: this.currentQuery,
|
|
1448
|
-
observer: this
|
|
1449
|
-
});
|
|
1450
|
-
}
|
|
1451
|
-
if (typeof this.options.enabled !== "undefined" && typeof this.options.enabled !== "boolean") {
|
|
1452
|
-
throw new Error("Expected enabled to be a boolean");
|
|
1453
|
-
}
|
|
1454
|
-
if (!this.options.queryKey) {
|
|
1455
|
-
this.options.queryKey = prevOptions.queryKey;
|
|
1456
|
-
}
|
|
1457
|
-
this.updateQuery();
|
|
1458
|
-
const mounted = this.hasListeners();
|
|
1459
|
-
if (mounted && shouldFetchOptionally(this.currentQuery, prevQuery, this.options, prevOptions)) {
|
|
1460
|
-
this.executeFetch();
|
|
1461
|
-
}
|
|
1462
|
-
this.updateResult(notifyOptions);
|
|
1463
|
-
if (mounted && (this.currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || this.options.staleTime !== prevOptions.staleTime)) {
|
|
1464
|
-
this.updateStaleTimeout();
|
|
1465
|
-
}
|
|
1466
|
-
const nextRefetchInterval = this.computeRefetchInterval();
|
|
1467
|
-
if (mounted && (this.currentQuery !== prevQuery || this.options.enabled !== prevOptions.enabled || nextRefetchInterval !== this.currentRefetchInterval)) {
|
|
1468
|
-
this.updateRefetchInterval(nextRefetchInterval);
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
getOptimisticResult(options) {
|
|
1472
|
-
const query = this.client.getQueryCache().build(this.client, options);
|
|
1473
|
-
const result = this.createResult(query, options);
|
|
1474
|
-
if (shouldAssignObserverCurrentProperties(this, result, options)) {
|
|
1475
|
-
this.currentResult = result;
|
|
1476
|
-
this.currentResultOptions = this.options;
|
|
1477
|
-
this.currentResultState = this.currentQuery.state;
|
|
1478
|
-
}
|
|
1479
|
-
return result;
|
|
1480
|
-
}
|
|
1481
|
-
getCurrentResult() {
|
|
1482
|
-
return this.currentResult;
|
|
1483
|
-
}
|
|
1484
|
-
trackResult(result) {
|
|
1485
|
-
const trackedResult = {};
|
|
1486
|
-
Object.keys(result).forEach((key) => {
|
|
1487
|
-
Object.defineProperty(trackedResult, key, {
|
|
1488
|
-
configurable: false,
|
|
1489
|
-
enumerable: true,
|
|
1490
|
-
get: () => {
|
|
1491
|
-
this.trackedProps.add(key);
|
|
1492
|
-
return result[key];
|
|
1493
|
-
}
|
|
1494
|
-
});
|
|
1495
|
-
});
|
|
1496
|
-
return trackedResult;
|
|
1497
|
-
}
|
|
1498
|
-
getCurrentQuery() {
|
|
1499
|
-
return this.currentQuery;
|
|
1500
|
-
}
|
|
1501
|
-
remove() {
|
|
1502
|
-
this.client.getQueryCache().remove(this.currentQuery);
|
|
1503
|
-
}
|
|
1504
|
-
refetch(_a = {}) {
|
|
1505
|
-
var _b = _a, {
|
|
1506
|
-
refetchPage
|
|
1507
|
-
} = _b, options = __objRest(_b, [
|
|
1508
|
-
"refetchPage"
|
|
1509
|
-
]);
|
|
1510
|
-
return this.fetch(__spreadProps(__spreadValues({}, options), {
|
|
1511
|
-
meta: {
|
|
1512
|
-
refetchPage
|
|
1513
|
-
}
|
|
1514
|
-
}));
|
|
1515
|
-
}
|
|
1516
|
-
fetchOptimistic(options) {
|
|
1517
|
-
const defaultedOptions = this.client.defaultQueryOptions(options);
|
|
1518
|
-
const query = this.client.getQueryCache().build(this.client, defaultedOptions);
|
|
1519
|
-
query.isFetchingOptimistic = true;
|
|
1520
|
-
return query.fetch().then(() => this.createResult(query, defaultedOptions));
|
|
1521
|
-
}
|
|
1522
|
-
fetch(fetchOptions) {
|
|
1523
|
-
var _fetchOptions$cancelR;
|
|
1524
|
-
return this.executeFetch(__spreadProps(__spreadValues({}, fetchOptions), {
|
|
1525
|
-
cancelRefetch: (_fetchOptions$cancelR = fetchOptions.cancelRefetch) != null ? _fetchOptions$cancelR : true
|
|
1526
|
-
})).then(() => {
|
|
1527
|
-
this.updateResult();
|
|
1528
|
-
return this.currentResult;
|
|
1529
|
-
});
|
|
1530
|
-
}
|
|
1531
|
-
executeFetch(fetchOptions) {
|
|
1532
|
-
this.updateQuery();
|
|
1533
|
-
let promise = this.currentQuery.fetch(this.options, fetchOptions);
|
|
1534
|
-
if (!(fetchOptions != null && fetchOptions.throwOnError)) {
|
|
1535
|
-
promise = promise.catch(noop);
|
|
1536
|
-
}
|
|
1537
|
-
return promise;
|
|
1538
|
-
}
|
|
1539
|
-
updateStaleTimeout() {
|
|
1540
|
-
this.clearStaleTimeout();
|
|
1541
|
-
if (isServer || this.currentResult.isStale || !isValidTimeout(this.options.staleTime)) {
|
|
1542
|
-
return;
|
|
1543
|
-
}
|
|
1544
|
-
const time = timeUntilStale(this.currentResult.dataUpdatedAt, this.options.staleTime);
|
|
1545
|
-
const timeout = time + 1;
|
|
1546
|
-
this.staleTimeoutId = setTimeout(() => {
|
|
1547
|
-
if (!this.currentResult.isStale) {
|
|
1548
|
-
this.updateResult();
|
|
1549
|
-
}
|
|
1550
|
-
}, timeout);
|
|
1551
|
-
}
|
|
1552
|
-
computeRefetchInterval() {
|
|
1553
|
-
var _this$options$refetch;
|
|
1554
|
-
return typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(this.currentResult.data, this.currentQuery) : (_this$options$refetch = this.options.refetchInterval) != null ? _this$options$refetch : false;
|
|
1555
|
-
}
|
|
1556
|
-
updateRefetchInterval(nextInterval) {
|
|
1557
|
-
this.clearRefetchInterval();
|
|
1558
|
-
this.currentRefetchInterval = nextInterval;
|
|
1559
|
-
if (isServer || this.options.enabled === false || !isValidTimeout(this.currentRefetchInterval) || this.currentRefetchInterval === 0) {
|
|
1560
|
-
return;
|
|
1561
|
-
}
|
|
1562
|
-
this.refetchIntervalId = setInterval(() => {
|
|
1563
|
-
if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
|
|
1564
|
-
this.executeFetch();
|
|
1565
|
-
}
|
|
1566
|
-
}, this.currentRefetchInterval);
|
|
1567
|
-
}
|
|
1568
|
-
updateTimers() {
|
|
1569
|
-
this.updateStaleTimeout();
|
|
1570
|
-
this.updateRefetchInterval(this.computeRefetchInterval());
|
|
1571
|
-
}
|
|
1572
|
-
clearStaleTimeout() {
|
|
1573
|
-
if (this.staleTimeoutId) {
|
|
1574
|
-
clearTimeout(this.staleTimeoutId);
|
|
1575
|
-
this.staleTimeoutId = void 0;
|
|
1576
|
-
}
|
|
1577
|
-
}
|
|
1578
|
-
clearRefetchInterval() {
|
|
1579
|
-
if (this.refetchIntervalId) {
|
|
1580
|
-
clearInterval(this.refetchIntervalId);
|
|
1581
|
-
this.refetchIntervalId = void 0;
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
createResult(query, options) {
|
|
1585
|
-
const prevQuery = this.currentQuery;
|
|
1586
|
-
const prevOptions = this.options;
|
|
1587
|
-
const prevResult = this.currentResult;
|
|
1588
|
-
const prevResultState = this.currentResultState;
|
|
1589
|
-
const prevResultOptions = this.currentResultOptions;
|
|
1590
|
-
const queryChange = query !== prevQuery;
|
|
1591
|
-
const queryInitialState = queryChange ? query.state : this.currentQueryInitialState;
|
|
1592
|
-
const prevQueryResult = queryChange ? this.currentResult : this.previousQueryResult;
|
|
1593
|
-
const {
|
|
1594
|
-
state
|
|
1595
|
-
} = query;
|
|
1596
|
-
let {
|
|
1597
|
-
dataUpdatedAt,
|
|
1598
|
-
error,
|
|
1599
|
-
errorUpdatedAt,
|
|
1600
|
-
fetchStatus,
|
|
1601
|
-
status
|
|
1602
|
-
} = state;
|
|
1603
|
-
let isPreviousData = false;
|
|
1604
|
-
let isPlaceholderData = false;
|
|
1605
|
-
let data;
|
|
1606
|
-
if (options._optimisticResults) {
|
|
1607
|
-
const mounted = this.hasListeners();
|
|
1608
|
-
const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
|
|
1609
|
-
const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
|
|
1610
|
-
if (fetchOnMount || fetchOptionally) {
|
|
1611
|
-
fetchStatus = canFetch(query.options.networkMode) ? "fetching" : "paused";
|
|
1612
|
-
if (!dataUpdatedAt) {
|
|
1613
|
-
status = "loading";
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
if (options._optimisticResults === "isRestoring") {
|
|
1617
|
-
fetchStatus = "idle";
|
|
1618
|
-
}
|
|
1619
|
-
}
|
|
1620
|
-
if (options.keepPreviousData && !state.dataUpdatedAt && prevQueryResult != null && prevQueryResult.isSuccess && status !== "error") {
|
|
1621
|
-
data = prevQueryResult.data;
|
|
1622
|
-
dataUpdatedAt = prevQueryResult.dataUpdatedAt;
|
|
1623
|
-
status = prevQueryResult.status;
|
|
1624
|
-
isPreviousData = true;
|
|
1625
|
-
} else if (options.select && typeof state.data !== "undefined") {
|
|
1626
|
-
if (prevResult && state.data === (prevResultState == null ? void 0 : prevResultState.data) && options.select === this.selectFn) {
|
|
1627
|
-
data = this.selectResult;
|
|
1628
|
-
} else {
|
|
1629
|
-
try {
|
|
1630
|
-
this.selectFn = options.select;
|
|
1631
|
-
data = options.select(state.data);
|
|
1632
|
-
data = replaceData(prevResult == null ? void 0 : prevResult.data, data, options);
|
|
1633
|
-
this.selectResult = data;
|
|
1634
|
-
this.selectError = null;
|
|
1635
|
-
} catch (selectError) {
|
|
1636
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1637
|
-
this.client.getLogger().error(selectError);
|
|
1638
|
-
}
|
|
1639
|
-
this.selectError = selectError;
|
|
1640
|
-
}
|
|
1641
|
-
}
|
|
1642
|
-
} else {
|
|
1643
|
-
data = state.data;
|
|
1644
|
-
}
|
|
1645
|
-
if (typeof options.placeholderData !== "undefined" && typeof data === "undefined" && status === "loading") {
|
|
1646
|
-
let placeholderData;
|
|
1647
|
-
if (prevResult != null && prevResult.isPlaceholderData && options.placeholderData === (prevResultOptions == null ? void 0 : prevResultOptions.placeholderData)) {
|
|
1648
|
-
placeholderData = prevResult.data;
|
|
1649
|
-
} else {
|
|
1650
|
-
placeholderData = typeof options.placeholderData === "function" ? options.placeholderData() : options.placeholderData;
|
|
1651
|
-
if (options.select && typeof placeholderData !== "undefined") {
|
|
1652
|
-
try {
|
|
1653
|
-
placeholderData = options.select(placeholderData);
|
|
1654
|
-
this.selectError = null;
|
|
1655
|
-
} catch (selectError) {
|
|
1656
|
-
if (process.env.NODE_ENV !== "production") {
|
|
1657
|
-
this.client.getLogger().error(selectError);
|
|
1658
|
-
}
|
|
1659
|
-
this.selectError = selectError;
|
|
1660
|
-
}
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
if (typeof placeholderData !== "undefined") {
|
|
1664
|
-
status = "success";
|
|
1665
|
-
data = replaceData(prevResult == null ? void 0 : prevResult.data, placeholderData, options);
|
|
1666
|
-
isPlaceholderData = true;
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
if (this.selectError) {
|
|
1670
|
-
error = this.selectError;
|
|
1671
|
-
data = this.selectResult;
|
|
1672
|
-
errorUpdatedAt = Date.now();
|
|
1673
|
-
status = "error";
|
|
1674
|
-
}
|
|
1675
|
-
const isFetching = fetchStatus === "fetching";
|
|
1676
|
-
const isLoading = status === "loading";
|
|
1677
|
-
const isError2 = status === "error";
|
|
1678
|
-
const result = {
|
|
1679
|
-
status,
|
|
1680
|
-
fetchStatus,
|
|
1681
|
-
isLoading,
|
|
1682
|
-
isSuccess: status === "success",
|
|
1683
|
-
isError: isError2,
|
|
1684
|
-
isInitialLoading: isLoading && isFetching,
|
|
1685
|
-
data,
|
|
1686
|
-
dataUpdatedAt,
|
|
1687
|
-
error,
|
|
1688
|
-
errorUpdatedAt,
|
|
1689
|
-
failureCount: state.fetchFailureCount,
|
|
1690
|
-
failureReason: state.fetchFailureReason,
|
|
1691
|
-
errorUpdateCount: state.errorUpdateCount,
|
|
1692
|
-
isFetched: state.dataUpdateCount > 0 || state.errorUpdateCount > 0,
|
|
1693
|
-
isFetchedAfterMount: state.dataUpdateCount > queryInitialState.dataUpdateCount || state.errorUpdateCount > queryInitialState.errorUpdateCount,
|
|
1694
|
-
isFetching,
|
|
1695
|
-
isRefetching: isFetching && !isLoading,
|
|
1696
|
-
isLoadingError: isError2 && state.dataUpdatedAt === 0,
|
|
1697
|
-
isPaused: fetchStatus === "paused",
|
|
1698
|
-
isPlaceholderData,
|
|
1699
|
-
isPreviousData,
|
|
1700
|
-
isRefetchError: isError2 && state.dataUpdatedAt !== 0,
|
|
1701
|
-
isStale: isStale(query, options),
|
|
1702
|
-
refetch: this.refetch,
|
|
1703
|
-
remove: this.remove
|
|
1704
|
-
};
|
|
1705
|
-
return result;
|
|
1706
|
-
}
|
|
1707
|
-
updateResult(notifyOptions) {
|
|
1708
|
-
const prevResult = this.currentResult;
|
|
1709
|
-
const nextResult = this.createResult(this.currentQuery, this.options);
|
|
1710
|
-
this.currentResultState = this.currentQuery.state;
|
|
1711
|
-
this.currentResultOptions = this.options;
|
|
1712
|
-
if (shallowEqualObjects(nextResult, prevResult)) {
|
|
1713
|
-
return;
|
|
1714
|
-
}
|
|
1715
|
-
this.currentResult = nextResult;
|
|
1716
|
-
const defaultNotifyOptions = {
|
|
1717
|
-
cache: true
|
|
1718
|
-
};
|
|
1719
|
-
const shouldNotifyListeners = () => {
|
|
1720
|
-
if (!prevResult) {
|
|
1721
|
-
return true;
|
|
1722
|
-
}
|
|
1723
|
-
const {
|
|
1724
|
-
notifyOnChangeProps
|
|
1725
|
-
} = this.options;
|
|
1726
|
-
const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
|
|
1727
|
-
if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !this.trackedProps.size) {
|
|
1728
|
-
return true;
|
|
1729
|
-
}
|
|
1730
|
-
const includedProps = new Set(notifyOnChangePropsValue != null ? notifyOnChangePropsValue : this.trackedProps);
|
|
1731
|
-
if (this.options.useErrorBoundary) {
|
|
1732
|
-
includedProps.add("error");
|
|
1733
|
-
}
|
|
1734
|
-
return Object.keys(this.currentResult).some((key) => {
|
|
1735
|
-
const typedKey = key;
|
|
1736
|
-
const changed = this.currentResult[typedKey] !== prevResult[typedKey];
|
|
1737
|
-
return changed && includedProps.has(typedKey);
|
|
1738
|
-
});
|
|
1739
|
-
};
|
|
1740
|
-
if ((notifyOptions == null ? void 0 : notifyOptions.listeners) !== false && shouldNotifyListeners()) {
|
|
1741
|
-
defaultNotifyOptions.listeners = true;
|
|
1742
|
-
}
|
|
1743
|
-
this.notify(__spreadValues(__spreadValues({}, defaultNotifyOptions), notifyOptions));
|
|
1744
|
-
}
|
|
1745
|
-
updateQuery() {
|
|
1746
|
-
const query = this.client.getQueryCache().build(this.client, this.options);
|
|
1747
|
-
if (query === this.currentQuery) {
|
|
1748
|
-
return;
|
|
1749
|
-
}
|
|
1750
|
-
const prevQuery = this.currentQuery;
|
|
1751
|
-
this.currentQuery = query;
|
|
1752
|
-
this.currentQueryInitialState = query.state;
|
|
1753
|
-
this.previousQueryResult = this.currentResult;
|
|
1754
|
-
if (this.hasListeners()) {
|
|
1755
|
-
prevQuery == null ? void 0 : prevQuery.removeObserver(this);
|
|
1756
|
-
query.addObserver(this);
|
|
1757
|
-
}
|
|
1758
|
-
}
|
|
1759
|
-
onQueryUpdate(action) {
|
|
1760
|
-
const notifyOptions = {};
|
|
1761
|
-
if (action.type === "success") {
|
|
1762
|
-
notifyOptions.onSuccess = !action.manual;
|
|
1763
|
-
} else if (action.type === "error" && !isCancelledError(action.error)) {
|
|
1764
|
-
notifyOptions.onError = true;
|
|
1765
|
-
}
|
|
1766
|
-
this.updateResult(notifyOptions);
|
|
1767
|
-
if (this.hasListeners()) {
|
|
1768
|
-
this.updateTimers();
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
notify(notifyOptions) {
|
|
1772
|
-
notifyManager.batch(() => {
|
|
1773
|
-
if (notifyOptions.onSuccess) {
|
|
1774
|
-
var _this$options$onSucce, _this$options, _this$options$onSettl, _this$options2;
|
|
1775
|
-
(_this$options$onSucce = (_this$options = this.options).onSuccess) == null ? void 0 : _this$options$onSucce.call(_this$options, this.currentResult.data);
|
|
1776
|
-
(_this$options$onSettl = (_this$options2 = this.options).onSettled) == null ? void 0 : _this$options$onSettl.call(_this$options2, this.currentResult.data, null);
|
|
1777
|
-
} else if (notifyOptions.onError) {
|
|
1778
|
-
var _this$options$onError, _this$options3, _this$options$onSettl2, _this$options4;
|
|
1779
|
-
(_this$options$onError = (_this$options3 = this.options).onError) == null ? void 0 : _this$options$onError.call(_this$options3, this.currentResult.error);
|
|
1780
|
-
(_this$options$onSettl2 = (_this$options4 = this.options).onSettled) == null ? void 0 : _this$options$onSettl2.call(_this$options4, void 0, this.currentResult.error);
|
|
1781
|
-
}
|
|
1782
|
-
if (notifyOptions.listeners) {
|
|
1783
|
-
this.listeners.forEach(({
|
|
1784
|
-
listener
|
|
1785
|
-
}) => {
|
|
1786
|
-
listener(this.currentResult);
|
|
1787
|
-
});
|
|
1788
|
-
}
|
|
1789
|
-
if (notifyOptions.cache) {
|
|
1790
|
-
this.client.getQueryCache().notify({
|
|
1791
|
-
query: this.currentQuery,
|
|
1792
|
-
type: "observerResultsUpdated"
|
|
1793
|
-
});
|
|
1794
|
-
}
|
|
1795
|
-
});
|
|
1796
|
-
}
|
|
1797
|
-
};
|
|
1798
|
-
function shouldLoadOnMount(query, options) {
|
|
1799
|
-
return options.enabled !== false && !query.state.dataUpdatedAt && !(query.state.status === "error" && options.retryOnMount === false);
|
|
1800
|
-
}
|
|
1801
|
-
function shouldFetchOnMount(query, options) {
|
|
1802
|
-
return shouldLoadOnMount(query, options) || query.state.dataUpdatedAt > 0 && shouldFetchOn(query, options, options.refetchOnMount);
|
|
1803
|
-
}
|
|
1804
|
-
function shouldFetchOn(query, options, field) {
|
|
1805
|
-
if (options.enabled !== false) {
|
|
1806
|
-
const value = typeof field === "function" ? field(query) : field;
|
|
1807
|
-
return value === "always" || value !== false && isStale(query, options);
|
|
1808
|
-
}
|
|
1809
|
-
return false;
|
|
1810
|
-
}
|
|
1811
|
-
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
1812
|
-
return options.enabled !== false && (query !== prevQuery || prevOptions.enabled === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
1813
|
-
}
|
|
1814
|
-
function isStale(query, options) {
|
|
1815
|
-
return query.isStaleByTime(options.staleTime);
|
|
1816
|
-
}
|
|
1817
|
-
function shouldAssignObserverCurrentProperties(observer, optimisticResult, options) {
|
|
1818
|
-
if (options.keepPreviousData) {
|
|
1819
|
-
return false;
|
|
1820
|
-
}
|
|
1821
|
-
if (options.placeholderData !== void 0) {
|
|
1822
|
-
return optimisticResult.isPlaceholderData;
|
|
1823
|
-
}
|
|
1824
|
-
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
1825
|
-
return true;
|
|
1826
|
-
}
|
|
1827
|
-
return false;
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
// ../../node_modules/@tanstack/react-query/build/lib/useSyncExternalStore.mjs
|
|
1831
|
-
var import_shim = __toESM(require_shim(), 1);
|
|
1832
|
-
var useSyncExternalStore = import_shim.useSyncExternalStore;
|
|
1833
|
-
|
|
1834
|
-
// ../../node_modules/@tanstack/react-query/build/lib/QueryClientProvider.mjs
|
|
1835
|
-
var React = __toESM(require("react"), 1);
|
|
1836
|
-
var defaultContext = /* @__PURE__ */ React.createContext(void 0);
|
|
1837
|
-
var QueryClientSharingContext = /* @__PURE__ */ React.createContext(false);
|
|
1838
|
-
function getQueryClientContext(context, contextSharing) {
|
|
1839
|
-
if (context) {
|
|
1840
|
-
return context;
|
|
1841
|
-
}
|
|
1842
|
-
if (contextSharing && typeof window !== "undefined") {
|
|
1843
|
-
if (!window.ReactQueryClientContext) {
|
|
1844
|
-
window.ReactQueryClientContext = defaultContext;
|
|
1845
|
-
}
|
|
1846
|
-
return window.ReactQueryClientContext;
|
|
1847
|
-
}
|
|
1848
|
-
return defaultContext;
|
|
1849
|
-
}
|
|
1850
|
-
var useQueryClient = ({
|
|
1851
|
-
context
|
|
1852
|
-
} = {}) => {
|
|
1853
|
-
const queryClient = React.useContext(getQueryClientContext(context, React.useContext(QueryClientSharingContext)));
|
|
1854
|
-
if (!queryClient) {
|
|
1855
|
-
throw new Error("No QueryClient set, use QueryClientProvider to set one");
|
|
1856
|
-
}
|
|
1857
|
-
return queryClient;
|
|
1858
|
-
};
|
|
1859
|
-
|
|
1860
|
-
// ../../node_modules/@tanstack/react-query/build/lib/isRestoring.mjs
|
|
1861
|
-
var React2 = __toESM(require("react"), 1);
|
|
1862
|
-
var IsRestoringContext = /* @__PURE__ */ React2.createContext(false);
|
|
1863
|
-
var useIsRestoring = () => React2.useContext(IsRestoringContext);
|
|
1864
|
-
var IsRestoringProvider = IsRestoringContext.Provider;
|
|
1865
|
-
|
|
1866
|
-
// ../../node_modules/@tanstack/react-query/build/lib/QueryErrorResetBoundary.mjs
|
|
1867
|
-
var React3 = __toESM(require("react"), 1);
|
|
1868
|
-
function createValue() {
|
|
1869
|
-
let isReset = false;
|
|
1870
|
-
return {
|
|
1871
|
-
clearReset: () => {
|
|
1872
|
-
isReset = false;
|
|
1873
|
-
},
|
|
1874
|
-
reset: () => {
|
|
1875
|
-
isReset = true;
|
|
1876
|
-
},
|
|
1877
|
-
isReset: () => {
|
|
1878
|
-
return isReset;
|
|
1879
|
-
}
|
|
1880
|
-
};
|
|
1881
|
-
}
|
|
1882
|
-
var QueryErrorResetBoundaryContext = /* @__PURE__ */ React3.createContext(createValue());
|
|
1883
|
-
var useQueryErrorResetBoundary = () => React3.useContext(QueryErrorResetBoundaryContext);
|
|
1884
|
-
|
|
1885
|
-
// ../../node_modules/@tanstack/react-query/build/lib/errorBoundaryUtils.mjs
|
|
1886
|
-
var React4 = __toESM(require("react"), 1);
|
|
1887
|
-
|
|
1888
|
-
// ../../node_modules/@tanstack/react-query/build/lib/utils.mjs
|
|
1889
|
-
function shouldThrowError(_useErrorBoundary, params) {
|
|
1890
|
-
if (typeof _useErrorBoundary === "function") {
|
|
1891
|
-
return _useErrorBoundary(...params);
|
|
1892
|
-
}
|
|
1893
|
-
return !!_useErrorBoundary;
|
|
1894
|
-
}
|
|
1895
|
-
|
|
1896
|
-
// ../../node_modules/@tanstack/react-query/build/lib/errorBoundaryUtils.mjs
|
|
1897
|
-
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
|
|
1898
|
-
if (options.suspense || options.useErrorBoundary) {
|
|
1899
|
-
if (!errorResetBoundary.isReset()) {
|
|
1900
|
-
options.retryOnMount = false;
|
|
1901
|
-
}
|
|
1902
|
-
}
|
|
1903
|
-
};
|
|
1904
|
-
var useClearResetErrorBoundary = (errorResetBoundary) => {
|
|
1905
|
-
React4.useEffect(() => {
|
|
1906
|
-
errorResetBoundary.clearReset();
|
|
1907
|
-
}, [errorResetBoundary]);
|
|
1908
|
-
};
|
|
1909
|
-
var getHasError = ({
|
|
1910
|
-
result,
|
|
1911
|
-
errorResetBoundary,
|
|
1912
|
-
useErrorBoundary,
|
|
1913
|
-
query
|
|
1914
|
-
}) => {
|
|
1915
|
-
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && shouldThrowError(useErrorBoundary, [result.error, query]);
|
|
1916
|
-
};
|
|
1917
|
-
|
|
1918
|
-
// ../../node_modules/@tanstack/react-query/build/lib/suspense.mjs
|
|
1919
|
-
var ensureStaleTime = (defaultedOptions) => {
|
|
1920
|
-
if (defaultedOptions.suspense) {
|
|
1921
|
-
if (typeof defaultedOptions.staleTime !== "number") {
|
|
1922
|
-
defaultedOptions.staleTime = 1e3;
|
|
1923
|
-
}
|
|
1924
|
-
}
|
|
1925
|
-
};
|
|
1926
|
-
var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
|
|
1927
|
-
var shouldSuspend = (defaultedOptions, result, isRestoring) => (defaultedOptions == null ? void 0 : defaultedOptions.suspense) && willFetch(result, isRestoring);
|
|
1928
|
-
var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).then(({
|
|
1929
|
-
data
|
|
1930
|
-
}) => {
|
|
1931
|
-
defaultedOptions.onSuccess == null ? void 0 : defaultedOptions.onSuccess(data);
|
|
1932
|
-
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(data, null);
|
|
1933
|
-
}).catch((error) => {
|
|
1934
|
-
errorResetBoundary.clearReset();
|
|
1935
|
-
defaultedOptions.onError == null ? void 0 : defaultedOptions.onError(error);
|
|
1936
|
-
defaultedOptions.onSettled == null ? void 0 : defaultedOptions.onSettled(void 0, error);
|
|
1937
|
-
});
|
|
1938
|
-
|
|
1939
|
-
// ../../node_modules/@tanstack/react-query/build/lib/useBaseQuery.mjs
|
|
1940
|
-
var React5 = __toESM(require("react"), 1);
|
|
1941
|
-
function useBaseQuery(options, Observer) {
|
|
1942
|
-
const queryClient = useQueryClient({
|
|
1943
|
-
context: options.context
|
|
1944
|
-
});
|
|
1945
|
-
const isRestoring = useIsRestoring();
|
|
1946
|
-
const errorResetBoundary = useQueryErrorResetBoundary();
|
|
1947
|
-
const defaultedOptions = queryClient.defaultQueryOptions(options);
|
|
1948
|
-
defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
|
|
1949
|
-
if (defaultedOptions.onError) {
|
|
1950
|
-
defaultedOptions.onError = notifyManager.batchCalls(defaultedOptions.onError);
|
|
1951
|
-
}
|
|
1952
|
-
if (defaultedOptions.onSuccess) {
|
|
1953
|
-
defaultedOptions.onSuccess = notifyManager.batchCalls(defaultedOptions.onSuccess);
|
|
1954
|
-
}
|
|
1955
|
-
if (defaultedOptions.onSettled) {
|
|
1956
|
-
defaultedOptions.onSettled = notifyManager.batchCalls(defaultedOptions.onSettled);
|
|
1957
|
-
}
|
|
1958
|
-
ensureStaleTime(defaultedOptions);
|
|
1959
|
-
ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
|
|
1960
|
-
useClearResetErrorBoundary(errorResetBoundary);
|
|
1961
|
-
const [observer] = React5.useState(() => new Observer(queryClient, defaultedOptions));
|
|
1962
|
-
const result = observer.getOptimisticResult(defaultedOptions);
|
|
1963
|
-
useSyncExternalStore(React5.useCallback((onStoreChange) => {
|
|
1964
|
-
const unsubscribe = isRestoring ? () => void 0 : observer.subscribe(notifyManager.batchCalls(onStoreChange));
|
|
1965
|
-
observer.updateResult();
|
|
1966
|
-
return unsubscribe;
|
|
1967
|
-
}, [observer, isRestoring]), () => observer.getCurrentResult(), () => observer.getCurrentResult());
|
|
1968
|
-
React5.useEffect(() => {
|
|
1969
|
-
observer.setOptions(defaultedOptions, {
|
|
1970
|
-
listeners: false
|
|
1971
|
-
});
|
|
1972
|
-
}, [defaultedOptions, observer]);
|
|
1973
|
-
if (shouldSuspend(defaultedOptions, result, isRestoring)) {
|
|
1974
|
-
throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
|
|
1975
|
-
}
|
|
1976
|
-
if (getHasError({
|
|
1977
|
-
result,
|
|
1978
|
-
errorResetBoundary,
|
|
1979
|
-
useErrorBoundary: defaultedOptions.useErrorBoundary,
|
|
1980
|
-
query: observer.getCurrentQuery()
|
|
1981
|
-
})) {
|
|
1982
|
-
throw result.error;
|
|
1983
|
-
}
|
|
1984
|
-
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
1985
|
-
}
|
|
1986
|
-
|
|
1987
|
-
// ../../node_modules/@tanstack/react-query/build/lib/useQuery.mjs
|
|
1988
|
-
function useQuery(arg1, arg2, arg3) {
|
|
1989
|
-
const parsedOptions = parseQueryArgs(arg1, arg2, arg3);
|
|
1990
|
-
return useBaseQuery(parsedOptions, QueryObserver);
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
1000
|
// src/lib/useUploadCore.tsx
|
|
1001
|
+
var import_react_query = require("@tanstack/react-query");
|
|
1994
1002
|
var import_upload_core2 = __toESM(require("@availity/upload-core"));
|
|
1995
1003
|
function startUpload2(file, options) {
|
|
1996
1004
|
return __async(this, null, function* () {
|
|
@@ -2007,7 +1015,7 @@ function startUpload2(file, options) {
|
|
|
2007
1015
|
}
|
|
2008
1016
|
function useUploadCore(file, options, queryOptions) {
|
|
2009
1017
|
const isQueryEnabled = !!file;
|
|
2010
|
-
return useQuery(__spreadValues({
|
|
1018
|
+
return (0, import_react_query.useQuery)(__spreadValues({
|
|
2011
1019
|
queryKey: ["upload", file.name, options],
|
|
2012
1020
|
queryFn: () => startUpload2(file, options),
|
|
2013
1021
|
enabled: isQueryEnabled,
|
|
@@ -2152,6 +1160,7 @@ var FileList2 = ({
|
|
|
2152
1160
|
// src/lib/FileSelector.tsx
|
|
2153
1161
|
var import_react5 = require("react");
|
|
2154
1162
|
var import_react_hook_form4 = require("react-hook-form");
|
|
1163
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
2155
1164
|
var import_mui_layout7 = require("@availity/mui-layout");
|
|
2156
1165
|
var import_mui_typography6 = require("@availity/mui-typography");
|
|
2157
1166
|
var import_mui_alert3 = require("@availity/mui-alert");
|
|
@@ -2162,14 +1171,18 @@ var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
|
2162
1171
|
var FileTypesMessage = ({
|
|
2163
1172
|
allowedFileTypes = [],
|
|
2164
1173
|
customSizeMessage,
|
|
1174
|
+
customTotalSizeMessage,
|
|
2165
1175
|
customTypesMessage,
|
|
2166
1176
|
maxFileSize,
|
|
1177
|
+
maxTotalSize,
|
|
2167
1178
|
variant = "caption"
|
|
2168
1179
|
}) => {
|
|
2169
1180
|
const fileSizeMsg = customSizeMessage || (typeof maxFileSize === "number" ? `Maximum file size is ${formatBytes(maxFileSize)}. ` : null);
|
|
1181
|
+
const totalFileSizeMsg = customTotalSizeMessage || (typeof maxTotalSize === "number" ? `Maximum total upload size is ${formatBytes(maxTotalSize)}. ` : null);
|
|
2170
1182
|
const fileTypesMsg = customTypesMessage || (allowedFileTypes.length > 0 ? `Supported file types include: ${allowedFileTypes.join(", ")}` : "All file types allowed.");
|
|
2171
1183
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_mui_typography4.Typography, { variant, children: [
|
|
2172
1184
|
fileSizeMsg,
|
|
1185
|
+
totalFileSizeMsg,
|
|
2173
1186
|
fileTypesMsg
|
|
2174
1187
|
] });
|
|
2175
1188
|
};
|
|
@@ -2177,12 +1190,14 @@ var FileTypesMessage = ({
|
|
|
2177
1190
|
// src/lib/HeaderMessage.tsx
|
|
2178
1191
|
var import_mui_typography5 = require("@availity/mui-typography");
|
|
2179
1192
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
2180
|
-
var HeaderMessage = ({ maxFiles, maxSize }) => {
|
|
1193
|
+
var HeaderMessage = ({ maxFiles, maxSize, maxTotalSize }) => {
|
|
2181
1194
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_mui_typography5.Typography, { variant: "h6", children: [
|
|
2182
1195
|
"Attach up to ",
|
|
2183
1196
|
maxFiles,
|
|
2184
1197
|
" file(s), with a maximum individual size of ",
|
|
2185
|
-
formatBytes(maxSize)
|
|
1198
|
+
formatBytes(maxSize),
|
|
1199
|
+
" ",
|
|
1200
|
+
maxTotalSize && `and a maximum total size of ${formatBytes(maxTotalSize)}`
|
|
2186
1201
|
] });
|
|
2187
1202
|
};
|
|
2188
1203
|
|
|
@@ -2197,6 +1212,7 @@ var FileSelector = ({
|
|
|
2197
1212
|
clientId,
|
|
2198
1213
|
children,
|
|
2199
1214
|
customSizeMessage,
|
|
1215
|
+
customTotalSizeMessage,
|
|
2200
1216
|
customTypesMessage,
|
|
2201
1217
|
customerId,
|
|
2202
1218
|
customFileRow,
|
|
@@ -2207,6 +1223,7 @@ var FileSelector = ({
|
|
|
2207
1223
|
label = "Upload file",
|
|
2208
1224
|
maxFiles,
|
|
2209
1225
|
maxSize,
|
|
1226
|
+
maxTotalSize,
|
|
2210
1227
|
multiple = true,
|
|
2211
1228
|
onChange,
|
|
2212
1229
|
onDrop,
|
|
@@ -2218,7 +1235,7 @@ var FileSelector = ({
|
|
|
2218
1235
|
}) => {
|
|
2219
1236
|
const [totalSize, setTotalSize] = (0, import_react5.useState)(0);
|
|
2220
1237
|
const [fileRejections, setFileRejections] = (0, import_react5.useState)([]);
|
|
2221
|
-
const client = useQueryClient();
|
|
1238
|
+
const client = (0, import_react_query2.useQueryClient)();
|
|
2222
1239
|
const formMethods = (0, import_react_hook_form4.useFormContext)();
|
|
2223
1240
|
const options = __spreadProps(__spreadValues({}, uploadOptions), {
|
|
2224
1241
|
bucketId,
|
|
@@ -2270,6 +1287,7 @@ var FileSelector = ({
|
|
|
2270
1287
|
enableDropArea,
|
|
2271
1288
|
maxFiles,
|
|
2272
1289
|
maxSize,
|
|
1290
|
+
maxTotalSize,
|
|
2273
1291
|
multiple,
|
|
2274
1292
|
onChange,
|
|
2275
1293
|
onDrop,
|
|
@@ -2283,7 +1301,9 @@ var FileSelector = ({
|
|
|
2283
1301
|
{
|
|
2284
1302
|
allowedFileTypes,
|
|
2285
1303
|
maxFileSize: maxSize,
|
|
1304
|
+
maxTotalSize,
|
|
2286
1305
|
customSizeMessage,
|
|
1306
|
+
customTotalSizeMessage,
|
|
2287
1307
|
customTypesMessage,
|
|
2288
1308
|
variant: "caption"
|
|
2289
1309
|
}
|
|
@@ -2291,11 +1311,12 @@ var FileSelector = ({
|
|
|
2291
1311
|
children
|
|
2292
1312
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_mui_layout7.Grid, { container: true, rowSpacing: 3, flexDirection: "column", children: [
|
|
2293
1313
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_mui_layout7.Grid, { children: [
|
|
2294
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(HeaderMessage, { maxFiles, maxSize }),
|
|
1314
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(HeaderMessage, { maxFiles, maxSize, maxTotalSize }),
|
|
2295
1315
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
2296
1316
|
FileTypesMessage,
|
|
2297
1317
|
{
|
|
2298
1318
|
allowedFileTypes,
|
|
1319
|
+
customTotalSizeMessage,
|
|
2299
1320
|
customSizeMessage,
|
|
2300
1321
|
customTypesMessage,
|
|
2301
1322
|
variant: "body2"
|
|
@@ -2312,6 +1333,7 @@ var FileSelector = ({
|
|
|
2312
1333
|
enableDropArea,
|
|
2313
1334
|
maxFiles,
|
|
2314
1335
|
maxSize,
|
|
1336
|
+
maxTotalSize,
|
|
2315
1337
|
multiple,
|
|
2316
1338
|
onChange,
|
|
2317
1339
|
onDrop,
|
|
@@ -2373,6 +1395,7 @@ var FileSelector2 = ({
|
|
|
2373
1395
|
clientId,
|
|
2374
1396
|
children,
|
|
2375
1397
|
customSizeMessage,
|
|
1398
|
+
customTotalSizeMessage,
|
|
2376
1399
|
customTypesMessage,
|
|
2377
1400
|
customerId,
|
|
2378
1401
|
customFileRow,
|
|
@@ -2383,6 +1406,7 @@ var FileSelector2 = ({
|
|
|
2383
1406
|
label = "Upload file",
|
|
2384
1407
|
maxFiles,
|
|
2385
1408
|
maxSize,
|
|
1409
|
+
maxTotalSize,
|
|
2386
1410
|
multiple = true,
|
|
2387
1411
|
onChange,
|
|
2388
1412
|
onDrop,
|
|
@@ -2443,6 +1467,7 @@ var FileSelector2 = ({
|
|
|
2443
1467
|
enableDropArea,
|
|
2444
1468
|
maxFiles,
|
|
2445
1469
|
maxSize,
|
|
1470
|
+
maxTotalSize,
|
|
2446
1471
|
multiple,
|
|
2447
1472
|
onChange,
|
|
2448
1473
|
onDrop,
|
|
@@ -2457,7 +1482,9 @@ var FileSelector2 = ({
|
|
|
2457
1482
|
{
|
|
2458
1483
|
allowedFileTypes,
|
|
2459
1484
|
maxFileSize: maxSize,
|
|
1485
|
+
maxTotalSize,
|
|
2460
1486
|
customSizeMessage,
|
|
1487
|
+
customTotalSizeMessage,
|
|
2461
1488
|
customTypesMessage,
|
|
2462
1489
|
variant: "caption"
|
|
2463
1490
|
}
|
|
@@ -2465,12 +1492,13 @@ var FileSelector2 = ({
|
|
|
2465
1492
|
children
|
|
2466
1493
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_mui_layout8.Grid, { container: true, rowSpacing: 3, flexDirection: "column", children: [
|
|
2467
1494
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_mui_layout8.Grid, { children: [
|
|
2468
|
-
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(HeaderMessage, { maxFiles, maxSize }),
|
|
1495
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(HeaderMessage, { maxFiles, maxSize, maxTotalSize }),
|
|
2469
1496
|
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2470
1497
|
FileTypesMessage,
|
|
2471
1498
|
{
|
|
2472
1499
|
allowedFileTypes,
|
|
2473
1500
|
customSizeMessage,
|
|
1501
|
+
customTotalSizeMessage,
|
|
2474
1502
|
customTypesMessage,
|
|
2475
1503
|
variant: "body2"
|
|
2476
1504
|
}
|
|
@@ -2486,6 +1514,7 @@ var FileSelector2 = ({
|
|
|
2486
1514
|
enableDropArea,
|
|
2487
1515
|
maxFiles,
|
|
2488
1516
|
maxSize,
|
|
1517
|
+
maxTotalSize,
|
|
2489
1518
|
multiple,
|
|
2490
1519
|
onChange,
|
|
2491
1520
|
onDrop,
|
|
@@ -2554,27 +1583,3 @@ var FileSelector2 = ({
|
|
|
2554
1583
|
outerBoxStyles,
|
|
2555
1584
|
useUploadCore
|
|
2556
1585
|
});
|
|
2557
|
-
/*! Bundled license information:
|
|
2558
|
-
|
|
2559
|
-
use-sync-external-store/cjs/use-sync-external-store-shim.production.js:
|
|
2560
|
-
(**
|
|
2561
|
-
* @license React
|
|
2562
|
-
* use-sync-external-store-shim.production.js
|
|
2563
|
-
*
|
|
2564
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2565
|
-
*
|
|
2566
|
-
* This source code is licensed under the MIT license found in the
|
|
2567
|
-
* LICENSE file in the root directory of this source tree.
|
|
2568
|
-
*)
|
|
2569
|
-
|
|
2570
|
-
use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
|
|
2571
|
-
(**
|
|
2572
|
-
* @license React
|
|
2573
|
-
* use-sync-external-store-shim.development.js
|
|
2574
|
-
*
|
|
2575
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2576
|
-
*
|
|
2577
|
-
* This source code is licensed under the MIT license found in the
|
|
2578
|
-
* LICENSE file in the root directory of this source tree.
|
|
2579
|
-
*)
|
|
2580
|
-
*/
|