@tanstack/query-devtools 5.108.1 → 5.108.2
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/{DevtoolsComponent-e0KiEsCw.js → DevtoolsComponent-BBTUIw3a.js} +2 -2
- package/build/DevtoolsComponent-CqaQIX_J.cjs +45 -0
- package/build/DevtoolsComponent-KaCCT4mO.js +3 -0
- package/build/{DevtoolsComponent-CJG_H2ix.js.map → DevtoolsComponent-KaCCT4mO.js.map} +1 -1
- package/build/DevtoolsComponent-NOj66Dgq.cjs +2 -0
- package/build/DevtoolsPanelComponent-1en47poS.js +3 -0
- package/build/{DevtoolsPanelComponent-By2KdGQW.js.map → DevtoolsPanelComponent-1en47poS.js.map} +1 -1
- package/build/DevtoolsPanelComponent-C6-KUZMt.cjs +2 -0
- package/build/{DevtoolsPanelComponent-D9e2k2ne.js → DevtoolsPanelComponent-DA61oPj3.js} +2 -2
- package/build/DevtoolsPanelComponent-DHv0HzmU.cjs +52 -0
- package/build/{DevtoolsSubscriptionsProvider-CtZ2t7t0.js → DevtoolsSubscriptionsProvider-Cl_PUkf2.js} +1636 -2295
- package/build/{DevtoolsSubscriptionsProvider-D9zXQvDq.cjs → DevtoolsSubscriptionsProvider-DC-V1gB8.cjs} +2520 -3173
- package/build/DevtoolsSubscriptionsProvider-DpHm90Dj.js +10 -0
- package/build/DevtoolsSubscriptionsProvider-DpHm90Dj.js.map +1 -0
- package/build/DevtoolsSubscriptionsProvider-gZwQB0lN.cjs +9 -0
- package/build/dev.cjs +30 -30
- package/build/dev.js +11 -11
- package/build/index.cjs +1 -1
- package/build/index.d.cts +26 -10
- package/build/index.d.cts.map +1 -1
- package/build/index.d.ts +26 -10
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/{utils-CzP8C7c0.cjs → web-BD1Jlb-z.cjs} +43 -1036
- package/build/web-BRnEZuZ3.cjs +2 -0
- package/build/{utils-D7iZi04l.js → web-BZdVkndN.js} +42 -939
- package/build/web-da-lPyZC.js +3 -0
- package/build/web-da-lPyZC.js.map +1 -0
- package/package.json +3 -5
- package/src/Devtools.tsx +127 -1712
- package/src/Explorer.tsx +78 -285
- package/src/TanstackQueryDevtools.tsx +19 -10
- package/src/TanstackQueryDevtoolsPanel.tsx +19 -10
- package/src/contexts/PiPContext.tsx +4 -31
- package/src/contexts/types.ts +2 -2
- package/src/global.d.ts +1 -0
- package/src/styles.css +2158 -0
- package/src/styles.ts +49 -0
- package/src/utils.tsx +0 -23
- package/build/DevtoolsComponent-CJG_H2ix.js +0 -3
- package/build/DevtoolsComponent-CJb6tQE-.cjs +0 -2
- package/build/DevtoolsComponent-KSaqMRUY.cjs +0 -45
- package/build/DevtoolsPanelComponent-BXsLpTv2.cjs +0 -2
- package/build/DevtoolsPanelComponent-By2KdGQW.js +0 -3
- package/build/DevtoolsPanelComponent-CpAkTR9C.cjs +0 -52
- package/build/DevtoolsSubscriptionsProvider-CBn1lU_l.cjs +0 -1291
- package/build/DevtoolsSubscriptionsProvider-DQhbYH9U.js +0 -1292
- package/build/DevtoolsSubscriptionsProvider-DQhbYH9U.js.map +0 -1
- package/build/utils-DC2pN79q.js +0 -3
- package/build/utils-DC2pN79q.js.map +0 -1
- package/build/utils-DJl-N7L2.cjs +0 -2
package/src/Explorer.tsx
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Key } from '@solid-primitives/keyed'
|
|
2
|
-
import { clsx as cx } from 'clsx'
|
|
3
|
-
import * as goober from 'goober'
|
|
4
2
|
import {
|
|
5
3
|
Index,
|
|
6
4
|
Match,
|
|
@@ -27,7 +25,7 @@ import {
|
|
|
27
25
|
Trash,
|
|
28
26
|
} from './icons'
|
|
29
27
|
import { getNativeObjectType } from './nativeObjectType'
|
|
30
|
-
import {
|
|
28
|
+
import { createThemed } from './styles'
|
|
31
29
|
import {
|
|
32
30
|
deleteNestedDataByPath,
|
|
33
31
|
displayValue,
|
|
@@ -63,28 +61,9 @@ function chunkArray<T extends { label: string; value: unknown }>(
|
|
|
63
61
|
}
|
|
64
62
|
|
|
65
63
|
const Expander = (props: { expanded: boolean }) => {
|
|
66
|
-
const theme = useTheme()
|
|
67
|
-
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
68
|
-
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
69
|
-
: goober.css
|
|
70
|
-
const styles = createMemo(() => {
|
|
71
|
-
return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
64
|
return (
|
|
75
65
|
<span
|
|
76
|
-
class={
|
|
77
|
-
styles().expander,
|
|
78
|
-
css`
|
|
79
|
-
transform: rotate(${props.expanded ? 90 : 0}deg);
|
|
80
|
-
`,
|
|
81
|
-
props.expanded &&
|
|
82
|
-
css`
|
|
83
|
-
& svg {
|
|
84
|
-
top: -1px;
|
|
85
|
-
}
|
|
86
|
-
`,
|
|
87
|
-
)}
|
|
66
|
+
class={`tsqd-style-explorer-expander ${props.expanded ? 'tsqd-style-explorer-expander-expanded' : ''}`}
|
|
88
67
|
>
|
|
89
68
|
<svg
|
|
90
69
|
width="16"
|
|
@@ -107,17 +86,12 @@ const Expander = (props: { expanded: boolean }) => {
|
|
|
107
86
|
type CopyState = 'NoCopy' | 'SuccessCopy' | 'ErrorCopy'
|
|
108
87
|
const CopyButton = (props: { value: unknown }) => {
|
|
109
88
|
const theme = useTheme()
|
|
110
|
-
const
|
|
111
|
-
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
112
|
-
: goober.css
|
|
113
|
-
const styles = createMemo(() => {
|
|
114
|
-
return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
|
|
115
|
-
})
|
|
89
|
+
const themed = createThemed(theme)
|
|
116
90
|
const [copyState, setCopyState] = createSignal<CopyState>('NoCopy')
|
|
117
91
|
|
|
118
92
|
return (
|
|
119
93
|
<button
|
|
120
|
-
class={
|
|
94
|
+
class={themed('tsqd-style-explorer-action-button')}
|
|
121
95
|
title="Copy object to clipboard"
|
|
122
96
|
aria-label={`${
|
|
123
97
|
copyState() === 'NoCopy'
|
|
@@ -168,17 +142,12 @@ const ClearArrayButton = (props: {
|
|
|
168
142
|
activeQuery: Query
|
|
169
143
|
}) => {
|
|
170
144
|
const theme = useTheme()
|
|
171
|
-
const
|
|
172
|
-
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
173
|
-
: goober.css
|
|
174
|
-
const styles = createMemo(() => {
|
|
175
|
-
return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
|
|
176
|
-
})
|
|
145
|
+
const themed = createThemed(theme)
|
|
177
146
|
const queryClient = useQueryDevtoolsContext().client
|
|
178
147
|
|
|
179
148
|
return (
|
|
180
149
|
<button
|
|
181
|
-
class={
|
|
150
|
+
class={themed('tsqd-style-explorer-action-button')}
|
|
182
151
|
title={'Remove all items'}
|
|
183
152
|
aria-label={'Remove all items'}
|
|
184
153
|
onClick={() => {
|
|
@@ -197,17 +166,12 @@ const DeleteItemButton = (props: {
|
|
|
197
166
|
activeQuery: Query
|
|
198
167
|
}) => {
|
|
199
168
|
const theme = useTheme()
|
|
200
|
-
const
|
|
201
|
-
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
202
|
-
: goober.css
|
|
203
|
-
const styles = createMemo(() => {
|
|
204
|
-
return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
|
|
205
|
-
})
|
|
169
|
+
const themed = createThemed(theme)
|
|
206
170
|
const queryClient = useQueryDevtoolsContext().client
|
|
207
171
|
|
|
208
172
|
return (
|
|
209
173
|
<button
|
|
210
|
-
class={
|
|
174
|
+
class={themed('tsqd-style-explorer-action-button')}
|
|
211
175
|
title={'Delete item'}
|
|
212
176
|
aria-label={'Delete item'}
|
|
213
177
|
onClick={() => {
|
|
@@ -227,23 +191,12 @@ const ToggleValueButton = (props: {
|
|
|
227
191
|
value: boolean
|
|
228
192
|
}) => {
|
|
229
193
|
const theme = useTheme()
|
|
230
|
-
const
|
|
231
|
-
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
232
|
-
: goober.css
|
|
233
|
-
const styles = createMemo(() => {
|
|
234
|
-
return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
|
|
235
|
-
})
|
|
194
|
+
const themed = createThemed(theme)
|
|
236
195
|
const queryClient = useQueryDevtoolsContext().client
|
|
237
196
|
|
|
238
197
|
return (
|
|
239
198
|
<button
|
|
240
|
-
class={
|
|
241
|
-
styles().actionButton,
|
|
242
|
-
css`
|
|
243
|
-
width: ${tokens.size[3.5]};
|
|
244
|
-
height: ${tokens.size[3.5]};
|
|
245
|
-
`,
|
|
246
|
-
)}
|
|
199
|
+
class={`${themed('tsqd-style-explorer-action-button')} tsqd-style-explorer-toggle-button`}
|
|
247
200
|
title={'Toggle value'}
|
|
248
201
|
aria-label={'Toggle value'}
|
|
249
202
|
aria-pressed={props.value}
|
|
@@ -272,7 +225,17 @@ type ExplorerProps = {
|
|
|
272
225
|
itemsDeletable?: boolean
|
|
273
226
|
onEdit?: () => void
|
|
274
227
|
search?: ExplorerSearch
|
|
275
|
-
highlight?:
|
|
228
|
+
highlight?: SearchHighlight
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** The name of the native highlight that marks search matches. */
|
|
232
|
+
const HIGHLIGHT_NAME = 'tsqd-data-search'
|
|
233
|
+
|
|
234
|
+
/** The ranges that one search adds to the native highlight. */
|
|
235
|
+
type SearchHighlight = {
|
|
236
|
+
readonly size: number
|
|
237
|
+
add: (range: Range) => void
|
|
238
|
+
delete: (range: Range) => void
|
|
276
239
|
}
|
|
277
240
|
|
|
278
241
|
/**
|
|
@@ -285,12 +248,7 @@ export function SearchableExplorer(
|
|
|
285
248
|
props: ExplorerProps & { searchKey?: unknown; initialSearch?: string },
|
|
286
249
|
) {
|
|
287
250
|
const theme = useTheme()
|
|
288
|
-
const
|
|
289
|
-
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
290
|
-
: goober.css
|
|
291
|
-
const styles = createMemo(() =>
|
|
292
|
-
theme() === 'dark' ? darkStyles(css) : lightStyles(css),
|
|
293
|
-
)
|
|
251
|
+
const themed = createThemed(theme)
|
|
294
252
|
const [term, setTerm] = createSignal('')
|
|
295
253
|
const [debouncedTerm, setDebouncedTerm] = createSignal('')
|
|
296
254
|
const clear = () => {
|
|
@@ -320,46 +278,56 @@ export function SearchableExplorer(
|
|
|
320
278
|
? { term: activeTerm, match: searchExplorer(props.value, activeTerm) }
|
|
321
279
|
: undefined
|
|
322
280
|
})
|
|
323
|
-
const
|
|
324
|
-
const [nativeHighlight, setNativeHighlight] = createSignal<Highlight>()
|
|
281
|
+
const [nativeHighlight, setNativeHighlight] = createSignal<SearchHighlight>()
|
|
325
282
|
let root!: HTMLDivElement
|
|
326
283
|
onMount(() => {
|
|
327
284
|
const view = root.ownerDocument.defaultView!
|
|
328
285
|
const registry = view.CSS.highlights
|
|
286
|
+
// Explorers share one highlight per window, so styles.css can style it by
|
|
287
|
+
// name. Each search adds and removes only its own ranges.
|
|
288
|
+
const getHighlight = () => {
|
|
289
|
+
let highlight = registry.get(HIGHLIGHT_NAME)
|
|
290
|
+
if (!highlight) {
|
|
291
|
+
highlight = new view.Highlight()
|
|
292
|
+
registry.set(HIGHLIGHT_NAME, highlight)
|
|
293
|
+
}
|
|
294
|
+
return highlight
|
|
295
|
+
}
|
|
329
296
|
createEffect(
|
|
330
297
|
on(search, () => {
|
|
331
|
-
|
|
332
|
-
|
|
298
|
+
getHighlight()
|
|
299
|
+
const ranges = new Set<Range>()
|
|
300
|
+
const highlight: SearchHighlight = {
|
|
301
|
+
get size() {
|
|
302
|
+
return ranges.size
|
|
303
|
+
},
|
|
304
|
+
add(range) {
|
|
305
|
+
ranges.add(range)
|
|
306
|
+
getHighlight().add(range)
|
|
307
|
+
},
|
|
308
|
+
delete(range) {
|
|
309
|
+
ranges.delete(range)
|
|
310
|
+
registry.get(HIGHLIGHT_NAME)?.delete(range)
|
|
311
|
+
},
|
|
312
|
+
}
|
|
333
313
|
setNativeHighlight(highlight)
|
|
334
314
|
onCleanup(() => {
|
|
335
|
-
|
|
336
|
-
|
|
315
|
+
for (const range of ranges) highlight.delete(range)
|
|
316
|
+
if (registry.get(HIGHLIGHT_NAME)?.size === 0) {
|
|
317
|
+
registry.delete(HIGHLIGHT_NAME)
|
|
318
|
+
}
|
|
337
319
|
})
|
|
338
320
|
}),
|
|
339
321
|
)
|
|
340
322
|
})
|
|
341
|
-
const nativeHighlightStyle = createMemo(
|
|
342
|
-
() => css`
|
|
343
|
-
& ::highlight(${highlightName}) {
|
|
344
|
-
color: ${
|
|
345
|
-
theme() === 'dark' ? tokens.colors.gray[100] : tokens.colors.gray[900]
|
|
346
|
-
};
|
|
347
|
-
background-color: ${
|
|
348
|
-
theme() === 'dark'
|
|
349
|
-
? tokens.colors.yellow[900]
|
|
350
|
-
: tokens.colors.yellow[200]
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
`,
|
|
354
|
-
)
|
|
355
323
|
return (
|
|
356
|
-
<div ref={root} class={
|
|
357
|
-
<div class=
|
|
324
|
+
<div ref={root} class={themed('tsqd-style-explorer-search-root')}>
|
|
325
|
+
<div class="tsqd-style-explorer-search">
|
|
358
326
|
<input
|
|
359
327
|
type="search"
|
|
360
328
|
aria-label={`Search ${props.label.toLowerCase()}`}
|
|
361
329
|
placeholder={`Search ${props.label.toLowerCase()}`}
|
|
362
|
-
class={
|
|
330
|
+
class={themed('tsqd-style-explorer-search-input')}
|
|
363
331
|
value={term()}
|
|
364
332
|
onInput={(event) => setTerm(event.currentTarget.value)}
|
|
365
333
|
onKeyDown={(event) => {
|
|
@@ -372,7 +340,7 @@ export function SearchableExplorer(
|
|
|
372
340
|
<Show when={term()}>
|
|
373
341
|
<button
|
|
374
342
|
type="button"
|
|
375
|
-
class=
|
|
343
|
+
class="tsqd-style-explorer-clear-search"
|
|
376
344
|
onClick={clear}
|
|
377
345
|
aria-label="Clear search"
|
|
378
346
|
>
|
|
@@ -398,7 +366,7 @@ const MAX_HIGHLIGHT_RANGES = 1000
|
|
|
398
366
|
function HighlightedText(props: {
|
|
399
367
|
text: string
|
|
400
368
|
term?: string
|
|
401
|
-
highlight?:
|
|
369
|
+
highlight?: SearchHighlight
|
|
402
370
|
}) {
|
|
403
371
|
const matches = createMemo(() => {
|
|
404
372
|
const term = props.term
|
|
@@ -467,12 +435,7 @@ function isIterable(x: any): x is Iterable<unknown> {
|
|
|
467
435
|
*/
|
|
468
436
|
export default function Explorer(props: ExplorerProps) {
|
|
469
437
|
const theme = useTheme()
|
|
470
|
-
const
|
|
471
|
-
? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
|
|
472
|
-
: goober.css
|
|
473
|
-
const styles = createMemo(() => {
|
|
474
|
-
return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
|
|
475
|
-
})
|
|
438
|
+
const themed = createThemed(theme)
|
|
476
439
|
const queryClient = useQueryDevtoolsContext().client
|
|
477
440
|
|
|
478
441
|
const [expanded, setExpanded] = createSignal(
|
|
@@ -630,22 +593,22 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
630
593
|
const inputId = createUniqueId()
|
|
631
594
|
|
|
632
595
|
return (
|
|
633
|
-
<div class=
|
|
596
|
+
<div class="tsqd-style-explorer-entry">
|
|
634
597
|
<Show when={subEntryPages().length}>
|
|
635
|
-
<div class=
|
|
598
|
+
<div class="tsqd-style-explorer-expander-button-container">
|
|
636
599
|
<button
|
|
637
|
-
class=
|
|
600
|
+
class="tsqd-style-explorer-expander-button"
|
|
638
601
|
onClick={() => toggleExpanded()}
|
|
639
602
|
aria-expanded={isExpanded() ? 'true' : 'false'}
|
|
640
603
|
>
|
|
641
604
|
<Expander expanded={isExpanded()} /> <span>{label()}</span>{' '}
|
|
642
|
-
<span class=
|
|
605
|
+
<span class="tsqd-style-explorer-info">
|
|
643
606
|
{String(type()).toLowerCase() === 'iterable' ? '(Iterable) ' : ''}
|
|
644
607
|
{subEntries().length} {subEntries().length > 1 ? `items` : `item`}
|
|
645
608
|
</span>
|
|
646
609
|
</button>
|
|
647
610
|
<Show when={props.editable}>
|
|
648
|
-
<div class=
|
|
611
|
+
<div class="tsqd-style-explorer-actions">
|
|
649
612
|
<CopyButton value={props.value} />
|
|
650
613
|
|
|
651
614
|
<Show
|
|
@@ -674,7 +637,7 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
674
637
|
}
|
|
675
638
|
>
|
|
676
639
|
<button
|
|
677
|
-
class={
|
|
640
|
+
class={themed('tsqd-style-explorer-action-button')}
|
|
678
641
|
title={'Bulk Edit Data'}
|
|
679
642
|
aria-label={'Bulk Edit Data'}
|
|
680
643
|
onClick={() => {
|
|
@@ -689,7 +652,7 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
689
652
|
</div>
|
|
690
653
|
<Show when={isExpanded()}>
|
|
691
654
|
<Show when={subEntryPages().length === 1}>
|
|
692
|
-
<div class={
|
|
655
|
+
<div class={themed('tsqd-style-explorer-sub-entry')}>
|
|
693
656
|
<Key each={subEntries()} by={(item) => item.key}>
|
|
694
657
|
{(entry) => {
|
|
695
658
|
return (
|
|
@@ -714,11 +677,11 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
714
677
|
</div>
|
|
715
678
|
</Show>
|
|
716
679
|
<Show when={subEntryPages().length > 1}>
|
|
717
|
-
<div class={
|
|
680
|
+
<div class={themed('tsqd-style-explorer-sub-entry')}>
|
|
718
681
|
<Index each={subEntryPages()}>
|
|
719
682
|
{(entries, index) => (
|
|
720
683
|
<div>
|
|
721
|
-
<div class=
|
|
684
|
+
<div class="tsqd-style-explorer-entry">
|
|
722
685
|
<button
|
|
723
686
|
onClick={() => {
|
|
724
687
|
if (matchingPage() === index) return
|
|
@@ -728,10 +691,7 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
728
691
|
: [...old, index],
|
|
729
692
|
)
|
|
730
693
|
}}
|
|
731
|
-
class={
|
|
732
|
-
styles().expanderButton,
|
|
733
|
-
pageHasMatch(index) && styles().highlight,
|
|
734
|
-
)}
|
|
694
|
+
class={`tsqd-style-explorer-expander-button ${pageHasMatch(index) ? themed('tsqd-style-explorer-highlight') : ''}`}
|
|
735
695
|
aria-expanded={isPageExpanded(index)}
|
|
736
696
|
aria-description={
|
|
737
697
|
pageHasMatch(index)
|
|
@@ -744,7 +704,7 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
744
704
|
{index * 100 + 100 - 1}]
|
|
745
705
|
</button>
|
|
746
706
|
<Show when={isPageExpanded(index)}>
|
|
747
|
-
<div class={
|
|
707
|
+
<div class={themed('tsqd-style-explorer-sub-entry')}>
|
|
748
708
|
<Key each={entries()} by={(entry) => entry.key}>
|
|
749
709
|
{(entry) => (
|
|
750
710
|
<Explorer
|
|
@@ -770,8 +730,8 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
770
730
|
</Show>
|
|
771
731
|
</Show>
|
|
772
732
|
<Show when={subEntryPages().length === 0}>
|
|
773
|
-
<div class=
|
|
774
|
-
<label for={inputId} class={
|
|
733
|
+
<div class="tsqd-style-explorer-row">
|
|
734
|
+
<label for={inputId} class={themed('tsqd-style-explorer-label')}>
|
|
775
735
|
{label()}:
|
|
776
736
|
</label>
|
|
777
737
|
<Show
|
|
@@ -782,7 +742,11 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
782
742
|
type() === 'number' ||
|
|
783
743
|
type() === 'boolean')
|
|
784
744
|
}
|
|
785
|
-
fallback={
|
|
745
|
+
fallback={
|
|
746
|
+
<span class={themed('tsqd-style-explorer-value')}>
|
|
747
|
+
{renderedValue()}
|
|
748
|
+
</span>
|
|
749
|
+
}
|
|
786
750
|
>
|
|
787
751
|
<Show
|
|
788
752
|
when={
|
|
@@ -794,11 +758,7 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
794
758
|
<input
|
|
795
759
|
id={inputId}
|
|
796
760
|
type={type() === 'number' ? 'number' : 'text'}
|
|
797
|
-
class={
|
|
798
|
-
styles().value,
|
|
799
|
-
styles().editableInput,
|
|
800
|
-
props.search?.match.value && styles().highlight,
|
|
801
|
-
)}
|
|
761
|
+
class={`${themed('tsqd-style-explorer-value')} ${themed('tsqd-style-explorer-editable-input')} ${props.search?.match.value ? themed('tsqd-style-explorer-highlight') : ''}`}
|
|
802
762
|
data-search-match={props.search?.match.value || undefined}
|
|
803
763
|
value={props.value as string | number}
|
|
804
764
|
onChange={(changeEvent) => {
|
|
@@ -819,11 +779,7 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
819
779
|
|
|
820
780
|
<Show when={type() === 'boolean'}>
|
|
821
781
|
<span
|
|
822
|
-
class={
|
|
823
|
-
styles().value,
|
|
824
|
-
styles().actions,
|
|
825
|
-
styles().editableInput,
|
|
826
|
-
)}
|
|
782
|
+
class={`${themed('tsqd-style-explorer-value')} tsqd-style-explorer-actions ${themed('tsqd-style-explorer-editable-input')}`}
|
|
827
783
|
>
|
|
828
784
|
<ToggleValueButton
|
|
829
785
|
activeQuery={props.activeQuery!}
|
|
@@ -852,166 +808,3 @@ export default function Explorer(props: ExplorerProps) {
|
|
|
852
808
|
</div>
|
|
853
809
|
)
|
|
854
810
|
}
|
|
855
|
-
|
|
856
|
-
const stylesFactory = (
|
|
857
|
-
theme: 'light' | 'dark',
|
|
858
|
-
css: (typeof goober)['css'],
|
|
859
|
-
) => {
|
|
860
|
-
const { colors, font, size, border } = tokens
|
|
861
|
-
const t = (light: string, dark: string) => (theme === 'light' ? light : dark)
|
|
862
|
-
return {
|
|
863
|
-
search: css`
|
|
864
|
-
display: flex;
|
|
865
|
-
gap: ${size[2]};
|
|
866
|
-
margin-bottom: ${size[2]};
|
|
867
|
-
`,
|
|
868
|
-
searchInput: css`
|
|
869
|
-
min-width: 0;
|
|
870
|
-
flex: 1;
|
|
871
|
-
padding: ${size[1]} ${size[2]};
|
|
872
|
-
color: inherit;
|
|
873
|
-
background: ${t(colors.gray[100], colors.darkGray[600])};
|
|
874
|
-
border: 1px solid ${t(colors.gray[300], colors.darkGray[400])};
|
|
875
|
-
border-radius: ${border.radius.xs};
|
|
876
|
-
`,
|
|
877
|
-
clearSearch: css`
|
|
878
|
-
color: inherit;
|
|
879
|
-
background: transparent;
|
|
880
|
-
border: none;
|
|
881
|
-
cursor: pointer;
|
|
882
|
-
`,
|
|
883
|
-
highlight: css`
|
|
884
|
-
&& {
|
|
885
|
-
color: ${t(colors.gray[900], colors.gray[100])};
|
|
886
|
-
background-color: ${t(colors.yellow[200], colors.yellow[900])};
|
|
887
|
-
}
|
|
888
|
-
`,
|
|
889
|
-
entry: css`
|
|
890
|
-
& * {
|
|
891
|
-
font-size: ${font.size.xs};
|
|
892
|
-
font-family:
|
|
893
|
-
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
|
|
894
|
-
'Liberation Mono', 'Courier New', monospace;
|
|
895
|
-
}
|
|
896
|
-
position: relative;
|
|
897
|
-
outline: none;
|
|
898
|
-
word-break: break-word;
|
|
899
|
-
`,
|
|
900
|
-
subEntry: css`
|
|
901
|
-
margin: 0 0 0 0.5em;
|
|
902
|
-
padding-left: 0.75em;
|
|
903
|
-
border-left: 2px solid ${t(colors.gray[300], colors.darkGray[400])};
|
|
904
|
-
/* outline: 1px solid ${colors.teal[400]}; */
|
|
905
|
-
`,
|
|
906
|
-
expander: css`
|
|
907
|
-
& path {
|
|
908
|
-
stroke: ${colors.gray[400]};
|
|
909
|
-
}
|
|
910
|
-
& svg {
|
|
911
|
-
width: ${size[3]};
|
|
912
|
-
height: ${size[3]};
|
|
913
|
-
}
|
|
914
|
-
display: inline-flex;
|
|
915
|
-
align-items: center;
|
|
916
|
-
transition: all 0.1s ease;
|
|
917
|
-
/* outline: 1px solid ${colors.blue[400]}; */
|
|
918
|
-
`,
|
|
919
|
-
expanderButtonContainer: css`
|
|
920
|
-
display: flex;
|
|
921
|
-
align-items: center;
|
|
922
|
-
line-height: ${size[4]};
|
|
923
|
-
min-height: ${size[4]};
|
|
924
|
-
gap: ${size[2]};
|
|
925
|
-
`,
|
|
926
|
-
expanderButton: css`
|
|
927
|
-
cursor: pointer;
|
|
928
|
-
color: inherit;
|
|
929
|
-
font: inherit;
|
|
930
|
-
outline: inherit;
|
|
931
|
-
height: ${size[5]};
|
|
932
|
-
background: transparent;
|
|
933
|
-
border: none;
|
|
934
|
-
padding: 0;
|
|
935
|
-
display: inline-flex;
|
|
936
|
-
align-items: center;
|
|
937
|
-
gap: ${size[1]};
|
|
938
|
-
position: relative;
|
|
939
|
-
/* outline: 1px solid ${colors.green[400]}; */
|
|
940
|
-
|
|
941
|
-
&:focus-visible {
|
|
942
|
-
border-radius: ${border.radius.xs};
|
|
943
|
-
outline: 2px solid ${colors.blue[800]};
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
& svg {
|
|
947
|
-
position: relative;
|
|
948
|
-
left: 1px;
|
|
949
|
-
}
|
|
950
|
-
`,
|
|
951
|
-
info: css`
|
|
952
|
-
color: ${t(colors.gray[500], colors.gray[500])};
|
|
953
|
-
font-size: ${font.size.xs};
|
|
954
|
-
margin-left: ${size[1]};
|
|
955
|
-
/* outline: 1px solid ${colors.yellow[400]}; */
|
|
956
|
-
`,
|
|
957
|
-
label: css`
|
|
958
|
-
color: ${t(colors.gray[700], colors.gray[300])};
|
|
959
|
-
white-space: nowrap;
|
|
960
|
-
`,
|
|
961
|
-
value: css`
|
|
962
|
-
color: ${t(colors.purple[600], colors.purple[400])};
|
|
963
|
-
flex-grow: 1;
|
|
964
|
-
`,
|
|
965
|
-
actions: css`
|
|
966
|
-
display: inline-flex;
|
|
967
|
-
gap: ${size[2]};
|
|
968
|
-
align-items: center;
|
|
969
|
-
`,
|
|
970
|
-
row: css`
|
|
971
|
-
display: inline-flex;
|
|
972
|
-
gap: ${size[2]};
|
|
973
|
-
width: 100%;
|
|
974
|
-
margin: ${size[0.25]} 0px;
|
|
975
|
-
line-height: ${size[4.5]};
|
|
976
|
-
align-items: center;
|
|
977
|
-
`,
|
|
978
|
-
editableInput: css`
|
|
979
|
-
border: none;
|
|
980
|
-
padding: ${size[0.5]} ${size[1]} ${size[0.5]} ${size[1.5]};
|
|
981
|
-
flex-grow: 1;
|
|
982
|
-
border-radius: ${border.radius.xs};
|
|
983
|
-
background-color: ${t(colors.gray[200], colors.darkGray[500])};
|
|
984
|
-
|
|
985
|
-
&:hover {
|
|
986
|
-
background-color: ${t(colors.gray[300], colors.darkGray[600])};
|
|
987
|
-
}
|
|
988
|
-
`,
|
|
989
|
-
actionButton: css`
|
|
990
|
-
background-color: transparent;
|
|
991
|
-
color: ${t(colors.gray[500], colors.gray[500])};
|
|
992
|
-
border: none;
|
|
993
|
-
display: inline-flex;
|
|
994
|
-
padding: 0px;
|
|
995
|
-
align-items: center;
|
|
996
|
-
justify-content: center;
|
|
997
|
-
cursor: pointer;
|
|
998
|
-
width: ${size[3]};
|
|
999
|
-
height: ${size[3]};
|
|
1000
|
-
position: relative;
|
|
1001
|
-
z-index: 1;
|
|
1002
|
-
|
|
1003
|
-
&:hover svg {
|
|
1004
|
-
color: ${t(colors.gray[600], colors.gray[400])};
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
&:focus-visible {
|
|
1008
|
-
border-radius: ${border.radius.xs};
|
|
1009
|
-
outline: 2px solid ${colors.blue[800]};
|
|
1010
|
-
outline-offset: 2px;
|
|
1011
|
-
}
|
|
1012
|
-
`,
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
const lightStyles = (css: (typeof goober)['css']) => stylesFactory('light', css)
|
|
1017
|
-
const darkStyles = (css: (typeof goober)['css']) => stylesFactory('dark', css)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createSignal, lazy } from 'solid-js'
|
|
2
|
-
import { render } from 'solid-js/web'
|
|
3
|
-
import { setupStyleSheet } from './utils'
|
|
2
|
+
import { render, setTrustedTypesPolicy } from 'solid-js/web'
|
|
4
3
|
import type {
|
|
5
4
|
QueryClient,
|
|
6
5
|
onlineManager as TOnlineManager,
|
|
@@ -20,15 +19,21 @@ import type {
|
|
|
20
19
|
*/
|
|
21
20
|
export interface TanstackQueryDevtoolsConfig extends QueryDevtoolsProps {
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* @deprecated The devtools no longer add a `<style>` element, so they need no nonce. This option
|
|
23
|
+
* does nothing.
|
|
25
24
|
*/
|
|
26
25
|
styleNonce?: string
|
|
27
26
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
27
|
+
* The shadow root to add the devtools styles to. By default, the styles are added to the shadow
|
|
28
|
+
* root the devtools render in, or to the document when they do not render in a shadow root.
|
|
30
29
|
*/
|
|
31
30
|
shadowDOMTarget?: ShadowRoot
|
|
31
|
+
/**
|
|
32
|
+
* The Trusted Types policy the devtools use to create their HTML templates.
|
|
33
|
+
* Pass one when your page enforces `require-trusted-types-for 'script'`.
|
|
34
|
+
* The devtools only pass it their own markup.
|
|
35
|
+
*/
|
|
36
|
+
trustedTypesPolicy?: { createHTML: (html: string) => unknown }
|
|
32
37
|
}
|
|
33
38
|
|
|
34
39
|
class TanstackQueryDevtools {
|
|
@@ -37,8 +42,8 @@ class TanstackQueryDevtools {
|
|
|
37
42
|
#queryFlavor: string
|
|
38
43
|
#version: string
|
|
39
44
|
#isMounted = false
|
|
40
|
-
#styleNonce?: string
|
|
41
45
|
#shadowDOMTarget?: ShadowRoot
|
|
46
|
+
#trustedTypesPolicy?: { createHTML: (html: string) => unknown }
|
|
42
47
|
#buttonPosition: Signal<DevtoolsButtonPosition | undefined>
|
|
43
48
|
#position: Signal<DevtoolsPosition | undefined>
|
|
44
49
|
#initialIsOpen: Signal<boolean | undefined>
|
|
@@ -58,8 +63,8 @@ class TanstackQueryDevtools {
|
|
|
58
63
|
position,
|
|
59
64
|
initialIsOpen,
|
|
60
65
|
errorTypes,
|
|
61
|
-
styleNonce,
|
|
62
66
|
shadowDOMTarget,
|
|
67
|
+
trustedTypesPolicy,
|
|
63
68
|
hideDisabledQueries,
|
|
64
69
|
theme,
|
|
65
70
|
} = config
|
|
@@ -67,8 +72,8 @@ class TanstackQueryDevtools {
|
|
|
67
72
|
this.#queryFlavor = queryFlavor
|
|
68
73
|
this.#version = version
|
|
69
74
|
this.#onlineManager = onlineManager
|
|
70
|
-
this.#styleNonce = styleNonce
|
|
71
75
|
this.#shadowDOMTarget = shadowDOMTarget
|
|
76
|
+
this.#trustedTypesPolicy = trustedTypesPolicy
|
|
72
77
|
this.#buttonPosition = createSignal(buttonPosition)
|
|
73
78
|
this.#position = createSignal(position)
|
|
74
79
|
this.#initialIsOpen = createSignal(initialIsOpen)
|
|
@@ -105,6 +110,11 @@ class TanstackQueryDevtools {
|
|
|
105
110
|
if (this.#isMounted) {
|
|
106
111
|
throw new Error('Devtools is already mounted')
|
|
107
112
|
}
|
|
113
|
+
// Solid creates each template once, so set the policy before rendering.
|
|
114
|
+
// It is shared by every devtools instance, so never reset it.
|
|
115
|
+
if (this.#trustedTypesPolicy) {
|
|
116
|
+
setTrustedTypesPolicy(this.#trustedTypesPolicy)
|
|
117
|
+
}
|
|
108
118
|
const dispose = render(() => {
|
|
109
119
|
const [btnPosition] = this.#buttonPosition
|
|
110
120
|
const [pos] = this.#position
|
|
@@ -122,7 +132,6 @@ class TanstackQueryDevtools {
|
|
|
122
132
|
this.#Component = Devtools
|
|
123
133
|
}
|
|
124
134
|
|
|
125
|
-
setupStyleSheet(this.#styleNonce, this.#shadowDOMTarget)
|
|
126
135
|
return (
|
|
127
136
|
<Devtools
|
|
128
137
|
queryFlavor={this.#queryFlavor}
|