@tanstack/react-query-devtools 4.24.9 → 5.0.0-alpha.0
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/Explorer.d.ts +4 -4
- package/build/lib/Explorer.esm.js +5 -15
- package/build/lib/Explorer.esm.js.map +1 -1
- package/build/lib/Explorer.js +11 -25
- package/build/lib/Explorer.js.map +1 -1
- package/build/lib/Explorer.mjs +5 -15
- package/build/lib/Explorer.mjs.map +1 -1
- package/build/lib/Logo.d.ts +0 -1
- package/build/lib/Logo.esm.js.map +1 -1
- package/build/lib/Logo.js +5 -6
- package/build/lib/Logo.js.map +1 -1
- package/build/lib/Logo.mjs.map +1 -1
- package/build/lib/__tests__/devtools.test.d.ts +0 -5
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +0 -2
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -1
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js +1 -5
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +0 -2
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -1
- package/build/lib/devtools.d.ts +12 -4
- package/build/lib/devtools.esm.js +73 -108
- package/build/lib/devtools.esm.js.map +1 -1
- package/build/lib/devtools.js +95 -133
- package/build/lib/devtools.js.map +1 -1
- package/build/lib/devtools.mjs +73 -108
- package/build/lib/devtools.mjs.map +1 -1
- package/build/lib/index.d.ts +2 -2
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +0 -2
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs.map +1 -1
- package/build/lib/index.prod.d.ts +2 -2
- package/build/lib/index.prod.esm.js +121 -176
- package/build/lib/index.prod.esm.js.map +1 -1
- package/build/lib/index.prod.js +126 -187
- package/build/lib/index.prod.js.map +1 -1
- package/build/lib/index.prod.mjs +121 -176
- package/build/lib/index.prod.mjs.map +1 -1
- package/build/lib/screenreader.d.ts +0 -1
- package/build/lib/screenreader.esm.js.map +1 -1
- package/build/lib/screenreader.js +4 -5
- package/build/lib/screenreader.js.map +1 -1
- package/build/lib/screenreader.mjs.map +1 -1
- package/build/lib/styledComponents.esm.js +17 -16
- package/build/lib/styledComponents.esm.js.map +1 -1
- package/build/lib/styledComponents.js +17 -18
- package/build/lib/styledComponents.js.map +1 -1
- package/build/lib/styledComponents.mjs +17 -16
- package/build/lib/styledComponents.mjs.map +1 -1
- package/build/lib/theme.esm.js.map +1 -1
- package/build/lib/theme.js +4 -7
- package/build/lib/theme.js.map +1 -1
- package/build/lib/theme.mjs.map +1 -1
- package/build/lib/useLocalStorage.esm.js +0 -7
- package/build/lib/useLocalStorage.esm.js.map +1 -1
- package/build/lib/useLocalStorage.js +4 -12
- package/build/lib/useLocalStorage.js.map +1 -1
- package/build/lib/useLocalStorage.mjs +0 -7
- package/build/lib/useLocalStorage.mjs.map +1 -1
- package/build/lib/useMediaQuery.esm.js +6 -6
- package/build/lib/useMediaQuery.esm.js.map +1 -1
- package/build/lib/useMediaQuery.js +10 -11
- package/build/lib/useMediaQuery.js.map +1 -1
- package/build/lib/useMediaQuery.mjs +6 -6
- package/build/lib/useMediaQuery.mjs.map +1 -1
- package/build/lib/utils.esm.js +20 -22
- package/build/lib/utils.esm.js.map +1 -1
- package/build/lib/utils.js +24 -32
- package/build/lib/utils.js.map +1 -1
- package/build/lib/utils.mjs +20 -22
- package/build/lib/utils.mjs.map +1 -1
- package/build/umd/index.development.js +124 -439
- 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 +6 -10
- package/src/Explorer.tsx +4 -4
- package/src/__tests__/Explorer.test.tsx +5 -0
- package/src/__tests__/devtools.test.tsx +121 -175
- package/src/__tests__/utils.tsx +2 -2
- package/src/devtools.tsx +110 -116
- package/src/index.ts +2 -2
- package/build/lib/useSyncExternalStore.d.ts +0 -1
- package/build/lib/useSyncExternalStore.native.d.ts +0 -1
- package/src/useSyncExternalStore.native.ts +0 -3
- package/src/useSyncExternalStore.ts +0 -2
|
@@ -9,7 +9,6 @@ import ScreenReader from './screenreader.esm.js';
|
|
|
9
9
|
import { defaultTheme, ThemeProvider } from './theme.esm.js';
|
|
10
10
|
import Explorer from './Explorer.esm.js';
|
|
11
11
|
import Logo from './Logo.esm.js';
|
|
12
|
-
import { useSyncExternalStore } from 'use-sync-external-store/shim/index.js';
|
|
13
12
|
|
|
14
13
|
function ReactQueryDevtools({
|
|
15
14
|
initialIsOpen,
|
|
@@ -18,7 +17,7 @@ function ReactQueryDevtools({
|
|
|
18
17
|
toggleButtonProps = {},
|
|
19
18
|
position = 'bottom-left',
|
|
20
19
|
containerElement: Container = 'aside',
|
|
21
|
-
|
|
20
|
+
queryClient,
|
|
22
21
|
styleNonce,
|
|
23
22
|
panelPosition: initialPanelPosition = 'bottom'
|
|
24
23
|
}) {
|
|
@@ -31,11 +30,9 @@ function ReactQueryDevtools({
|
|
|
31
30
|
const [isResolvedOpen, setIsResolvedOpen] = React.useState(false);
|
|
32
31
|
const [isResizing, setIsResizing] = React.useState(false);
|
|
33
32
|
const isMounted = useIsMounted();
|
|
34
|
-
|
|
35
33
|
const handleDragStart = (panelElement, startEvent) => {
|
|
36
34
|
if (!panelElement) return;
|
|
37
35
|
if (startEvent.button !== 0) return; // Only allow left click for drag
|
|
38
|
-
|
|
39
36
|
const isVertical = isVerticalSide(panelPosition);
|
|
40
37
|
setIsResizing(true);
|
|
41
38
|
const {
|
|
@@ -45,12 +42,12 @@ function ReactQueryDevtools({
|
|
|
45
42
|
const startX = startEvent.clientX;
|
|
46
43
|
const startY = startEvent.clientY;
|
|
47
44
|
let newSize = 0;
|
|
48
|
-
|
|
49
45
|
const run = moveEvent => {
|
|
50
46
|
// prevent mouse selecting stuff with mouse drag
|
|
51
|
-
moveEvent.preventDefault();
|
|
52
|
-
// hint: it is different formula for the opposite sides
|
|
47
|
+
moveEvent.preventDefault();
|
|
53
48
|
|
|
49
|
+
// calculate the correct size based on mouse position and current panel position
|
|
50
|
+
// hint: it is different formula for the opposite sides
|
|
54
51
|
if (isVertical) {
|
|
55
52
|
newSize = width + (panelPosition === 'right' ? startX - moveEvent.clientX : moveEvent.clientX - startX);
|
|
56
53
|
setDevtoolsWidth(newSize);
|
|
@@ -58,48 +55,41 @@ function ReactQueryDevtools({
|
|
|
58
55
|
newSize = height + (panelPosition === 'bottom' ? startY - moveEvent.clientY : moveEvent.clientY - startY);
|
|
59
56
|
setDevtoolsHeight(newSize);
|
|
60
57
|
}
|
|
61
|
-
|
|
62
58
|
if (newSize < minPanelSize) {
|
|
63
59
|
setIsOpen(false);
|
|
64
60
|
} else {
|
|
65
61
|
setIsOpen(true);
|
|
66
62
|
}
|
|
67
63
|
};
|
|
68
|
-
|
|
69
64
|
const unsub = () => {
|
|
70
65
|
if (isResizing) {
|
|
71
66
|
setIsResizing(false);
|
|
72
67
|
}
|
|
73
|
-
|
|
74
68
|
document.removeEventListener('mousemove', run, false);
|
|
75
69
|
document.removeEventListener('mouseUp', unsub, false);
|
|
76
70
|
};
|
|
77
|
-
|
|
78
71
|
document.addEventListener('mousemove', run, false);
|
|
79
72
|
document.addEventListener('mouseup', unsub, false);
|
|
80
73
|
};
|
|
81
|
-
|
|
82
74
|
React.useEffect(() => {
|
|
83
|
-
setIsResolvedOpen(isOpen
|
|
84
|
-
}, [isOpen, isResolvedOpen, setIsResolvedOpen]);
|
|
85
|
-
// Prevents focusing in a closed panel.
|
|
75
|
+
setIsResolvedOpen(isOpen ?? false);
|
|
76
|
+
}, [isOpen, isResolvedOpen, setIsResolvedOpen]);
|
|
86
77
|
|
|
78
|
+
// Toggle panel visibility before/after transition (depending on direction).
|
|
79
|
+
// Prevents focusing in a closed panel.
|
|
87
80
|
React.useEffect(() => {
|
|
88
81
|
const ref = panelRef.current;
|
|
89
|
-
|
|
90
82
|
if (ref) {
|
|
91
83
|
const handlePanelTransitionStart = () => {
|
|
92
84
|
if (isResolvedOpen) {
|
|
93
85
|
ref.style.visibility = 'visible';
|
|
94
86
|
}
|
|
95
87
|
};
|
|
96
|
-
|
|
97
88
|
const handlePanelTransitionEnd = () => {
|
|
98
89
|
if (!isResolvedOpen) {
|
|
99
90
|
ref.style.visibility = 'hidden';
|
|
100
91
|
}
|
|
101
92
|
};
|
|
102
|
-
|
|
103
93
|
ref.addEventListener('transitionstart', handlePanelTransitionStart);
|
|
104
94
|
ref.addEventListener('transitionend', handlePanelTransitionEnd);
|
|
105
95
|
return () => {
|
|
@@ -107,19 +97,15 @@ function ReactQueryDevtools({
|
|
|
107
97
|
ref.removeEventListener('transitionend', handlePanelTransitionEnd);
|
|
108
98
|
};
|
|
109
99
|
}
|
|
110
|
-
|
|
111
100
|
return;
|
|
112
101
|
}, [isResolvedOpen]);
|
|
113
102
|
React.useEffect(() => {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if (isResolvedOpen && (_rootRef$current = rootRef.current) != null && _rootRef$current.parentElement) {
|
|
103
|
+
if (isResolvedOpen && rootRef.current?.parentElement) {
|
|
117
104
|
const {
|
|
118
105
|
parentElement
|
|
119
106
|
} = rootRef.current;
|
|
120
107
|
const styleProp = getSidedProp('padding', panelPosition);
|
|
121
108
|
const isVertical = isVerticalSide(panelPosition);
|
|
122
|
-
|
|
123
109
|
const previousPaddings = (({
|
|
124
110
|
padding,
|
|
125
111
|
paddingTop,
|
|
@@ -133,20 +119,18 @@ function ReactQueryDevtools({
|
|
|
133
119
|
paddingLeft,
|
|
134
120
|
paddingRight
|
|
135
121
|
}))(parentElement.style);
|
|
136
|
-
|
|
137
122
|
const run = () => {
|
|
138
123
|
// reset the padding
|
|
139
124
|
parentElement.style.padding = '0px';
|
|
140
125
|
parentElement.style.paddingTop = '0px';
|
|
141
126
|
parentElement.style.paddingBottom = '0px';
|
|
142
127
|
parentElement.style.paddingLeft = '0px';
|
|
143
|
-
parentElement.style.paddingRight = '0px';
|
|
128
|
+
parentElement.style.paddingRight = '0px';
|
|
129
|
+
// set the new padding based on the new panel position
|
|
144
130
|
|
|
145
|
-
parentElement.style[styleProp] =
|
|
131
|
+
parentElement.style[styleProp] = `${isVertical ? devtoolsWidth : devtoolsHeight}px`;
|
|
146
132
|
};
|
|
147
|
-
|
|
148
133
|
run();
|
|
149
|
-
|
|
150
134
|
if (typeof window !== 'undefined') {
|
|
151
135
|
window.addEventListener('resize', run);
|
|
152
136
|
return () => {
|
|
@@ -157,7 +141,6 @@ function ReactQueryDevtools({
|
|
|
157
141
|
};
|
|
158
142
|
}
|
|
159
143
|
}
|
|
160
|
-
|
|
161
144
|
return;
|
|
162
145
|
}, [isResolvedOpen, panelPosition, devtoolsHeight, devtoolsWidth]);
|
|
163
146
|
const {
|
|
@@ -168,8 +151,9 @@ function ReactQueryDevtools({
|
|
|
168
151
|
style: toggleButtonStyle = {},
|
|
169
152
|
onClick: onToggleClick,
|
|
170
153
|
...otherToggleButtonProps
|
|
171
|
-
} = toggleButtonProps;
|
|
154
|
+
} = toggleButtonProps;
|
|
172
155
|
|
|
156
|
+
// get computed style based on panel position
|
|
173
157
|
const style = getSidePanelStyle({
|
|
174
158
|
position: panelPosition,
|
|
175
159
|
devtoolsTheme: defaultTheme,
|
|
@@ -178,8 +162,9 @@ function ReactQueryDevtools({
|
|
|
178
162
|
width: devtoolsWidth,
|
|
179
163
|
isResizing,
|
|
180
164
|
panelStyle
|
|
181
|
-
});
|
|
165
|
+
});
|
|
182
166
|
|
|
167
|
+
// Do not render on the server
|
|
183
168
|
if (!isMounted()) return null;
|
|
184
169
|
return /*#__PURE__*/React.createElement(Container, {
|
|
185
170
|
ref: rootRef,
|
|
@@ -189,7 +174,7 @@ function ReactQueryDevtools({
|
|
|
189
174
|
theme: defaultTheme
|
|
190
175
|
}, /*#__PURE__*/React.createElement(ReactQueryDevtoolsPanel, _extends({
|
|
191
176
|
ref: panelRef,
|
|
192
|
-
|
|
177
|
+
queryClient: queryClient,
|
|
193
178
|
styleNonce: styleNonce,
|
|
194
179
|
position: panelPosition,
|
|
195
180
|
onPositionChange: setPanelPosition,
|
|
@@ -209,7 +194,7 @@ function ReactQueryDevtools({
|
|
|
209
194
|
"aria-expanded": "false",
|
|
210
195
|
onClick: e => {
|
|
211
196
|
setIsOpen(true);
|
|
212
|
-
onToggleClick
|
|
197
|
+
onToggleClick?.(e);
|
|
213
198
|
},
|
|
214
199
|
style: {
|
|
215
200
|
background: 'none',
|
|
@@ -243,22 +228,20 @@ function ReactQueryDevtools({
|
|
|
243
228
|
text: "Open React Query Devtools"
|
|
244
229
|
})) : null);
|
|
245
230
|
}
|
|
246
|
-
|
|
247
231
|
const useSubscribeToQueryCache = (queryCache, getSnapshot, skip = false) => {
|
|
248
|
-
return useSyncExternalStore(React.useCallback(onStoreChange => {
|
|
232
|
+
return React.useSyncExternalStore(React.useCallback(onStoreChange => {
|
|
249
233
|
if (!skip) return queryCache.subscribe(notifyManager.batchCalls(onStoreChange));
|
|
250
234
|
return () => {
|
|
251
235
|
return;
|
|
252
236
|
};
|
|
253
237
|
}, [queryCache, skip]), getSnapshot, getSnapshot);
|
|
254
238
|
};
|
|
255
|
-
|
|
256
239
|
const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
|
|
257
240
|
const {
|
|
258
241
|
isOpen = true,
|
|
259
242
|
styleNonce,
|
|
260
243
|
setIsOpen,
|
|
261
|
-
|
|
244
|
+
queryClient,
|
|
262
245
|
onDragStart,
|
|
263
246
|
onPositionChange,
|
|
264
247
|
showCloseButton,
|
|
@@ -270,10 +253,8 @@ const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQuer
|
|
|
270
253
|
onClick: onCloseClick,
|
|
271
254
|
...otherCloseButtonProps
|
|
272
255
|
} = closeButtonProps;
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
});
|
|
276
|
-
const queryCache = queryClient.getQueryCache();
|
|
256
|
+
const client = useQueryClient(queryClient);
|
|
257
|
+
const queryCache = client.getQueryCache();
|
|
277
258
|
const [sort, setSort] = useLocalStorage('reactQueryDevtoolsSortFn', Object.keys(sortFns)[0]);
|
|
278
259
|
const [filter, setFilter] = useLocalStorage('reactQueryDevtoolsFilter', '');
|
|
279
260
|
const [baseSort, setBaseSort] = useLocalStorage('reactQueryDevtoolsBaseSort', 1);
|
|
@@ -282,11 +263,9 @@ const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQuer
|
|
|
282
263
|
const [activeQueryHash, setActiveQueryHash] = useLocalStorage('reactQueryDevtoolsActiveQueryHash', '');
|
|
283
264
|
const queries = React.useMemo(() => {
|
|
284
265
|
const unsortedQueries = queryCache.getAll();
|
|
285
|
-
|
|
286
266
|
if (queriesCount === 0) {
|
|
287
267
|
return [];
|
|
288
268
|
}
|
|
289
|
-
|
|
290
269
|
const filtered = filter ? unsortedQueries.filter(item => rankItem(item.queryHash, filter).passed) : [...unsortedQueries];
|
|
291
270
|
const sorted = sortFn ? filtered.sort((a, b) => sortFn(a, b) * baseSort) : filtered;
|
|
292
271
|
return sorted;
|
|
@@ -308,7 +287,26 @@ const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQuer
|
|
|
308
287
|
}), /*#__PURE__*/React.createElement("style", {
|
|
309
288
|
nonce: styleNonce,
|
|
310
289
|
dangerouslySetInnerHTML: {
|
|
311
|
-
__html:
|
|
290
|
+
__html: `
|
|
291
|
+
.ReactQueryDevtoolsPanel * {
|
|
292
|
+
scrollbar-color: ${defaultTheme.backgroundAlt} ${defaultTheme.gray};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
.ReactQueryDevtoolsPanel *::-webkit-scrollbar, .ReactQueryDevtoolsPanel scrollbar {
|
|
296
|
+
width: 1em;
|
|
297
|
+
height: 1em;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.ReactQueryDevtoolsPanel *::-webkit-scrollbar-track, .ReactQueryDevtoolsPanel scrollbar-track {
|
|
301
|
+
background: ${defaultTheme.backgroundAlt};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.ReactQueryDevtoolsPanel *::-webkit-scrollbar-thumb, .ReactQueryDevtoolsPanel scrollbar-thumb {
|
|
305
|
+
background: ${defaultTheme.gray};
|
|
306
|
+
border-radius: .5em;
|
|
307
|
+
border: 3px solid ${defaultTheme.backgroundAlt};
|
|
308
|
+
}
|
|
309
|
+
`
|
|
312
310
|
}
|
|
313
311
|
}), /*#__PURE__*/React.createElement("div", {
|
|
314
312
|
style: getResizeHandleStyle(position),
|
|
@@ -319,7 +317,7 @@ const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQuer
|
|
|
319
317
|
minHeight: '40%',
|
|
320
318
|
maxHeight: '100%',
|
|
321
319
|
overflow: 'auto',
|
|
322
|
-
borderRight:
|
|
320
|
+
borderRight: `1px solid ${defaultTheme.grayAlt}`,
|
|
323
321
|
display: 'flex',
|
|
324
322
|
flexDirection: 'column'
|
|
325
323
|
}
|
|
@@ -387,7 +385,7 @@ const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQuer
|
|
|
387
385
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
388
386
|
placeholder: "Filter",
|
|
389
387
|
"aria-label": "Filter by queryhash",
|
|
390
|
-
value: filter
|
|
388
|
+
value: filter ?? '',
|
|
391
389
|
onChange: e => setFilter(e.target.value),
|
|
392
390
|
onKeyDown: e => {
|
|
393
391
|
if (e.key === 'Escape') setFilter('');
|
|
@@ -397,7 +395,7 @@ const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQuer
|
|
|
397
395
|
marginRight: '.5em',
|
|
398
396
|
width: '100%'
|
|
399
397
|
}
|
|
400
|
-
}),
|
|
398
|
+
}), /*#__PURE__*/React.createElement(Select, {
|
|
401
399
|
"aria-label": "Sort queries",
|
|
402
400
|
value: sort,
|
|
403
401
|
onChange: e => setSort(e.target.value),
|
|
@@ -478,7 +476,7 @@ const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQuer
|
|
|
478
476
|
d: "M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0"
|
|
479
477
|
}))), /*#__PURE__*/React.createElement(ScreenReader, {
|
|
480
478
|
text: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior'
|
|
481
|
-
})))
|
|
479
|
+
}))))), /*#__PURE__*/React.createElement("div", {
|
|
482
480
|
style: {
|
|
483
481
|
overflowY: 'auto',
|
|
484
482
|
flex: '1'
|
|
@@ -494,7 +492,7 @@ const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQuer
|
|
|
494
492
|
}))), activeQueryHash && isOpen ? /*#__PURE__*/React.createElement(ActiveQuery, {
|
|
495
493
|
activeQueryHash: activeQueryHash,
|
|
496
494
|
queryCache: queryCache,
|
|
497
|
-
queryClient:
|
|
495
|
+
queryClient: client
|
|
498
496
|
}) : null, showCloseButton ? /*#__PURE__*/React.createElement(Button, _extends({
|
|
499
497
|
type: "button",
|
|
500
498
|
"aria-controls": "ReactQueryDevtoolsPanel",
|
|
@@ -511,44 +509,26 @@ const ReactQueryDevtoolsPanel = /*#__PURE__*/React.forwardRef(function ReactQuer
|
|
|
511
509
|
},
|
|
512
510
|
onClick: e => {
|
|
513
511
|
setIsOpen(false);
|
|
514
|
-
onCloseClick
|
|
512
|
+
onCloseClick?.(e);
|
|
515
513
|
}
|
|
516
514
|
}), "Close") : null));
|
|
517
515
|
});
|
|
518
|
-
|
|
519
516
|
const ActiveQuery = ({
|
|
520
517
|
queryCache,
|
|
521
518
|
activeQueryHash,
|
|
522
519
|
queryClient
|
|
523
520
|
}) => {
|
|
524
|
-
var _useSubscribeToQueryC, _useSubscribeToQueryC2;
|
|
525
|
-
|
|
526
521
|
const activeQuery = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash));
|
|
527
|
-
const activeQueryState = useSubscribeToQueryCache(queryCache, () =>
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
return (_queryCache$getAll$fi = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi.state;
|
|
531
|
-
});
|
|
532
|
-
const isStale = (_useSubscribeToQueryC = useSubscribeToQueryCache(queryCache, () => {
|
|
533
|
-
var _queryCache$getAll$fi2;
|
|
534
|
-
|
|
535
|
-
return (_queryCache$getAll$fi2 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi2.isStale();
|
|
536
|
-
})) != null ? _useSubscribeToQueryC : false;
|
|
537
|
-
const observerCount = (_useSubscribeToQueryC2 = useSubscribeToQueryCache(queryCache, () => {
|
|
538
|
-
var _queryCache$getAll$fi3;
|
|
539
|
-
|
|
540
|
-
return (_queryCache$getAll$fi3 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi3.getObserversCount();
|
|
541
|
-
})) != null ? _useSubscribeToQueryC2 : 0;
|
|
542
|
-
|
|
522
|
+
const activeQueryState = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.state);
|
|
523
|
+
const isStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.isStale()) ?? false;
|
|
524
|
+
const observerCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.getObserversCount()) ?? 0;
|
|
543
525
|
const handleRefetch = () => {
|
|
544
|
-
const promise = activeQuery
|
|
545
|
-
promise
|
|
526
|
+
const promise = activeQuery?.fetch();
|
|
527
|
+
promise?.catch(noop);
|
|
546
528
|
};
|
|
547
|
-
|
|
548
529
|
if (!activeQuery || !activeQueryState) {
|
|
549
530
|
return null;
|
|
550
531
|
}
|
|
551
|
-
|
|
552
532
|
return /*#__PURE__*/React.createElement(ActiveQueryPanel, null, /*#__PURE__*/React.createElement("div", {
|
|
553
533
|
style: {
|
|
554
534
|
padding: '.5em',
|
|
@@ -680,7 +660,6 @@ const ActiveQuery = ({
|
|
|
680
660
|
}
|
|
681
661
|
})));
|
|
682
662
|
};
|
|
683
|
-
|
|
684
663
|
const QueryStatusCount = ({
|
|
685
664
|
queryCache
|
|
686
665
|
}) => {
|
|
@@ -718,52 +697,37 @@ const QueryStatusCount = ({
|
|
|
718
697
|
}
|
|
719
698
|
}, "inactive ", /*#__PURE__*/React.createElement(Code, null, "(", hasInactive, ")")));
|
|
720
699
|
};
|
|
721
|
-
|
|
722
700
|
const QueryRow = /*#__PURE__*/React.memo(({
|
|
723
701
|
queryKey,
|
|
724
702
|
setActiveQueryHash,
|
|
725
703
|
activeQueryHash,
|
|
726
704
|
queryCache
|
|
727
705
|
}) => {
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
});
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
return (_queryCache$find3 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find3.isStale();
|
|
744
|
-
})) != null ? _useSubscribeToQueryC4 : false;
|
|
745
|
-
const isDisabled = (_useSubscribeToQueryC5 = useSubscribeToQueryCache(queryCache, () => {
|
|
746
|
-
var _queryCache$find4;
|
|
747
|
-
|
|
748
|
-
return (_queryCache$find4 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find4.isDisabled();
|
|
749
|
-
})) != null ? _useSubscribeToQueryC5 : false;
|
|
750
|
-
const observerCount = (_useSubscribeToQueryC6 = useSubscribeToQueryCache(queryCache, () => {
|
|
751
|
-
var _queryCache$find5;
|
|
752
|
-
|
|
753
|
-
return (_queryCache$find5 = queryCache.find(queryKey)) == null ? void 0 : _queryCache$find5.getObserversCount();
|
|
754
|
-
})) != null ? _useSubscribeToQueryC6 : 0;
|
|
755
|
-
|
|
706
|
+
const queryHash = useSubscribeToQueryCache(queryCache, () => queryCache.find({
|
|
707
|
+
queryKey
|
|
708
|
+
})?.queryHash) ?? '';
|
|
709
|
+
const queryState = useSubscribeToQueryCache(queryCache, () => queryCache.find({
|
|
710
|
+
queryKey
|
|
711
|
+
})?.state);
|
|
712
|
+
const isStale = useSubscribeToQueryCache(queryCache, () => queryCache.find({
|
|
713
|
+
queryKey
|
|
714
|
+
})?.isStale()) ?? false;
|
|
715
|
+
const isDisabled = useSubscribeToQueryCache(queryCache, () => queryCache.find({
|
|
716
|
+
queryKey
|
|
717
|
+
})?.isDisabled()) ?? false;
|
|
718
|
+
const observerCount = useSubscribeToQueryCache(queryCache, () => queryCache.find({
|
|
719
|
+
queryKey
|
|
720
|
+
})?.getObserversCount()) ?? 0;
|
|
756
721
|
if (!queryState) {
|
|
757
722
|
return null;
|
|
758
723
|
}
|
|
759
|
-
|
|
760
724
|
return /*#__PURE__*/React.createElement("div", {
|
|
761
725
|
role: "button",
|
|
762
|
-
"aria-label":
|
|
726
|
+
"aria-label": `Open query details for ${queryHash}`,
|
|
763
727
|
onClick: () => setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash),
|
|
764
728
|
style: {
|
|
765
729
|
display: 'flex',
|
|
766
|
-
borderBottom:
|
|
730
|
+
borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
|
|
767
731
|
cursor: 'pointer',
|
|
768
732
|
background: queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined
|
|
769
733
|
}
|
|
@@ -799,9 +763,10 @@ const QueryRow = /*#__PURE__*/React.memo(({
|
|
|
799
763
|
style: {
|
|
800
764
|
padding: '.5em'
|
|
801
765
|
}
|
|
802
|
-
},
|
|
803
|
-
});
|
|
766
|
+
}, `${queryHash}`));
|
|
767
|
+
});
|
|
804
768
|
|
|
769
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
805
770
|
function noop() {}
|
|
806
771
|
|
|
807
772
|
export { ReactQueryDevtools, ReactQueryDevtoolsPanel };
|