@availity/mui-file-selector 1.7.0 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.js +4 -1103
- package/dist/index.mjs +8 -1133
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -34,9 +34,6 @@ var __objRest = (source, exclude) => {
|
|
|
34
34
|
}
|
|
35
35
|
return target;
|
|
36
36
|
};
|
|
37
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
38
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
39
|
-
};
|
|
40
37
|
var __export = (target, all) => {
|
|
41
38
|
for (var name in all)
|
|
42
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -79,135 +76,6 @@ var __async = (__this, __arguments, generator) => {
|
|
|
79
76
|
});
|
|
80
77
|
};
|
|
81
78
|
|
|
82
|
-
// ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js
|
|
83
|
-
var require_use_sync_external_store_shim_production = __commonJS({
|
|
84
|
-
"../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js"(exports2) {
|
|
85
|
-
"use strict";
|
|
86
|
-
var React6 = require("react");
|
|
87
|
-
function is(x, y) {
|
|
88
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
89
|
-
}
|
|
90
|
-
var objectIs = "function" === typeof Object.is ? Object.is : is;
|
|
91
|
-
var useState7 = React6.useState;
|
|
92
|
-
var useEffect4 = React6.useEffect;
|
|
93
|
-
var useLayoutEffect = React6.useLayoutEffect;
|
|
94
|
-
var useDebugValue = React6.useDebugValue;
|
|
95
|
-
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
96
|
-
var value = getSnapshot(), _useState = useState7({ inst: { value, getSnapshot } }), inst = _useState[0].inst, forceUpdate = _useState[1];
|
|
97
|
-
useLayoutEffect(
|
|
98
|
-
function() {
|
|
99
|
-
inst.value = value;
|
|
100
|
-
inst.getSnapshot = getSnapshot;
|
|
101
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
102
|
-
},
|
|
103
|
-
[subscribe, value, getSnapshot]
|
|
104
|
-
);
|
|
105
|
-
useEffect4(
|
|
106
|
-
function() {
|
|
107
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
108
|
-
return subscribe(function() {
|
|
109
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
[subscribe]
|
|
113
|
-
);
|
|
114
|
-
useDebugValue(value);
|
|
115
|
-
return value;
|
|
116
|
-
}
|
|
117
|
-
function checkIfSnapshotChanged(inst) {
|
|
118
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
119
|
-
inst = inst.value;
|
|
120
|
-
try {
|
|
121
|
-
var nextValue = latestGetSnapshot();
|
|
122
|
-
return !objectIs(inst, nextValue);
|
|
123
|
-
} catch (error) {
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
function useSyncExternalStore$12(subscribe, getSnapshot) {
|
|
128
|
-
return getSnapshot();
|
|
129
|
-
}
|
|
130
|
-
var shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$12 : useSyncExternalStore$2;
|
|
131
|
-
exports2.useSyncExternalStore = void 0 !== React6.useSyncExternalStore ? React6.useSyncExternalStore : shim;
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// ../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
|
|
136
|
-
var require_use_sync_external_store_shim_development = __commonJS({
|
|
137
|
-
"../../node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports2) {
|
|
138
|
-
"use strict";
|
|
139
|
-
"production" !== process.env.NODE_ENV && function() {
|
|
140
|
-
function is(x, y) {
|
|
141
|
-
return x === y && (0 !== x || 1 / x === 1 / y) || x !== x && y !== y;
|
|
142
|
-
}
|
|
143
|
-
function useSyncExternalStore$2(subscribe, getSnapshot) {
|
|
144
|
-
didWarnOld18Alpha || void 0 === React6.startTransition || (didWarnOld18Alpha = true, console.error(
|
|
145
|
-
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
146
|
-
));
|
|
147
|
-
var value = getSnapshot();
|
|
148
|
-
if (!didWarnUncachedGetSnapshot) {
|
|
149
|
-
var cachedValue = getSnapshot();
|
|
150
|
-
objectIs(value, cachedValue) || (console.error(
|
|
151
|
-
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
152
|
-
), didWarnUncachedGetSnapshot = true);
|
|
153
|
-
}
|
|
154
|
-
cachedValue = useState7({
|
|
155
|
-
inst: { value, getSnapshot }
|
|
156
|
-
});
|
|
157
|
-
var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
|
|
158
|
-
useLayoutEffect(
|
|
159
|
-
function() {
|
|
160
|
-
inst.value = value;
|
|
161
|
-
inst.getSnapshot = getSnapshot;
|
|
162
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
163
|
-
},
|
|
164
|
-
[subscribe, value, getSnapshot]
|
|
165
|
-
);
|
|
166
|
-
useEffect4(
|
|
167
|
-
function() {
|
|
168
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
169
|
-
return subscribe(function() {
|
|
170
|
-
checkIfSnapshotChanged(inst) && forceUpdate({ inst });
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
[subscribe]
|
|
174
|
-
);
|
|
175
|
-
useDebugValue(value);
|
|
176
|
-
return value;
|
|
177
|
-
}
|
|
178
|
-
function checkIfSnapshotChanged(inst) {
|
|
179
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
180
|
-
inst = inst.value;
|
|
181
|
-
try {
|
|
182
|
-
var nextValue = latestGetSnapshot();
|
|
183
|
-
return !objectIs(inst, nextValue);
|
|
184
|
-
} catch (error) {
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
function useSyncExternalStore$12(subscribe, getSnapshot) {
|
|
189
|
-
return getSnapshot();
|
|
190
|
-
}
|
|
191
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
192
|
-
var React6 = require("react"), objectIs = "function" === typeof Object.is ? Object.is : is, useState7 = React6.useState, useEffect4 = React6.useEffect, useLayoutEffect = React6.useLayoutEffect, useDebugValue = React6.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$12 : useSyncExternalStore$2;
|
|
193
|
-
exports2.useSyncExternalStore = void 0 !== React6.useSyncExternalStore ? React6.useSyncExternalStore : shim;
|
|
194
|
-
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
195
|
-
}();
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
// ../../node_modules/use-sync-external-store/shim/index.js
|
|
200
|
-
var require_shim = __commonJS({
|
|
201
|
-
"../../node_modules/use-sync-external-store/shim/index.js"(exports2, module2) {
|
|
202
|
-
"use strict";
|
|
203
|
-
if (process.env.NODE_ENV === "production") {
|
|
204
|
-
module2.exports = require_use_sync_external_store_shim_production();
|
|
205
|
-
} else {
|
|
206
|
-
module2.exports = require_use_sync_external_store_shim_development();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
|
|
211
79
|
// src/index.ts
|
|
212
80
|
var index_exports = {};
|
|
213
81
|
__export(index_exports, {
|
|
@@ -1045,952 +913,8 @@ var UploadProgressBar = ({ upload, onProgress, onError, onSuccess }) => {
|
|
|
1045
913
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_mui_progress.LinearProgress, { value: statePercentage, "aria-label": `${upload.file.name}-progress` });
|
|
1046
914
|
};
|
|
1047
915
|
|
|
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
916
|
// src/lib/useUploadCore.tsx
|
|
917
|
+
var import_react_query = require("@tanstack/react-query");
|
|
1994
918
|
var import_upload_core2 = __toESM(require("@availity/upload-core"));
|
|
1995
919
|
function startUpload2(file, options) {
|
|
1996
920
|
return __async(this, null, function* () {
|
|
@@ -2007,7 +931,7 @@ function startUpload2(file, options) {
|
|
|
2007
931
|
}
|
|
2008
932
|
function useUploadCore(file, options, queryOptions) {
|
|
2009
933
|
const isQueryEnabled = !!file;
|
|
2010
|
-
return useQuery(__spreadValues({
|
|
934
|
+
return (0, import_react_query.useQuery)(__spreadValues({
|
|
2011
935
|
queryKey: ["upload", file.name, options],
|
|
2012
936
|
queryFn: () => startUpload2(file, options),
|
|
2013
937
|
enabled: isQueryEnabled,
|
|
@@ -2152,6 +1076,7 @@ var FileList2 = ({
|
|
|
2152
1076
|
// src/lib/FileSelector.tsx
|
|
2153
1077
|
var import_react5 = require("react");
|
|
2154
1078
|
var import_react_hook_form4 = require("react-hook-form");
|
|
1079
|
+
var import_react_query2 = require("@tanstack/react-query");
|
|
2155
1080
|
var import_mui_layout7 = require("@availity/mui-layout");
|
|
2156
1081
|
var import_mui_typography6 = require("@availity/mui-typography");
|
|
2157
1082
|
var import_mui_alert3 = require("@availity/mui-alert");
|
|
@@ -2218,7 +1143,7 @@ var FileSelector = ({
|
|
|
2218
1143
|
}) => {
|
|
2219
1144
|
const [totalSize, setTotalSize] = (0, import_react5.useState)(0);
|
|
2220
1145
|
const [fileRejections, setFileRejections] = (0, import_react5.useState)([]);
|
|
2221
|
-
const client = useQueryClient();
|
|
1146
|
+
const client = (0, import_react_query2.useQueryClient)();
|
|
2222
1147
|
const formMethods = (0, import_react_hook_form4.useFormContext)();
|
|
2223
1148
|
const options = __spreadProps(__spreadValues({}, uploadOptions), {
|
|
2224
1149
|
bucketId,
|
|
@@ -2554,27 +1479,3 @@ var FileSelector2 = ({
|
|
|
2554
1479
|
outerBoxStyles,
|
|
2555
1480
|
useUploadCore
|
|
2556
1481
|
});
|
|
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
|
-
*/
|