@tanstack/query-devtools 5.106.1 → 5.107.1
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/Devtools-B2jiIqEJ.js +1292 -0
- package/build/Devtools-B2jiIqEJ.js.map +1 -0
- package/build/Devtools-C6D0zIvx.cjs +1291 -0
- package/build/{Devtools-rtsOXx72.js → Devtools-CXcMqCPe.js} +470 -278
- package/build/{Devtools-v4_2Fgnd.cjs → Devtools-Dy8Npldt.cjs} +470 -278
- package/build/{DevtoolsComponent-DjX8H_OS.js → DevtoolsComponent-C7hVCcUy.js} +1 -1
- package/build/{DevtoolsComponent-D-GGWO6D.cjs → DevtoolsComponent-CfBgdmsl.cjs} +1 -1
- package/build/{DevtoolsComponent-BhxzD0Z_.cjs → DevtoolsComponent-D5toeyeh.cjs} +1 -1
- package/build/{DevtoolsComponent-Y_UD6BDS.js → DevtoolsComponent-DGRxtIwZ.js} +2 -2
- package/build/{DevtoolsComponent-Y_UD6BDS.js.map → DevtoolsComponent-DGRxtIwZ.js.map} +1 -1
- package/build/{DevtoolsPanelComponent-azgDvAlF.js → DevtoolsPanelComponent-CPGCRAPs.js} +2 -2
- package/build/{DevtoolsPanelComponent-azgDvAlF.js.map → DevtoolsPanelComponent-CPGCRAPs.js.map} +1 -1
- package/build/{DevtoolsPanelComponent-ecGfyOWI.cjs → DevtoolsPanelComponent-D_S99j7E.cjs} +1 -1
- package/build/{DevtoolsPanelComponent-BtyHS22R.cjs → DevtoolsPanelComponent-Dc49CXag.cjs} +1 -1
- package/build/{DevtoolsPanelComponent-BryTHuft.js → DevtoolsPanelComponent-XShN-s8X.js} +1 -1
- package/build/dev.cjs +2 -2
- package/build/dev.js +2 -2
- package/build/index.cjs +1 -1
- package/build/index.js +1 -1
- package/package.json +2 -2
- package/src/Devtools.tsx +235 -14
- package/src/Explorer.tsx +12 -5
- package/src/constants.ts +4 -0
- package/src/explorerSearch.ts +40 -0
- package/build/Devtools-75tXP6g3.cjs +0 -1269
- package/build/Devtools-DJ2H9xNC.js +0 -1270
- package/build/Devtools-DJ2H9xNC.js.map +0 -1
package/src/Explorer.tsx
CHANGED
|
@@ -277,11 +277,12 @@ type ExplorerProps = {
|
|
|
277
277
|
|
|
278
278
|
/**
|
|
279
279
|
* Adds nested data search without changing the explorer's manual expansion.
|
|
280
|
-
* @param props - Data explorer options
|
|
280
|
+
* @param props - Data explorer options, the selected query or mutation identity, and the search
|
|
281
|
+
* term to start with when another one is selected.
|
|
281
282
|
* @returns The search controls and the original data tree.
|
|
282
283
|
*/
|
|
283
284
|
export function SearchableExplorer(
|
|
284
|
-
props: ExplorerProps & { searchKey?: unknown },
|
|
285
|
+
props: ExplorerProps & { searchKey?: unknown; initialSearch?: string },
|
|
285
286
|
) {
|
|
286
287
|
const theme = useTheme()
|
|
287
288
|
const css = useQueryDevtoolsContext().shadowDOMTarget
|
|
@@ -297,7 +298,13 @@ export function SearchableExplorer(
|
|
|
297
298
|
setDebouncedTerm('')
|
|
298
299
|
}
|
|
299
300
|
const searchKey = createMemo(() => props.searchKey)
|
|
300
|
-
createEffect(
|
|
301
|
+
createEffect(
|
|
302
|
+
on(searchKey, () => {
|
|
303
|
+
const initial = props.initialSearch ?? ''
|
|
304
|
+
setTerm(initial)
|
|
305
|
+
setDebouncedTerm(initial.toLowerCase())
|
|
306
|
+
}),
|
|
307
|
+
)
|
|
301
308
|
createEffect(() => {
|
|
302
309
|
const next = term().toLowerCase()
|
|
303
310
|
if (!next) {
|
|
@@ -350,8 +357,8 @@ export function SearchableExplorer(
|
|
|
350
357
|
<div class={styles().search}>
|
|
351
358
|
<input
|
|
352
359
|
type="search"
|
|
353
|
-
aria-label=
|
|
354
|
-
placeholder=
|
|
360
|
+
aria-label={`Search ${props.label.toLowerCase()}`}
|
|
361
|
+
placeholder={`Search ${props.label.toLowerCase()}`}
|
|
355
362
|
class={styles().searchInput}
|
|
356
363
|
value={term()}
|
|
357
364
|
onInput={(event) => setTerm(event.currentTarget.value)}
|
package/src/constants.ts
CHANGED
|
@@ -15,3 +15,7 @@ export const DEFAULT_WIDTH = 500
|
|
|
15
15
|
export const DEFAULT_SORT_FN_NAME = Object.keys(sortFns)[0]
|
|
16
16
|
export const DEFAULT_SORT_ORDER = 1
|
|
17
17
|
export const DEFAULT_MUTATION_SORT_FN_NAME = Object.keys(mutationSortFns)[0]
|
|
18
|
+
export const FILTER_SCOPES = ['key', 'data', 'all'] as const
|
|
19
|
+
/** What the query and mutation list filters match: the key, the data, or either. */
|
|
20
|
+
export type FilterScope = (typeof FILTER_SCOPES)[number]
|
|
21
|
+
export const DEFAULT_FILTER_SCOPE: FilterScope = 'key'
|
package/src/explorerSearch.ts
CHANGED
|
@@ -104,6 +104,46 @@ export function searchEntries(value: unknown): Array<SearchEntry> | undefined {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
// `toLowerCase` never outputs it, so a lowercased term can't match across two joined parts
|
|
108
|
+
const SEARCH_TEXT_SEPARATOR = 'A'
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Builds the text that `searchExplorer` matches: every entry label and
|
|
112
|
+
* primitive value, lowercased. Visiting breadth-first reaches each object once
|
|
113
|
+
* at its shallowest depth, so shared data is searched once with the same depth
|
|
114
|
+
* bound.
|
|
115
|
+
* @param rootValue - The data to build the search text of.
|
|
116
|
+
* @returns Text that contains a lowercased term exactly when `searchExplorer` matches it.
|
|
117
|
+
*/
|
|
118
|
+
export function createSearchText(rootValue: unknown): string {
|
|
119
|
+
const rootText = primitiveText(rootValue)
|
|
120
|
+
if (rootText !== undefined) return rootText.toLowerCase()
|
|
121
|
+
const parts: Array<string> = []
|
|
122
|
+
const seen = new Set<unknown>([rootValue])
|
|
123
|
+
const queue: Array<{ value: unknown; depth: number }> = [
|
|
124
|
+
{ value: rootValue, depth: 0 },
|
|
125
|
+
]
|
|
126
|
+
// Also visits the entries pushed while iterating
|
|
127
|
+
for (const { value, depth } of queue) {
|
|
128
|
+
for (const entry of searchEntries(value) ?? []) {
|
|
129
|
+
parts.push(entry.label.toLowerCase())
|
|
130
|
+
if (entry.accessor) continue
|
|
131
|
+
const text = primitiveText(entry.value)
|
|
132
|
+
if (text !== undefined) {
|
|
133
|
+
parts.push(text.toLowerCase())
|
|
134
|
+
} else if (
|
|
135
|
+
depth < 500 &&
|
|
136
|
+
typeof entry.value === 'object' &&
|
|
137
|
+
!seen.has(entry.value)
|
|
138
|
+
) {
|
|
139
|
+
seen.add(entry.value)
|
|
140
|
+
queue.push({ value: entry.value, depth: depth + 1 })
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return parts.join(SEARCH_TEXT_SEPARATOR)
|
|
145
|
+
}
|
|
146
|
+
|
|
107
147
|
/**
|
|
108
148
|
* Builds one search tree, stopping ancestor cycles while visiting shared siblings.
|
|
109
149
|
* @param rootValue - The current root data.
|