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