@availity/mui-file-selector 1.6.6 → 1.7.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 +14 -0
- package/README.md +84 -1
- package/dist/index.d.mts +81 -1
- package/dist/index.d.ts +81 -1
- package/dist/index.js +1671 -126
- package/dist/index.mjs +1691 -129
- package/package.json +6 -7
- package/src/index.ts +3 -0
- package/src/lib/Dropzone.tsx +4 -4
- package/src/lib/Dropzone2.test.tsx +28 -0
- package/src/lib/Dropzone2.tsx +244 -0
- package/src/lib/FileList2.test.tsx +73 -0
- package/src/lib/FileList2.tsx +118 -0
- package/src/lib/FileSelector.tsx +1 -1
- package/src/lib/FileSelector2.stories.tsx +253 -0
- package/src/lib/FileSelector2.test.tsx +23 -0
- package/src/lib/FileSelector2.tsx +209 -0
- package/src/lib/util.test.ts +16 -0
- package/src/lib/util.ts +15 -4
package/dist/index.js
CHANGED
|
@@ -34,6 +34,9 @@ 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
|
+
};
|
|
37
40
|
var __export = (target, all) => {
|
|
38
41
|
for (var name in all)
|
|
39
42
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -76,19 +79,157 @@ var __async = (__this, __arguments, generator) => {
|
|
|
76
79
|
});
|
|
77
80
|
};
|
|
78
81
|
|
|
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
|
+
|
|
79
211
|
// src/index.ts
|
|
80
212
|
var index_exports = {};
|
|
81
213
|
__export(index_exports, {
|
|
214
|
+
CLOUD_URL: () => CLOUD_URL,
|
|
82
215
|
Dropzone: () => Dropzone,
|
|
216
|
+
Dropzone2: () => Dropzone2,
|
|
217
|
+
DropzoneContainer: () => DropzoneContainer,
|
|
83
218
|
ErrorAlert: () => ErrorAlert,
|
|
84
219
|
FileList: () => FileList,
|
|
220
|
+
FileList2: () => FileList2,
|
|
85
221
|
FilePickerBtn: () => FilePickerBtn,
|
|
86
222
|
FileRow: () => FileRow,
|
|
223
|
+
FileRow2: () => FileRow2,
|
|
87
224
|
FileSelector: () => FileSelector,
|
|
225
|
+
FileSelector2: () => FileSelector2,
|
|
88
226
|
FileTypesMessage: () => FileTypesMessage,
|
|
89
227
|
HeaderMessage: () => HeaderMessage,
|
|
90
228
|
UploadProgressBar: () => UploadProgressBar,
|
|
229
|
+
createCounter: () => createCounter,
|
|
91
230
|
formatFileTooLarge: () => formatFileTooLarge,
|
|
231
|
+
innerBoxStyles: () => innerBoxStyles,
|
|
232
|
+
outerBoxStyles: () => outerBoxStyles,
|
|
92
233
|
useUploadCore: () => useUploadCore
|
|
93
234
|
});
|
|
94
235
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -340,9 +481,15 @@ var Dropzone = ({
|
|
|
340
481
|
);
|
|
341
482
|
};
|
|
342
483
|
|
|
343
|
-
// src/lib/
|
|
344
|
-
var
|
|
345
|
-
var
|
|
484
|
+
// src/lib/Dropzone2.tsx
|
|
485
|
+
var import_react2 = require("react");
|
|
486
|
+
var import_react_dropzone2 = require("react-dropzone");
|
|
487
|
+
var import_react_hook_form3 = require("react-hook-form");
|
|
488
|
+
var import_mui_divider2 = require("@availity/mui-divider");
|
|
489
|
+
var import_mui_icon3 = require("@availity/mui-icon");
|
|
490
|
+
var import_mui_layout2 = require("@availity/mui-layout");
|
|
491
|
+
var import_mui_typography2 = require("@availity/mui-typography");
|
|
492
|
+
var import_upload_core = __toESM(require("@availity/upload-core"));
|
|
346
493
|
|
|
347
494
|
// src/lib/util.ts
|
|
348
495
|
var import_mui_icon2 = require("@availity/mui-icon");
|
|
@@ -375,15 +522,196 @@ var FILE_EXT_ICONS = {
|
|
|
375
522
|
pdf: import_mui_icon2.FilePdfIcon
|
|
376
523
|
};
|
|
377
524
|
var isValidKey = (key) => key ? key in FILE_EXT_ICONS : false;
|
|
378
|
-
var
|
|
525
|
+
var getFileExtension = (fileName) => {
|
|
379
526
|
var _a;
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
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;
|
|
383
541
|
};
|
|
384
542
|
|
|
385
|
-
// src/lib/
|
|
543
|
+
// src/lib/Dropzone2.tsx
|
|
386
544
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
545
|
+
var counter2 = createCounter();
|
|
546
|
+
function startUpload(file, options) {
|
|
547
|
+
return __async(this, null, function* () {
|
|
548
|
+
const _a = options, { onSuccess, onError, onProgress, onChunkComplete } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError", "onProgress", "onChunkComplete"]);
|
|
549
|
+
const upload = new import_upload_core.default(file, uploadOptions);
|
|
550
|
+
yield upload.generateId();
|
|
551
|
+
if (onSuccess) upload.onSuccess.push(onSuccess);
|
|
552
|
+
if (onError) upload.onError.push(onError);
|
|
553
|
+
if (onProgress) upload.onProgress.push(onProgress);
|
|
554
|
+
if (onChunkComplete) upload.onChunkComplete.push(onChunkComplete);
|
|
555
|
+
upload.start();
|
|
556
|
+
return upload;
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
var Dropzone2 = ({
|
|
560
|
+
allowedFileTypes = [],
|
|
561
|
+
disabled,
|
|
562
|
+
enableDropArea = true,
|
|
563
|
+
maxFiles,
|
|
564
|
+
maxSize,
|
|
565
|
+
multiple,
|
|
566
|
+
name,
|
|
567
|
+
onChange,
|
|
568
|
+
onClick,
|
|
569
|
+
onDrop,
|
|
570
|
+
setFileRejections,
|
|
571
|
+
setTotalSize,
|
|
572
|
+
uploadOptions,
|
|
573
|
+
validator
|
|
574
|
+
}) => {
|
|
575
|
+
const { getValues, setValue, watch } = (0, import_react_hook_form3.useFormContext)();
|
|
576
|
+
const accept = allowedFileTypes.join(",");
|
|
577
|
+
const handleValidation = (0, import_react2.useCallback)(
|
|
578
|
+
(file) => {
|
|
579
|
+
var _a2;
|
|
580
|
+
const previous = (_a2 = watch(name)) != null ? _a2 : [];
|
|
581
|
+
const errors = [];
|
|
582
|
+
const isDuplicate = previous.some((prev) => prev.file.name === file.name);
|
|
583
|
+
if (isDuplicate) {
|
|
584
|
+
errors.push({
|
|
585
|
+
code: "duplicate-name",
|
|
586
|
+
message: "A file with this name already exists"
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
const hasMaxFiles = maxFiles && previous.length >= maxFiles;
|
|
590
|
+
if (hasMaxFiles) {
|
|
591
|
+
errors.push({
|
|
592
|
+
code: "too-many-files",
|
|
593
|
+
message: `Too many files. You may only upload ${maxFiles} file(s).`
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
if (validator) {
|
|
597
|
+
const validatorErrors = validator(file);
|
|
598
|
+
if (validatorErrors) {
|
|
599
|
+
if (Array.isArray(validatorErrors)) {
|
|
600
|
+
errors.push(...validatorErrors);
|
|
601
|
+
} else {
|
|
602
|
+
errors.push(validatorErrors);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return errors.length > 0 ? dedupeErrors(errors) : null;
|
|
607
|
+
},
|
|
608
|
+
[maxFiles, validator]
|
|
609
|
+
);
|
|
610
|
+
const handleOnDrop = (0, import_react2.useCallback)(
|
|
611
|
+
(acceptedFiles, fileRejections, event) => __async(void 0, null, function* () {
|
|
612
|
+
var _a2;
|
|
613
|
+
let newSize = 0;
|
|
614
|
+
for (const file of acceptedFiles) {
|
|
615
|
+
newSize += file.size;
|
|
616
|
+
}
|
|
617
|
+
setTotalSize((prev) => prev + newSize);
|
|
618
|
+
const previous = (_a2 = watch(name)) != null ? _a2 : [];
|
|
619
|
+
const uploads = acceptedFiles.map((file) => startUpload(file, uploadOptions));
|
|
620
|
+
setValue(name, previous.concat(yield Promise.all(uploads)));
|
|
621
|
+
if (fileRejections.length > 0) {
|
|
622
|
+
const TOO_MANY_FILES_CODE = "too-many-files";
|
|
623
|
+
let hasTooManyFiles = false;
|
|
624
|
+
fileRejections = fileRejections.reduce(
|
|
625
|
+
(acc, rejection) => {
|
|
626
|
+
const isTooManyFiles = rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE);
|
|
627
|
+
if (isTooManyFiles) {
|
|
628
|
+
if (!hasTooManyFiles) {
|
|
629
|
+
hasTooManyFiles = true;
|
|
630
|
+
acc.push(__spreadProps(__spreadValues({}, rejection), {
|
|
631
|
+
id: counter2.increment()
|
|
632
|
+
}));
|
|
633
|
+
}
|
|
634
|
+
} else {
|
|
635
|
+
acc.push(__spreadProps(__spreadValues({}, rejection), {
|
|
636
|
+
id: counter2.increment()
|
|
637
|
+
}));
|
|
638
|
+
}
|
|
639
|
+
return acc;
|
|
640
|
+
},
|
|
641
|
+
[]
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
if (setFileRejections) setFileRejections(fileRejections);
|
|
645
|
+
if (onDrop) onDrop(acceptedFiles, fileRejections, event);
|
|
646
|
+
}),
|
|
647
|
+
[setFileRejections]
|
|
648
|
+
);
|
|
649
|
+
const { getRootProps, getInputProps } = (0, import_react_dropzone2.useDropzone)({
|
|
650
|
+
onDrop: handleOnDrop,
|
|
651
|
+
maxSize,
|
|
652
|
+
maxFiles,
|
|
653
|
+
disabled,
|
|
654
|
+
multiple,
|
|
655
|
+
accept,
|
|
656
|
+
validator: handleValidation
|
|
657
|
+
});
|
|
658
|
+
const inputProps = getInputProps({
|
|
659
|
+
multiple,
|
|
660
|
+
accept,
|
|
661
|
+
onChange
|
|
662
|
+
});
|
|
663
|
+
const _a = getRootProps(), { role, tabIndex } = _a, rootProps = __objRest(_a, ["role", "tabIndex"]);
|
|
664
|
+
const handleOnChange = (event) => {
|
|
665
|
+
if (inputProps.onChange) {
|
|
666
|
+
inputProps.onChange(event);
|
|
667
|
+
}
|
|
668
|
+
};
|
|
669
|
+
const handleOnClick = (event) => {
|
|
670
|
+
if (!enableDropArea && rootProps.onClick) rootProps.onClick(event);
|
|
671
|
+
if (onClick) onClick;
|
|
672
|
+
};
|
|
673
|
+
const getFieldValue = () => {
|
|
674
|
+
const field = getValues();
|
|
675
|
+
return field[name] || [];
|
|
676
|
+
};
|
|
677
|
+
const hasFiles = getFieldValue().length > 0;
|
|
678
|
+
return enableDropArea ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DropzoneContainer, __spreadProps(__spreadValues({ sx: outerBoxStyles }, rootProps), { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_layout2.Box, { sx: innerBoxStyles, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_layout2.Stack, { spacing: 2, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
679
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_icon3.CloudUploadIcon, { fontSize: "xlarge", color: "secondary" }),
|
|
680
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_typography2.Typography, { variant: "subtitle2", fontWeight: "700", children: "Drag and Drop Files Here" }),
|
|
681
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_divider2.Divider, { flexItem: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_typography2.Typography, { variant: "subtitle2", children: "OR" }) }),
|
|
682
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
683
|
+
FilePickerBtn,
|
|
684
|
+
{
|
|
685
|
+
name,
|
|
686
|
+
color: "primary",
|
|
687
|
+
disabled,
|
|
688
|
+
maxSize,
|
|
689
|
+
onClick,
|
|
690
|
+
inputProps,
|
|
691
|
+
onChange: handleOnChange,
|
|
692
|
+
children: "Browse Files"
|
|
693
|
+
}
|
|
694
|
+
)
|
|
695
|
+
] }) }) }) })) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
696
|
+
FilePickerBtn,
|
|
697
|
+
{
|
|
698
|
+
name,
|
|
699
|
+
color: "tertiary",
|
|
700
|
+
disabled,
|
|
701
|
+
maxSize,
|
|
702
|
+
onClick: handleOnClick,
|
|
703
|
+
inputProps,
|
|
704
|
+
onChange: handleOnChange,
|
|
705
|
+
startIcon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_mui_icon3.PlusIcon, {}),
|
|
706
|
+
children: hasFiles ? "Add More Files" : "Add File(s)"
|
|
707
|
+
}
|
|
708
|
+
);
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
// src/lib/ErrorAlert.tsx
|
|
712
|
+
var import_mui_alert = require("@availity/mui-alert");
|
|
713
|
+
var import_mui_list = require("@availity/mui-list");
|
|
714
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
387
715
|
var codes = {
|
|
388
716
|
"file-too-large": "File exceeds maximum size",
|
|
389
717
|
"file-invalid-type": "File has an invalid type",
|
|
@@ -400,14 +728,14 @@ var formatFileTooLarge = (message) => {
|
|
|
400
728
|
};
|
|
401
729
|
var ErrorAlert = ({ errors, fileName, id, onClose }) => {
|
|
402
730
|
if (errors.length === 0) return null;
|
|
403
|
-
return /* @__PURE__ */ (0,
|
|
404
|
-
/* @__PURE__ */ (0,
|
|
731
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_mui_alert.Alert, { severity: "error", onClose, children: errors.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
732
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_mui_alert.AlertTitle, { children: [
|
|
405
733
|
"There were ",
|
|
406
734
|
errors.length,
|
|
407
735
|
" error(s) found when uploading ",
|
|
408
736
|
fileName
|
|
409
737
|
] }),
|
|
410
|
-
/* @__PURE__ */ (0,
|
|
738
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
411
739
|
import_mui_list.List,
|
|
412
740
|
{
|
|
413
741
|
sx: {
|
|
@@ -419,14 +747,14 @@ var ErrorAlert = ({ errors, fileName, id, onClose }) => {
|
|
|
419
747
|
}
|
|
420
748
|
},
|
|
421
749
|
disablePadding: true,
|
|
422
|
-
children: /* @__PURE__ */ (0,
|
|
750
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: errors.map((error) => {
|
|
423
751
|
const message = error.code === "file-too-large" ? formatFileTooLarge(error.message) : error.message;
|
|
424
|
-
return /* @__PURE__ */ (0,
|
|
752
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_mui_list.ListItem, { disableGutters: true, disablePadding: true, divider: false, children: message }, `${id}-${error.code}`);
|
|
425
753
|
}) })
|
|
426
754
|
}
|
|
427
755
|
)
|
|
428
|
-
] }) : /* @__PURE__ */ (0,
|
|
429
|
-
/* @__PURE__ */ (0,
|
|
756
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
757
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_mui_alert.AlertTitle, { children: [
|
|
430
758
|
codes[errors[0].code] || "Error",
|
|
431
759
|
": ",
|
|
432
760
|
fileName
|
|
@@ -438,21 +766,21 @@ var ErrorAlert = ({ errors, fileName, id, onClose }) => {
|
|
|
438
766
|
// src/lib/FileList.tsx
|
|
439
767
|
var import_mui_list3 = require("@availity/mui-list");
|
|
440
768
|
var import_mui_button4 = require("@availity/mui-button");
|
|
441
|
-
var
|
|
442
|
-
var
|
|
443
|
-
var
|
|
769
|
+
var import_mui_icon6 = require("@availity/mui-icon");
|
|
770
|
+
var import_mui_layout5 = require("@availity/mui-layout");
|
|
771
|
+
var import_mui_divider3 = require("@availity/mui-divider");
|
|
444
772
|
|
|
445
773
|
// src/lib/UploadProgressBar.tsx
|
|
446
|
-
var
|
|
774
|
+
var import_react4 = require("react");
|
|
447
775
|
var import_mui_button3 = require("@availity/mui-button");
|
|
448
776
|
|
|
449
777
|
// ../dialog/src/lib/Dialog.tsx
|
|
450
778
|
var import_Dialog = __toESM(require("@mui/material/Dialog"));
|
|
451
779
|
var import_styles2 = require("@mui/material/styles");
|
|
452
780
|
var import_mui_button2 = require("@availity/mui-button");
|
|
453
|
-
var
|
|
454
|
-
var
|
|
455
|
-
var CloseButton = (args) => /* @__PURE__ */ (0,
|
|
781
|
+
var import_mui_icon4 = require("@availity/mui-icon");
|
|
782
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
783
|
+
var CloseButton = (args) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_button2.IconButton, __spreadProps(__spreadValues({ title: "Close Dialog", color: "secondary" }, args), { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_mui_icon4.CloseIcon, { fontSize: "xsmall" }) }));
|
|
456
784
|
var CloseButtonSlot = (0, import_styles2.styled)(CloseButton, {
|
|
457
785
|
name: "MuiDialog",
|
|
458
786
|
slot: "AvCloseButton",
|
|
@@ -467,37 +795,37 @@ var CloseButtonSlot = (0, import_styles2.styled)(CloseButton, {
|
|
|
467
795
|
});
|
|
468
796
|
var Dialog = (_a) => {
|
|
469
797
|
var _b = _a, { children, closeButton = true, onClose } = _b, rest = __objRest(_b, ["children", "closeButton", "onClose"]);
|
|
470
|
-
return /* @__PURE__ */ (0,
|
|
471
|
-
closeButton ? /* @__PURE__ */ (0,
|
|
798
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Dialog.default, __spreadProps(__spreadValues({ onClose }, rest), { children: [
|
|
799
|
+
closeButton ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CloseButtonSlot, { onClick: onClose }) : null,
|
|
472
800
|
children
|
|
473
801
|
] }));
|
|
474
802
|
};
|
|
475
803
|
|
|
476
804
|
// ../dialog/src/lib/DialogActions.tsx
|
|
477
805
|
var import_DialogActions = __toESM(require("@mui/material/DialogActions"));
|
|
478
|
-
var
|
|
806
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
479
807
|
var DialogActions = (_a) => {
|
|
480
808
|
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
481
|
-
return /* @__PURE__ */ (0,
|
|
809
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_DialogActions.default, __spreadProps(__spreadValues({}, rest), { children }));
|
|
482
810
|
};
|
|
483
811
|
|
|
484
812
|
// ../dialog/src/lib/DialogContent.tsx
|
|
485
813
|
var import_DialogContent = __toESM(require("@mui/material/DialogContent"));
|
|
486
|
-
var
|
|
814
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
487
815
|
var DialogContent = (_a) => {
|
|
488
816
|
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
489
|
-
return /* @__PURE__ */ (0,
|
|
817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_DialogContent.default, __spreadProps(__spreadValues({}, rest), { children }));
|
|
490
818
|
};
|
|
491
819
|
|
|
492
820
|
// ../dialog/src/lib/DialogContentText.tsx
|
|
493
821
|
var import_DialogContentText = __toESM(require("@mui/material/DialogContentText"));
|
|
494
|
-
var
|
|
822
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
495
823
|
|
|
496
824
|
// ../dialog/src/lib/DialogTitle.tsx
|
|
497
825
|
var import_DialogTitle = __toESM(require("@mui/material/DialogTitle"));
|
|
498
826
|
var import_mui_alert2 = require("@availity/mui-alert");
|
|
499
827
|
var import_styles3 = require("@mui/material/styles");
|
|
500
|
-
var
|
|
828
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
501
829
|
var AlertIcon = (0, import_styles3.styled)("div", {
|
|
502
830
|
name: "MuiDialogTitle",
|
|
503
831
|
slot: "AvIcon",
|
|
@@ -510,26 +838,26 @@ var AlertIcon = (0, import_styles3.styled)("div", {
|
|
|
510
838
|
});
|
|
511
839
|
var DialogTitle = (_a) => {
|
|
512
840
|
var _b = _a, { children, component = "h2", icon, variant = "h5" } = _b, rest = __objRest(_b, ["children", "component", "icon", "variant"]);
|
|
513
|
-
return /* @__PURE__ */ (0,
|
|
514
|
-
icon ? /* @__PURE__ */ (0,
|
|
841
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_DialogTitle.default, __spreadProps(__spreadValues({ component, variant }, rest), { children: [
|
|
842
|
+
icon ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AlertIcon, { children: import_mui_alert2.AlertIcons[icon] }) : null,
|
|
515
843
|
children
|
|
516
844
|
] }));
|
|
517
845
|
};
|
|
518
846
|
|
|
519
847
|
// src/lib/UploadProgressBar.tsx
|
|
520
848
|
var import_mui_form_utils3 = require("@availity/mui-form-utils");
|
|
521
|
-
var
|
|
522
|
-
var
|
|
849
|
+
var import_mui_icon5 = require("@availity/mui-icon");
|
|
850
|
+
var import_mui_layout4 = require("@availity/mui-layout");
|
|
523
851
|
var import_mui_list2 = require("@availity/mui-list");
|
|
524
852
|
var import_mui_progress = require("@availity/mui-progress");
|
|
525
853
|
|
|
526
854
|
// ../textfield/src/lib/TextField.tsx
|
|
527
|
-
var
|
|
855
|
+
var import_react3 = require("react");
|
|
528
856
|
var import_TextField = __toESM(require("@mui/material/TextField"));
|
|
529
857
|
var import_mui_form_utils2 = require("@availity/mui-form-utils");
|
|
530
|
-
var
|
|
531
|
-
var
|
|
532
|
-
var
|
|
858
|
+
var import_mui_layout3 = require("@availity/mui-layout");
|
|
859
|
+
var import_mui_typography3 = require("@availity/mui-typography");
|
|
860
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
533
861
|
var TextFieldFormHelperText = (_a) => {
|
|
534
862
|
var _b = _a, {
|
|
535
863
|
charCount,
|
|
@@ -543,18 +871,18 @@ var TextFieldFormHelperText = (_a) => {
|
|
|
543
871
|
"showCharacterCount"
|
|
544
872
|
]);
|
|
545
873
|
if (showCharacterCount) {
|
|
546
|
-
return /* @__PURE__ */ (0,
|
|
547
|
-
/* @__PURE__ */ (0,
|
|
548
|
-
/* @__PURE__ */ (0,
|
|
549
|
-
/* @__PURE__ */ (0,
|
|
874
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_mui_layout3.Grid, { container: true, justifyContent: "space-between", flexWrap: "nowrap", children: [
|
|
875
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_mui_form_utils2.FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { sx: { marginRight: "12px" }, children: helperText })),
|
|
876
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_mui_typography3.Typography, { variant: "caption", marginTop: "4px", lineHeight: "1.25rem", children: [
|
|
877
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_mui_typography3.Typography, { component: "span", variant: "inherit", color: charCount > maxLength ? "error" : "textPrimary", children: charCount || 0 }),
|
|
550
878
|
"/",
|
|
551
879
|
maxLength
|
|
552
880
|
] })
|
|
553
881
|
] });
|
|
554
882
|
}
|
|
555
|
-
return /* @__PURE__ */ (0,
|
|
883
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_mui_form_utils2.FormHelperText, __spreadProps(__spreadValues({}, FormHelperTextProps2), { children: helperText }));
|
|
556
884
|
};
|
|
557
|
-
var TextField = (0,
|
|
885
|
+
var TextField = (0, import_react3.forwardRef)((props, ref) => {
|
|
558
886
|
var _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
559
887
|
const _a = props, {
|
|
560
888
|
InputProps: InputProps2,
|
|
@@ -579,19 +907,19 @@ var TextField = (0, import_react2.forwardRef)((props, ref) => {
|
|
|
579
907
|
"showCharacterCount",
|
|
580
908
|
"displayOverflowMaxLength"
|
|
581
909
|
]);
|
|
582
|
-
const [openDetected, setOpenDetected] = (0,
|
|
583
|
-
const [charCount, setCharCount] = (0,
|
|
910
|
+
const [openDetected, setOpenDetected] = (0, import_react3.useState)(false);
|
|
911
|
+
const [charCount, setCharCount] = (0, import_react3.useState)(0);
|
|
584
912
|
const maxLength = (inputProps == null ? void 0 : inputProps.maxLength) || ((_c = (_b = rest.slotProps) == null ? void 0 : _b.htmlInput) == null ? void 0 : _c.maxLength);
|
|
585
913
|
const allReadOnly = (InputProps2 == null ? void 0 : InputProps2.readOnly) || (inputProps == null ? void 0 : inputProps.readOnly) || ((_e = (_d = rest.slotProps) == null ? void 0 : _d.htmlInput) == null ? void 0 : _e.readOnly) || ((_g = (_f = rest.slotProps) == null ? void 0 : _f.input) == null ? void 0 : _g.readOnly);
|
|
586
914
|
const resolvedProps = (props2) => !props2 || Object.keys(props2).length === 0 ? void 0 : props2;
|
|
587
|
-
return /* @__PURE__ */ (0,
|
|
915
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
588
916
|
import_TextField.default,
|
|
589
917
|
__spreadProps(__spreadValues({}, rest), {
|
|
590
918
|
onChange: (event) => {
|
|
591
919
|
setCharCount(event.target.value.length);
|
|
592
920
|
if (rest.onChange) rest.onChange(event);
|
|
593
921
|
},
|
|
594
|
-
helperText: helperText || /* @__PURE__ */ (0,
|
|
922
|
+
helperText: helperText || /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, {}),
|
|
595
923
|
slots: { formHelperText: TextFieldFormHelperText },
|
|
596
924
|
slotProps: {
|
|
597
925
|
input: resolvedProps(__spreadProps(__spreadValues(__spreadValues(__spreadValues({}, InputProps2), import_mui_form_utils2.InputPropOverrides), (_h = rest.slotProps) == null ? void 0 : _h.input), {
|
|
@@ -624,7 +952,7 @@ var TextField = (0, import_react2.forwardRef)((props, ref) => {
|
|
|
624
952
|
});
|
|
625
953
|
|
|
626
954
|
// src/lib/UploadProgressBar.tsx
|
|
627
|
-
var
|
|
955
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
628
956
|
var ERROR_MAPPINGS = [
|
|
629
957
|
{
|
|
630
958
|
pattern: /but has an extension for/i,
|
|
@@ -636,13 +964,13 @@ var friendlyErrorMessage = (errorMessage) => {
|
|
|
636
964
|
return mapping ? mapping.friendlyMessage : errorMessage;
|
|
637
965
|
};
|
|
638
966
|
var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
639
|
-
const [statePercentage, setStatePercentage] = (0,
|
|
640
|
-
const [errorMessage, setErrorMessage] = (0,
|
|
967
|
+
const [statePercentage, setStatePercentage] = (0, import_react4.useState)(upload.percentage || 0);
|
|
968
|
+
const [errorMessage, setErrorMessage] = (0, import_react4.useState)(
|
|
641
969
|
upload.errorMessage ? friendlyErrorMessage(upload.errorMessage) : ""
|
|
642
970
|
);
|
|
643
|
-
const [password, setPassword] = (0,
|
|
644
|
-
const [showPassword, setShowPassword] = (0,
|
|
645
|
-
const [modalOpen, setModalOpen] = (0,
|
|
971
|
+
const [password, setPassword] = (0, import_react4.useState)("");
|
|
972
|
+
const [showPassword, setShowPassword] = (0, import_react4.useState)(false);
|
|
973
|
+
const [modalOpen, setModalOpen] = (0, import_react4.useState)(false);
|
|
646
974
|
const handleOnProgress = () => {
|
|
647
975
|
setStatePercentage(upload.percentage);
|
|
648
976
|
setErrorMessage("");
|
|
@@ -673,24 +1001,24 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
|
673
1001
|
upload.onProgress.push(handleOnProgress);
|
|
674
1002
|
upload.onSuccess.push(handleOnSuccess);
|
|
675
1003
|
upload.onError.push(handleOnError);
|
|
676
|
-
return errorMessage ? /* @__PURE__ */ (0,
|
|
677
|
-
/* @__PURE__ */ (0,
|
|
1004
|
+
return errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_mui_layout4.Box, { sx: { display: "flex", flexWrap: "wrap", columnGap: "4px" }, children: [
|
|
1005
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
678
1006
|
import_mui_list2.ListItemText,
|
|
679
1007
|
{
|
|
680
1008
|
slotProps: { primary: { color: "text.error", variant: "body2", component: "div" } },
|
|
681
1009
|
sx: { wordWrap: "break-word" },
|
|
682
1010
|
children: [
|
|
683
|
-
/* @__PURE__ */ (0,
|
|
1011
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_icon5.WarningTriangleIcon, { sx: { verticalAlign: "middle", mt: "-2px" } }),
|
|
684
1012
|
" ",
|
|
685
1013
|
errorMessage
|
|
686
1014
|
]
|
|
687
1015
|
}
|
|
688
1016
|
),
|
|
689
|
-
upload.status === "encrypted" && /* @__PURE__ */ (0,
|
|
690
|
-
/* @__PURE__ */ (0,
|
|
691
|
-
/* @__PURE__ */ (0,
|
|
692
|
-
/* @__PURE__ */ (0,
|
|
693
|
-
/* @__PURE__ */ (0,
|
|
1017
|
+
upload.status === "encrypted" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "pwRequired", children: [
|
|
1018
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_button3.Button, { color: "secondary", size: "small", onClick: toggleModal, children: "Enter Password" }),
|
|
1019
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Dialog, { open: modalOpen, onClose: toggleModal, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("form", { onSubmit: verifyPassword, children: [
|
|
1020
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DialogTitle, { children: "Enter Password" }),
|
|
1021
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DialogContent, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
694
1022
|
TextField,
|
|
695
1023
|
{
|
|
696
1024
|
type: showPassword ? "text" : "password",
|
|
@@ -699,45 +1027,989 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
|
699
1027
|
onChange: handlePasswordChange,
|
|
700
1028
|
autoFocus: true,
|
|
701
1029
|
InputProps: {
|
|
702
|
-
endAdornment: /* @__PURE__ */ (0,
|
|
1030
|
+
endAdornment: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_form_utils3.InputAdornment, { position: "end", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
703
1031
|
import_mui_button3.IconButton,
|
|
704
1032
|
{
|
|
705
1033
|
title: "password visibility",
|
|
706
1034
|
onClick: () => setShowPassword((prev) => !prev),
|
|
707
1035
|
edge: "end",
|
|
708
|
-
children: showPassword ? /* @__PURE__ */ (0,
|
|
1036
|
+
children: showPassword ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_icon5.EyeIcon, { fontSize: "small" }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_icon5.EyeSlashIcon, { fontSize: "small" })
|
|
709
1037
|
}
|
|
710
1038
|
) })
|
|
711
1039
|
}
|
|
712
1040
|
}
|
|
713
1041
|
) }),
|
|
714
|
-
/* @__PURE__ */ (0,
|
|
1042
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DialogActions, { children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_button3.Button, { color: "primary", type: "submit", children: "Ok" }) })
|
|
715
1043
|
] }) })
|
|
716
1044
|
] })
|
|
717
|
-
] }) : /* @__PURE__ */ (0,
|
|
1045
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_progress.LinearProgress, { value: statePercentage, "aria-label": `${upload.file.name}-progress` });
|
|
718
1046
|
};
|
|
719
1047
|
|
|
720
|
-
//
|
|
721
|
-
var
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
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
|
+
// src/lib/useUploadCore.tsx
|
|
1994
|
+
var import_upload_core2 = __toESM(require("@availity/upload-core"));
|
|
1995
|
+
function startUpload2(file, options) {
|
|
1996
|
+
return __async(this, null, function* () {
|
|
1997
|
+
const _a = options, { onSuccess, onError, onProgress, onChunkComplete } = _a, uploadOptions = __objRest(_a, ["onSuccess", "onError", "onProgress", "onChunkComplete"]);
|
|
1998
|
+
const upload = new import_upload_core2.default(file, uploadOptions);
|
|
1999
|
+
yield upload.generateId();
|
|
2000
|
+
if (onSuccess) upload.onSuccess.push(onSuccess);
|
|
2001
|
+
if (onError) upload.onError.push(onError);
|
|
2002
|
+
if (onProgress) upload.onProgress.push(onProgress);
|
|
2003
|
+
if (onChunkComplete) upload.onChunkComplete.push(onChunkComplete);
|
|
2004
|
+
upload.start();
|
|
2005
|
+
return upload;
|
|
734
2006
|
});
|
|
735
2007
|
}
|
|
736
2008
|
function useUploadCore(file, options, queryOptions) {
|
|
737
2009
|
const isQueryEnabled = !!file;
|
|
738
|
-
return
|
|
2010
|
+
return useQuery(__spreadValues({
|
|
739
2011
|
queryKey: ["upload", file.name, options],
|
|
740
|
-
queryFn: () =>
|
|
2012
|
+
queryFn: () => startUpload2(file, options),
|
|
741
2013
|
enabled: isQueryEnabled,
|
|
742
2014
|
retry: false,
|
|
743
2015
|
refetchOnWindowFocus: false
|
|
@@ -745,7 +2017,7 @@ function useUploadCore(file, options, queryOptions) {
|
|
|
745
2017
|
}
|
|
746
2018
|
|
|
747
2019
|
// src/lib/FileList.tsx
|
|
748
|
-
var
|
|
2020
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
749
2021
|
var FileRow = ({
|
|
750
2022
|
file,
|
|
751
2023
|
options,
|
|
@@ -757,12 +2029,12 @@ var FileRow = ({
|
|
|
757
2029
|
const Icon = getFileExtIcon(file.name);
|
|
758
2030
|
const { data: upload } = useUploadCore(file, options, queryOptions);
|
|
759
2031
|
if (!upload) return null;
|
|
760
|
-
if (CustomRow) return /* @__PURE__ */ (0,
|
|
761
|
-
return /* @__PURE__ */ (0,
|
|
2032
|
+
if (CustomRow) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CustomRow, { upload, options, onRemoveFile });
|
|
2033
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
762
2034
|
import_mui_list3.ListItem,
|
|
763
2035
|
{
|
|
764
2036
|
disableGutters: true,
|
|
765
|
-
secondaryAction: !disableRemove && /* @__PURE__ */ (0,
|
|
2037
|
+
secondaryAction: !disableRemove && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
766
2038
|
import_mui_button4.IconButton,
|
|
767
2039
|
{
|
|
768
2040
|
title: "remove file",
|
|
@@ -770,17 +2042,17 @@ var FileRow = ({
|
|
|
770
2042
|
onClick: () => {
|
|
771
2043
|
onRemoveFile(upload.id, upload);
|
|
772
2044
|
},
|
|
773
|
-
children: /* @__PURE__ */ (0,
|
|
2045
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_icon6.DeleteIcon, {})
|
|
774
2046
|
}
|
|
775
2047
|
),
|
|
776
2048
|
children: [
|
|
777
|
-
/* @__PURE__ */ (0,
|
|
778
|
-
/* @__PURE__ */ (0,
|
|
779
|
-
/* @__PURE__ */ (0,
|
|
780
|
-
/* @__PURE__ */ (0,
|
|
781
|
-
/* @__PURE__ */ (0,
|
|
2049
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_mui_layout5.Grid, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
|
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_layout5.Grid, { size: { xs: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_list3.ListItemIcon, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Icon, {}) }) }),
|
|
2051
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_layout5.Grid, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_list3.ListItemText, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
|
|
2052
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_layout5.Grid, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_list3.ListItemText, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
|
|
2053
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_layout5.Grid, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(UploadProgressBar, { upload }) })
|
|
782
2054
|
] }),
|
|
783
|
-
/* @__PURE__ */ (0,
|
|
2055
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_divider3.Divider, {})
|
|
784
2056
|
]
|
|
785
2057
|
}
|
|
786
2058
|
);
|
|
@@ -794,8 +2066,8 @@ var FileList = ({
|
|
|
794
2066
|
disableRemove
|
|
795
2067
|
}) => {
|
|
796
2068
|
if (files.length === 0) return null;
|
|
797
|
-
return /* @__PURE__ */ (0,
|
|
798
|
-
return /* @__PURE__ */ (0,
|
|
2069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_mui_list3.List, { children: files.map((file) => {
|
|
2070
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
799
2071
|
FileRow,
|
|
800
2072
|
{
|
|
801
2073
|
file,
|
|
@@ -810,17 +2082,83 @@ var FileList = ({
|
|
|
810
2082
|
}) });
|
|
811
2083
|
};
|
|
812
2084
|
|
|
2085
|
+
// src/lib/FileList2.tsx
|
|
2086
|
+
var import_mui_list4 = require("@availity/mui-list");
|
|
2087
|
+
var import_mui_button5 = require("@availity/mui-button");
|
|
2088
|
+
var import_mui_icon7 = require("@availity/mui-icon");
|
|
2089
|
+
var import_mui_layout6 = require("@availity/mui-layout");
|
|
2090
|
+
var import_mui_divider4 = require("@availity/mui-divider");
|
|
2091
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2092
|
+
var FileRow2 = ({
|
|
2093
|
+
upload,
|
|
2094
|
+
options,
|
|
2095
|
+
onRemoveFile,
|
|
2096
|
+
customFileRow: CustomRow,
|
|
2097
|
+
disableRemove = false
|
|
2098
|
+
}) => {
|
|
2099
|
+
const Icon = getFileExtIcon(upload.file.name);
|
|
2100
|
+
if (!upload) return null;
|
|
2101
|
+
if (CustomRow) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CustomRow, { upload, options, onRemoveFile });
|
|
2102
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
2103
|
+
import_mui_list4.ListItem,
|
|
2104
|
+
{
|
|
2105
|
+
disableGutters: true,
|
|
2106
|
+
secondaryAction: !disableRemove && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2107
|
+
import_mui_button5.IconButton,
|
|
2108
|
+
{
|
|
2109
|
+
title: "remove file",
|
|
2110
|
+
edge: "end",
|
|
2111
|
+
onClick: () => {
|
|
2112
|
+
onRemoveFile(upload.id, upload);
|
|
2113
|
+
},
|
|
2114
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_icon7.DeleteIcon, {})
|
|
2115
|
+
}
|
|
2116
|
+
),
|
|
2117
|
+
children: [
|
|
2118
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_mui_layout6.Grid, { container: true, spacing: 2, alignItems: "center", justifyContent: "space-between", width: "100%", flexWrap: "wrap", children: [
|
|
2119
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_layout6.Grid, { size: { xs: "auto" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_list4.ListItemIcon, { sx: { minWidth: "1.5rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Icon, {}) }) }),
|
|
2120
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_layout6.Grid, { size: { xs: 4 }, sx: { minWidth: "8rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_list4.ListItemText, { sx: { wordBreak: "break-all" }, children: upload.trimFileName(upload.file.name) }) }),
|
|
2121
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_layout6.Grid, { size: { xs: 2 }, sx: { minWidth: "3rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_list4.ListItemText, { sx: { textAlign: "end" }, children: formatBytes(upload.file.size) }) }),
|
|
2122
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_layout6.Grid, { size: { xs: "grow" }, sx: { minWidth: "6rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(UploadProgressBar, { upload }) })
|
|
2123
|
+
] }),
|
|
2124
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_divider4.Divider, {})
|
|
2125
|
+
]
|
|
2126
|
+
}
|
|
2127
|
+
);
|
|
2128
|
+
};
|
|
2129
|
+
var FileList2 = ({
|
|
2130
|
+
uploads,
|
|
2131
|
+
options,
|
|
2132
|
+
onRemoveFile,
|
|
2133
|
+
customFileRow,
|
|
2134
|
+
disableRemove
|
|
2135
|
+
}) => {
|
|
2136
|
+
if (uploads.length === 0) return null;
|
|
2137
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_mui_list4.List, { children: uploads.map((upload) => {
|
|
2138
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
2139
|
+
FileRow2,
|
|
2140
|
+
{
|
|
2141
|
+
upload,
|
|
2142
|
+
options,
|
|
2143
|
+
onRemoveFile,
|
|
2144
|
+
customFileRow,
|
|
2145
|
+
disableRemove
|
|
2146
|
+
},
|
|
2147
|
+
upload.id
|
|
2148
|
+
);
|
|
2149
|
+
}) });
|
|
2150
|
+
};
|
|
2151
|
+
|
|
813
2152
|
// src/lib/FileSelector.tsx
|
|
814
|
-
var
|
|
815
|
-
var
|
|
816
|
-
var
|
|
817
|
-
var
|
|
818
|
-
var import_mui_typography5 = require("@availity/mui-typography");
|
|
2153
|
+
var import_react5 = require("react");
|
|
2154
|
+
var import_react_hook_form4 = require("react-hook-form");
|
|
2155
|
+
var import_mui_layout7 = require("@availity/mui-layout");
|
|
2156
|
+
var import_mui_typography6 = require("@availity/mui-typography");
|
|
819
2157
|
var import_mui_alert3 = require("@availity/mui-alert");
|
|
820
2158
|
|
|
821
2159
|
// src/lib/FileTypesMessage.tsx
|
|
822
|
-
var
|
|
823
|
-
var
|
|
2160
|
+
var import_mui_typography4 = require("@availity/mui-typography");
|
|
2161
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
824
2162
|
var FileTypesMessage = ({
|
|
825
2163
|
allowedFileTypes = [],
|
|
826
2164
|
customSizeMessage,
|
|
@@ -830,17 +2168,17 @@ var FileTypesMessage = ({
|
|
|
830
2168
|
}) => {
|
|
831
2169
|
const fileSizeMsg = customSizeMessage || (typeof maxFileSize === "number" ? `Maximum file size is ${formatBytes(maxFileSize)}. ` : null);
|
|
832
2170
|
const fileTypesMsg = customTypesMessage || (allowedFileTypes.length > 0 ? `Supported file types include: ${allowedFileTypes.join(", ")}` : "All file types allowed.");
|
|
833
|
-
return /* @__PURE__ */ (0,
|
|
2171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(import_mui_typography4.Typography, { variant, children: [
|
|
834
2172
|
fileSizeMsg,
|
|
835
2173
|
fileTypesMsg
|
|
836
2174
|
] });
|
|
837
2175
|
};
|
|
838
2176
|
|
|
839
2177
|
// src/lib/HeaderMessage.tsx
|
|
840
|
-
var
|
|
841
|
-
var
|
|
2178
|
+
var import_mui_typography5 = require("@availity/mui-typography");
|
|
2179
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
842
2180
|
var HeaderMessage = ({ maxFiles, maxSize }) => {
|
|
843
|
-
return /* @__PURE__ */ (0,
|
|
2181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_mui_typography5.Typography, { variant: "h6", children: [
|
|
844
2182
|
"Attach up to ",
|
|
845
2183
|
maxFiles,
|
|
846
2184
|
" file(s), with a maximum individual size of ",
|
|
@@ -849,7 +2187,7 @@ var HeaderMessage = ({ maxFiles, maxSize }) => {
|
|
|
849
2187
|
};
|
|
850
2188
|
|
|
851
2189
|
// src/lib/FileSelector.tsx
|
|
852
|
-
var
|
|
2190
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
853
2191
|
var CLOUD_URL = "/cloud/web/appl/vault/upload/v1/resumable";
|
|
854
2192
|
var FileSelector = ({
|
|
855
2193
|
name,
|
|
@@ -878,10 +2216,10 @@ var FileSelector = ({
|
|
|
878
2216
|
validator,
|
|
879
2217
|
disableRemove
|
|
880
2218
|
}) => {
|
|
881
|
-
const [totalSize, setTotalSize] = (0,
|
|
882
|
-
const [fileRejections, setFileRejections] = (0,
|
|
883
|
-
const client =
|
|
884
|
-
const formMethods = (0,
|
|
2219
|
+
const [totalSize, setTotalSize] = (0, import_react5.useState)(0);
|
|
2220
|
+
const [fileRejections, setFileRejections] = (0, import_react5.useState)([]);
|
|
2221
|
+
const client = useQueryClient();
|
|
2222
|
+
const formMethods = (0, import_react_hook_form4.useFormContext)();
|
|
885
2223
|
const options = __spreadProps(__spreadValues({}, uploadOptions), {
|
|
886
2224
|
bucketId,
|
|
887
2225
|
customerId,
|
|
@@ -920,10 +2258,10 @@ var FileSelector = ({
|
|
|
920
2258
|
const otherRejections = fileRejections.filter(
|
|
921
2259
|
(rejection) => !rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
|
|
922
2260
|
);
|
|
923
|
-
return /* @__PURE__ */ (0,
|
|
924
|
-
enableDropArea ? /* @__PURE__ */ (0,
|
|
925
|
-
label ? /* @__PURE__ */ (0,
|
|
926
|
-
/* @__PURE__ */ (0,
|
|
2261
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
2262
|
+
enableDropArea ? /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
2263
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_mui_typography6.Typography, { marginBottom: "4px", children: label }) : null,
|
|
2264
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
927
2265
|
Dropzone,
|
|
928
2266
|
{
|
|
929
2267
|
name,
|
|
@@ -940,7 +2278,7 @@ var FileSelector = ({
|
|
|
940
2278
|
validator
|
|
941
2279
|
}
|
|
942
2280
|
),
|
|
943
|
-
/* @__PURE__ */ (0,
|
|
2281
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
944
2282
|
FileTypesMessage,
|
|
945
2283
|
{
|
|
946
2284
|
allowedFileTypes,
|
|
@@ -951,10 +2289,10 @@ var FileSelector = ({
|
|
|
951
2289
|
}
|
|
952
2290
|
),
|
|
953
2291
|
children
|
|
954
|
-
] }) : /* @__PURE__ */ (0,
|
|
955
|
-
/* @__PURE__ */ (0,
|
|
956
|
-
/* @__PURE__ */ (0,
|
|
957
|
-
/* @__PURE__ */ (0,
|
|
2292
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_mui_layout7.Grid, { container: true, rowSpacing: 3, flexDirection: "column", children: [
|
|
2293
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_mui_layout7.Grid, { children: [
|
|
2294
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(HeaderMessage, { maxFiles, maxSize }),
|
|
2295
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
958
2296
|
FileTypesMessage,
|
|
959
2297
|
{
|
|
960
2298
|
allowedFileTypes,
|
|
@@ -964,8 +2302,8 @@ var FileSelector = ({
|
|
|
964
2302
|
}
|
|
965
2303
|
)
|
|
966
2304
|
] }),
|
|
967
|
-
children ? /* @__PURE__ */ (0,
|
|
968
|
-
/* @__PURE__ */ (0,
|
|
2305
|
+
children ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_mui_layout7.Grid, { children }) : null,
|
|
2306
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_mui_layout7.Grid, { children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
969
2307
|
Dropzone,
|
|
970
2308
|
{
|
|
971
2309
|
name,
|
|
@@ -983,20 +2321,20 @@ var FileSelector = ({
|
|
|
983
2321
|
}
|
|
984
2322
|
) })
|
|
985
2323
|
] }),
|
|
986
|
-
tooManyFilesRejections.length > 0 && /* @__PURE__ */ (0,
|
|
2324
|
+
tooManyFilesRejections.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
987
2325
|
import_mui_alert3.Alert,
|
|
988
2326
|
{
|
|
989
2327
|
severity: "error",
|
|
990
2328
|
onClose: () => tooManyFilesRejections.forEach((rejection) => handleRemoveRejection(rejection.id)),
|
|
991
2329
|
children: [
|
|
992
|
-
/* @__PURE__ */ (0,
|
|
2330
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_mui_alert3.AlertTitle, { children: "Items not allowed." }),
|
|
993
2331
|
"Too many files are selected for upload, maximum ",
|
|
994
2332
|
maxFiles,
|
|
995
2333
|
" allowed."
|
|
996
2334
|
]
|
|
997
2335
|
}
|
|
998
2336
|
),
|
|
999
|
-
otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ (0,
|
|
2337
|
+
otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1000
2338
|
ErrorAlert,
|
|
1001
2339
|
{
|
|
1002
2340
|
errors: rejection.errors,
|
|
@@ -1006,7 +2344,7 @@ var FileSelector = ({
|
|
|
1006
2344
|
},
|
|
1007
2345
|
rejection.id
|
|
1008
2346
|
)),
|
|
1009
|
-
/* @__PURE__ */ (0,
|
|
2347
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1010
2348
|
FileList,
|
|
1011
2349
|
{
|
|
1012
2350
|
files: files || [],
|
|
@@ -1019,17 +2357,224 @@ var FileSelector = ({
|
|
|
1019
2357
|
)
|
|
1020
2358
|
] });
|
|
1021
2359
|
};
|
|
2360
|
+
|
|
2361
|
+
// src/lib/FileSelector2.tsx
|
|
2362
|
+
var import_react6 = require("react");
|
|
2363
|
+
var import_react_hook_form5 = require("react-hook-form");
|
|
2364
|
+
var import_mui_layout8 = require("@availity/mui-layout");
|
|
2365
|
+
var import_mui_typography7 = require("@availity/mui-typography");
|
|
2366
|
+
var import_mui_alert4 = require("@availity/mui-alert");
|
|
2367
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
2368
|
+
var FileSelector2 = ({
|
|
2369
|
+
name,
|
|
2370
|
+
allowedFileNameCharacters,
|
|
2371
|
+
allowedFileTypes = [],
|
|
2372
|
+
bucketId,
|
|
2373
|
+
clientId,
|
|
2374
|
+
children,
|
|
2375
|
+
customSizeMessage,
|
|
2376
|
+
customTypesMessage,
|
|
2377
|
+
customerId,
|
|
2378
|
+
customFileRow,
|
|
2379
|
+
disabled = false,
|
|
2380
|
+
enableDropArea = true,
|
|
2381
|
+
endpoint,
|
|
2382
|
+
isCloud,
|
|
2383
|
+
label = "Upload file",
|
|
2384
|
+
maxFiles,
|
|
2385
|
+
maxSize,
|
|
2386
|
+
multiple = true,
|
|
2387
|
+
onChange,
|
|
2388
|
+
onDrop,
|
|
2389
|
+
onUploadRemove,
|
|
2390
|
+
uploadOptions,
|
|
2391
|
+
validator,
|
|
2392
|
+
disableRemove
|
|
2393
|
+
}) => {
|
|
2394
|
+
const [totalSize, setTotalSize] = (0, import_react6.useState)(0);
|
|
2395
|
+
const [fileRejections, setFileRejections] = (0, import_react6.useState)([]);
|
|
2396
|
+
const formMethods = (0, import_react_hook_form5.useFormContext)();
|
|
2397
|
+
const options = __spreadProps(__spreadValues({}, uploadOptions), {
|
|
2398
|
+
bucketId,
|
|
2399
|
+
customerId,
|
|
2400
|
+
clientId,
|
|
2401
|
+
fileTypes: allowedFileTypes,
|
|
2402
|
+
maxSize,
|
|
2403
|
+
allowedFileNameCharacters
|
|
2404
|
+
});
|
|
2405
|
+
if (endpoint) options.endpoint = endpoint;
|
|
2406
|
+
if (isCloud) options.endpoint = CLOUD_URL;
|
|
2407
|
+
const handleOnRemoveFile = (uploadId, upload) => {
|
|
2408
|
+
const prevFiles = formMethods.getValues(name);
|
|
2409
|
+
const newFiles = prevFiles.filter((prev) => prev.file.name !== upload.file.name);
|
|
2410
|
+
if (newFiles.length !== prevFiles.length) {
|
|
2411
|
+
const removedFile = prevFiles.find((prev) => prev.file.name === upload.file.name);
|
|
2412
|
+
try {
|
|
2413
|
+
upload.abort();
|
|
2414
|
+
} catch (e) {
|
|
2415
|
+
console.error("Encountered an issue stopping the file upload");
|
|
2416
|
+
}
|
|
2417
|
+
formMethods.setValue(name, newFiles);
|
|
2418
|
+
if (removedFile == null ? void 0 : removedFile.file.size) setTotalSize(totalSize - removedFile.file.size);
|
|
2419
|
+
if (onUploadRemove) onUploadRemove(newFiles, uploadId);
|
|
2420
|
+
}
|
|
2421
|
+
};
|
|
2422
|
+
const uploads = formMethods.watch(name) || [];
|
|
2423
|
+
const handleRemoveRejection = (id) => {
|
|
2424
|
+
const rejections = fileRejections.filter((value) => value.id !== id);
|
|
2425
|
+
setFileRejections(rejections);
|
|
2426
|
+
};
|
|
2427
|
+
const TOO_MANY_FILES_CODE = "too-many-files";
|
|
2428
|
+
const tooManyFilesRejections = fileRejections.filter(
|
|
2429
|
+
(rejection) => rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
|
|
2430
|
+
);
|
|
2431
|
+
const otherRejections = fileRejections.filter(
|
|
2432
|
+
(rejection) => !rejection.errors.some((error) => error.code === TOO_MANY_FILES_CODE)
|
|
2433
|
+
);
|
|
2434
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
2435
|
+
enableDropArea ? /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
2436
|
+
label ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_mui_typography7.Typography, { marginBottom: "4px", children: label }) : null,
|
|
2437
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2438
|
+
Dropzone2,
|
|
2439
|
+
{
|
|
2440
|
+
name,
|
|
2441
|
+
allowedFileTypes,
|
|
2442
|
+
disabled,
|
|
2443
|
+
enableDropArea,
|
|
2444
|
+
maxFiles,
|
|
2445
|
+
maxSize,
|
|
2446
|
+
multiple,
|
|
2447
|
+
onChange,
|
|
2448
|
+
onDrop,
|
|
2449
|
+
setFileRejections,
|
|
2450
|
+
setTotalSize,
|
|
2451
|
+
uploadOptions: options,
|
|
2452
|
+
validator
|
|
2453
|
+
}
|
|
2454
|
+
),
|
|
2455
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2456
|
+
FileTypesMessage,
|
|
2457
|
+
{
|
|
2458
|
+
allowedFileTypes,
|
|
2459
|
+
maxFileSize: maxSize,
|
|
2460
|
+
customSizeMessage,
|
|
2461
|
+
customTypesMessage,
|
|
2462
|
+
variant: "caption"
|
|
2463
|
+
}
|
|
2464
|
+
),
|
|
2465
|
+
children
|
|
2466
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_mui_layout8.Grid, { container: true, rowSpacing: 3, flexDirection: "column", children: [
|
|
2467
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_mui_layout8.Grid, { children: [
|
|
2468
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(HeaderMessage, { maxFiles, maxSize }),
|
|
2469
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2470
|
+
FileTypesMessage,
|
|
2471
|
+
{
|
|
2472
|
+
allowedFileTypes,
|
|
2473
|
+
customSizeMessage,
|
|
2474
|
+
customTypesMessage,
|
|
2475
|
+
variant: "body2"
|
|
2476
|
+
}
|
|
2477
|
+
)
|
|
2478
|
+
] }),
|
|
2479
|
+
children ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_mui_layout8.Grid, { children }) : null,
|
|
2480
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_mui_layout8.Grid, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2481
|
+
Dropzone2,
|
|
2482
|
+
{
|
|
2483
|
+
name,
|
|
2484
|
+
allowedFileTypes,
|
|
2485
|
+
disabled,
|
|
2486
|
+
enableDropArea,
|
|
2487
|
+
maxFiles,
|
|
2488
|
+
maxSize,
|
|
2489
|
+
multiple,
|
|
2490
|
+
onChange,
|
|
2491
|
+
onDrop,
|
|
2492
|
+
setFileRejections,
|
|
2493
|
+
setTotalSize,
|
|
2494
|
+
uploadOptions: options,
|
|
2495
|
+
validator
|
|
2496
|
+
}
|
|
2497
|
+
) })
|
|
2498
|
+
] }),
|
|
2499
|
+
tooManyFilesRejections.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
2500
|
+
import_mui_alert4.Alert,
|
|
2501
|
+
{
|
|
2502
|
+
severity: "error",
|
|
2503
|
+
onClose: () => tooManyFilesRejections.forEach((rejection) => handleRemoveRejection(rejection.id)),
|
|
2504
|
+
children: [
|
|
2505
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_mui_alert4.AlertTitle, { children: "Items not allowed." }),
|
|
2506
|
+
"Too many files are selected for upload, maximum ",
|
|
2507
|
+
maxFiles,
|
|
2508
|
+
" allowed."
|
|
2509
|
+
]
|
|
2510
|
+
}
|
|
2511
|
+
),
|
|
2512
|
+
otherRejections.length > 0 && otherRejections.map((rejection) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2513
|
+
ErrorAlert,
|
|
2514
|
+
{
|
|
2515
|
+
errors: rejection.errors,
|
|
2516
|
+
fileName: rejection.file.name,
|
|
2517
|
+
id: rejection.id,
|
|
2518
|
+
onClose: () => handleRemoveRejection(rejection.id)
|
|
2519
|
+
},
|
|
2520
|
+
rejection.id
|
|
2521
|
+
)),
|
|
2522
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
2523
|
+
FileList2,
|
|
2524
|
+
{
|
|
2525
|
+
uploads: uploads || [],
|
|
2526
|
+
options,
|
|
2527
|
+
onRemoveFile: handleOnRemoveFile,
|
|
2528
|
+
customFileRow,
|
|
2529
|
+
disableRemove
|
|
2530
|
+
}
|
|
2531
|
+
)
|
|
2532
|
+
] });
|
|
2533
|
+
};
|
|
1022
2534
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1023
2535
|
0 && (module.exports = {
|
|
2536
|
+
CLOUD_URL,
|
|
1024
2537
|
Dropzone,
|
|
2538
|
+
Dropzone2,
|
|
2539
|
+
DropzoneContainer,
|
|
1025
2540
|
ErrorAlert,
|
|
1026
2541
|
FileList,
|
|
2542
|
+
FileList2,
|
|
1027
2543
|
FilePickerBtn,
|
|
1028
2544
|
FileRow,
|
|
2545
|
+
FileRow2,
|
|
1029
2546
|
FileSelector,
|
|
2547
|
+
FileSelector2,
|
|
1030
2548
|
FileTypesMessage,
|
|
1031
2549
|
HeaderMessage,
|
|
1032
2550
|
UploadProgressBar,
|
|
2551
|
+
createCounter,
|
|
1033
2552
|
formatFileTooLarge,
|
|
2553
|
+
innerBoxStyles,
|
|
2554
|
+
outerBoxStyles,
|
|
1034
2555
|
useUploadCore
|
|
1035
2556
|
});
|
|
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
|
+
*/
|