@tanstack/query-devtools 5.0.0-rc.1 → 5.0.0-rc.5
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/{H2EROWFU.jsx → 336SHOD5.jsx} +220 -27
- package/build/Devtools/{ALVY75L5.jsx → 5OOWR6BQ.jsx} +220 -27
- package/build/Devtools/{66PXWIOF.js → CIR3WCBJ.js} +338 -99
- package/build/Devtools/{HTDVDYMT.js → XXDYGLB2.js} +338 -99
- package/build/dev.cjs +349 -108
- package/build/dev.js +1 -1
- package/build/dev.jsx +1 -1
- package/build/index.cjs +349 -108
- package/build/index.js +1 -1
- package/build/index.jsx +1 -1
- package/package.json +2 -2
- package/src/Devtools.tsx +2 -1
- package/src/Explorer.tsx +173 -19
- package/src/__tests__/utils.test.ts +725 -0
- package/src/icons/index.tsx +19 -0
- package/src/utils.tsx +137 -0
package/src/icons/index.tsx
CHANGED
|
@@ -271,6 +271,25 @@ export function ErrorCopier() {
|
|
|
271
271
|
)
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
export function List() {
|
|
275
|
+
return (
|
|
276
|
+
<svg
|
|
277
|
+
width="24"
|
|
278
|
+
height="24"
|
|
279
|
+
viewBox="0 0 24 24"
|
|
280
|
+
fill="none"
|
|
281
|
+
stroke="#98A2B3"
|
|
282
|
+
stroke-width="2"
|
|
283
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
284
|
+
>
|
|
285
|
+
<rect class="list" width="20" height="20" y="2" x="2" rx="2" />
|
|
286
|
+
<line class="list-item" y1="7" y2="7" x1="6" x2="18" />
|
|
287
|
+
<line class="list-item" y2="12" y1="12" x1="6" x2="18" />
|
|
288
|
+
<line class="list-item" y1="17" y2="17" x1="6" x2="18" />
|
|
289
|
+
</svg>
|
|
290
|
+
)
|
|
291
|
+
}
|
|
292
|
+
|
|
274
293
|
export function TanstackLogo() {
|
|
275
294
|
return (
|
|
276
295
|
<svg version="1.0" viewBox="0 0 633 633">
|
package/src/utils.tsx
CHANGED
|
@@ -111,3 +111,140 @@ export const convertRemToPixels = (rem: number) => {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export const convertPixelsToRem = (px: number) => px / convertRemToPixels(1)
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* updates nested data by path
|
|
117
|
+
*
|
|
118
|
+
* @param {unknown} oldData Data to be updated
|
|
119
|
+
* @param {Array<string>} updatePath Path to the data to be updated
|
|
120
|
+
* @param {unknown} value New value
|
|
121
|
+
*/
|
|
122
|
+
export const updateNestedDataByPath = (
|
|
123
|
+
oldData: unknown,
|
|
124
|
+
updatePath: Array<string>,
|
|
125
|
+
value: unknown,
|
|
126
|
+
): any => {
|
|
127
|
+
if (updatePath.length === 0) {
|
|
128
|
+
return value
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (oldData instanceof Map) {
|
|
132
|
+
const newData = new Map(oldData)
|
|
133
|
+
|
|
134
|
+
if (updatePath.length === 1) {
|
|
135
|
+
newData.set(updatePath[0], value)
|
|
136
|
+
return newData
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const [head, ...tail] = updatePath
|
|
140
|
+
newData.set(head, updateNestedDataByPath(newData.get(head), tail, value))
|
|
141
|
+
return newData
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (oldData instanceof Set) {
|
|
145
|
+
const setAsArray = updateNestedDataByPath(
|
|
146
|
+
Array.from(oldData),
|
|
147
|
+
updatePath,
|
|
148
|
+
value,
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
return new Set(setAsArray)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (Array.isArray(oldData)) {
|
|
155
|
+
const newData = [...oldData]
|
|
156
|
+
|
|
157
|
+
if (updatePath.length === 1) {
|
|
158
|
+
// @ts-expect-error
|
|
159
|
+
newData[updatePath[0]] = value
|
|
160
|
+
return newData
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const [head, ...tail] = updatePath
|
|
164
|
+
// @ts-expect-error
|
|
165
|
+
newData[head] = updateNestedDataByPath(newData[head], tail, value)
|
|
166
|
+
|
|
167
|
+
return newData
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (oldData instanceof Object) {
|
|
171
|
+
const newData = { ...oldData }
|
|
172
|
+
|
|
173
|
+
if (updatePath.length === 1) {
|
|
174
|
+
// @ts-expect-error
|
|
175
|
+
newData[updatePath[0]] = value
|
|
176
|
+
return newData
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const [head, ...tail] = updatePath
|
|
180
|
+
// @ts-expect-error
|
|
181
|
+
newData[head] = updateNestedDataByPath(newData[head], tail, value)
|
|
182
|
+
|
|
183
|
+
return newData
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return oldData
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Deletes nested data by path
|
|
191
|
+
*
|
|
192
|
+
* @param {unknown} oldData Data to be updated
|
|
193
|
+
* @param {Array<string>} deletePath Path to the data to be deleted
|
|
194
|
+
* @returns newData without the deleted items by path
|
|
195
|
+
*/
|
|
196
|
+
export const deleteNestedDataByPath = (
|
|
197
|
+
oldData: unknown,
|
|
198
|
+
deletePath: Array<string>,
|
|
199
|
+
): any => {
|
|
200
|
+
if (oldData instanceof Map) {
|
|
201
|
+
const newData = new Map(oldData)
|
|
202
|
+
|
|
203
|
+
if (deletePath.length === 1) {
|
|
204
|
+
newData.delete(deletePath[0])
|
|
205
|
+
return newData
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const [head, ...tail] = deletePath
|
|
209
|
+
newData.set(head, deleteNestedDataByPath(newData.get(head), tail))
|
|
210
|
+
return newData
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (oldData instanceof Set) {
|
|
214
|
+
const setAsArray = deleteNestedDataByPath(Array.from(oldData), deletePath)
|
|
215
|
+
return new Set(setAsArray)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (Array.isArray(oldData)) {
|
|
219
|
+
const newData = [...oldData]
|
|
220
|
+
|
|
221
|
+
if (deletePath.length === 1) {
|
|
222
|
+
return newData.filter((_, idx) => idx.toString() !== deletePath[0])
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const [head, ...tail] = deletePath
|
|
226
|
+
|
|
227
|
+
// @ts-expect-error
|
|
228
|
+
newData[head] = deleteNestedDataByPath(newData[head], tail)
|
|
229
|
+
|
|
230
|
+
return newData
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (oldData instanceof Object) {
|
|
234
|
+
const newData = { ...oldData }
|
|
235
|
+
|
|
236
|
+
if (deletePath.length === 1) {
|
|
237
|
+
// @ts-expect-error
|
|
238
|
+
delete newData[deletePath[0]]
|
|
239
|
+
return newData
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const [head, ...tail] = deletePath
|
|
243
|
+
// @ts-expect-error
|
|
244
|
+
newData[head] = deleteNestedDataByPath(newData[head], tail)
|
|
245
|
+
|
|
246
|
+
return newData
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
return oldData
|
|
250
|
+
}
|