@tanstack/react-query-devtools 5.0.0-alpha.2 → 5.0.0-alpha.21

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.
Files changed (88) hide show
  1. package/build/lib/CachePanel/ActiveQuery.d.ts +18 -0
  2. package/build/lib/CachePanel/ActiveQuery.esm.js +271 -0
  3. package/build/lib/CachePanel/ActiveQuery.esm.js.map +1 -0
  4. package/build/lib/CachePanel/ActiveQuery.js +275 -0
  5. package/build/lib/CachePanel/ActiveQuery.js.map +1 -0
  6. package/build/lib/CachePanel/ActiveQuery.mjs +257 -0
  7. package/build/lib/CachePanel/ActiveQuery.mjs.map +1 -0
  8. package/build/lib/CachePanel/CachePanel.d.ts +57 -0
  9. package/build/lib/CachePanel/CachePanel.esm.js +310 -0
  10. package/build/lib/CachePanel/CachePanel.esm.js.map +1 -0
  11. package/build/lib/CachePanel/CachePanel.js +315 -0
  12. package/build/lib/CachePanel/CachePanel.js.map +1 -0
  13. package/build/lib/CachePanel/CachePanel.mjs +310 -0
  14. package/build/lib/CachePanel/CachePanel.mjs.map +1 -0
  15. package/build/lib/CachePanel/Header/QueryStatusCount.d.ts +7 -0
  16. package/build/lib/CachePanel/Header/QueryStatusCount.esm.js +49 -0
  17. package/build/lib/CachePanel/Header/QueryStatusCount.esm.js.map +1 -0
  18. package/build/lib/CachePanel/Header/QueryStatusCount.js +53 -0
  19. package/build/lib/CachePanel/Header/QueryStatusCount.js.map +1 -0
  20. package/build/lib/CachePanel/Header/QueryStatusCount.mjs +49 -0
  21. package/build/lib/CachePanel/Header/QueryStatusCount.mjs.map +1 -0
  22. package/build/lib/CachePanel/QueryRow.d.ts +13 -0
  23. package/build/lib/CachePanel/QueryRow.esm.js +98 -0
  24. package/build/lib/CachePanel/QueryRow.esm.js.map +1 -0
  25. package/build/lib/CachePanel/QueryRow.js +102 -0
  26. package/build/lib/CachePanel/QueryRow.js.map +1 -0
  27. package/build/lib/CachePanel/QueryRow.mjs +82 -0
  28. package/build/lib/CachePanel/QueryRow.mjs.map +1 -0
  29. package/build/lib/Explorer.esm.js +2 -1
  30. package/build/lib/Explorer.esm.js.map +1 -1
  31. package/build/lib/Explorer.js +2 -1
  32. package/build/lib/Explorer.js.map +1 -1
  33. package/build/lib/Explorer.mjs +1 -0
  34. package/build/lib/Explorer.mjs.map +1 -1
  35. package/build/lib/devtools.d.ts +5 -48
  36. package/build/lib/devtools.esm.js +11 -550
  37. package/build/lib/devtools.esm.js.map +1 -1
  38. package/build/lib/devtools.js +12 -551
  39. package/build/lib/devtools.js.map +1 -1
  40. package/build/lib/devtools.mjs +7 -547
  41. package/build/lib/devtools.mjs.map +1 -1
  42. package/build/lib/index.esm.js +3 -1
  43. package/build/lib/index.esm.js.map +1 -1
  44. package/build/lib/index.js +3 -1
  45. package/build/lib/index.js.map +1 -1
  46. package/build/lib/index.mjs +3 -1
  47. package/build/lib/index.mjs.map +1 -1
  48. package/build/lib/index.prod.esm.js +821 -651
  49. package/build/lib/index.prod.esm.js.map +1 -1
  50. package/build/lib/index.prod.js +819 -650
  51. package/build/lib/index.prod.js.map +1 -1
  52. package/build/lib/index.prod.mjs +764 -625
  53. package/build/lib/index.prod.mjs.map +1 -1
  54. package/build/lib/styledComponents.d.ts +0 -1
  55. package/build/lib/styledComponents.esm.js +11 -1
  56. package/build/lib/styledComponents.esm.js.map +1 -1
  57. package/build/lib/styledComponents.js +11 -1
  58. package/build/lib/styledComponents.js.map +1 -1
  59. package/build/lib/styledComponents.mjs +11 -1
  60. package/build/lib/styledComponents.mjs.map +1 -1
  61. package/build/lib/theme.esm.js +1 -0
  62. package/build/lib/theme.esm.js.map +1 -1
  63. package/build/lib/theme.js +1 -0
  64. package/build/lib/theme.js.map +1 -1
  65. package/build/lib/theme.mjs +1 -0
  66. package/build/lib/theme.mjs.map +1 -1
  67. package/build/lib/types.d.ts +11 -0
  68. package/build/lib/useSubscribeToQueryCache.d.ts +3 -0
  69. package/build/lib/useSubscribeToQueryCache.esm.js +15 -0
  70. package/build/lib/useSubscribeToQueryCache.esm.js.map +1 -0
  71. package/build/lib/useSubscribeToQueryCache.js +19 -0
  72. package/build/lib/useSubscribeToQueryCache.js.map +1 -0
  73. package/build/lib/useSubscribeToQueryCache.mjs +15 -0
  74. package/build/lib/useSubscribeToQueryCache.mjs.map +1 -0
  75. package/build/umd/index.development.js +1667 -1529
  76. package/build/umd/index.development.js.map +1 -1
  77. package/build/umd/index.production.js.map +1 -1
  78. package/package.json +4 -4
  79. package/src/CachePanel/ActiveQuery.tsx +380 -0
  80. package/src/CachePanel/CachePanel.tsx +439 -0
  81. package/src/CachePanel/Header/QueryStatusCount.tsx +93 -0
  82. package/src/CachePanel/QueryRow.tsx +125 -0
  83. package/src/__tests__/Explorer.test.tsx +3 -2
  84. package/src/__tests__/devtools.test.tsx +229 -9
  85. package/src/devtools.tsx +10 -865
  86. package/src/styledComponents.ts +19 -1
  87. package/src/types.ts +12 -0
  88. package/src/useSubscribeToQueryCache.ts +26 -0
@@ -1,16 +1,14 @@
1
+ 'use client';
1
2
  'use strict';
2
3
 
3
4
  var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
4
5
  var React = require('react');
5
- var reactQuery = require('@tanstack/react-query');
6
- var matchSorterUtils = require('@tanstack/match-sorter-utils');
7
6
  var useLocalStorage = require('./useLocalStorage.js');
8
7
  var utils = require('./utils.js');
9
- var styledComponents = require('./styledComponents.js');
10
8
  var screenreader = require('./screenreader.js');
11
9
  var theme = require('./theme.js');
12
- var Explorer = require('./Explorer.js');
13
10
  var Logo = require('./Logo.js');
11
+ var CachePanel = require('./CachePanel/CachePanel.js');
14
12
 
15
13
  function _interopNamespaceDefault(e) {
16
14
  var n = Object.create(null);
@@ -40,7 +38,8 @@ function ReactQueryDevtools({
40
38
  containerElement: Container = 'aside',
41
39
  queryClient,
42
40
  styleNonce,
43
- panelPosition: initialPanelPosition = 'bottom'
41
+ panelPosition: initialPanelPosition = 'bottom',
42
+ errorTypes = []
44
43
  }) {
45
44
  const rootRef = React__namespace.useRef(null);
46
45
  const panelRef = React__namespace.useRef(null);
@@ -93,7 +92,7 @@ function ReactQueryDevtools({
93
92
  document.addEventListener('mouseup', unsub, false);
94
93
  };
95
94
  React__namespace.useEffect(() => {
96
- setIsResolvedOpen(isOpen ?? false);
95
+ setIsResolvedOpen(isOpen != null ? isOpen : false);
97
96
  }, [isOpen, isResolvedOpen, setIsResolvedOpen]);
98
97
 
99
98
  // Toggle panel visibility before/after transition (depending on direction).
@@ -121,7 +120,8 @@ function ReactQueryDevtools({
121
120
  return;
122
121
  }, [isResolvedOpen]);
123
122
  React__namespace.useEffect(() => {
124
- if (isResolvedOpen && rootRef.current?.parentElement) {
123
+ var _rootRef$current;
124
+ if (isResolvedOpen && (_rootRef$current = rootRef.current) != null && _rootRef$current.parentElement) {
125
125
  const {
126
126
  parentElement
127
127
  } = rootRef.current;
@@ -193,7 +193,7 @@ function ReactQueryDevtools({
193
193
  "aria-label": "React Query Devtools"
194
194
  }, /*#__PURE__*/React__namespace.createElement(theme.ThemeProvider, {
195
195
  theme: theme.defaultTheme
196
- }, /*#__PURE__*/React__namespace.createElement(ReactQueryDevtoolsPanel, _rollupPluginBabelHelpers.extends({
196
+ }, /*#__PURE__*/React__namespace.createElement(CachePanel.default, _rollupPluginBabelHelpers.extends({
197
197
  ref: panelRef,
198
198
  queryClient: queryClient,
199
199
  styleNonce: styleNonce,
@@ -205,7 +205,8 @@ function ReactQueryDevtools({
205
205
  style: style,
206
206
  isOpen: isResolvedOpen,
207
207
  setIsOpen: setIsOpen,
208
- onDragStart: e => handleDragStart(panelRef.current, e)
208
+ onDragStart: e => handleDragStart(panelRef.current, e),
209
+ errorTypes: errorTypes
209
210
  }))), !isResolvedOpen ? /*#__PURE__*/React__namespace.createElement("button", _rollupPluginBabelHelpers.extends({
210
211
  type: "button"
211
212
  }, otherToggleButtonProps, {
@@ -215,7 +216,7 @@ function ReactQueryDevtools({
215
216
  "aria-expanded": "false",
216
217
  onClick: e => {
217
218
  setIsOpen(true);
218
- onToggleClick?.(e);
219
+ onToggleClick == null ? void 0 : onToggleClick(e);
219
220
  },
220
221
  style: {
221
222
  background: 'none',
@@ -249,547 +250,7 @@ function ReactQueryDevtools({
249
250
  text: "Open React Query Devtools"
250
251
  })) : null);
251
252
  }
252
- const useSubscribeToQueryCache = (queryCache, getSnapshot, skip = false) => {
253
- return React__namespace.useSyncExternalStore(React__namespace.useCallback(onStoreChange => {
254
- if (!skip) return queryCache.subscribe(reactQuery.notifyManager.batchCalls(onStoreChange));
255
- return () => {
256
- return;
257
- };
258
- }, [queryCache, skip]), getSnapshot, getSnapshot);
259
- };
260
- const ReactQueryDevtoolsPanel = /*#__PURE__*/React__namespace.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
261
- const {
262
- isOpen = true,
263
- styleNonce,
264
- setIsOpen,
265
- queryClient,
266
- onDragStart,
267
- onPositionChange,
268
- showCloseButton,
269
- position,
270
- closeButtonProps = {},
271
- ...panelProps
272
- } = props;
273
- const {
274
- onClick: onCloseClick,
275
- ...otherCloseButtonProps
276
- } = closeButtonProps;
277
- const client = reactQuery.useQueryClient(queryClient);
278
- const queryCache = client.getQueryCache();
279
- const [sort, setSort] = useLocalStorage.default('reactQueryDevtoolsSortFn', Object.keys(utils.sortFns)[0]);
280
- const [filter, setFilter] = useLocalStorage.default('reactQueryDevtoolsFilter', '');
281
- const [baseSort, setBaseSort] = useLocalStorage.default('reactQueryDevtoolsBaseSort', 1);
282
- const sortFn = React__namespace.useMemo(() => utils.sortFns[sort], [sort]);
283
- const queriesCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().length, !isOpen);
284
- const [activeQueryHash, setActiveQueryHash] = useLocalStorage.default('reactQueryDevtoolsActiveQueryHash', '');
285
- const queries = React__namespace.useMemo(() => {
286
- const unsortedQueries = queryCache.getAll();
287
- if (queriesCount === 0) {
288
- return [];
289
- }
290
- const filtered = filter ? unsortedQueries.filter(item => matchSorterUtils.rankItem(item.queryHash, filter).passed) : [...unsortedQueries];
291
- const sorted = sortFn ? filtered.sort((a, b) => sortFn(a, b) * baseSort) : filtered;
292
- return sorted;
293
- }, [baseSort, sortFn, filter, queriesCount, queryCache]);
294
- const [isMockOffline, setMockOffline] = React__namespace.useState(false);
295
- return /*#__PURE__*/React__namespace.createElement(theme.ThemeProvider, {
296
- theme: theme.defaultTheme
297
- }, /*#__PURE__*/React__namespace.createElement(styledComponents.Panel, _rollupPluginBabelHelpers.extends({
298
- ref: ref,
299
- className: "ReactQueryDevtoolsPanel",
300
- "aria-label": "React Query Devtools Panel",
301
- id: "ReactQueryDevtoolsPanel"
302
- }, panelProps, {
303
- style: {
304
- height: utils.defaultPanelSize,
305
- position: 'relative',
306
- ...panelProps.style
307
- }
308
- }), /*#__PURE__*/React__namespace.createElement("style", {
309
- nonce: styleNonce,
310
- dangerouslySetInnerHTML: {
311
- __html: `
312
- .ReactQueryDevtoolsPanel * {
313
- scrollbar-color: ${theme.defaultTheme.backgroundAlt} ${theme.defaultTheme.gray};
314
- }
315
-
316
- .ReactQueryDevtoolsPanel *::-webkit-scrollbar, .ReactQueryDevtoolsPanel scrollbar {
317
- width: 1em;
318
- height: 1em;
319
- }
320
-
321
- .ReactQueryDevtoolsPanel *::-webkit-scrollbar-track, .ReactQueryDevtoolsPanel scrollbar-track {
322
- background: ${theme.defaultTheme.backgroundAlt};
323
- }
324
-
325
- .ReactQueryDevtoolsPanel *::-webkit-scrollbar-thumb, .ReactQueryDevtoolsPanel scrollbar-thumb {
326
- background: ${theme.defaultTheme.gray};
327
- border-radius: .5em;
328
- border: 3px solid ${theme.defaultTheme.backgroundAlt};
329
- }
330
- `
331
- }
332
- }), /*#__PURE__*/React__namespace.createElement("div", {
333
- style: utils.getResizeHandleStyle(position),
334
- onMouseDown: onDragStart
335
- }), isOpen && /*#__PURE__*/React__namespace.createElement("div", {
336
- style: {
337
- flex: '1 1 500px',
338
- minHeight: '40%',
339
- maxHeight: '100%',
340
- overflow: 'auto',
341
- borderRight: `1px solid ${theme.defaultTheme.grayAlt}`,
342
- display: 'flex',
343
- flexDirection: 'column'
344
- }
345
- }, /*#__PURE__*/React__namespace.createElement("div", {
346
- style: {
347
- padding: '.5em',
348
- background: theme.defaultTheme.backgroundAlt,
349
- display: 'flex',
350
- justifyContent: 'space-between',
351
- alignItems: 'center'
352
- }
353
- }, /*#__PURE__*/React__namespace.createElement("button", {
354
- type: "button",
355
- "aria-label": "Close React Query Devtools",
356
- "aria-controls": "ReactQueryDevtoolsPanel",
357
- "aria-haspopup": "true",
358
- "aria-expanded": "true",
359
- onClick: () => setIsOpen(false),
360
- style: {
361
- display: 'inline-flex',
362
- background: 'none',
363
- border: 0,
364
- padding: 0,
365
- marginRight: '.5em',
366
- cursor: 'pointer'
367
- }
368
- }, /*#__PURE__*/React__namespace.createElement(Logo.default, {
369
- "aria-hidden": true
370
- }), /*#__PURE__*/React__namespace.createElement(screenreader.default, {
371
- text: "Close React Query Devtools"
372
- })), /*#__PURE__*/React__namespace.createElement("div", {
373
- style: {
374
- display: 'flex',
375
- flexDirection: 'column'
376
- }
377
- }, /*#__PURE__*/React__namespace.createElement("div", {
378
- style: {
379
- display: 'flex',
380
- justifyContent: 'space-between',
381
- alignItems: 'center',
382
- marginBottom: '.5em'
383
- }
384
- }, /*#__PURE__*/React__namespace.createElement(QueryStatusCount, {
385
- queryCache: queryCache
386
- }), position && onPositionChange ? /*#__PURE__*/React__namespace.createElement(styledComponents.Select, {
387
- "aria-label": "Panel position",
388
- value: position,
389
- style: {
390
- marginInlineStart: '.5em'
391
- },
392
- onChange: e => onPositionChange(e.target.value)
393
- }, /*#__PURE__*/React__namespace.createElement("option", {
394
- value: "left"
395
- }, "Left"), /*#__PURE__*/React__namespace.createElement("option", {
396
- value: "right"
397
- }, "Right"), /*#__PURE__*/React__namespace.createElement("option", {
398
- value: "top"
399
- }, "Top"), /*#__PURE__*/React__namespace.createElement("option", {
400
- value: "bottom"
401
- }, "Bottom")) : null), /*#__PURE__*/React__namespace.createElement("div", {
402
- style: {
403
- display: 'flex',
404
- alignItems: 'center'
405
- }
406
- }, /*#__PURE__*/React__namespace.createElement(styledComponents.Input, {
407
- placeholder: "Filter",
408
- "aria-label": "Filter by queryhash",
409
- value: filter ?? '',
410
- onChange: e => setFilter(e.target.value),
411
- onKeyDown: e => {
412
- if (e.key === 'Escape') setFilter('');
413
- },
414
- style: {
415
- flex: '1',
416
- marginRight: '.5em',
417
- width: '100%'
418
- }
419
- }), /*#__PURE__*/React__namespace.createElement(styledComponents.Select, {
420
- "aria-label": "Sort queries",
421
- value: sort,
422
- onChange: e => setSort(e.target.value),
423
- style: {
424
- flex: '1',
425
- minWidth: 75,
426
- marginRight: '.5em'
427
- }
428
- }, Object.keys(utils.sortFns).map(key => /*#__PURE__*/React__namespace.createElement("option", {
429
- key: key,
430
- value: key
431
- }, "Sort by ", key))), /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
432
- type: "button",
433
- onClick: () => setBaseSort(old => old * -1),
434
- style: {
435
- padding: '.3em .4em',
436
- marginRight: '.5em'
437
- }
438
- }, baseSort === 1 ? '⬆ Asc' : '⬇ Desc'), /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
439
- type: "button",
440
- onClick: () => {
441
- if (isMockOffline) {
442
- reactQuery.onlineManager.setOnline(undefined);
443
- setMockOffline(false);
444
- window.dispatchEvent(new Event('online'));
445
- } else {
446
- reactQuery.onlineManager.setOnline(false);
447
- setMockOffline(true);
448
- }
449
- },
450
- "aria-label": isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
451
- title: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
452
- style: {
453
- padding: '0',
454
- height: '2em'
455
- }
456
- }, /*#__PURE__*/React__namespace.createElement("svg", {
457
- xmlns: "http://www.w3.org/2000/svg",
458
- width: "2em",
459
- height: "2em",
460
- viewBox: "0 0 24 24",
461
- stroke: isMockOffline ? theme.defaultTheme.danger : 'currentColor',
462
- fill: "none"
463
- }, isMockOffline ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("path", {
464
- stroke: "none",
465
- d: "M0 0h24v24H0z",
466
- fill: "none"
467
- }), /*#__PURE__*/React__namespace.createElement("line", {
468
- x1: "12",
469
- y1: "18",
470
- x2: "12.01",
471
- y2: "18"
472
- }), /*#__PURE__*/React__namespace.createElement("path", {
473
- d: "M9.172 15.172a4 4 0 0 1 5.656 0"
474
- }), /*#__PURE__*/React__namespace.createElement("path", {
475
- d: "M6.343 12.343a7.963 7.963 0 0 1 3.864 -2.14m4.163 .155a7.965 7.965 0 0 1 3.287 2"
476
- }), /*#__PURE__*/React__namespace.createElement("path", {
477
- d: "M3.515 9.515a12 12 0 0 1 3.544 -2.455m3.101 -.92a12 12 0 0 1 10.325 3.374"
478
- }), /*#__PURE__*/React__namespace.createElement("line", {
479
- x1: "3",
480
- y1: "3",
481
- x2: "21",
482
- y2: "21"
483
- })) : /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("path", {
484
- stroke: "none",
485
- d: "M0 0h24v24H0z",
486
- fill: "none"
487
- }), /*#__PURE__*/React__namespace.createElement("line", {
488
- x1: "12",
489
- y1: "18",
490
- x2: "12.01",
491
- y2: "18"
492
- }), /*#__PURE__*/React__namespace.createElement("path", {
493
- d: "M9.172 15.172a4 4 0 0 1 5.656 0"
494
- }), /*#__PURE__*/React__namespace.createElement("path", {
495
- d: "M6.343 12.343a8 8 0 0 1 11.314 0"
496
- }), /*#__PURE__*/React__namespace.createElement("path", {
497
- d: "M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0"
498
- }))), /*#__PURE__*/React__namespace.createElement(screenreader.default, {
499
- text: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior'
500
- }))))), /*#__PURE__*/React__namespace.createElement("div", {
501
- style: {
502
- overflowY: 'auto',
503
- flex: '1'
504
- }
505
- }, queries.map(query => {
506
- return /*#__PURE__*/React__namespace.createElement(QueryRow, {
507
- queryKey: query.queryKey,
508
- activeQueryHash: activeQueryHash,
509
- setActiveQueryHash: setActiveQueryHash,
510
- key: query.queryHash,
511
- queryCache: queryCache
512
- });
513
- }))), activeQueryHash && isOpen ? /*#__PURE__*/React__namespace.createElement(ActiveQuery, {
514
- activeQueryHash: activeQueryHash,
515
- queryCache: queryCache,
516
- queryClient: client
517
- }) : null, showCloseButton ? /*#__PURE__*/React__namespace.createElement(styledComponents.Button, _rollupPluginBabelHelpers.extends({
518
- type: "button",
519
- "aria-controls": "ReactQueryDevtoolsPanel",
520
- "aria-haspopup": "true",
521
- "aria-expanded": "true"
522
- }, otherCloseButtonProps, {
523
- style: {
524
- position: 'absolute',
525
- zIndex: 99999,
526
- margin: '.5em',
527
- bottom: 0,
528
- left: 0,
529
- ...otherCloseButtonProps.style
530
- },
531
- onClick: e => {
532
- setIsOpen(false);
533
- onCloseClick?.(e);
534
- }
535
- }), "Close") : null));
536
- });
537
- const ActiveQuery = ({
538
- queryCache,
539
- activeQueryHash,
540
- queryClient
541
- }) => {
542
- const activeQuery = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash));
543
- const activeQueryState = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.state);
544
- const isStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.isStale()) ?? false;
545
- const observerCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.getObserversCount()) ?? 0;
546
- const handleRefetch = () => {
547
- const promise = activeQuery?.fetch();
548
- promise?.catch(noop);
549
- };
550
- if (!activeQuery || !activeQueryState) {
551
- return null;
552
- }
553
- return /*#__PURE__*/React__namespace.createElement(styledComponents.ActiveQueryPanel, null, /*#__PURE__*/React__namespace.createElement("div", {
554
- style: {
555
- padding: '.5em',
556
- background: theme.defaultTheme.backgroundAlt,
557
- position: 'sticky',
558
- top: 0,
559
- zIndex: 1
560
- }
561
- }, "Query Details"), /*#__PURE__*/React__namespace.createElement("div", {
562
- style: {
563
- padding: '.5em'
564
- }
565
- }, /*#__PURE__*/React__namespace.createElement("div", {
566
- style: {
567
- marginBottom: '.5em',
568
- display: 'flex',
569
- alignItems: 'flex-start',
570
- justifyContent: 'space-between'
571
- }
572
- }, /*#__PURE__*/React__namespace.createElement(styledComponents.Code, {
573
- style: {
574
- lineHeight: '1.8em'
575
- }
576
- }, /*#__PURE__*/React__namespace.createElement("pre", {
577
- style: {
578
- margin: 0,
579
- padding: 0,
580
- overflow: 'auto'
581
- }
582
- }, utils.displayValue(activeQuery.queryKey, true))), /*#__PURE__*/React__namespace.createElement("span", {
583
- style: {
584
- padding: '0.3em .6em',
585
- borderRadius: '0.4em',
586
- fontWeight: 'bold',
587
- textShadow: '0 2px 10px black',
588
- background: utils.getQueryStatusColor({
589
- queryState: activeQueryState,
590
- isStale: isStale,
591
- observerCount: observerCount,
592
- theme: theme.defaultTheme
593
- }),
594
- flexShrink: 0
595
- }
596
- }, utils.getQueryStatusLabel(activeQuery))), /*#__PURE__*/React__namespace.createElement("div", {
597
- style: {
598
- marginBottom: '.5em',
599
- display: 'flex',
600
- alignItems: 'center',
601
- justifyContent: 'space-between'
602
- }
603
- }, "Observers: ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, observerCount)), /*#__PURE__*/React__namespace.createElement("div", {
604
- style: {
605
- display: 'flex',
606
- alignItems: 'center',
607
- justifyContent: 'space-between'
608
- }
609
- }, "Last Updated:", ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, new Date(activeQueryState.dataUpdatedAt).toLocaleTimeString()))), /*#__PURE__*/React__namespace.createElement("div", {
610
- style: {
611
- background: theme.defaultTheme.backgroundAlt,
612
- padding: '.5em',
613
- position: 'sticky',
614
- top: 0,
615
- zIndex: 1
616
- }
617
- }, "Actions"), /*#__PURE__*/React__namespace.createElement("div", {
618
- style: {
619
- padding: '0.5em'
620
- }
621
- }, /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
622
- type: "button",
623
- onClick: handleRefetch,
624
- disabled: activeQueryState.fetchStatus === 'fetching',
625
- style: {
626
- background: theme.defaultTheme.active
627
- }
628
- }, "Refetch"), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
629
- type: "button",
630
- onClick: () => queryClient.invalidateQueries(activeQuery),
631
- style: {
632
- background: theme.defaultTheme.warning,
633
- color: theme.defaultTheme.inputTextColor
634
- }
635
- }, "Invalidate"), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
636
- type: "button",
637
- onClick: () => queryClient.resetQueries(activeQuery),
638
- style: {
639
- background: theme.defaultTheme.gray
640
- }
641
- }, "Reset"), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
642
- type: "button",
643
- onClick: () => queryClient.removeQueries(activeQuery),
644
- style: {
645
- background: theme.defaultTheme.danger
646
- }
647
- }, "Remove")), /*#__PURE__*/React__namespace.createElement("div", {
648
- style: {
649
- background: theme.defaultTheme.backgroundAlt,
650
- padding: '.5em',
651
- position: 'sticky',
652
- top: 0,
653
- zIndex: 1
654
- }
655
- }, "Data Explorer"), /*#__PURE__*/React__namespace.createElement("div", {
656
- style: {
657
- padding: '.5em'
658
- }
659
- }, /*#__PURE__*/React__namespace.createElement(Explorer.default, {
660
- label: "Data",
661
- value: activeQueryState.data,
662
- defaultExpanded: {},
663
- copyable: true
664
- })), /*#__PURE__*/React__namespace.createElement("div", {
665
- style: {
666
- background: theme.defaultTheme.backgroundAlt,
667
- padding: '.5em',
668
- position: 'sticky',
669
- top: 0,
670
- zIndex: 1
671
- }
672
- }, "Query Explorer"), /*#__PURE__*/React__namespace.createElement("div", {
673
- style: {
674
- padding: '.5em'
675
- }
676
- }, /*#__PURE__*/React__namespace.createElement(Explorer.default, {
677
- label: "Query",
678
- value: activeQuery,
679
- defaultExpanded: {
680
- queryKey: true
681
- }
682
- })));
683
- };
684
- const QueryStatusCount = ({
685
- queryCache
686
- }) => {
687
- const hasFresh = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'fresh').length);
688
- const hasFetching = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'fetching').length);
689
- const hasPaused = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'paused').length);
690
- const hasStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'stale').length);
691
- const hasInactive = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'inactive').length);
692
- return /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKeys, null, /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
693
- style: {
694
- background: theme.defaultTheme.success,
695
- opacity: hasFresh ? 1 : 0.3
696
- }
697
- }, "fresh ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasFresh, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
698
- style: {
699
- background: theme.defaultTheme.active,
700
- opacity: hasFetching ? 1 : 0.3
701
- }
702
- }, "fetching ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasFetching, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
703
- style: {
704
- background: theme.defaultTheme.paused,
705
- opacity: hasPaused ? 1 : 0.3
706
- }
707
- }, "paused ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasPaused, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
708
- style: {
709
- background: theme.defaultTheme.warning,
710
- color: 'black',
711
- textShadow: '0',
712
- opacity: hasStale ? 1 : 0.3
713
- }
714
- }, "stale ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasStale, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
715
- style: {
716
- background: theme.defaultTheme.gray,
717
- opacity: hasInactive ? 1 : 0.3
718
- }
719
- }, "inactive ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasInactive, ")")));
720
- };
721
- const QueryRow = /*#__PURE__*/React__namespace.memo(({
722
- queryKey,
723
- setActiveQueryHash,
724
- activeQueryHash,
725
- queryCache
726
- }) => {
727
- const queryHash = useSubscribeToQueryCache(queryCache, () => queryCache.find({
728
- queryKey
729
- })?.queryHash) ?? '';
730
- const queryState = useSubscribeToQueryCache(queryCache, () => queryCache.find({
731
- queryKey
732
- })?.state);
733
- const isStale = useSubscribeToQueryCache(queryCache, () => queryCache.find({
734
- queryKey
735
- })?.isStale()) ?? false;
736
- const isDisabled = useSubscribeToQueryCache(queryCache, () => queryCache.find({
737
- queryKey
738
- })?.isDisabled()) ?? false;
739
- const observerCount = useSubscribeToQueryCache(queryCache, () => queryCache.find({
740
- queryKey
741
- })?.getObserversCount()) ?? 0;
742
- if (!queryState) {
743
- return null;
744
- }
745
- return /*#__PURE__*/React__namespace.createElement("div", {
746
- role: "button",
747
- "aria-label": `Open query details for ${queryHash}`,
748
- onClick: () => setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash),
749
- style: {
750
- display: 'flex',
751
- borderBottom: `solid 1px ${theme.defaultTheme.grayAlt}`,
752
- cursor: 'pointer',
753
- background: queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined
754
- }
755
- }, /*#__PURE__*/React__namespace.createElement("div", {
756
- style: {
757
- flex: '0 0 auto',
758
- width: '2em',
759
- height: '2em',
760
- background: utils.getQueryStatusColor({
761
- queryState,
762
- isStale,
763
- observerCount,
764
- theme: theme.defaultTheme
765
- }),
766
- display: 'flex',
767
- alignItems: 'center',
768
- justifyContent: 'center',
769
- fontWeight: 'bold',
770
- textShadow: isStale ? '0' : '0 0 10px black',
771
- color: isStale ? 'black' : 'white'
772
- }
773
- }, observerCount), isDisabled ? /*#__PURE__*/React__namespace.createElement("div", {
774
- style: {
775
- flex: '0 0 auto',
776
- height: '2em',
777
- background: theme.defaultTheme.gray,
778
- display: 'flex',
779
- alignItems: 'center',
780
- fontWeight: 'bold',
781
- padding: '0 0.5em'
782
- }
783
- }, "disabled") : null, /*#__PURE__*/React__namespace.createElement(styledComponents.Code, {
784
- style: {
785
- padding: '.5em'
786
- }
787
- }, `${queryHash}`));
788
- });
789
-
790
- // eslint-disable-next-line @typescript-eslint/no-empty-function
791
- function noop() {}
792
253
 
254
+ exports.ReactQueryDevtoolsPanel = CachePanel.default;
793
255
  exports.ReactQueryDevtools = ReactQueryDevtools;
794
- exports.ReactQueryDevtoolsPanel = ReactQueryDevtoolsPanel;
795
256
  //# sourceMappingURL=devtools.js.map