Open History to see the last commit
1import React from 'react'
2β
3import { Query, useQueryClient } from 'react-query'
4import { matchSorter } from 'match-sorter'
5import useLocalStorage from './useLocalStorage'
6import { useIsMounted, useSafeState } from './utils'
7β
8import {
9 Panel,
10 QueryKeys,
11 QueryKey,
12 Button,
13 Code,
14 Input,
15 Select,
16 ActiveQueryPanel,
17} from './styledComponents'
18import { ThemeProvider, defaultTheme as theme } from './theme'
19import { getQueryStatusLabel, getQueryStatusColor } from './utils'
20import Explorer from './Explorer'
21import Logo from './Logo'
22import { noop } from '../core/utils'
23β
24interface DevtoolsOptions {
25 /**
26 * Set this true if you want the dev tools to default to being open
27 */
28 initialIsOpen?: boolean
29 /**
30 * Use this to add props to the panel. For example, you can add className, style (merge and override default style), etc.
31 */
32 panelProps?: React.DetailedHTMLProps<
33 React.HTMLAttributes<HTMLDivElement>,
34 HTMLDivElement
35 >
36 /**
37 * Use this to add props to the close button. For example, you can add className, style (merge and override default style), onClick (extend default handler), etc.
38 */
39 closeButtonProps?: React.DetailedHTMLProps<
40 React.ButtonHTMLAttributes<HTMLButtonElement>,
41 HTMLButtonElement
42 >
43 /**
44 * Use this to add props to the toggle button. For example, you can add className, style (merge and override default style), onClick (extend default handler), etc.
45 */
46 toggleButtonProps?: React.DetailedHTMLProps<
47 React.ButtonHTMLAttributes<HTMLButtonElement>,
48 HTMLButtonElement
49 >
50 /**
51 * The position of the React Query logo to open and close the devtools panel.
52 * Defaults to 'bottom-left'.
53 */
54 position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
55 /**
56 * Use this to render the devtools inside a different type of container element for a11y purposes.
57 * Any string which corresponds to a valid intrinsic JSX element is allowed.
58 * Defaults to 'aside'.
59 */
60 containerElement?: string | any
61 /**
62 * nonce for style element for CSP
63 */
64 styleNonce?: string
65}
66β
67interface DevtoolsPanelOptions {
68 /**
69 * The standard React style object used to style a component with inline styles
70 */
71 style?: React.CSSProperties
72 /**
73 * The standard React className property used to style a component with classes
74 */
75 className?: string
76 /**
77 * A boolean variable indicating whether the panel is open or closed
78 */
79 isOpen?: boolean
80 /**
81 * nonce for style element for CSP
82 */
83 styleNonce?: string
84 /**
85 * A function that toggles the open and close state of the panel
86 */
87 setIsOpen: (isOpen: boolean) => void
88 /**
89 * Handles the opening and closing the devtools panel
90 */
91 handleDragStart: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void
92}
93β
94const isServer = typeof window === 'undefined'
95β
96export function ReactQueryDevtools({
97 initialIsOpen,
98 panelProps = {},
99 closeButtonProps = {},
100 toggleButtonProps = {},
101 position = 'bottom-left',
102 containerElement: Container = 'aside',
103 styleNonce,
104}: DevtoolsOptions): React.ReactElement | null {
105 const rootRef = React.useRef<HTMLDivElement>(null)
106 const panelRef = React.useRef<HTMLDivElement>(null)
107 const [isOpen, setIsOpen] = useLocalStorage(
108 'reactQueryDevtoolsOpen',
109 initialIsOpen
110 )
111 const [devtoolsHeight, setDevtoolsHeight] = useLocalStorage<number | null>(
112 'reactQueryDevtoolsHeight',
113 null
114 )
115 const [isResolvedOpen, setIsResolvedOpen] = useSafeState(false)
116 const [isResizing, setIsResizing] = useSafeState(false)
117 const isMounted = useIsMounted()
118β
119 const handleDragStart = (
120 panelElement: HTMLDivElement | null,
121 startEvent: React.MouseEvent<HTMLDivElement, MouseEvent>
122 ) => {
123 if (startEvent.button !== 0) return // Only allow left click for drag
124β
125 setIsResizing(true)
126β
127 const dragInfo = {
128 originalHeight: panelElement?.getBoundingClientRect().height ?? 0,
129 pageY: startEvent.pageY,
130 }
131β
132 const run = (moveEvent: MouseEvent) => {
133 const delta = dragInfo.pageY - moveEvent.pageY
134 const newHeight = dragInfo?.originalHeight + delta
135β
136 setDevtoolsHeight(newHeight)
137β
138 if (newHeight < 70) {
139 setIsOpen(false)
140 } else {
141 setIsOpen(true)
142 }
143 }
144β
145 const unsub = () => {
146 setIsResizing(false)
147 document.removeEventListener('mousemove', run)
148 document.removeEventListener('mouseUp', unsub)
149 }
150β
151 document.addEventListener('mousemove', run)
152 document.addEventListener('mouseup', unsub)
153 }
154β
155 React.useEffect(() => {
156 setIsResolvedOpen(isOpen ?? false)
157 }, [isOpen, isResolvedOpen, setIsResolvedOpen])
158β
159 // Toggle panel visibility before/after transition (depending on direction).
160 // Prevents focusing in a closed panel.
161 React.useEffect(() => {
162 const ref = panelRef.current
163 if (ref) {
164 const handlePanelTransitionStart = () => {
165 if (ref && isResolvedOpen) {
166 ref.style.visibility = 'visible'
167 }
168 }
169β
170 const handlePanelTransitionEnd = () => {
171 if (ref && !isResolvedOpen) {
172 ref.style.visibility = 'hidden'
173 }
174 }
175β
176 ref.addEventListener('transitionstart', handlePanelTransitionStart)
177 ref.addEventListener('transitionend', handlePanelTransitionEnd)
178β
179 return () => {
180 ref.removeEventListener('transitionstart', handlePanelTransitionStart)
181 ref.removeEventListener('transitionend', handlePanelTransitionEnd)
182 }
183 }
184 }, [isResolvedOpen])
185β
186 React[isServer ? 'useEffect' : 'useLayoutEffect'](() => {
187 if (isResolvedOpen) {
188 const previousValue = rootRef.current?.parentElement?.style.paddingBottom
189β
190 const run = () => {
191 const containerHeight = panelRef.current?.getBoundingClientRect().height
192 if (rootRef.current?.parentElement) {
193 rootRef.current.parentElement.style.paddingBottom = `${containerHeight}px`
194 }
195 }
196β
197 run()
198β
199 if (typeof window !== 'undefined') {
200 window.addEventListener('resize', run)
201β
202 return () => {
203 window.removeEventListener('resize', run)
204 if (
205 rootRef.current?.parentElement &&
206 typeof previousValue === 'string'
207 ) {
208 rootRef.current.parentElement.style.paddingBottom = previousValue
209 }
210 }
211 }
212 }
213 }, [isResolvedOpen])
214β
215 const { style: panelStyle = {}, ...otherPanelProps } = panelProps
216β
217 const {
218 style: closeButtonStyle = {},
219 onClick: onCloseClick,
220 ...otherCloseButtonProps
221 } = closeButtonProps
222β
223 const {
224 style: toggleButtonStyle = {},
225 onClick: onToggleClick,
226 ...otherToggleButtonProps
227 } = toggleButtonProps
228β
229 // Do not render on the server
230 if (!isMounted()) return null
231β
232 return (
233 <Container
234 ref={rootRef}
235 className="ReactQueryDevtools"
236 aria-label="React Query Devtools"
237 >
238 <ThemeProvider theme={theme}>
239 <ReactQueryDevtoolsPanel
240 ref={panelRef as any}
241 styleNonce={styleNonce}
242 {...otherPanelProps}
243 style={{
244 position: 'fixed',
245 bottom: '0',
246 right: '0',
247 zIndex: 99999,
248 width: '100%',
249 height: devtoolsHeight ?? 500,
250 maxHeight: '90%',
251 boxShadow: '0 0 20px rgba(0,0,0,.3)',
252 borderTop: `1px solid ${theme.gray}`,
253 transformOrigin: 'top',
254 // visibility will be toggled after transitions, but set initial state here
255 visibility: isOpen ? 'visible' : 'hidden',
256 ...panelStyle,
257 ...(isResizing
258 ? {
259 transition: `none`,
260 }
261 : { transition: `all .2s ease` }),
262 ...(isResolvedOpen
263 ? {
264 opacity: 1,
265 pointerEvents: 'all',
266 transform: `translateY(0) scale(1)`,
267 }
268 : {
269 opacity: 0,
270 pointerEvents: 'none',
271 transform: `translateY(15px) scale(1.02)`,
272 }),
273 }}
274 isOpen={isResolvedOpen}
275 setIsOpen={setIsOpen}
276 handleDragStart={e => handleDragStart(panelRef.current, e)}
277 />
278 {isResolvedOpen ? (
279 <Button
280 type="button"
281 aria-controls="ReactQueryDevtoolsPanel"
282 aria-haspopup="true"
283 aria-expanded="true"
284 {...(otherCloseButtonProps as unknown)}
285 onClick={e => {
286 setIsOpen(false)
287 onCloseClick && onCloseClick(e)
288 }}
289 style={{
290 position: 'fixed',
291 zIndex: 99999,
292 margin: '.5em',
293 bottom: 0,
294 ...(position === 'top-right'
295 ? {
296 right: '0',
297 }
298 : position === 'top-left'
299 ? {
300 left: '0',
301 }
302 : position === 'bottom-right'
303 ? {
304 right: '0',
305 }
306 : {
307 left: '0',
308 }),
309 ...closeButtonStyle,
310 }}
311 >
312 Close
313 </Button>
314 ) : null}
315 </ThemeProvider>
316 {!isResolvedOpen ? (
317 <button
318 type="button"
319 {...otherToggleButtonProps}
320 aria-label="Open React Query Devtools"
321 aria-controls="ReactQueryDevtoolsPanel"
322 aria-haspopup="true"
323 aria-expanded="false"
324 onClick={e => {
325 setIsOpen(true)
326 onToggleClick && onToggleClick(e)
327 }}
328 style={{
329 background: 'none',
330 border: 0,
331 padding: 0,
332 position: 'fixed',
333 zIndex: 99999,
334 display: 'inline-flex',
335 fontSize: '1.5em',
336 margin: '.5em',
337 cursor: 'pointer',
338 width: 'fit-content',
339 ...(position === 'top-right'
340 ? {
341 top: '0',
342 right: '0',
343 }
344 : position === 'top-left'
345 ? {
346 top: '0',
347 left: '0',
348 }
349 : position === 'bottom-right'
350 ? {
351 bottom: '0',
352 right: '0',
353 }
354 : {
355 bottom: '0',
356 left: '0',
357 }),
358 ...toggleButtonStyle,
359 }}
360 >
361 <Logo aria-hidden />
362 </button>
363 ) : null}
364 </Container>
365 )
366}
367β
368const getStatusRank = (q: Query) =>
369 q.state.isFetching ? 0 : !q.getObserversCount() ? 3 : q.isStale() ? 2 : 1
370β
371const sortFns: Record<string, (a: Query, b: Query) => number> = {
372 'Status > Last Updated': (a, b) =>
373 getStatusRank(a) === getStatusRank(b)
374 ? (sortFns['Last Updated']?.(a, b) as number)
375 : getStatusRank(a) > getStatusRank(b)
376 ? 1
377 : -1,
378 'Query Hash': (a, b) => (a.queryHash > b.queryHash ? 1 : -1),
379 'Last Updated': (a, b) =>
380 a.state.dataUpdatedAt < b.state.dataUpdatedAt ? 1 : -1,
381}
382β
383export const ReactQueryDevtoolsPanel = React.forwardRef<
384 HTMLDivElement,
385 DevtoolsPanelOptions
386>(function ReactQueryDevtoolsPanel(props, ref): React.ReactElement {
387 const {
388 isOpen = true,
389 styleNonce,
390 setIsOpen,
391 handleDragStart,
392 ...panelProps
393 } = props
394β
395 const queryClient = useQueryClient()
396 const queryCache = queryClient.getQueryCache()
397β
398 const [sort, setSort] = useLocalStorage(
399 'reactQueryDevtoolsSortFn',
400 Object.keys(sortFns)[0]
401 )
402β
403 const [filter, setFilter] = useLocalStorage('reactQueryDevtoolsFilter', '')
404β
405 const [sortDesc, setSortDesc] = useLocalStorage(
406 'reactQueryDevtoolsSortDesc',
407 false
408 )
409β
410 const sortFn = React.useMemo(() => sortFns[sort as string], [sort])
411β
412 React[isServer ? 'useEffect' : 'useLayoutEffect'](() => {
413 if (!sortFn) {
414 setSort(Object.keys(sortFns)[0] as string)
415 }
416 }, [setSort, sortFn])
417β
418 const [unsortedQueries, setUnsortedQueries] = useSafeState(
419 Object.values(queryCache.findAll())
420 )
421β
422 const [activeQueryHash, setActiveQueryHash] = useLocalStorage(
423 'reactQueryDevtoolsActiveQueryHash',
424 ''
425 )
426β
427 const queries = React.useMemo(() => {
428 const sorted = [...unsortedQueries].sort(sortFn)
429β
430 if (sortDesc) {
431 sorted.reverse()
432 }
433β
434 if (!filter) {
435 return sorted
436 }
437β
438 return matchSorter(sorted, filter, { keys: ['queryHash'] }).filter(
439 d => d.queryHash
440 )
441 }, [sortDesc, sortFn, unsortedQueries, filter])
442β
443 const activeQuery = React.useMemo(() => {
444 return queries.find(query => query.queryHash === activeQueryHash)
445 }, [activeQueryHash, queries])
446β
447 const hasFresh = queries.filter(q => getQueryStatusLabel(q) === 'fresh')
448 .length
449 const hasFetching = queries.filter(q => getQueryStatusLabel(q) === 'fetching')
450 .length
451 const hasStale = queries.filter(q => getQueryStatusLabel(q) === 'stale')
452 .length
453 const hasInactive = queries.filter(q => getQueryStatusLabel(q) === 'inactive')
454 .length
455β
456 React.useEffect(() => {
457 if (isOpen) {
458 const unsubscribe = queryCache.subscribe(() => {
459 setUnsortedQueries(Object.values(queryCache.getAll()))
460 })
461 // re-subscribing after the panel is closed and re-opened won't trigger the callback,
462 // So we'll manually populate our state
463 setUnsortedQueries(Object.values(queryCache.getAll()))
464β
465 return unsubscribe
466 }
467 return undefined
468 }, [isOpen, sort, sortFn, sortDesc, setUnsortedQueries, queryCache])
469β
470 const handleRefetch = () => {
471 const promise = activeQuery?.fetch()
472 promise?.catch(noop)
473 }
474β
475 return (
476 <ThemeProvider theme={theme}>
477 <Panel
478 ref={ref}
479 className="ReactQueryDevtoolsPanel"
480 aria-label="React Query Devtools Panel"
481 id="ReactQueryDevtoolsPanel"
482 {...panelProps}
483 >
484 <style
485 nonce={styleNonce}
486 dangerouslySetInnerHTML={{
487 __html: `
488 .ReactQueryDevtoolsPanel * {
489 scrollbar-color: ${theme.backgroundAlt} ${theme.gray};
490 }
491β
492 .ReactQueryDevtoolsPanel *::-webkit-scrollbar, .ReactQueryDevtoolsPanel scrollbar {
493 width: 1em;
494 height: 1em;
495 }
496β
497 .ReactQueryDevtoolsPanel *::-webkit-scrollbar-track, .ReactQueryDevtoolsPanel scrollbar-track {
498 background: ${theme.backgroundAlt};
499 }
500β
501 .ReactQueryDevtoolsPanel *::-webkit-scrollbar-thumb, .ReactQueryDevtoolsPanel scrollbar-thumb {
502 background: ${theme.gray};
503 border-radius: .5em;
504 border: 3px solid ${theme.backgroundAlt};
505 }
506 `,
507 }}
508 />
509 <div
510 style={{
511 position: 'absolute',
512 left: 0,
513 top: 0,
514 width: '100%',
515 height: '4px',
516 marginBottom: '-4px',
517 cursor: 'row-resize',
518 zIndex: 100000,
519 }}
520 onMouseDown={handleDragStart}
521 ></div>
522 <div
523 style={{
524 flex: '1 1 500px',
525 minHeight: '40%',
526 maxHeight: '100%',
527 overflow: 'auto',
528 borderRight: `1px solid ${theme.grayAlt}`,
529 display: isOpen ? 'flex' : 'none',
530 flexDirection: 'column',
531 }}
532 >
533 <div
534 style={{
535 padding: '.5em',
536 background: theme.backgroundAlt,
537 display: 'flex',
538 justifyContent: 'space-between',
539 alignItems: 'center',
540 }}
541 >
542 <button
543 type="button"
544 aria-label="Close React Query Devtools"
545 aria-controls="ReactQueryDevtoolsPanel"
546 aria-haspopup="true"
547 aria-expanded="true"
548 onClick={() => setIsOpen(false)}
549 style={{
550 display: 'inline-flex',
551 background: 'none',
552 border: 0,
553 padding: 0,
554 marginRight: '.5em',
555 cursor: 'pointer',
556 }}
557 >
558 <Logo aria-hidden />
559 </button>
560 <div
561 style={{
562 display: 'flex',
563 flexDirection: 'column',
564 }}
565 >
566 <QueryKeys style={{ marginBottom: '.5em' }}>
567 <QueryKey
568 style={{
569 background: theme.success,
570 opacity: hasFresh ? 1 : 0.3,
571 }}
572 >
573 fresh <Code>({hasFresh})</Code>
574 </QueryKey>{' '}
575 <QueryKey
576 style={{
577 background: theme.active,
578 opacity: hasFetching ? 1 : 0.3,
579 }}
580 >
581 fetching <Code>({hasFetching})</Code>
582 </QueryKey>{' '}
583 <QueryKey
584 style={{
585 background: theme.warning,
586 color: 'black',
587 textShadow: '0',
588 opacity: hasStale ? 1 : 0.3,
589 }}
590 >
591 stale <Code>({hasStale})</Code>
592 </QueryKey>{' '}
593 <QueryKey
594 style={{
595 background: theme.gray,
596 opacity: hasInactive ? 1 : 0.3,
597 }}
598 >
599 inactive <Code>({hasInactive})</Code>
600 </QueryKey>
601 </QueryKeys>
602 <div
603 style={{
604 display: 'flex',
605 alignItems: 'center',
606 }}
607 >
608 <Input
609 placeholder="Filter"
610 aria-label="Filter by queryhash"
611 value={filter ?? ''}
612 onChange={e => setFilter(e.target.value)}
613 onKeyDown={e => {
614 if (e.key === 'Escape') setFilter('')
615 }}
616 style={{
617 flex: '1',
618 marginRight: '.5em',
619 width: '100%',
620 }}
621 />
622 {!filter ? (
623 <>
624 <Select
625 aria-label="Sort queries"
626 value={sort}
627 onChange={e => setSort(e.target.value)}
628 style={{
629 flex: '1',
630 minWidth: 75,
631 marginRight: '.5em',
632 }}
633 >
634 {Object.keys(sortFns).map(key => (
635 <option key={key} value={key}>
636 Sort by {key}
637 </option>
638 ))}
639 </Select>
640 <Button
641 type="button"
642 onClick={() => setSortDesc(old => !old)}
643 style={{
644 padding: '.3em .4em',
645 }}
646 >
647 {sortDesc ? 'β¬ Desc' : 'β¬ Asc'}
648 </Button>
649 </>
650 ) : null}
651 </div>
652 </div>
653 </div>
654 <div
655 style={{
656 overflowY: 'auto',
657 flex: '1',
658 }}
659 >
660 {queries.map((query, i) => {
661 const isDisabled =
662 query.getObserversCount() > 0 && !query.isActive()
663 return (
664 <div
665 key={query.queryHash || i}
666 role="button"
667 aria-label={`Open query details for ${query.queryHash}`}
668 onClick={() =>
669 setActiveQueryHash(
670 activeQueryHash === query.queryHash ? '' : query.queryHash
671 )
672 }
673 style={{
674 display: 'flex',
675 borderBottom: `solid 1px ${theme.grayAlt}`,
676 cursor: 'pointer',
677 background:
678 query === activeQuery
679 ? 'rgba(255,255,255,.1)'
680 : undefined,
681 }}
682 >
683 <div
684 style={{
685 flex: '0 0 auto',
686 width: '2em',
687 height: '2em',
688 background: getQueryStatusColor(query, theme),
689 display: 'flex',
690 alignItems: 'center',
691 justifyContent: 'center',
692 fontWeight: 'bold',
693 textShadow:
694 getQueryStatusLabel(query) === 'stale'
695 ? '0'
696 : '0 0 10px black',
697 color:
698 getQueryStatusLabel(query) === 'stale'
699 ? 'black'
700 : 'white',
701 }}
702 >
703 {query.getObserversCount()}
704 </div>
705 {isDisabled ? (
706 <div
707 style={{
708 flex: '0 0 auto',
709 height: '2em',
710 background: theme.gray,
711 display: 'flex',
712 alignItems: 'center',
713 fontWeight: 'bold',
714 padding: '0 0.5em',
715 }}
716 >
717 disabled
718 </div>
719 ) : null}
720 <Code
721 style={{
722 padding: '.5em',
723 }}
724 >
725 {`${query.queryHash}`}
726 </Code>
727 </div>
728 )
729 })}
730 </div>
731 </div>
732β
733 {activeQuery ? (
734 <ActiveQueryPanel>
735 <div
736 style={{
737 padding: '.5em',
738 background: theme.backgroundAlt,
739 position: 'sticky',
740 top: 0,
741 zIndex: 1,
742 }}
743 >
744 Query Details
745 </div>
746 <div
747 style={{
748 padding: '.5em',
749 }}
750 >
751 <div
752 style={{
753 marginBottom: '.5em',
754 display: 'flex',
755 alignItems: 'start',
756 justifyContent: 'space-between',
757 }}
758 >
759 <Code
760 style={{
761 lineHeight: '1.8em',
762 }}
763 >
764 <pre
765 style={{
766 margin: 0,
767 padding: 0,
768 overflow: 'auto',
769 }}
770 >
771 {JSON.stringify(activeQuery.queryKey, null, 2)}
772 </pre>
773 </Code>
774 <span
775 style={{
776 padding: '0.3em .6em',
777 borderRadius: '0.4em',
778 fontWeight: 'bold',
779 textShadow: '0 2px 10px black',
780 background: getQueryStatusColor(activeQuery, theme),
781 flexShrink: 0,
782 }}
783 >
784 {getQueryStatusLabel(activeQuery)}
785 </span>
786 </div>
787 <div
788 style={{
789 marginBottom: '.5em',
790 display: 'flex',
791 alignItems: 'center',
792 justifyContent: 'space-between',
793 }}
794 >
795 Observers: <Code>{activeQuery.getObserversCount()}</Code>
796 </div>
797 <div
798 style={{
799 display: 'flex',
800 alignItems: 'center',
801 justifyContent: 'space-between',
802 }}
803 >
804 Last Updated:{' '}
805 <Code>
806 {new Date(
807 activeQuery.state.dataUpdatedAt
808 ).toLocaleTimeString()}
809 </Code>
810 </div>
811 </div>
812 <div
813 style={{
814 background: theme.backgroundAlt,
815 padding: '.5em',
816 position: 'sticky',
817 top: 0,
818 zIndex: 1,
819 }}
820 >
821 Actions
822 </div>
823 <div
824 style={{
825 padding: '0.5em',
826 }}
827 >
828 <Button
829 type="button"
830 onClick={handleRefetch}
831 disabled={activeQuery.state.isFetching}
832 style={{
833 background: theme.active,
834 }}
835 >
836 Refetch
837 </Button>{' '}
838 <Button
839 type="button"
840 onClick={() => queryClient.invalidateQueries(activeQuery)}
841 style={{
842 background: theme.warning,
843 color: theme.inputTextColor,
844 }}
845 >
846 Invalidate
847 </Button>{' '}
848 <Button
849 type="button"
850 onClick={() => queryClient.resetQueries(activeQuery)}
851 style={{
852 background: theme.gray,
853 }}
854 >
855 Reset
856 </Button>{' '}
857 <Button
858 type="button"
859 onClick={() => queryClient.removeQueries(activeQuery)}
860 style={{
861 background: theme.danger,
862 }}
863 >
864 Remove
865 </Button>
866 </div>
867 <div
868 style={{
869 background: theme.backgroundAlt,
870 padding: '.5em',
871 position: 'sticky',
872 top: 0,
873 zIndex: 1,
874 }}
875 >
876 Data Explorer
877 </div>
878 <div
879 style={{
880 padding: '.5em',
881 }}
882 >
883 <Explorer
884 label="Data"
885 value={activeQuery?.state?.data}
886 defaultExpanded={{}}
887 />
888 </div>
889 <div
890 style={{
891 background: theme.backgroundAlt,
892 padding: '.5em',
893 position: 'sticky',
894 top: 0,
895 zIndex: 1,
896 }}
897 >
898 Query Explorer
899 </div>
900 <div
901 style={{
902 padding: '.5em',
903 }}
904 >
905 <Explorer
906 label="Query"
907 value={activeQuery}
908 defaultExpanded={{
909 queryKey: true,
910 }}
911 />
912 </div>
913 </ActiveQueryPanel>
914 ) : null}
915 </Panel>
916 </ThemeProvider>
917 )
918})