@tanstack/query-devtools 5.91.0 → 5.92.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/src/Explorer.tsx CHANGED
@@ -1,6 +1,14 @@
1
1
  import { serialize, stringify } from 'superjson'
2
2
  import { clsx as cx } from 'clsx'
3
- import { Index, Match, Show, Switch, createMemo, createSignal } from 'solid-js'
3
+ import {
4
+ Index,
5
+ Match,
6
+ Show,
7
+ Switch,
8
+ createMemo,
9
+ createSignal,
10
+ createUniqueId,
11
+ } from 'solid-js'
4
12
  import { Key } from '@solid-primitives/keyed'
5
13
  import * as goober from 'goober'
6
14
  import { tokens } from './theme'
@@ -325,6 +333,8 @@ export default function Explorer(props: ExplorerProps) {
325
333
 
326
334
  const currentDataPath = props.dataPath ?? []
327
335
 
336
+ const inputId = createUniqueId()
337
+
328
338
  return (
329
339
  <div class={styles().entry}>
330
340
  <Show when={subEntryPages().length}>
@@ -332,6 +342,7 @@ export default function Explorer(props: ExplorerProps) {
332
342
  <button
333
343
  class={styles().expanderButton}
334
344
  onClick={() => toggleExpanded()}
345
+ aria-expanded={expanded() ? 'true' : 'false'}
335
346
  >
336
347
  <Expander expanded={expanded()} /> <span>{props.label}</span>{' '}
337
348
  <span class={styles().info}>
@@ -446,7 +457,9 @@ export default function Explorer(props: ExplorerProps) {
446
457
  </Show>
447
458
  <Show when={subEntryPages().length === 0}>
448
459
  <div class={styles().row}>
449
- <span class={styles().label}>{props.label}:</span>
460
+ <label for={inputId} class={styles().label}>
461
+ {props.label}:
462
+ </label>
450
463
  <Show
451
464
  when={
452
465
  props.editable &&
@@ -467,6 +480,7 @@ export default function Explorer(props: ExplorerProps) {
467
480
  }
468
481
  >
469
482
  <input
483
+ id={inputId}
470
484
  type={type() === 'number' ? 'number' : 'text'}
471
485
  class={cx(styles().value, styles().editableInput)}
472
486
  value={props.value as string | number}
@@ -26,6 +26,8 @@ type PiPContextType = {
26
26
  disabled: boolean
27
27
  }
28
28
 
29
+ class PipOpenError extends Error {}
30
+
29
31
  const PiPContext = createContext<Accessor<PiPContextType> | undefined>(
30
32
  undefined,
31
33
  )
@@ -57,7 +59,7 @@ export const PiPProvider = (props: PiPProviderProps) => {
57
59
  )
58
60
 
59
61
  if (!pip) {
60
- throw new Error(
62
+ throw new PipOpenError(
61
63
  'Failed to open popup. Please allow popups for this site to view the devtools in picture-in-picture mode.',
62
64
  )
63
65
  }
@@ -134,10 +136,20 @@ export const PiPProvider = (props: PiPProviderProps) => {
134
136
  createEffect(() => {
135
137
  const pip_open = (props.localStore.pip_open ?? 'false') as 'true' | 'false'
136
138
  if (pip_open === 'true' && !props.disabled) {
137
- requestPipWindow(
138
- Number(window.innerWidth),
139
- Number(props.localStore.height || PIP_DEFAULT_HEIGHT),
140
- )
139
+ try {
140
+ requestPipWindow(
141
+ Number(window.innerWidth),
142
+ Number(props.localStore.height || PIP_DEFAULT_HEIGHT),
143
+ )
144
+ } catch (error) {
145
+ if (error instanceof PipOpenError) {
146
+ console.error(error.message)
147
+ props.setLocalStore('pip_open', 'false')
148
+ props.setLocalStore('open', 'false')
149
+ return
150
+ }
151
+ throw error
152
+ }
141
153
  }
142
154
  })
143
155