@tanstack/query-devtools 5.0.0-rc.1 → 5.0.0-rc.13

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.
@@ -1,4 +1,4 @@
1
- import { tokens } from '../theme'
1
+ import { Show } from 'solid-js'
2
2
 
3
3
  export function Search() {
4
4
  return (
@@ -11,7 +11,7 @@ export function Search() {
11
11
  >
12
12
  <path
13
13
  d="M13 13L9.00007 9M10.3333 5.66667C10.3333 8.244 8.244 10.3333 5.66667 10.3333C3.08934 10.3333 1 8.244 1 5.66667C1 3.08934 3.08934 1 5.66667 1C8.244 1 10.3333 3.08934 10.3333 5.66667Z"
14
- stroke="#98A2B3"
14
+ stroke="currentColor"
15
15
  stroke-width="1.66667"
16
16
  stroke-linecap="round"
17
17
  stroke-linejoin="round"
@@ -31,8 +31,8 @@ export function Trash() {
31
31
  >
32
32
  <path
33
33
  d="M9 3H15M3 6H21M19 6L18.2987 16.5193C18.1935 18.0975 18.1409 18.8867 17.8 19.485C17.4999 20.0118 17.0472 20.4353 16.5017 20.6997C15.882 21 15.0911 21 13.5093 21H10.4907C8.90891 21 8.11803 21 7.49834 20.6997C6.95276 20.4353 6.50009 20.0118 6.19998 19.485C5.85911 18.8867 5.8065 18.0975 5.70129 16.5193L5 6M10 10.5V15.5M14 10.5V15.5"
34
- stroke="#d0d5dd"
35
- stroke-width="1.66667"
34
+ stroke="currentColor"
35
+ stroke-width="2"
36
36
  stroke-linecap="round"
37
37
  stroke-linejoin="round"
38
38
  />
@@ -51,7 +51,7 @@ export function ChevronDown() {
51
51
  >
52
52
  <path
53
53
  d="M1 1L5 5L9 1"
54
- stroke="#98A2B3"
54
+ stroke="currentColor"
55
55
  stroke-width="1.66667"
56
56
  stroke-linecap="round"
57
57
  stroke-linejoin="round"
@@ -71,7 +71,7 @@ export function ArrowUp() {
71
71
  >
72
72
  <path
73
73
  d="M8 13.3333V2.66667M8 2.66667L4 6.66667M8 2.66667L12 6.66667"
74
- stroke="#98A2B3"
74
+ stroke="currentColor"
75
75
  stroke-width="1.66667"
76
76
  stroke-linecap="round"
77
77
  stroke-linejoin="round"
@@ -91,7 +91,7 @@ export function ArrowDown() {
91
91
  >
92
92
  <path
93
93
  d="M8 2.66667V13.3333M8 13.3333L4 9.33333M8 13.3333L12 9.33333"
94
- stroke="#98A2B3"
94
+ stroke="currentColor"
95
95
  stroke-width="1.66667"
96
96
  stroke-linecap="round"
97
97
  stroke-linejoin="round"
@@ -114,7 +114,7 @@ export function ArrowLeft() {
114
114
  >
115
115
  <path
116
116
  d="M8 2.66667V13.3333M8 13.3333L4 9.33333M8 13.3333L12 9.33333"
117
- stroke="#98A2B3"
117
+ stroke="currentColor"
118
118
  stroke-width="1.66667"
119
119
  stroke-linecap="round"
120
120
  stroke-linejoin="round"
@@ -137,7 +137,7 @@ export function ArrowRight() {
137
137
  >
138
138
  <path
139
139
  d="M8 2.66667V13.3333M8 13.3333L4 9.33333M8 13.3333L12 9.33333"
140
- stroke="#98A2B3"
140
+ stroke="currentColor"
141
141
  stroke-width="1.66667"
142
142
  stroke-linecap="round"
143
143
  stroke-linejoin="round"
@@ -146,11 +146,71 @@ export function ArrowRight() {
146
146
  )
147
147
  }
148
148
 
149
+ export function Sun() {
150
+ return (
151
+ <svg
152
+ viewBox="0 0 24 24"
153
+ height="12"
154
+ width="12"
155
+ fill="none"
156
+ xmlns="http://www.w3.org/2000/svg"
157
+ >
158
+ <path
159
+ d="M12 2v2m0 16v2M4 12H2m4.314-5.686L4.9 4.9m12.786 1.414L19.1 4.9M6.314 17.69 4.9 19.104m12.786-1.414 1.414 1.414M22 12h-2m-3 0a5 5 0 1 1-10 0 5 5 0 0 1 10 0Z"
160
+ stroke="currentColor"
161
+ stroke-width="2"
162
+ stroke-linecap="round"
163
+ stroke-linejoin="round"
164
+ ></path>
165
+ </svg>
166
+ )
167
+ }
168
+
169
+ export function Moon() {
170
+ return (
171
+ <svg
172
+ viewBox="0 0 24 24"
173
+ height="12"
174
+ width="12"
175
+ fill="none"
176
+ xmlns="http://www.w3.org/2000/svg"
177
+ >
178
+ <path
179
+ d="M22 15.844a10.424 10.424 0 0 1-4.306.925c-5.779 0-10.463-4.684-10.463-10.462 0-1.536.33-2.994.925-4.307A10.464 10.464 0 0 0 2 11.538C2 17.316 6.684 22 12.462 22c4.243 0 7.896-2.526 9.538-6.156Z"
180
+ stroke="currentColor"
181
+ stroke-width="2"
182
+ stroke-linecap="round"
183
+ stroke-linejoin="round"
184
+ ></path>
185
+ </svg>
186
+ )
187
+ }
188
+
189
+ export function Monitor() {
190
+ return (
191
+ <svg
192
+ viewBox="0 0 24 24"
193
+ height="12"
194
+ width="12"
195
+ fill="none"
196
+ xmlns="http://www.w3.org/2000/svg"
197
+ >
198
+ <path
199
+ d="M8 21h8m-4-4v4m-5.2-4h10.4c1.68 0 2.52 0 3.162-.327a3 3 0 0 0 1.311-1.311C22 14.72 22 13.88 22 12.2V7.8c0-1.68 0-2.52-.327-3.162a3 3 0 0 0-1.311-1.311C19.72 3 18.88 3 17.2 3H6.8c-1.68 0-2.52 0-3.162.327a3 3 0 0 0-1.311 1.311C2 5.28 2 6.12 2 7.8v4.4c0 1.68 0 2.52.327 3.162a3 3 0 0 0 1.311 1.311C4.28 17 5.12 17 6.8 17Z"
200
+ stroke="currentColor"
201
+ stroke-width="2"
202
+ stroke-linecap="round"
203
+ stroke-linejoin="round"
204
+ ></path>
205
+ </svg>
206
+ )
207
+ }
208
+
149
209
  export function Wifi() {
150
210
  return (
151
211
  <svg
152
- stroke="#d0d5dd"
153
- fill="#d0d5dd"
212
+ stroke="currentColor"
213
+ fill="currentColor"
154
214
  stroke-width="0"
155
215
  viewBox="0 0 24 24"
156
216
  height="1em"
@@ -166,8 +226,6 @@ export function Wifi() {
166
226
  export function Offline() {
167
227
  return (
168
228
  <svg
169
- stroke={tokens.colors.yellow[500]}
170
- fill={tokens.colors.yellow[500]}
171
229
  stroke-width="0"
172
230
  viewBox="0 0 24 24"
173
231
  height="1em"
@@ -194,14 +252,14 @@ export function Settings() {
194
252
  >
195
253
  <path
196
254
  d="M9.3951 19.3711L9.97955 20.6856C10.1533 21.0768 10.4368 21.4093 10.7958 21.6426C11.1547 21.8759 11.5737 22.0001 12.0018 22C12.4299 22.0001 12.8488 21.8759 13.2078 21.6426C13.5667 21.4093 13.8503 21.0768 14.024 20.6856L14.6084 19.3711C14.8165 18.9047 15.1664 18.5159 15.6084 18.26C16.0532 18.0034 16.5678 17.8941 17.0784 17.9478L18.5084 18.1C18.9341 18.145 19.3637 18.0656 19.7451 17.8713C20.1265 17.6771 20.4434 17.3763 20.6573 17.0056C20.8715 16.635 20.9735 16.2103 20.9511 15.7829C20.9286 15.3555 20.7825 14.9438 20.5307 14.5978L19.684 13.4344C19.3825 13.0171 19.2214 12.5148 19.224 12C19.2239 11.4866 19.3865 10.9864 19.6884 10.5711L20.5351 9.40778C20.787 9.06175 20.933 8.65007 20.9555 8.22267C20.978 7.79528 20.8759 7.37054 20.6618 7C20.4479 6.62923 20.131 6.32849 19.7496 6.13423C19.3681 5.93997 18.9386 5.86053 18.5129 5.90556L17.0829 6.05778C16.5722 6.11141 16.0577 6.00212 15.6129 5.74556C15.17 5.48825 14.82 5.09736 14.6129 4.62889L14.024 3.31444C13.8503 2.92317 13.5667 2.59072 13.2078 2.3574C12.8488 2.12408 12.4299 1.99993 12.0018 2C11.5737 1.99993 11.1547 2.12408 10.7958 2.3574C10.4368 2.59072 10.1533 2.92317 9.97955 3.31444L9.3951 4.62889C9.18803 5.09736 8.83798 5.48825 8.3951 5.74556C7.95032 6.00212 7.43577 6.11141 6.9251 6.05778L5.49066 5.90556C5.06499 5.86053 4.6354 5.93997 4.25397 6.13423C3.87255 6.32849 3.55567 6.62923 3.34177 7C3.12759 7.37054 3.02555 7.79528 3.04804 8.22267C3.07052 8.65007 3.21656 9.06175 3.46844 9.40778L4.3151 10.5711C4.61704 10.9864 4.77964 11.4866 4.77955 12C4.77964 12.5134 4.61704 13.0137 4.3151 13.4289L3.46844 14.5922C3.21656 14.9382 3.07052 15.3499 3.04804 15.7773C3.02555 16.2047 3.12759 16.6295 3.34177 17C3.55589 17.3706 3.8728 17.6712 4.25417 17.8654C4.63554 18.0596 5.06502 18.1392 5.49066 18.0944L6.92066 17.9422C7.43133 17.8886 7.94587 17.9979 8.39066 18.2544C8.83519 18.511 9.18687 18.902 9.3951 19.3711Z"
197
- stroke="#d0d5dd"
255
+ stroke="currentColor"
198
256
  stroke-width="2"
199
257
  stroke-linecap="round"
200
258
  stroke-linejoin="round"
201
259
  />
202
260
  <path
203
261
  d="M12 15C13.6568 15 15 13.6569 15 12C15 10.3431 13.6568 9 12 9C10.3431 9 8.99998 10.3431 8.99998 12C8.99998 13.6569 10.3431 15 12 15Z"
204
- stroke="#d0d5dd"
262
+ stroke="currentColor"
205
263
  stroke-width="2"
206
264
  stroke-linecap="round"
207
265
  stroke-linejoin="round"
@@ -225,13 +283,13 @@ export function Copier() {
225
283
  stroke-width="2"
226
284
  stroke-linecap="round"
227
285
  stroke-linejoin="round"
228
- stroke="#98A2B3"
286
+ stroke="currentColor"
229
287
  />
230
288
  </svg>
231
289
  )
232
290
  }
233
291
 
234
- export function CopiedCopier() {
292
+ export function CopiedCopier(props: { theme: 'light' | 'dark' }) {
235
293
  return (
236
294
  <svg
237
295
  width="24"
@@ -242,7 +300,7 @@ export function CopiedCopier() {
242
300
  >
243
301
  <path
244
302
  d="M7.5 12L10.5 15L16.5 9M7.8 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V16.2C3 17.8802 3 18.7202 3.32698 19.362C3.6146 19.9265 4.07354 20.3854 4.63803 20.673C5.27976 21 6.11984 21 7.8 21Z"
245
- stroke="#12B76A"
303
+ stroke={props.theme === 'dark' ? '#12B76A' : '#027A48'}
246
304
  stroke-width="2"
247
305
  stroke-linecap="round"
248
306
  stroke-linejoin="round"
@@ -271,6 +329,66 @@ export function ErrorCopier() {
271
329
  )
272
330
  }
273
331
 
332
+ export function List() {
333
+ return (
334
+ <svg
335
+ width="24"
336
+ height="24"
337
+ viewBox="0 0 24 24"
338
+ fill="none"
339
+ stroke="currentColor"
340
+ stroke-width="2"
341
+ xmlns="http://www.w3.org/2000/svg"
342
+ >
343
+ <rect class="list" width="20" height="20" y="2" x="2" rx="2" />
344
+ <line class="list-item" y1="7" y2="7" x1="6" x2="18" />
345
+ <line class="list-item" y2="12" y1="12" x1="6" x2="18" />
346
+ <line class="list-item" y1="17" y2="17" x1="6" x2="18" />
347
+ </svg>
348
+ )
349
+ }
350
+
351
+ export function Check(props: { checked: boolean; theme: 'light' | 'dark' }) {
352
+ return (
353
+ <>
354
+ <Show when={props.checked}>
355
+ <svg
356
+ width="24"
357
+ height="24"
358
+ viewBox="0 0 24 24"
359
+ fill="none"
360
+ xmlns="http://www.w3.org/2000/svg"
361
+ >
362
+ <path
363
+ d="M7.5 12L10.5 15L16.5 9M7.8 21H16.2C17.8802 21 18.7202 21 19.362 20.673C19.9265 20.3854 20.3854 19.9265 20.673 19.362C21 18.7202 21 17.8802 21 16.2V7.8C21 6.11984 21 5.27976 20.673 4.63803C20.3854 4.07354 19.9265 3.6146 19.362 3.32698C18.7202 3 17.8802 3 16.2 3H7.8C6.11984 3 5.27976 3 4.63803 3.32698C4.07354 3.6146 3.6146 4.07354 3.32698 4.63803C3 5.27976 3 6.11984 3 7.8V16.2C3 17.8802 3 18.7202 3.32698 19.362C3.6146 19.9265 4.07354 20.3854 4.63803 20.673C5.27976 21 6.11984 21 7.8 21Z"
364
+ stroke={props.theme === 'dark' ? '#9B8AFB' : '#6938EF'}
365
+ stroke-width="2"
366
+ stroke-linecap="round"
367
+ stroke-linejoin="round"
368
+ />
369
+ </svg>
370
+ </Show>
371
+ <Show when={!props.checked}>
372
+ <svg
373
+ viewBox="0 0 24 24"
374
+ height="20"
375
+ width="20"
376
+ fill="none"
377
+ xmlns="http://www.w3.org/2000/svg"
378
+ >
379
+ <path
380
+ d="M3 7.8c0-1.68 0-2.52.327-3.162a3 3 0 0 1 1.311-1.311C5.28 3 6.12 3 7.8 3h8.4c1.68 0 2.52 0 3.162.327a3 3 0 0 1 1.311 1.311C21 5.28 21 6.12 21 7.8v8.4c0 1.68 0 2.52-.327 3.162a3 3 0 0 1-1.311 1.311C18.72 21 17.88 21 16.2 21H7.8c-1.68 0-2.52 0-3.162-.327a3 3 0 0 1-1.311-1.311C3 18.72 3 17.88 3 16.2V7.8Z"
381
+ stroke={props.theme === 'dark' ? '#9B8AFB' : '#6938EF'}
382
+ stroke-width="2"
383
+ stroke-linecap="round"
384
+ stroke-linejoin="round"
385
+ ></path>
386
+ </svg>
387
+ </Show>
388
+ </>
389
+ )
390
+ }
391
+
274
392
  export function TanstackLogo() {
275
393
  return (
276
394
  <svg version="1.0" viewBox="0 0 633 633">
package/src/utils.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  import { serialize } from 'superjson'
2
+ import { createSignal, onCleanup, onMount } from 'solid-js'
2
3
  import type { Query } from '@tanstack/query-core'
3
4
  import type { DevtoolsPosition } from './Context'
4
5
 
@@ -111,3 +112,156 @@ export const convertRemToPixels = (rem: number) => {
111
112
  }
112
113
 
113
114
  export const convertPixelsToRem = (px: number) => px / convertRemToPixels(1)
115
+
116
+ export const getPreferredColorScheme = () => {
117
+ const [colorScheme, setColorScheme] = createSignal<'light' | 'dark'>('dark')
118
+
119
+ onMount(() => {
120
+ const query = window.matchMedia('(prefers-color-scheme: dark)')
121
+ setColorScheme(query.matches ? 'dark' : 'light')
122
+ const listener = (e: MediaQueryListEvent) => {
123
+ setColorScheme(e.matches ? 'dark' : 'light')
124
+ }
125
+ query.addEventListener('change', listener)
126
+ onCleanup(() => query.removeEventListener('change', listener))
127
+ })
128
+
129
+ return colorScheme
130
+ }
131
+
132
+ /**
133
+ * updates nested data by path
134
+ *
135
+ * @param {unknown} oldData Data to be updated
136
+ * @param {Array<string>} updatePath Path to the data to be updated
137
+ * @param {unknown} value New value
138
+ */
139
+ export const updateNestedDataByPath = (
140
+ oldData: unknown,
141
+ updatePath: Array<string>,
142
+ value: unknown,
143
+ ): any => {
144
+ if (updatePath.length === 0) {
145
+ return value
146
+ }
147
+
148
+ if (oldData instanceof Map) {
149
+ const newData = new Map(oldData)
150
+
151
+ if (updatePath.length === 1) {
152
+ newData.set(updatePath[0], value)
153
+ return newData
154
+ }
155
+
156
+ const [head, ...tail] = updatePath
157
+ newData.set(head, updateNestedDataByPath(newData.get(head), tail, value))
158
+ return newData
159
+ }
160
+
161
+ if (oldData instanceof Set) {
162
+ const setAsArray = updateNestedDataByPath(
163
+ Array.from(oldData),
164
+ updatePath,
165
+ value,
166
+ )
167
+
168
+ return new Set(setAsArray)
169
+ }
170
+
171
+ if (Array.isArray(oldData)) {
172
+ const newData = [...oldData]
173
+
174
+ if (updatePath.length === 1) {
175
+ // @ts-expect-error
176
+ newData[updatePath[0]] = value
177
+ return newData
178
+ }
179
+
180
+ const [head, ...tail] = updatePath
181
+ // @ts-expect-error
182
+ newData[head] = updateNestedDataByPath(newData[head], tail, value)
183
+
184
+ return newData
185
+ }
186
+
187
+ if (oldData instanceof Object) {
188
+ const newData = { ...oldData }
189
+
190
+ if (updatePath.length === 1) {
191
+ // @ts-expect-error
192
+ newData[updatePath[0]] = value
193
+ return newData
194
+ }
195
+
196
+ const [head, ...tail] = updatePath
197
+ // @ts-expect-error
198
+ newData[head] = updateNestedDataByPath(newData[head], tail, value)
199
+
200
+ return newData
201
+ }
202
+
203
+ return oldData
204
+ }
205
+
206
+ /**
207
+ * Deletes nested data by path
208
+ *
209
+ * @param {unknown} oldData Data to be updated
210
+ * @param {Array<string>} deletePath Path to the data to be deleted
211
+ * @returns newData without the deleted items by path
212
+ */
213
+ export const deleteNestedDataByPath = (
214
+ oldData: unknown,
215
+ deletePath: Array<string>,
216
+ ): any => {
217
+ if (oldData instanceof Map) {
218
+ const newData = new Map(oldData)
219
+
220
+ if (deletePath.length === 1) {
221
+ newData.delete(deletePath[0])
222
+ return newData
223
+ }
224
+
225
+ const [head, ...tail] = deletePath
226
+ newData.set(head, deleteNestedDataByPath(newData.get(head), tail))
227
+ return newData
228
+ }
229
+
230
+ if (oldData instanceof Set) {
231
+ const setAsArray = deleteNestedDataByPath(Array.from(oldData), deletePath)
232
+ return new Set(setAsArray)
233
+ }
234
+
235
+ if (Array.isArray(oldData)) {
236
+ const newData = [...oldData]
237
+
238
+ if (deletePath.length === 1) {
239
+ return newData.filter((_, idx) => idx.toString() !== deletePath[0])
240
+ }
241
+
242
+ const [head, ...tail] = deletePath
243
+
244
+ // @ts-expect-error
245
+ newData[head] = deleteNestedDataByPath(newData[head], tail)
246
+
247
+ return newData
248
+ }
249
+
250
+ if (oldData instanceof Object) {
251
+ const newData = { ...oldData }
252
+
253
+ if (deletePath.length === 1) {
254
+ // @ts-expect-error
255
+ delete newData[deletePath[0]]
256
+ return newData
257
+ }
258
+
259
+ const [head, ...tail] = deletePath
260
+ // @ts-expect-error
261
+ newData[head] = deleteNestedDataByPath(newData[head], tail)
262
+
263
+ return newData
264
+ }
265
+
266
+ return oldData
267
+ }