MCPcopy
hub / github.com/TanStack/query / Explorer

Function Explorer

packages/query-devtools/src/Explorer.tsx:261–523  ·  view source on GitHub ↗
(props: ExplorerProps)

Source from the content-addressed store, hash-verified

259}
260
261export default function Explorer(props: ExplorerProps) {
262 const theme = useTheme()
263 const css = useQueryDevtoolsContext().shadowDOMTarget
264 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
265 : goober.css
266 const styles = createMemo(() => {
267 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
268 })
269 const queryClient = useQueryDevtoolsContext().client
270
271 const [expanded, setExpanded] = createSignal(
272 (props.defaultExpanded || []).includes(props.label),
273 )
274 const toggleExpanded = () => setExpanded((old) => !old)
275 const [expandedPages, setExpandedPages] = createSignal<Array<number>>([])
276
277 const subEntries = createMemo(() => {
278 if (Array.isArray(props.value)) {
279 return props.value.map((d, i) => ({
280 label: i.toString(),
281 value: d,
282 }))
283 } else if (
284 props.value !== null &&
285 typeof props.value === 'object' &&
286 isIterable(props.value) &&
287 typeof props.value[Symbol.iterator] === 'function'
288 ) {
289 if (props.value instanceof Map) {
290 return Array.from(props.value, ([key, val]) => ({
291 label: key,
292 value: val,
293 }))
294 }
295 return Array.from(props.value, (val, i) => ({
296 label: i.toString(),
297 value: val,
298 }))
299 } else if (typeof props.value === 'object' && props.value !== null) {
300 return Object.entries(props.value).map(([key, val]) => ({
301 label: key,
302 value: val,
303 }))
304 }
305 return []
306 })
307
308 const type = createMemo<string>(() => {
309 if (Array.isArray(props.value)) {
310 return 'array'
311 } else if (
312 props.value !== null &&
313 typeof props.value === 'object' &&
314 isIterable(props.value) &&
315 typeof props.value[Symbol.iterator] === 'function'
316 ) {
317 return 'Iterable'
318 } else if (typeof props.value === 'object' && props.value !== null) {

Callers

nothing calls this directly

Calls 11

useThemeFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
displayValueFunction · 0.90
updateNestedDataByPathFunction · 0.90
isIterableFunction · 0.85
chunkArrayFunction · 0.85
toggleExpandedFunction · 0.85
toStringMethod · 0.80
darkStylesFunction · 0.70
lightStylesFunction · 0.70
setQueryDataMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…