@tanstack/react-query-devtools 4.3.0-beta.3 → 4.3.0-beta.7
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/build/lib/index.js +27 -1029
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +25 -1025
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/index.prod.d.ts +3 -0
- package/build/lib/index.prod.js +1280 -0
- package/build/lib/index.prod.js.map +1 -0
- package/build/lib/index.prod.mjs +1255 -0
- package/build/lib/index.prod.mjs.map +1 -0
- package/build/lib/screenreader.d.ts +4 -0
- package/build/lib/utils.d.ts +0 -1
- package/build/umd/index.development.js +22 -5
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +16 -16
- package/src/devtools.tsx +11 -3
- package/src/screenreader.tsx +16 -0
- package/src/utils.ts +1 -3
- package/build/lib/noop.js +0 -24
- package/build/lib/noop.js.map +0 -1
- package/build/lib/noop.mjs +0 -19
- package/build/lib/noop.mjs.map +0 -1
- package/build/umd/noop.development.js +0 -30
- package/build/umd/noop.development.js.map +0 -1
- package/build/umd/noop.production.js +0 -12
- package/build/umd/noop.production.js.map +0 -1
- package/cjs.fallback.js +0 -13
package/build/lib/index.mjs
CHANGED
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
import * as React from 'react';
|
|
12
|
-
import React__default from 'react';
|
|
13
12
|
import { useQueryClient, notifyManager, onlineManager } from '@tanstack/react-query';
|
|
13
|
+
import { rankItem, compareItems } from '@tanstack/match-sorter-utils';
|
|
14
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
|
|
14
15
|
|
|
15
16
|
function _extends() {
|
|
16
17
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -29,1024 +30,6 @@ function _extends() {
|
|
|
29
30
|
return _extends.apply(this, arguments);
|
|
30
31
|
}
|
|
31
32
|
|
|
32
|
-
var shim = {exports: {}};
|
|
33
|
-
|
|
34
|
-
var useSyncExternalStoreShim_production_min = {};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @license React
|
|
38
|
-
* use-sync-external-store-shim.production.min.js
|
|
39
|
-
*
|
|
40
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
41
|
-
*
|
|
42
|
-
* This source code is licensed under the MIT license found in the
|
|
43
|
-
* LICENSE file in the root directory of this source tree.
|
|
44
|
-
*/
|
|
45
|
-
|
|
46
|
-
var hasRequiredUseSyncExternalStoreShim_production_min;
|
|
47
|
-
|
|
48
|
-
function requireUseSyncExternalStoreShim_production_min () {
|
|
49
|
-
if (hasRequiredUseSyncExternalStoreShim_production_min) return useSyncExternalStoreShim_production_min;
|
|
50
|
-
hasRequiredUseSyncExternalStoreShim_production_min = 1;
|
|
51
|
-
var e=React__default;function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c});},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c});})},[a]);p(d);return d}
|
|
52
|
-
function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f){return !0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;useSyncExternalStoreShim_production_min.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;
|
|
53
|
-
return useSyncExternalStoreShim_production_min;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var useSyncExternalStoreShim_development = {};
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* @license React
|
|
60
|
-
* use-sync-external-store-shim.development.js
|
|
61
|
-
*
|
|
62
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the MIT license found in the
|
|
65
|
-
* LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/
|
|
67
|
-
|
|
68
|
-
var hasRequiredUseSyncExternalStoreShim_development;
|
|
69
|
-
|
|
70
|
-
function requireUseSyncExternalStoreShim_development () {
|
|
71
|
-
if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
|
|
72
|
-
hasRequiredUseSyncExternalStoreShim_development = 1;
|
|
73
|
-
|
|
74
|
-
if (process.env.NODE_ENV !== "production") {
|
|
75
|
-
(function() {
|
|
76
|
-
|
|
77
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
78
|
-
if (
|
|
79
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
80
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
81
|
-
'function'
|
|
82
|
-
) {
|
|
83
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
84
|
-
}
|
|
85
|
-
var React = React__default;
|
|
86
|
-
|
|
87
|
-
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
88
|
-
|
|
89
|
-
function error(format) {
|
|
90
|
-
{
|
|
91
|
-
{
|
|
92
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
93
|
-
args[_key2 - 1] = arguments[_key2];
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
printWarning('error', format, args);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function printWarning(level, format, args) {
|
|
102
|
-
// When changing this logic, you might want to also
|
|
103
|
-
// update consoleWithStackDev.www.js as well.
|
|
104
|
-
{
|
|
105
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
106
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
107
|
-
|
|
108
|
-
if (stack !== '') {
|
|
109
|
-
format += '%s';
|
|
110
|
-
args = args.concat([stack]);
|
|
111
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
var argsWithFormat = args.map(function (item) {
|
|
115
|
-
return String(item);
|
|
116
|
-
}); // Careful: RN currently depends on this prefix
|
|
117
|
-
|
|
118
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
119
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
120
|
-
// eslint-disable-next-line react-internal/no-production-logging
|
|
121
|
-
|
|
122
|
-
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
128
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
129
|
-
*/
|
|
130
|
-
function is(x, y) {
|
|
131
|
-
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
132
|
-
;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
136
|
-
|
|
137
|
-
// dispatch for CommonJS interop named imports.
|
|
138
|
-
|
|
139
|
-
var useState = React.useState,
|
|
140
|
-
useEffect = React.useEffect,
|
|
141
|
-
useLayoutEffect = React.useLayoutEffect,
|
|
142
|
-
useDebugValue = React.useDebugValue;
|
|
143
|
-
var didWarnOld18Alpha = false;
|
|
144
|
-
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
|
|
145
|
-
// because of a very particular set of implementation details and assumptions
|
|
146
|
-
// -- change any one of them and it will break. The most important assumption
|
|
147
|
-
// is that updates are always synchronous, because concurrent rendering is
|
|
148
|
-
// only available in versions of React that also have a built-in
|
|
149
|
-
// useSyncExternalStore API. And we only use this shim when the built-in API
|
|
150
|
-
// does not exist.
|
|
151
|
-
//
|
|
152
|
-
// Do not assume that the clever hacks used by this hook also work in general.
|
|
153
|
-
// The point of this shim is to replace the need for hacks by other libraries.
|
|
154
|
-
|
|
155
|
-
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
156
|
-
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
157
|
-
// will need to track that themselves and return the correct value
|
|
158
|
-
// from `getSnapshot`.
|
|
159
|
-
getServerSnapshot) {
|
|
160
|
-
{
|
|
161
|
-
if (!didWarnOld18Alpha) {
|
|
162
|
-
if (React.startTransition !== undefined) {
|
|
163
|
-
didWarnOld18Alpha = true;
|
|
164
|
-
|
|
165
|
-
error('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.');
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
} // Read the current snapshot from the store on every render. Again, this
|
|
169
|
-
// breaks the rules of React, and only works here because of specific
|
|
170
|
-
// implementation details, most importantly that updates are
|
|
171
|
-
// always synchronous.
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
var value = getSnapshot();
|
|
175
|
-
|
|
176
|
-
{
|
|
177
|
-
if (!didWarnUncachedGetSnapshot) {
|
|
178
|
-
var cachedValue = getSnapshot();
|
|
179
|
-
|
|
180
|
-
if (!objectIs(value, cachedValue)) {
|
|
181
|
-
error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
182
|
-
|
|
183
|
-
didWarnUncachedGetSnapshot = true;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
} // Because updates are synchronous, we don't queue them. Instead we force a
|
|
187
|
-
// re-render whenever the subscribed state changes by updating an some
|
|
188
|
-
// arbitrary useState hook. Then, during render, we call getSnapshot to read
|
|
189
|
-
// the current value.
|
|
190
|
-
//
|
|
191
|
-
// Because we don't actually use the state returned by the useState hook, we
|
|
192
|
-
// can save a bit of memory by storing other stuff in that slot.
|
|
193
|
-
//
|
|
194
|
-
// To implement the early bailout, we need to track some things on a mutable
|
|
195
|
-
// object. Usually, we would put that in a useRef hook, but we can stash it in
|
|
196
|
-
// our useState hook instead.
|
|
197
|
-
//
|
|
198
|
-
// To force a re-render, we call forceUpdate({inst}). That works because the
|
|
199
|
-
// new object always fails an equality check.
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
var _useState = useState({
|
|
203
|
-
inst: {
|
|
204
|
-
value: value,
|
|
205
|
-
getSnapshot: getSnapshot
|
|
206
|
-
}
|
|
207
|
-
}),
|
|
208
|
-
inst = _useState[0].inst,
|
|
209
|
-
forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
|
|
210
|
-
// in the layout phase so we can access it during the tearing check that
|
|
211
|
-
// happens on subscribe.
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
useLayoutEffect(function () {
|
|
215
|
-
inst.value = value;
|
|
216
|
-
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
|
|
217
|
-
// commit phase if there was an interleaved mutation. In concurrent mode
|
|
218
|
-
// this can happen all the time, but even in synchronous mode, an earlier
|
|
219
|
-
// effect may have mutated the store.
|
|
220
|
-
|
|
221
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
222
|
-
// Force a re-render.
|
|
223
|
-
forceUpdate({
|
|
224
|
-
inst: inst
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}, [subscribe, value, getSnapshot]);
|
|
228
|
-
useEffect(function () {
|
|
229
|
-
// Check for changes right before subscribing. Subsequent changes will be
|
|
230
|
-
// detected in the subscription handler.
|
|
231
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
232
|
-
// Force a re-render.
|
|
233
|
-
forceUpdate({
|
|
234
|
-
inst: inst
|
|
235
|
-
});
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
var handleStoreChange = function () {
|
|
239
|
-
// TODO: Because there is no cross-renderer API for batching updates, it's
|
|
240
|
-
// up to the consumer of this library to wrap their subscription event
|
|
241
|
-
// with unstable_batchedUpdates. Should we try to detect when this isn't
|
|
242
|
-
// the case and print a warning in development?
|
|
243
|
-
// The store changed. Check if the snapshot changed since the last time we
|
|
244
|
-
// read from the store.
|
|
245
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
246
|
-
// Force a re-render.
|
|
247
|
-
forceUpdate({
|
|
248
|
-
inst: inst
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
}; // Subscribe to the store and return a clean-up function.
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return subscribe(handleStoreChange);
|
|
255
|
-
}, [subscribe]);
|
|
256
|
-
useDebugValue(value);
|
|
257
|
-
return value;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function checkIfSnapshotChanged(inst) {
|
|
261
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
262
|
-
var prevValue = inst.value;
|
|
263
|
-
|
|
264
|
-
try {
|
|
265
|
-
var nextValue = latestGetSnapshot();
|
|
266
|
-
return !objectIs(prevValue, nextValue);
|
|
267
|
-
} catch (error) {
|
|
268
|
-
return true;
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
|
|
273
|
-
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
274
|
-
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
275
|
-
// will need to track that themselves and return the correct value
|
|
276
|
-
// from `getSnapshot`.
|
|
277
|
-
return getSnapshot();
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
|
|
281
|
-
|
|
282
|
-
var isServerEnvironment = !canUseDOM;
|
|
283
|
-
|
|
284
|
-
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
285
|
-
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
|
|
286
|
-
|
|
287
|
-
useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
|
|
288
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
289
|
-
if (
|
|
290
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
291
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
292
|
-
'function'
|
|
293
|
-
) {
|
|
294
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
})();
|
|
298
|
-
}
|
|
299
|
-
return useSyncExternalStoreShim_development;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
(function (module) {
|
|
303
|
-
|
|
304
|
-
if (process.env.NODE_ENV === 'production') {
|
|
305
|
-
module.exports = requireUseSyncExternalStoreShim_production_min();
|
|
306
|
-
} else {
|
|
307
|
-
module.exports = requireUseSyncExternalStoreShim_development();
|
|
308
|
-
}
|
|
309
|
-
} (shim));
|
|
310
|
-
|
|
311
|
-
/**
|
|
312
|
-
* match-sorter-utils
|
|
313
|
-
*
|
|
314
|
-
* Copyright (c) TanStack
|
|
315
|
-
*
|
|
316
|
-
* This source code is licensed under the MIT license found in the
|
|
317
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
318
|
-
*
|
|
319
|
-
* @license MIT
|
|
320
|
-
*/
|
|
321
|
-
const characterMap = {
|
|
322
|
-
À: 'A',
|
|
323
|
-
Á: 'A',
|
|
324
|
-
Â: 'A',
|
|
325
|
-
Ã: 'A',
|
|
326
|
-
Ä: 'A',
|
|
327
|
-
Å: 'A',
|
|
328
|
-
Ấ: 'A',
|
|
329
|
-
Ắ: 'A',
|
|
330
|
-
Ẳ: 'A',
|
|
331
|
-
Ẵ: 'A',
|
|
332
|
-
Ặ: 'A',
|
|
333
|
-
Æ: 'AE',
|
|
334
|
-
Ầ: 'A',
|
|
335
|
-
Ằ: 'A',
|
|
336
|
-
Ȃ: 'A',
|
|
337
|
-
Ç: 'C',
|
|
338
|
-
Ḉ: 'C',
|
|
339
|
-
È: 'E',
|
|
340
|
-
É: 'E',
|
|
341
|
-
Ê: 'E',
|
|
342
|
-
Ë: 'E',
|
|
343
|
-
Ế: 'E',
|
|
344
|
-
Ḗ: 'E',
|
|
345
|
-
Ề: 'E',
|
|
346
|
-
Ḕ: 'E',
|
|
347
|
-
Ḝ: 'E',
|
|
348
|
-
Ȇ: 'E',
|
|
349
|
-
Ì: 'I',
|
|
350
|
-
Í: 'I',
|
|
351
|
-
Î: 'I',
|
|
352
|
-
Ï: 'I',
|
|
353
|
-
Ḯ: 'I',
|
|
354
|
-
Ȋ: 'I',
|
|
355
|
-
Ð: 'D',
|
|
356
|
-
Ñ: 'N',
|
|
357
|
-
Ò: 'O',
|
|
358
|
-
Ó: 'O',
|
|
359
|
-
Ô: 'O',
|
|
360
|
-
Õ: 'O',
|
|
361
|
-
Ö: 'O',
|
|
362
|
-
Ø: 'O',
|
|
363
|
-
Ố: 'O',
|
|
364
|
-
Ṍ: 'O',
|
|
365
|
-
Ṓ: 'O',
|
|
366
|
-
Ȏ: 'O',
|
|
367
|
-
Ù: 'U',
|
|
368
|
-
Ú: 'U',
|
|
369
|
-
Û: 'U',
|
|
370
|
-
Ü: 'U',
|
|
371
|
-
Ý: 'Y',
|
|
372
|
-
à: 'a',
|
|
373
|
-
á: 'a',
|
|
374
|
-
â: 'a',
|
|
375
|
-
ã: 'a',
|
|
376
|
-
ä: 'a',
|
|
377
|
-
å: 'a',
|
|
378
|
-
ấ: 'a',
|
|
379
|
-
ắ: 'a',
|
|
380
|
-
ẳ: 'a',
|
|
381
|
-
ẵ: 'a',
|
|
382
|
-
ặ: 'a',
|
|
383
|
-
æ: 'ae',
|
|
384
|
-
ầ: 'a',
|
|
385
|
-
ằ: 'a',
|
|
386
|
-
ȃ: 'a',
|
|
387
|
-
ç: 'c',
|
|
388
|
-
ḉ: 'c',
|
|
389
|
-
è: 'e',
|
|
390
|
-
é: 'e',
|
|
391
|
-
ê: 'e',
|
|
392
|
-
ë: 'e',
|
|
393
|
-
ế: 'e',
|
|
394
|
-
ḗ: 'e',
|
|
395
|
-
ề: 'e',
|
|
396
|
-
ḕ: 'e',
|
|
397
|
-
ḝ: 'e',
|
|
398
|
-
ȇ: 'e',
|
|
399
|
-
ì: 'i',
|
|
400
|
-
í: 'i',
|
|
401
|
-
î: 'i',
|
|
402
|
-
ï: 'i',
|
|
403
|
-
ḯ: 'i',
|
|
404
|
-
ȋ: 'i',
|
|
405
|
-
ð: 'd',
|
|
406
|
-
ñ: 'n',
|
|
407
|
-
ò: 'o',
|
|
408
|
-
ó: 'o',
|
|
409
|
-
ô: 'o',
|
|
410
|
-
õ: 'o',
|
|
411
|
-
ö: 'o',
|
|
412
|
-
ø: 'o',
|
|
413
|
-
ố: 'o',
|
|
414
|
-
ṍ: 'o',
|
|
415
|
-
ṓ: 'o',
|
|
416
|
-
ȏ: 'o',
|
|
417
|
-
ù: 'u',
|
|
418
|
-
ú: 'u',
|
|
419
|
-
û: 'u',
|
|
420
|
-
ü: 'u',
|
|
421
|
-
ý: 'y',
|
|
422
|
-
ÿ: 'y',
|
|
423
|
-
Ā: 'A',
|
|
424
|
-
ā: 'a',
|
|
425
|
-
Ă: 'A',
|
|
426
|
-
ă: 'a',
|
|
427
|
-
Ą: 'A',
|
|
428
|
-
ą: 'a',
|
|
429
|
-
Ć: 'C',
|
|
430
|
-
ć: 'c',
|
|
431
|
-
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537
|
-
Ș: 'S',
|
|
538
|
-
ș: 's',
|
|
539
|
-
ş: 's',
|
|
540
|
-
Š: 'S',
|
|
541
|
-
š: 's',
|
|
542
|
-
Ţ: 'T',
|
|
543
|
-
ţ: 't',
|
|
544
|
-
ț: 't',
|
|
545
|
-
Ț: 'T',
|
|
546
|
-
Ť: 'T',
|
|
547
|
-
ť: 't',
|
|
548
|
-
Ŧ: 'T',
|
|
549
|
-
ŧ: 't',
|
|
550
|
-
T̆: 'T',
|
|
551
|
-
t̆: 't',
|
|
552
|
-
Ũ: 'U',
|
|
553
|
-
ũ: 'u',
|
|
554
|
-
Ū: 'U',
|
|
555
|
-
ū: 'u',
|
|
556
|
-
Ŭ: 'U',
|
|
557
|
-
ŭ: 'u',
|
|
558
|
-
Ů: 'U',
|
|
559
|
-
ů: 'u',
|
|
560
|
-
Ű: 'U',
|
|
561
|
-
ű: 'u',
|
|
562
|
-
Ų: 'U',
|
|
563
|
-
ų: 'u',
|
|
564
|
-
Ȗ: 'U',
|
|
565
|
-
ȗ: 'u',
|
|
566
|
-
V̆: 'V',
|
|
567
|
-
v̆: 'v',
|
|
568
|
-
Ŵ: 'W',
|
|
569
|
-
ŵ: 'w',
|
|
570
|
-
Ẃ: 'W',
|
|
571
|
-
ẃ: 'w',
|
|
572
|
-
X̆: 'X',
|
|
573
|
-
x̆: 'x',
|
|
574
|
-
Ŷ: 'Y',
|
|
575
|
-
ŷ: 'y',
|
|
576
|
-
Ÿ: 'Y',
|
|
577
|
-
Y̆: 'Y',
|
|
578
|
-
y̆: 'y',
|
|
579
|
-
Ź: 'Z',
|
|
580
|
-
ź: 'z',
|
|
581
|
-
Ż: 'Z',
|
|
582
|
-
ż: 'z',
|
|
583
|
-
Ž: 'Z',
|
|
584
|
-
ž: 'z',
|
|
585
|
-
ſ: 's',
|
|
586
|
-
ƒ: 'f',
|
|
587
|
-
Ơ: 'O',
|
|
588
|
-
ơ: 'o',
|
|
589
|
-
Ư: 'U',
|
|
590
|
-
ư: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|
693
|
-
A̧: 'A',
|
|
694
|
-
a̧: 'a',
|
|
695
|
-
B̧: 'B',
|
|
696
|
-
b̧: 'b',
|
|
697
|
-
Ḑ: 'D',
|
|
698
|
-
ḑ: 'd',
|
|
699
|
-
Ȩ: 'E',
|
|
700
|
-
ȩ: 'e',
|
|
701
|
-
Ɛ̧: 'E',
|
|
702
|
-
ɛ̧: 'e',
|
|
703
|
-
Ḩ: 'H',
|
|
704
|
-
ḩ: 'h',
|
|
705
|
-
I̧: 'I',
|
|
706
|
-
i̧: 'i',
|
|
707
|
-
Ɨ̧: 'I',
|
|
708
|
-
ɨ̧: 'i',
|
|
709
|
-
M̧: 'M',
|
|
710
|
-
m̧: 'm',
|
|
711
|
-
O̧: 'O',
|
|
712
|
-
o̧: 'o',
|
|
713
|
-
Q̧: 'Q',
|
|
714
|
-
q̧: 'q',
|
|
715
|
-
U̧: 'U',
|
|
716
|
-
u̧: 'u',
|
|
717
|
-
X̧: 'X',
|
|
718
|
-
x̧: 'x',
|
|
719
|
-
Z̧: 'Z',
|
|
720
|
-
z̧: 'z'
|
|
721
|
-
};
|
|
722
|
-
const chars = Object.keys(characterMap).join('|');
|
|
723
|
-
const allAccents = new RegExp(chars, 'g');
|
|
724
|
-
function removeAccents(str) {
|
|
725
|
-
return str.replace(allAccents, match => {
|
|
726
|
-
return characterMap[match];
|
|
727
|
-
});
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
/**
|
|
731
|
-
* @name match-sorter
|
|
732
|
-
* @license MIT license.
|
|
733
|
-
* @copyright (c) 2099 Kent C. Dodds
|
|
734
|
-
* @author Kent C. Dodds <me@kentcdodds.com> (https://kentcdodds.com)
|
|
735
|
-
*/
|
|
736
|
-
const rankings = {
|
|
737
|
-
CASE_SENSITIVE_EQUAL: 7,
|
|
738
|
-
EQUAL: 6,
|
|
739
|
-
STARTS_WITH: 5,
|
|
740
|
-
WORD_STARTS_WITH: 4,
|
|
741
|
-
CONTAINS: 3,
|
|
742
|
-
ACRONYM: 2,
|
|
743
|
-
MATCHES: 1,
|
|
744
|
-
NO_MATCH: 0
|
|
745
|
-
};
|
|
746
|
-
|
|
747
|
-
/**
|
|
748
|
-
* Gets the highest ranking for value for the given item based on its values for the given keys
|
|
749
|
-
* @param {*} item - the item to rank
|
|
750
|
-
* @param {Array} keys - the keys to get values from the item for the ranking
|
|
751
|
-
* @param {String} value - the value to rank against
|
|
752
|
-
* @param {Object} options - options to control the ranking
|
|
753
|
-
* @return {{rank: Number, accessorIndex: Number, accessorThreshold: Number}} - the highest ranking
|
|
754
|
-
*/
|
|
755
|
-
function rankItem(item, value, options) {
|
|
756
|
-
var _options$threshold;
|
|
757
|
-
|
|
758
|
-
options = options || {};
|
|
759
|
-
options.threshold = (_options$threshold = options.threshold) != null ? _options$threshold : rankings.MATCHES;
|
|
760
|
-
|
|
761
|
-
if (!options.accessors) {
|
|
762
|
-
// if keys is not specified, then we assume the item given is ready to be matched
|
|
763
|
-
const rank = getMatchRanking(item, value, options);
|
|
764
|
-
return {
|
|
765
|
-
// ends up being duplicate of 'item' in matches but consistent
|
|
766
|
-
rankedValue: item,
|
|
767
|
-
rank,
|
|
768
|
-
accessorIndex: -1,
|
|
769
|
-
accessorThreshold: options.threshold,
|
|
770
|
-
passed: rank >= options.threshold
|
|
771
|
-
};
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
const valuesToRank = getAllValuesToRank(item, options.accessors);
|
|
775
|
-
const rankingInfo = {
|
|
776
|
-
rankedValue: item,
|
|
777
|
-
rank: rankings.NO_MATCH,
|
|
778
|
-
accessorIndex: -1,
|
|
779
|
-
accessorThreshold: options.threshold,
|
|
780
|
-
passed: false
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
for (let i = 0; i < valuesToRank.length; i++) {
|
|
784
|
-
const rankValue = valuesToRank[i];
|
|
785
|
-
let newRank = getMatchRanking(rankValue.itemValue, value, options);
|
|
786
|
-
const {
|
|
787
|
-
minRanking,
|
|
788
|
-
maxRanking,
|
|
789
|
-
threshold
|
|
790
|
-
} = rankValue.attributes;
|
|
791
|
-
|
|
792
|
-
if (newRank < minRanking && newRank >= rankings.MATCHES) {
|
|
793
|
-
newRank = minRanking;
|
|
794
|
-
} else if (newRank > maxRanking) {
|
|
795
|
-
newRank = maxRanking;
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
newRank = Math.min(newRank, maxRanking);
|
|
799
|
-
|
|
800
|
-
if (newRank > rankingInfo.rank) {
|
|
801
|
-
rankingInfo.rank = newRank;
|
|
802
|
-
rankingInfo.accessorIndex = i;
|
|
803
|
-
rankingInfo.accessorThreshold = threshold;
|
|
804
|
-
rankingInfo.rankedValue = rankValue.itemValue;
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
return rankingInfo;
|
|
809
|
-
}
|
|
810
|
-
/**
|
|
811
|
-
* Gives a rankings score based on how well the two strings match.
|
|
812
|
-
* @param {String} testString - the string to test against
|
|
813
|
-
* @param {String} stringToRank - the string to rank
|
|
814
|
-
* @param {Object} options - options for the match (like keepDiacritics for comparison)
|
|
815
|
-
* @returns {Number} the ranking for how well stringToRank matches testString
|
|
816
|
-
*/
|
|
817
|
-
|
|
818
|
-
function getMatchRanking(testString, stringToRank, options) {
|
|
819
|
-
testString = prepareValueForComparison(testString, options);
|
|
820
|
-
stringToRank = prepareValueForComparison(stringToRank, options); // too long
|
|
821
|
-
|
|
822
|
-
if (stringToRank.length > testString.length) {
|
|
823
|
-
return rankings.NO_MATCH;
|
|
824
|
-
} // case sensitive equals
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
if (testString === stringToRank) {
|
|
828
|
-
return rankings.CASE_SENSITIVE_EQUAL;
|
|
829
|
-
} // Lower casing before further comparison
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
testString = testString.toLowerCase();
|
|
833
|
-
stringToRank = stringToRank.toLowerCase(); // case insensitive equals
|
|
834
|
-
|
|
835
|
-
if (testString === stringToRank) {
|
|
836
|
-
return rankings.EQUAL;
|
|
837
|
-
} // starts with
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
if (testString.startsWith(stringToRank)) {
|
|
841
|
-
return rankings.STARTS_WITH;
|
|
842
|
-
} // word starts with
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
if (testString.includes(" " + stringToRank)) {
|
|
846
|
-
return rankings.WORD_STARTS_WITH;
|
|
847
|
-
} // contains
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
if (testString.includes(stringToRank)) {
|
|
851
|
-
return rankings.CONTAINS;
|
|
852
|
-
} else if (stringToRank.length === 1) {
|
|
853
|
-
// If the only character in the given stringToRank
|
|
854
|
-
// isn't even contained in the testString, then
|
|
855
|
-
// it's definitely not a match.
|
|
856
|
-
return rankings.NO_MATCH;
|
|
857
|
-
} // acronym
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
if (getAcronym(testString).includes(stringToRank)) {
|
|
861
|
-
return rankings.ACRONYM;
|
|
862
|
-
} // will return a number between rankings.MATCHES and
|
|
863
|
-
// rankings.MATCHES + 1 depending on how close of a match it is.
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
return getClosenessRanking(testString, stringToRank);
|
|
867
|
-
}
|
|
868
|
-
/**
|
|
869
|
-
* Generates an acronym for a string.
|
|
870
|
-
*
|
|
871
|
-
* @param {String} string the string for which to produce the acronym
|
|
872
|
-
* @returns {String} the acronym
|
|
873
|
-
*/
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
function getAcronym(string) {
|
|
877
|
-
let acronym = '';
|
|
878
|
-
const wordsInString = string.split(' ');
|
|
879
|
-
wordsInString.forEach(wordInString => {
|
|
880
|
-
const splitByHyphenWords = wordInString.split('-');
|
|
881
|
-
splitByHyphenWords.forEach(splitByHyphenWord => {
|
|
882
|
-
acronym += splitByHyphenWord.substr(0, 1);
|
|
883
|
-
});
|
|
884
|
-
});
|
|
885
|
-
return acronym;
|
|
886
|
-
}
|
|
887
|
-
/**
|
|
888
|
-
* Returns a score based on how spread apart the
|
|
889
|
-
* characters from the stringToRank are within the testString.
|
|
890
|
-
* A number close to rankings.MATCHES represents a loose match. A number close
|
|
891
|
-
* to rankings.MATCHES + 1 represents a tighter match.
|
|
892
|
-
* @param {String} testString - the string to test against
|
|
893
|
-
* @param {String} stringToRank - the string to rank
|
|
894
|
-
* @returns {Number} the number between rankings.MATCHES and
|
|
895
|
-
* rankings.MATCHES + 1 for how well stringToRank matches testString
|
|
896
|
-
*/
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
function getClosenessRanking(testString, stringToRank) {
|
|
900
|
-
let matchingInOrderCharCount = 0;
|
|
901
|
-
let charNumber = 0;
|
|
902
|
-
|
|
903
|
-
function findMatchingCharacter(matchChar, string, index) {
|
|
904
|
-
for (let j = index, J = string.length; j < J; j++) {
|
|
905
|
-
const stringChar = string[j];
|
|
906
|
-
|
|
907
|
-
if (stringChar === matchChar) {
|
|
908
|
-
matchingInOrderCharCount += 1;
|
|
909
|
-
return j + 1;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
|
|
913
|
-
return -1;
|
|
914
|
-
}
|
|
915
|
-
|
|
916
|
-
function getRanking(spread) {
|
|
917
|
-
const spreadPercentage = 1 / spread;
|
|
918
|
-
const inOrderPercentage = matchingInOrderCharCount / stringToRank.length;
|
|
919
|
-
const ranking = rankings.MATCHES + inOrderPercentage * spreadPercentage;
|
|
920
|
-
return ranking;
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
const firstIndex = findMatchingCharacter(stringToRank[0], testString, 0);
|
|
924
|
-
|
|
925
|
-
if (firstIndex < 0) {
|
|
926
|
-
return rankings.NO_MATCH;
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
charNumber = firstIndex;
|
|
930
|
-
|
|
931
|
-
for (let i = 1, I = stringToRank.length; i < I; i++) {
|
|
932
|
-
const matchChar = stringToRank[i];
|
|
933
|
-
charNumber = findMatchingCharacter(matchChar, testString, charNumber);
|
|
934
|
-
const found = charNumber > -1;
|
|
935
|
-
|
|
936
|
-
if (!found) {
|
|
937
|
-
return rankings.NO_MATCH;
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
const spread = charNumber - firstIndex;
|
|
942
|
-
return getRanking(spread);
|
|
943
|
-
}
|
|
944
|
-
/**
|
|
945
|
-
* Sorts items that have a rank, index, and accessorIndex
|
|
946
|
-
* @param {Object} a - the first item to sort
|
|
947
|
-
* @param {Object} b - the second item to sort
|
|
948
|
-
* @return {Number} -1 if a should come first, 1 if b should come first, 0 if equal
|
|
949
|
-
*/
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
function compareItems(a, b) {
|
|
953
|
-
return a.rank === b.rank ? 0 : a.rank > b.rank ? -1 : 1;
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Prepares value for comparison by stringifying it, removing diacritics (if specified)
|
|
957
|
-
* @param {String} value - the value to clean
|
|
958
|
-
* @param {Object} options - {keepDiacritics: whether to remove diacritics}
|
|
959
|
-
* @return {String} the prepared value
|
|
960
|
-
*/
|
|
961
|
-
|
|
962
|
-
function prepareValueForComparison(value, _ref) {
|
|
963
|
-
let {
|
|
964
|
-
keepDiacritics
|
|
965
|
-
} = _ref;
|
|
966
|
-
// value might not actually be a string at this point (we don't get to choose)
|
|
967
|
-
// so part of preparing the value for comparison is ensure that it is a string
|
|
968
|
-
value = "" + value; // toString
|
|
969
|
-
|
|
970
|
-
if (!keepDiacritics) {
|
|
971
|
-
value = removeAccents(value);
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
return value;
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Gets value for key in item at arbitrarily nested keypath
|
|
978
|
-
* @param {Object} item - the item
|
|
979
|
-
* @param {Object|Function} key - the potentially nested keypath or property callback
|
|
980
|
-
* @return {Array} - an array containing the value(s) at the nested keypath
|
|
981
|
-
*/
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
function getItemValues(item, accessor) {
|
|
985
|
-
let accessorFn = accessor;
|
|
986
|
-
|
|
987
|
-
if (typeof accessor === 'object') {
|
|
988
|
-
accessorFn = accessor.accessor;
|
|
989
|
-
}
|
|
990
|
-
|
|
991
|
-
const value = accessorFn(item); // because `value` can also be undefined
|
|
992
|
-
|
|
993
|
-
if (value == null) {
|
|
994
|
-
return [];
|
|
995
|
-
}
|
|
996
|
-
|
|
997
|
-
if (Array.isArray(value)) {
|
|
998
|
-
return value;
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
return [String(value)];
|
|
1002
|
-
}
|
|
1003
|
-
/**
|
|
1004
|
-
* Gets all the values for the given keys in the given item and returns an array of those values
|
|
1005
|
-
* @param item - the item from which the values will be retrieved
|
|
1006
|
-
* @param keys - the keys to use to retrieve the values
|
|
1007
|
-
* @return objects with {itemValue, attributes}
|
|
1008
|
-
*/
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
function getAllValuesToRank(item, accessors) {
|
|
1012
|
-
const allValues = [];
|
|
1013
|
-
|
|
1014
|
-
for (let j = 0, J = accessors.length; j < J; j++) {
|
|
1015
|
-
const accessor = accessors[j];
|
|
1016
|
-
const attributes = getAccessorAttributes(accessor);
|
|
1017
|
-
const itemValues = getItemValues(item, accessor);
|
|
1018
|
-
|
|
1019
|
-
for (let i = 0, I = itemValues.length; i < I; i++) {
|
|
1020
|
-
allValues.push({
|
|
1021
|
-
itemValue: itemValues[i],
|
|
1022
|
-
attributes
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
return allValues;
|
|
1028
|
-
}
|
|
1029
|
-
|
|
1030
|
-
const defaultKeyAttributes = {
|
|
1031
|
-
maxRanking: Infinity,
|
|
1032
|
-
minRanking: -Infinity
|
|
1033
|
-
};
|
|
1034
|
-
/**
|
|
1035
|
-
* Gets all the attributes for the given accessor
|
|
1036
|
-
* @param accessor - the accessor from which the attributes will be retrieved
|
|
1037
|
-
* @return object containing the accessor's attributes
|
|
1038
|
-
*/
|
|
1039
|
-
|
|
1040
|
-
function getAccessorAttributes(accessor) {
|
|
1041
|
-
if (typeof accessor === 'function') {
|
|
1042
|
-
return defaultKeyAttributes;
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
return { ...defaultKeyAttributes,
|
|
1046
|
-
...accessor
|
|
1047
|
-
};
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
33
|
const getItem = key => {
|
|
1051
34
|
try {
|
|
1052
35
|
const itemValue = localStorage.getItem(key);
|
|
@@ -1145,7 +128,6 @@ function useMediaQuery(query) {
|
|
|
1145
128
|
return isMatch;
|
|
1146
129
|
}
|
|
1147
130
|
|
|
1148
|
-
const isServer$1 = typeof window === 'undefined';
|
|
1149
131
|
function getQueryStatusColor({
|
|
1150
132
|
queryState,
|
|
1151
133
|
observerCount,
|
|
@@ -1181,7 +163,7 @@ function styled(type, newStyles, queries = {}) {
|
|
|
1181
163
|
function useIsMounted() {
|
|
1182
164
|
const mountedRef = React.useRef(false);
|
|
1183
165
|
const isMounted = React.useCallback(() => mountedRef.current, []);
|
|
1184
|
-
React
|
|
166
|
+
React.useEffect(() => {
|
|
1185
167
|
mountedRef.current = true;
|
|
1186
168
|
return () => {
|
|
1187
169
|
mountedRef.current = false;
|
|
@@ -1212,6 +194,19 @@ const sortFns = {
|
|
|
1212
194
|
'Last Updated': (a, b) => a.state.dataUpdatedAt < b.state.dataUpdatedAt ? 1 : -1
|
|
1213
195
|
};
|
|
1214
196
|
|
|
197
|
+
function ScreenReader({
|
|
198
|
+
text
|
|
199
|
+
}) {
|
|
200
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
201
|
+
style: {
|
|
202
|
+
position: 'absolute',
|
|
203
|
+
width: '0.1px',
|
|
204
|
+
height: '0.1px',
|
|
205
|
+
overflow: 'hidden'
|
|
206
|
+
}
|
|
207
|
+
}, text);
|
|
208
|
+
}
|
|
209
|
+
|
|
1215
210
|
const Panel = styled('div', (_props, theme) => ({
|
|
1216
211
|
fontSize: 'clamp(12px, 1.5vw, 14px)',
|
|
1217
212
|
fontFamily: "sans-serif",
|
|
@@ -1492,7 +487,6 @@ function Logo(props) {
|
|
|
1492
487
|
}))));
|
|
1493
488
|
}
|
|
1494
489
|
|
|
1495
|
-
const isServer = typeof window === 'undefined';
|
|
1496
490
|
function ReactQueryDevtools$1({
|
|
1497
491
|
initialIsOpen,
|
|
1498
492
|
panelProps = {},
|
|
@@ -1573,7 +567,7 @@ function ReactQueryDevtools$1({
|
|
|
1573
567
|
};
|
|
1574
568
|
}
|
|
1575
569
|
}, [isResolvedOpen]);
|
|
1576
|
-
React
|
|
570
|
+
React.useEffect(() => {
|
|
1577
571
|
if (isResolvedOpen) {
|
|
1578
572
|
var _rootRef$current, _rootRef$current$pare;
|
|
1579
573
|
|
|
@@ -1729,11 +723,13 @@ function ReactQueryDevtools$1({
|
|
|
1729
723
|
}
|
|
1730
724
|
}), /*#__PURE__*/React.createElement(Logo, {
|
|
1731
725
|
"aria-hidden": true
|
|
726
|
+
}), /*#__PURE__*/React.createElement(ScreenReader, {
|
|
727
|
+
text: "Open React Query Devtools"
|
|
1732
728
|
})) : null);
|
|
1733
729
|
}
|
|
1734
730
|
|
|
1735
731
|
const useSubscribeToQueryCache = (queryCache, getSnapshot) => {
|
|
1736
|
-
return
|
|
732
|
+
return useSyncExternalStore(React.useCallback(onStoreChange => queryCache.subscribe(notifyManager.batchCalls(onStoreChange)), [queryCache]), getSnapshot, getSnapshot);
|
|
1737
733
|
};
|
|
1738
734
|
|
|
1739
735
|
const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
|
|
@@ -1832,6 +828,8 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQu
|
|
|
1832
828
|
}
|
|
1833
829
|
}, /*#__PURE__*/React.createElement(Logo, {
|
|
1834
830
|
"aria-hidden": true
|
|
831
|
+
}), /*#__PURE__*/React.createElement(ScreenReader, {
|
|
832
|
+
text: "Close React Query Devtools"
|
|
1835
833
|
})), /*#__PURE__*/React.createElement("div", {
|
|
1836
834
|
style: {
|
|
1837
835
|
display: 'flex',
|
|
@@ -1936,7 +934,9 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQu
|
|
|
1936
934
|
d: "M6.343 12.343a8 8 0 0 1 11.314 0"
|
|
1937
935
|
}), /*#__PURE__*/React.createElement("path", {
|
|
1938
936
|
d: "M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0"
|
|
1939
|
-
})))
|
|
937
|
+
}))), /*#__PURE__*/React.createElement(ScreenReader, {
|
|
938
|
+
text: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior'
|
|
939
|
+
}))) : null))), /*#__PURE__*/React.createElement("div", {
|
|
1940
940
|
style: {
|
|
1941
941
|
overflowY: 'auto',
|
|
1942
942
|
flex: '1'
|