(props: ExplorerProps)
| 259 | } |
| 260 | |
| 261 | export 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) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…