@tanstack/react-query-devtools 4.3.0-beta.5 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/build/lib/Explorer.js +205 -0
  2. package/build/lib/Explorer.js.map +1 -0
  3. package/build/lib/Explorer.mjs +171 -0
  4. package/build/lib/Explorer.mjs.map +1 -0
  5. package/build/lib/Logo.js +56 -0
  6. package/build/lib/Logo.js.map +1 -0
  7. package/build/lib/Logo.mjs +32 -0
  8. package/build/lib/Logo.mjs.map +1 -0
  9. package/build/lib/_virtual/_rollupPluginBabelHelpers.js +23 -0
  10. package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  11. package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +19 -0
  12. package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -0
  13. package/build/lib/devtools.js +801 -0
  14. package/build/lib/devtools.js.map +1 -0
  15. package/build/lib/{index.prod.mjs → devtools.mjs} +13 -494
  16. package/build/lib/devtools.mjs.map +1 -0
  17. package/build/lib/index.js +3 -1277
  18. package/build/lib/index.js.map +1 -1
  19. package/build/lib/index.mjs +3 -1257
  20. package/build/lib/index.mjs.map +1 -1
  21. package/build/lib/screenreader.js +41 -0
  22. package/build/lib/screenreader.js.map +1 -0
  23. package/build/lib/screenreader.mjs +17 -0
  24. package/build/lib/screenreader.mjs.map +1 -0
  25. package/build/lib/styledComponents.js +103 -0
  26. package/build/lib/styledComponents.js.map +1 -0
  27. package/build/lib/styledComponents.mjs +92 -0
  28. package/build/lib/styledComponents.mjs.map +1 -0
  29. package/build/lib/theme.js +58 -0
  30. package/build/lib/theme.js.map +1 -0
  31. package/build/lib/theme.mjs +32 -0
  32. package/build/lib/theme.mjs.map +1 -0
  33. package/build/lib/useLocalStorage.js +71 -0
  34. package/build/lib/useLocalStorage.js.map +1 -0
  35. package/build/lib/useLocalStorage.mjs +47 -0
  36. package/build/lib/useLocalStorage.mjs.map +1 -0
  37. package/build/lib/useMediaQuery.js +56 -0
  38. package/build/lib/useMediaQuery.js.map +1 -0
  39. package/build/lib/useMediaQuery.mjs +32 -0
  40. package/build/lib/useMediaQuery.mjs.map +1 -0
  41. package/build/lib/utils.d.ts +0 -1
  42. package/build/lib/utils.js +101 -0
  43. package/build/lib/utils.js.map +1 -0
  44. package/build/lib/utils.mjs +72 -0
  45. package/build/lib/utils.mjs.map +1 -0
  46. package/build/umd/index.development.js +2 -14
  47. package/build/umd/index.development.js.map +1 -1
  48. package/build/umd/index.production.js +0 -10
  49. package/build/umd/index.production.js.map +1 -1
  50. package/package.json +7 -2
  51. package/src/devtools.tsx +1 -3
  52. package/src/utils.ts +1 -3
  53. package/build/lib/index.prod.js +0 -1282
  54. package/build/lib/index.prod.js.map +0 -1
  55. package/build/lib/index.prod.mjs.map +0 -1
@@ -0,0 +1,801 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
6
+ var React = require('react');
7
+ var reactQuery = require('@tanstack/react-query');
8
+ var matchSorterUtils = require('@tanstack/match-sorter-utils');
9
+ var useLocalStorage = require('./useLocalStorage.js');
10
+ var utils = require('./utils.js');
11
+ var screenreader = require('./screenreader.js');
12
+ var styledComponents = require('./styledComponents.js');
13
+ var theme = require('./theme.js');
14
+ var Explorer = require('./Explorer.js');
15
+ var Logo = require('./Logo.js');
16
+ var index_js = require('use-sync-external-store/shim/index.js');
17
+
18
+ function _interopNamespace(e) {
19
+ if (e && e.__esModule) return e;
20
+ var n = Object.create(null);
21
+ if (e) {
22
+ Object.keys(e).forEach(function (k) {
23
+ if (k !== 'default') {
24
+ var d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () { return e[k]; }
28
+ });
29
+ }
30
+ });
31
+ }
32
+ n["default"] = e;
33
+ return Object.freeze(n);
34
+ }
35
+
36
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
37
+
38
+ function ReactQueryDevtools({
39
+ initialIsOpen,
40
+ panelProps = {},
41
+ closeButtonProps = {},
42
+ toggleButtonProps = {},
43
+ position = 'bottom-left',
44
+ containerElement: Container = 'aside',
45
+ context,
46
+ styleNonce
47
+ }) {
48
+ const rootRef = React__namespace.useRef(null);
49
+ const panelRef = React__namespace.useRef(null);
50
+ const [isOpen, setIsOpen] = useLocalStorage["default"]('reactQueryDevtoolsOpen', initialIsOpen);
51
+ const [devtoolsHeight, setDevtoolsHeight] = useLocalStorage["default"]('reactQueryDevtoolsHeight', null);
52
+ const [isResolvedOpen, setIsResolvedOpen] = React__namespace.useState(false);
53
+ const [isResizing, setIsResizing] = React__namespace.useState(false);
54
+ const isMounted = utils.useIsMounted();
55
+
56
+ const handleDragStart = (panelElement, startEvent) => {
57
+ var _panelElement$getBoun;
58
+
59
+ if (startEvent.button !== 0) return; // Only allow left click for drag
60
+
61
+ setIsResizing(true);
62
+ const dragInfo = {
63
+ originalHeight: (_panelElement$getBoun = panelElement == null ? void 0 : panelElement.getBoundingClientRect().height) != null ? _panelElement$getBoun : 0,
64
+ pageY: startEvent.pageY
65
+ };
66
+
67
+ const run = moveEvent => {
68
+ const delta = dragInfo.pageY - moveEvent.pageY;
69
+ const newHeight = dragInfo.originalHeight + delta;
70
+ setDevtoolsHeight(newHeight);
71
+
72
+ if (newHeight < 70) {
73
+ setIsOpen(false);
74
+ } else {
75
+ setIsOpen(true);
76
+ }
77
+ };
78
+
79
+ const unsub = () => {
80
+ setIsResizing(false);
81
+ document.removeEventListener('mousemove', run);
82
+ document.removeEventListener('mouseUp', unsub);
83
+ };
84
+
85
+ document.addEventListener('mousemove', run);
86
+ document.addEventListener('mouseup', unsub);
87
+ };
88
+
89
+ React__namespace.useEffect(() => {
90
+ setIsResolvedOpen(isOpen != null ? isOpen : false);
91
+ }, [isOpen, isResolvedOpen, setIsResolvedOpen]); // Toggle panel visibility before/after transition (depending on direction).
92
+ // Prevents focusing in a closed panel.
93
+
94
+ React__namespace.useEffect(() => {
95
+ const ref = panelRef.current;
96
+
97
+ if (ref) {
98
+ const handlePanelTransitionStart = () => {
99
+ if (isResolvedOpen) {
100
+ ref.style.visibility = 'visible';
101
+ }
102
+ };
103
+
104
+ const handlePanelTransitionEnd = () => {
105
+ if (!isResolvedOpen) {
106
+ ref.style.visibility = 'hidden';
107
+ }
108
+ };
109
+
110
+ ref.addEventListener('transitionstart', handlePanelTransitionStart);
111
+ ref.addEventListener('transitionend', handlePanelTransitionEnd);
112
+ return () => {
113
+ ref.removeEventListener('transitionstart', handlePanelTransitionStart);
114
+ ref.removeEventListener('transitionend', handlePanelTransitionEnd);
115
+ };
116
+ }
117
+ }, [isResolvedOpen]);
118
+ React__namespace.useEffect(() => {
119
+ if (isResolvedOpen) {
120
+ var _rootRef$current, _rootRef$current$pare;
121
+
122
+ const previousValue = (_rootRef$current = rootRef.current) == null ? void 0 : (_rootRef$current$pare = _rootRef$current.parentElement) == null ? void 0 : _rootRef$current$pare.style.paddingBottom;
123
+
124
+ const run = () => {
125
+ var _panelRef$current, _rootRef$current2;
126
+
127
+ const containerHeight = (_panelRef$current = panelRef.current) == null ? void 0 : _panelRef$current.getBoundingClientRect().height;
128
+
129
+ if ((_rootRef$current2 = rootRef.current) != null && _rootRef$current2.parentElement) {
130
+ rootRef.current.parentElement.style.paddingBottom = containerHeight + "px";
131
+ }
132
+ };
133
+
134
+ run();
135
+
136
+ if (typeof window !== 'undefined') {
137
+ window.addEventListener('resize', run);
138
+ return () => {
139
+ var _rootRef$current3;
140
+
141
+ window.removeEventListener('resize', run);
142
+
143
+ if ((_rootRef$current3 = rootRef.current) != null && _rootRef$current3.parentElement && typeof previousValue === 'string') {
144
+ rootRef.current.parentElement.style.paddingBottom = previousValue;
145
+ }
146
+ };
147
+ }
148
+ }
149
+ }, [isResolvedOpen]);
150
+ const {
151
+ style: panelStyle = {},
152
+ ...otherPanelProps
153
+ } = panelProps;
154
+ const {
155
+ style: closeButtonStyle = {},
156
+ onClick: onCloseClick,
157
+ ...otherCloseButtonProps
158
+ } = closeButtonProps;
159
+ const {
160
+ style: toggleButtonStyle = {},
161
+ onClick: onToggleClick,
162
+ ...otherToggleButtonProps
163
+ } = toggleButtonProps; // Do not render on the server
164
+
165
+ if (!isMounted()) return null;
166
+ return /*#__PURE__*/React__namespace.createElement(Container, {
167
+ ref: rootRef,
168
+ className: "ReactQueryDevtools",
169
+ "aria-label": "React Query Devtools"
170
+ }, /*#__PURE__*/React__namespace.createElement(theme.ThemeProvider, {
171
+ theme: theme.defaultTheme
172
+ }, /*#__PURE__*/React__namespace.createElement(ReactQueryDevtoolsPanel, _rollupPluginBabelHelpers["extends"]({
173
+ ref: panelRef,
174
+ context: context,
175
+ styleNonce: styleNonce
176
+ }, otherPanelProps, {
177
+ style: {
178
+ position: 'fixed',
179
+ bottom: '0',
180
+ right: '0',
181
+ zIndex: 99999,
182
+ width: '100%',
183
+ height: devtoolsHeight != null ? devtoolsHeight : 500,
184
+ maxHeight: '90%',
185
+ boxShadow: '0 0 20px rgba(0,0,0,.3)',
186
+ borderTop: "1px solid " + theme.defaultTheme.gray,
187
+ transformOrigin: 'top',
188
+ // visibility will be toggled after transitions, but set initial state here
189
+ visibility: isOpen ? 'visible' : 'hidden',
190
+ ...panelStyle,
191
+ ...(isResizing ? {
192
+ transition: "none"
193
+ } : {
194
+ transition: "all .2s ease"
195
+ }),
196
+ ...(isResolvedOpen ? {
197
+ opacity: 1,
198
+ pointerEvents: 'all',
199
+ transform: "translateY(0) scale(1)"
200
+ } : {
201
+ opacity: 0,
202
+ pointerEvents: 'none',
203
+ transform: "translateY(15px) scale(1.02)"
204
+ })
205
+ },
206
+ isOpen: isResolvedOpen,
207
+ setIsOpen: setIsOpen,
208
+ handleDragStart: e => handleDragStart(panelRef.current, e)
209
+ })), isResolvedOpen ? /*#__PURE__*/React__namespace.createElement(styledComponents.Button, _rollupPluginBabelHelpers["extends"]({
210
+ type: "button",
211
+ "aria-controls": "ReactQueryDevtoolsPanel",
212
+ "aria-haspopup": "true",
213
+ "aria-expanded": "true"
214
+ }, otherCloseButtonProps, {
215
+ onClick: e => {
216
+ setIsOpen(false);
217
+ onCloseClick == null ? void 0 : onCloseClick(e);
218
+ },
219
+ style: {
220
+ position: 'fixed',
221
+ zIndex: 99999,
222
+ margin: '.5em',
223
+ bottom: 0,
224
+ ...(position === 'top-right' ? {
225
+ right: '0'
226
+ } : position === 'top-left' ? {
227
+ left: '0'
228
+ } : position === 'bottom-right' ? {
229
+ right: '0'
230
+ } : {
231
+ left: '0'
232
+ }),
233
+ ...closeButtonStyle
234
+ }
235
+ }), "Close") : null), !isResolvedOpen ? /*#__PURE__*/React__namespace.createElement("button", _rollupPluginBabelHelpers["extends"]({
236
+ type: "button"
237
+ }, otherToggleButtonProps, {
238
+ "aria-label": "Open React Query Devtools",
239
+ "aria-controls": "ReactQueryDevtoolsPanel",
240
+ "aria-haspopup": "true",
241
+ "aria-expanded": "false",
242
+ onClick: e => {
243
+ setIsOpen(true);
244
+ onToggleClick == null ? void 0 : onToggleClick(e);
245
+ },
246
+ style: {
247
+ background: 'none',
248
+ border: 0,
249
+ padding: 0,
250
+ position: 'fixed',
251
+ zIndex: 99999,
252
+ display: 'inline-flex',
253
+ fontSize: '1.5em',
254
+ margin: '.5em',
255
+ cursor: 'pointer',
256
+ width: 'fit-content',
257
+ ...(position === 'top-right' ? {
258
+ top: '0',
259
+ right: '0'
260
+ } : position === 'top-left' ? {
261
+ top: '0',
262
+ left: '0'
263
+ } : position === 'bottom-right' ? {
264
+ bottom: '0',
265
+ right: '0'
266
+ } : {
267
+ bottom: '0',
268
+ left: '0'
269
+ }),
270
+ ...toggleButtonStyle
271
+ }
272
+ }), /*#__PURE__*/React__namespace.createElement(Logo["default"], {
273
+ "aria-hidden": true
274
+ }), /*#__PURE__*/React__namespace.createElement(screenreader["default"], {
275
+ text: "Open React Query Devtools"
276
+ })) : null);
277
+ }
278
+
279
+ const useSubscribeToQueryCache = (queryCache, getSnapshot) => {
280
+ return index_js.useSyncExternalStore(React__namespace.useCallback(onStoreChange => queryCache.subscribe(reactQuery.notifyManager.batchCalls(onStoreChange)), [queryCache]), getSnapshot, getSnapshot);
281
+ };
282
+
283
+ const ReactQueryDevtoolsPanel = /*#__PURE__*/React__namespace.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
284
+ const {
285
+ isOpen = true,
286
+ styleNonce,
287
+ setIsOpen,
288
+ handleDragStart,
289
+ context,
290
+ ...panelProps
291
+ } = props;
292
+ const queryClient = reactQuery.useQueryClient({
293
+ context
294
+ });
295
+ const queryCache = queryClient.getQueryCache();
296
+ const [sort, setSort] = useLocalStorage["default"]('reactQueryDevtoolsSortFn', Object.keys(utils.sortFns)[0]);
297
+ const [filter, setFilter] = useLocalStorage["default"]('reactQueryDevtoolsFilter', '');
298
+ const [sortDesc, setSortDesc] = useLocalStorage["default"]('reactQueryDevtoolsSortDesc', false);
299
+ const sortFn = React__namespace.useMemo(() => utils.sortFns[sort], [sort]);
300
+ const queriesCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().length);
301
+ const [activeQueryHash, setActiveQueryHash] = useLocalStorage["default"]('reactQueryDevtoolsActiveQueryHash', '');
302
+ const queries = React__namespace.useMemo(() => {
303
+ const unsortedQueries = queryCache.getAll();
304
+ const sorted = queriesCount > 0 ? [...unsortedQueries].sort(sortFn) : [];
305
+
306
+ if (sortDesc) {
307
+ sorted.reverse();
308
+ }
309
+
310
+ if (!filter) {
311
+ return sorted;
312
+ }
313
+
314
+ let ranked = sorted.map(item => [item, matchSorterUtils.rankItem(item.queryHash, filter)]);
315
+ ranked = ranked.filter(d => d[1].passed);
316
+ ranked = ranked.sort((a, b) => matchSorterUtils.compareItems(a[1], b[1]));
317
+ return ranked.map(d => d[0]);
318
+ }, [sortDesc, sortFn, filter, queriesCount, queryCache]);
319
+ const [isMockOffline, setMockOffline] = React__namespace.useState(false);
320
+ return /*#__PURE__*/React__namespace.createElement(theme.ThemeProvider, {
321
+ theme: theme.defaultTheme
322
+ }, /*#__PURE__*/React__namespace.createElement(styledComponents.Panel, _rollupPluginBabelHelpers["extends"]({
323
+ ref: ref,
324
+ className: "ReactQueryDevtoolsPanel",
325
+ "aria-label": "React Query Devtools Panel",
326
+ id: "ReactQueryDevtoolsPanel"
327
+ }, panelProps), /*#__PURE__*/React__namespace.createElement("style", {
328
+ nonce: styleNonce,
329
+ dangerouslySetInnerHTML: {
330
+ __html: "\n .ReactQueryDevtoolsPanel * {\n scrollbar-color: " + theme.defaultTheme.backgroundAlt + " " + theme.defaultTheme.gray + ";\n }\n\n .ReactQueryDevtoolsPanel *::-webkit-scrollbar, .ReactQueryDevtoolsPanel scrollbar {\n width: 1em;\n height: 1em;\n }\n\n .ReactQueryDevtoolsPanel *::-webkit-scrollbar-track, .ReactQueryDevtoolsPanel scrollbar-track {\n background: " + theme.defaultTheme.backgroundAlt + ";\n }\n\n .ReactQueryDevtoolsPanel *::-webkit-scrollbar-thumb, .ReactQueryDevtoolsPanel scrollbar-thumb {\n background: " + theme.defaultTheme.gray + ";\n border-radius: .5em;\n border: 3px solid " + theme.defaultTheme.backgroundAlt + ";\n }\n "
331
+ }
332
+ }), /*#__PURE__*/React__namespace.createElement("div", {
333
+ style: {
334
+ position: 'absolute',
335
+ left: 0,
336
+ top: 0,
337
+ width: '100%',
338
+ height: '4px',
339
+ marginBottom: '-4px',
340
+ cursor: 'row-resize',
341
+ zIndex: 100000
342
+ },
343
+ onMouseDown: handleDragStart
344
+ }), /*#__PURE__*/React__namespace.createElement("div", {
345
+ style: {
346
+ flex: '1 1 500px',
347
+ minHeight: '40%',
348
+ maxHeight: '100%',
349
+ overflow: 'auto',
350
+ borderRight: "1px solid " + theme.defaultTheme.grayAlt,
351
+ display: isOpen ? 'flex' : 'none',
352
+ flexDirection: 'column'
353
+ }
354
+ }, /*#__PURE__*/React__namespace.createElement("div", {
355
+ style: {
356
+ padding: '.5em',
357
+ background: theme.defaultTheme.backgroundAlt,
358
+ display: 'flex',
359
+ justifyContent: 'space-between',
360
+ alignItems: 'center'
361
+ }
362
+ }, /*#__PURE__*/React__namespace.createElement("button", {
363
+ type: "button",
364
+ "aria-label": "Close React Query Devtools",
365
+ "aria-controls": "ReactQueryDevtoolsPanel",
366
+ "aria-haspopup": "true",
367
+ "aria-expanded": "true",
368
+ onClick: () => setIsOpen(false),
369
+ style: {
370
+ display: 'inline-flex',
371
+ background: 'none',
372
+ border: 0,
373
+ padding: 0,
374
+ marginRight: '.5em',
375
+ cursor: 'pointer'
376
+ }
377
+ }, /*#__PURE__*/React__namespace.createElement(Logo["default"], {
378
+ "aria-hidden": true
379
+ }), /*#__PURE__*/React__namespace.createElement(screenreader["default"], {
380
+ text: "Close React Query Devtools"
381
+ })), /*#__PURE__*/React__namespace.createElement("div", {
382
+ style: {
383
+ display: 'flex',
384
+ flexDirection: 'column'
385
+ }
386
+ }, /*#__PURE__*/React__namespace.createElement(QueryStatusCount, {
387
+ queryCache: queryCache
388
+ }), /*#__PURE__*/React__namespace.createElement("div", {
389
+ style: {
390
+ display: 'flex',
391
+ alignItems: 'center'
392
+ }
393
+ }, /*#__PURE__*/React__namespace.createElement(styledComponents.Input, {
394
+ placeholder: "Filter",
395
+ "aria-label": "Filter by queryhash",
396
+ value: filter != null ? filter : '',
397
+ onChange: e => setFilter(e.target.value),
398
+ onKeyDown: e => {
399
+ if (e.key === 'Escape') setFilter('');
400
+ },
401
+ style: {
402
+ flex: '1',
403
+ marginRight: '.5em',
404
+ width: '100%'
405
+ }
406
+ }), !filter ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(styledComponents.Select, {
407
+ "aria-label": "Sort queries",
408
+ value: sort,
409
+ onChange: e => setSort(e.target.value),
410
+ style: {
411
+ flex: '1',
412
+ minWidth: 75,
413
+ marginRight: '.5em'
414
+ }
415
+ }, Object.keys(utils.sortFns).map(key => /*#__PURE__*/React__namespace.createElement("option", {
416
+ key: key,
417
+ value: key
418
+ }, "Sort by ", key))), /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
419
+ type: "button",
420
+ onClick: () => setSortDesc(old => !old),
421
+ style: {
422
+ padding: '.3em .4em',
423
+ marginRight: '.5em'
424
+ }
425
+ }, sortDesc ? '⬇ Desc' : '⬆ Asc'), /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
426
+ type: "button",
427
+ onClick: () => {
428
+ if (isMockOffline) {
429
+ reactQuery.onlineManager.setOnline(undefined);
430
+ setMockOffline(false);
431
+ window.dispatchEvent(new Event('online'));
432
+ } else {
433
+ reactQuery.onlineManager.setOnline(false);
434
+ setMockOffline(true);
435
+ }
436
+ },
437
+ "aria-label": isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
438
+ title: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
439
+ style: {
440
+ padding: '0',
441
+ height: '2em'
442
+ }
443
+ }, /*#__PURE__*/React__namespace.createElement("svg", {
444
+ xmlns: "http://www.w3.org/2000/svg",
445
+ width: "2em",
446
+ height: "2em",
447
+ viewBox: "0 0 24 24",
448
+ stroke: isMockOffline ? theme.defaultTheme.danger : 'currentColor',
449
+ fill: "none"
450
+ }, isMockOffline ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("path", {
451
+ stroke: "none",
452
+ d: "M0 0h24v24H0z",
453
+ fill: "none"
454
+ }), /*#__PURE__*/React__namespace.createElement("line", {
455
+ x1: "12",
456
+ y1: "18",
457
+ x2: "12.01",
458
+ y2: "18"
459
+ }), /*#__PURE__*/React__namespace.createElement("path", {
460
+ d: "M9.172 15.172a4 4 0 0 1 5.656 0"
461
+ }), /*#__PURE__*/React__namespace.createElement("path", {
462
+ 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"
463
+ }), /*#__PURE__*/React__namespace.createElement("path", {
464
+ d: "M3.515 9.515a12 12 0 0 1 3.544 -2.455m3.101 -.92a12 12 0 0 1 10.325 3.374"
465
+ }), /*#__PURE__*/React__namespace.createElement("line", {
466
+ x1: "3",
467
+ y1: "3",
468
+ x2: "21",
469
+ y2: "21"
470
+ })) : /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("path", {
471
+ stroke: "none",
472
+ d: "M0 0h24v24H0z",
473
+ fill: "none"
474
+ }), /*#__PURE__*/React__namespace.createElement("line", {
475
+ x1: "12",
476
+ y1: "18",
477
+ x2: "12.01",
478
+ y2: "18"
479
+ }), /*#__PURE__*/React__namespace.createElement("path", {
480
+ d: "M9.172 15.172a4 4 0 0 1 5.656 0"
481
+ }), /*#__PURE__*/React__namespace.createElement("path", {
482
+ d: "M6.343 12.343a8 8 0 0 1 11.314 0"
483
+ }), /*#__PURE__*/React__namespace.createElement("path", {
484
+ d: "M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0"
485
+ }))), /*#__PURE__*/React__namespace.createElement(screenreader["default"], {
486
+ text: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior'
487
+ }))) : null))), /*#__PURE__*/React__namespace.createElement("div", {
488
+ style: {
489
+ overflowY: 'auto',
490
+ flex: '1'
491
+ }
492
+ }, queries.map(query => {
493
+ return /*#__PURE__*/React__namespace.createElement(QueryRow, {
494
+ queryKey: query.queryKey,
495
+ activeQueryHash: activeQueryHash,
496
+ setActiveQueryHash: setActiveQueryHash,
497
+ key: query.queryHash,
498
+ queryCache: queryCache
499
+ });
500
+ }))), activeQueryHash ? /*#__PURE__*/React__namespace.createElement(ActiveQuery, {
501
+ activeQueryHash: activeQueryHash,
502
+ queryCache: queryCache,
503
+ queryClient: queryClient
504
+ }) : null));
505
+ });
506
+
507
+ const ActiveQuery = ({
508
+ queryCache,
509
+ activeQueryHash,
510
+ queryClient
511
+ }) => {
512
+ var _useSubscribeToQueryC, _useSubscribeToQueryC2;
513
+
514
+ const activeQuery = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash));
515
+ const activeQueryState = useSubscribeToQueryCache(queryCache, () => {
516
+ var _queryCache$getAll$fi;
517
+
518
+ return (_queryCache$getAll$fi = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi.state;
519
+ });
520
+ const isStale = (_useSubscribeToQueryC = useSubscribeToQueryCache(queryCache, () => {
521
+ var _queryCache$getAll$fi2;
522
+
523
+ return (_queryCache$getAll$fi2 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi2.isStale();
524
+ })) != null ? _useSubscribeToQueryC : false;
525
+ const observerCount = (_useSubscribeToQueryC2 = useSubscribeToQueryCache(queryCache, () => {
526
+ var _queryCache$getAll$fi3;
527
+
528
+ return (_queryCache$getAll$fi3 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi3.getObserversCount();
529
+ })) != null ? _useSubscribeToQueryC2 : 0;
530
+
531
+ const handleRefetch = () => {
532
+ const promise = activeQuery == null ? void 0 : activeQuery.fetch();
533
+ promise == null ? void 0 : promise.catch(noop);
534
+ };
535
+
536
+ if (!activeQuery || !activeQueryState) {
537
+ return null;
538
+ }
539
+
540
+ return /*#__PURE__*/React__namespace.createElement(styledComponents.ActiveQueryPanel, null, /*#__PURE__*/React__namespace.createElement("div", {
541
+ style: {
542
+ padding: '.5em',
543
+ background: theme.defaultTheme.backgroundAlt,
544
+ position: 'sticky',
545
+ top: 0,
546
+ zIndex: 1
547
+ }
548
+ }, "Query Details"), /*#__PURE__*/React__namespace.createElement("div", {
549
+ style: {
550
+ padding: '.5em'
551
+ }
552
+ }, /*#__PURE__*/React__namespace.createElement("div", {
553
+ style: {
554
+ marginBottom: '.5em',
555
+ display: 'flex',
556
+ alignItems: 'stretch',
557
+ justifyContent: 'space-between'
558
+ }
559
+ }, /*#__PURE__*/React__namespace.createElement(styledComponents.Code, {
560
+ style: {
561
+ lineHeight: '1.8em'
562
+ }
563
+ }, /*#__PURE__*/React__namespace.createElement("pre", {
564
+ style: {
565
+ margin: 0,
566
+ padding: 0,
567
+ overflow: 'auto'
568
+ }
569
+ }, JSON.stringify(activeQuery.queryKey, null, 2))), /*#__PURE__*/React__namespace.createElement("span", {
570
+ style: {
571
+ padding: '0.3em .6em',
572
+ borderRadius: '0.4em',
573
+ fontWeight: 'bold',
574
+ textShadow: '0 2px 10px black',
575
+ background: utils.getQueryStatusColor({
576
+ queryState: activeQueryState,
577
+ isStale: isStale,
578
+ observerCount: observerCount,
579
+ theme: theme.defaultTheme
580
+ }),
581
+ flexShrink: 0
582
+ }
583
+ }, utils.getQueryStatusLabel(activeQuery))), /*#__PURE__*/React__namespace.createElement("div", {
584
+ style: {
585
+ marginBottom: '.5em',
586
+ display: 'flex',
587
+ alignItems: 'center',
588
+ justifyContent: 'space-between'
589
+ }
590
+ }, "Observers: ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, observerCount)), /*#__PURE__*/React__namespace.createElement("div", {
591
+ style: {
592
+ display: 'flex',
593
+ alignItems: 'center',
594
+ justifyContent: 'space-between'
595
+ }
596
+ }, "Last Updated:", ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, new Date(activeQueryState.dataUpdatedAt).toLocaleTimeString()))), /*#__PURE__*/React__namespace.createElement("div", {
597
+ style: {
598
+ background: theme.defaultTheme.backgroundAlt,
599
+ padding: '.5em',
600
+ position: 'sticky',
601
+ top: 0,
602
+ zIndex: 1
603
+ }
604
+ }, "Actions"), /*#__PURE__*/React__namespace.createElement("div", {
605
+ style: {
606
+ padding: '0.5em'
607
+ }
608
+ }, /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
609
+ type: "button",
610
+ onClick: handleRefetch,
611
+ disabled: activeQueryState.fetchStatus === 'fetching',
612
+ style: {
613
+ background: theme.defaultTheme.active
614
+ }
615
+ }, "Refetch"), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
616
+ type: "button",
617
+ onClick: () => queryClient.invalidateQueries(activeQuery),
618
+ style: {
619
+ background: theme.defaultTheme.warning,
620
+ color: theme.defaultTheme.inputTextColor
621
+ }
622
+ }, "Invalidate"), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
623
+ type: "button",
624
+ onClick: () => queryClient.resetQueries(activeQuery),
625
+ style: {
626
+ background: theme.defaultTheme.gray
627
+ }
628
+ }, "Reset"), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.Button, {
629
+ type: "button",
630
+ onClick: () => queryClient.removeQueries(activeQuery),
631
+ style: {
632
+ background: theme.defaultTheme.danger
633
+ }
634
+ }, "Remove")), /*#__PURE__*/React__namespace.createElement("div", {
635
+ style: {
636
+ background: theme.defaultTheme.backgroundAlt,
637
+ padding: '.5em',
638
+ position: 'sticky',
639
+ top: 0,
640
+ zIndex: 1
641
+ }
642
+ }, "Data Explorer"), /*#__PURE__*/React__namespace.createElement("div", {
643
+ style: {
644
+ padding: '.5em'
645
+ }
646
+ }, /*#__PURE__*/React__namespace.createElement(Explorer["default"], {
647
+ label: "Data",
648
+ value: activeQueryState.data,
649
+ defaultExpanded: {}
650
+ })), /*#__PURE__*/React__namespace.createElement("div", {
651
+ style: {
652
+ background: theme.defaultTheme.backgroundAlt,
653
+ padding: '.5em',
654
+ position: 'sticky',
655
+ top: 0,
656
+ zIndex: 1
657
+ }
658
+ }, "Query Explorer"), /*#__PURE__*/React__namespace.createElement("div", {
659
+ style: {
660
+ padding: '.5em'
661
+ }
662
+ }, /*#__PURE__*/React__namespace.createElement(Explorer["default"], {
663
+ label: "Query",
664
+ value: activeQuery,
665
+ defaultExpanded: {
666
+ queryKey: true
667
+ }
668
+ })));
669
+ };
670
+
671
+ const QueryStatusCount = ({
672
+ queryCache
673
+ }) => {
674
+ const hasFresh = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'fresh').length);
675
+ const hasFetching = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'fetching').length);
676
+ const hasPaused = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'paused').length);
677
+ const hasStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'stale').length);
678
+ const hasInactive = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => utils.getQueryStatusLabel(q) === 'inactive').length);
679
+ return /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKeys, {
680
+ style: {
681
+ marginBottom: '.5em'
682
+ }
683
+ }, /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
684
+ style: {
685
+ background: theme.defaultTheme.success,
686
+ opacity: hasFresh ? 1 : 0.3
687
+ }
688
+ }, "fresh ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasFresh, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
689
+ style: {
690
+ background: theme.defaultTheme.active,
691
+ opacity: hasFetching ? 1 : 0.3
692
+ }
693
+ }, "fetching ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasFetching, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
694
+ style: {
695
+ background: theme.defaultTheme.paused,
696
+ opacity: hasPaused ? 1 : 0.3
697
+ }
698
+ }, "paused ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasPaused, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
699
+ style: {
700
+ background: theme.defaultTheme.warning,
701
+ color: 'black',
702
+ textShadow: '0',
703
+ opacity: hasStale ? 1 : 0.3
704
+ }
705
+ }, "stale ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasStale, ")")), ' ', /*#__PURE__*/React__namespace.createElement(styledComponents.QueryKey, {
706
+ style: {
707
+ background: theme.defaultTheme.gray,
708
+ opacity: hasInactive ? 1 : 0.3
709
+ }
710
+ }, "inactive ", /*#__PURE__*/React__namespace.createElement(styledComponents.Code, null, "(", hasInactive, ")")));
711
+ };
712
+
713
+ const QueryRow = ({
714
+ queryKey,
715
+ setActiveQueryHash,
716
+ activeQueryHash,
717
+ queryCache
718
+ }) => {
719
+ var _useSubscribeToQueryC3, _useSubscribeToQueryC4, _useSubscribeToQueryC5, _useSubscribeToQueryC6;
720
+
721
+ const queryHash = (_useSubscribeToQueryC3 = useSubscribeToQueryCache(queryCache, () => {
722
+ var _queryCache$find;
723
+
724
+ return (_queryCache$find = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find.queryHash;
725
+ })) != null ? _useSubscribeToQueryC3 : '';
726
+ const queryState = useSubscribeToQueryCache(queryCache, () => {
727
+ var _queryCache$find2;
728
+
729
+ return (_queryCache$find2 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find2.state;
730
+ });
731
+ const isStale = (_useSubscribeToQueryC4 = useSubscribeToQueryCache(queryCache, () => {
732
+ var _queryCache$find3;
733
+
734
+ return (_queryCache$find3 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find3.isStale();
735
+ })) != null ? _useSubscribeToQueryC4 : false;
736
+ const isDisabled = (_useSubscribeToQueryC5 = useSubscribeToQueryCache(queryCache, () => {
737
+ var _queryCache$find4;
738
+
739
+ return (_queryCache$find4 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find4.isDisabled();
740
+ })) != null ? _useSubscribeToQueryC5 : false;
741
+ const observerCount = (_useSubscribeToQueryC6 = useSubscribeToQueryCache(queryCache, () => {
742
+ var _queryCache$find5;
743
+
744
+ return (_queryCache$find5 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find5.getObserversCount();
745
+ })) != null ? _useSubscribeToQueryC6 : 0;
746
+
747
+ if (!queryState) {
748
+ return null;
749
+ }
750
+
751
+ return /*#__PURE__*/React__namespace.createElement("div", {
752
+ role: "button",
753
+ "aria-label": "Open query details for " + queryHash,
754
+ onClick: () => setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash),
755
+ style: {
756
+ display: 'flex',
757
+ borderBottom: "solid 1px " + theme.defaultTheme.grayAlt,
758
+ cursor: 'pointer',
759
+ background: queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined
760
+ }
761
+ }, /*#__PURE__*/React__namespace.createElement("div", {
762
+ style: {
763
+ flex: '0 0 auto',
764
+ width: '2em',
765
+ height: '2em',
766
+ background: utils.getQueryStatusColor({
767
+ queryState,
768
+ isStale,
769
+ observerCount,
770
+ theme: theme.defaultTheme
771
+ }),
772
+ display: 'flex',
773
+ alignItems: 'center',
774
+ justifyContent: 'center',
775
+ fontWeight: 'bold',
776
+ textShadow: isStale ? '0' : '0 0 10px black',
777
+ color: isStale ? 'black' : 'white'
778
+ }
779
+ }, observerCount), isDisabled ? /*#__PURE__*/React__namespace.createElement("div", {
780
+ style: {
781
+ flex: '0 0 auto',
782
+ height: '2em',
783
+ background: theme.defaultTheme.gray,
784
+ display: 'flex',
785
+ alignItems: 'center',
786
+ fontWeight: 'bold',
787
+ padding: '0 0.5em'
788
+ }
789
+ }, "disabled") : null, /*#__PURE__*/React__namespace.createElement(styledComponents.Code, {
790
+ style: {
791
+ padding: '.5em'
792
+ }
793
+ }, "" + queryHash));
794
+ }; // eslint-disable-next-line @typescript-eslint/no-empty-function
795
+
796
+
797
+ function noop() {}
798
+
799
+ exports.ReactQueryDevtools = ReactQueryDevtools;
800
+ exports.ReactQueryDevtoolsPanel = ReactQueryDevtoolsPanel;
801
+ //# sourceMappingURL=devtools.js.map