@tanstack/react-query-devtools 4.15.1 → 4.16.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/build/lib/Explorer.d.ts +6 -1
- package/build/lib/Explorer.esm.js +102 -3
- package/build/lib/Explorer.esm.js.map +1 -1
- package/build/lib/Explorer.js +105 -2
- package/build/lib/Explorer.js.map +1 -1
- package/build/lib/Explorer.mjs +102 -3
- package/build/lib/Explorer.mjs.map +1 -1
- package/build/lib/devtools.esm.js +2 -1
- package/build/lib/devtools.esm.js.map +1 -1
- package/build/lib/devtools.js +2 -1
- package/build/lib/devtools.js.map +1 -1
- package/build/lib/devtools.mjs +2 -1
- package/build/lib/devtools.mjs.map +1 -1
- package/build/lib/index.prod.esm.js +102 -3
- package/build/lib/index.prod.esm.js.map +1 -1
- package/build/lib/index.prod.js +102 -3
- package/build/lib/index.prod.js.map +1 -1
- package/build/lib/index.prod.mjs +102 -3
- package/build/lib/index.prod.mjs.map +1 -1
- package/build/umd/index.development.js +104 -5
- package/build/umd/index.development.js.map +1 -1
- package/package.json +1 -1
- package/src/Explorer.tsx +127 -0
- package/src/__tests__/Explorer.test.tsx +66 -2
- package/src/devtools.tsx +1 -0
|
@@ -2006,7 +2006,7 @@
|
|
|
2006
2006
|
var registerCustom = function (transformer, name) {
|
|
2007
2007
|
return CustomTransformerRegistry.register(__assign({ name: name }, transformer));
|
|
2008
2008
|
};
|
|
2009
|
-
var
|
|
2009
|
+
var superjson = {
|
|
2010
2010
|
stringify: stringify,
|
|
2011
2011
|
parse: parse,
|
|
2012
2012
|
serialize: serialize,
|
|
@@ -2124,7 +2124,7 @@
|
|
|
2124
2124
|
const displayValue = (value, beautify = false) => {
|
|
2125
2125
|
const {
|
|
2126
2126
|
json
|
|
2127
|
-
} =
|
|
2127
|
+
} = superjson.serialize(value);
|
|
2128
2128
|
return JSON.stringify(json, null, beautify ? 2 : undefined);
|
|
2129
2129
|
}; // Sorting functions
|
|
2130
2130
|
|
|
@@ -2375,6 +2375,36 @@
|
|
|
2375
2375
|
border: 'none',
|
|
2376
2376
|
padding: 0
|
|
2377
2377
|
});
|
|
2378
|
+
const CopyButton = ({
|
|
2379
|
+
value
|
|
2380
|
+
}) => {
|
|
2381
|
+
const [copyState, setCopyState] = React__namespace.useState('NoCopy');
|
|
2382
|
+
return /*#__PURE__*/React__namespace.createElement("button", {
|
|
2383
|
+
onClick: copyState === 'NoCopy' ? () => {
|
|
2384
|
+
navigator.clipboard.writeText(superjson.stringify(value)).then(() => {
|
|
2385
|
+
setCopyState('SuccessCopy');
|
|
2386
|
+
setTimeout(() => {
|
|
2387
|
+
setCopyState('NoCopy');
|
|
2388
|
+
}, 1500);
|
|
2389
|
+
}, err => {
|
|
2390
|
+
console.error('Failed to copy: ', err);
|
|
2391
|
+
setCopyState('ErrorCopy');
|
|
2392
|
+
setTimeout(() => {
|
|
2393
|
+
setCopyState('NoCopy');
|
|
2394
|
+
}, 1500);
|
|
2395
|
+
});
|
|
2396
|
+
} : undefined,
|
|
2397
|
+
style: {
|
|
2398
|
+
cursor: 'pointer',
|
|
2399
|
+
color: 'inherit',
|
|
2400
|
+
font: 'inherit',
|
|
2401
|
+
outline: 'inherit',
|
|
2402
|
+
background: 'transparent',
|
|
2403
|
+
border: 'none',
|
|
2404
|
+
padding: 0
|
|
2405
|
+
}
|
|
2406
|
+
}, copyState === 'NoCopy' ? /*#__PURE__*/React__namespace.createElement(Copier, null) : copyState === 'SuccessCopy' ? /*#__PURE__*/React__namespace.createElement(CopiedCopier, null) : /*#__PURE__*/React__namespace.createElement(ErrorCopier, null));
|
|
2407
|
+
};
|
|
2378
2408
|
const Value = styled('span', (_props, theme) => ({
|
|
2379
2409
|
color: theme.danger
|
|
2380
2410
|
}));
|
|
@@ -2399,6 +2429,68 @@
|
|
|
2399
2429
|
}
|
|
2400
2430
|
}, "\u25B6");
|
|
2401
2431
|
|
|
2432
|
+
const Copier = () => /*#__PURE__*/React__namespace.createElement("span", {
|
|
2433
|
+
"aria-label": "Copy object to clipboard",
|
|
2434
|
+
title: "Copy object to clipboard",
|
|
2435
|
+
style: {
|
|
2436
|
+
paddingLeft: '1em'
|
|
2437
|
+
}
|
|
2438
|
+
}, /*#__PURE__*/React__namespace.createElement("svg", {
|
|
2439
|
+
height: "12",
|
|
2440
|
+
viewBox: "0 0 16 12",
|
|
2441
|
+
width: "10"
|
|
2442
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
2443
|
+
fill: "currentColor",
|
|
2444
|
+
d: "M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"
|
|
2445
|
+
}), /*#__PURE__*/React__namespace.createElement("path", {
|
|
2446
|
+
fill: "currentColor",
|
|
2447
|
+
d: "M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"
|
|
2448
|
+
})));
|
|
2449
|
+
|
|
2450
|
+
const ErrorCopier = () => /*#__PURE__*/React__namespace.createElement("span", {
|
|
2451
|
+
"aria-label": "Failed copying to clipboard",
|
|
2452
|
+
title: "Failed copying to clipboard",
|
|
2453
|
+
style: {
|
|
2454
|
+
paddingLeft: '1em',
|
|
2455
|
+
display: 'flex',
|
|
2456
|
+
alignItems: 'center'
|
|
2457
|
+
}
|
|
2458
|
+
}, /*#__PURE__*/React__namespace.createElement("svg", {
|
|
2459
|
+
height: "12",
|
|
2460
|
+
viewBox: "0 0 16 12",
|
|
2461
|
+
width: "10",
|
|
2462
|
+
display: "block"
|
|
2463
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
2464
|
+
fill: "red",
|
|
2465
|
+
d: "M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"
|
|
2466
|
+
})), /*#__PURE__*/React__namespace.createElement("span", {
|
|
2467
|
+
style: {
|
|
2468
|
+
color: 'red',
|
|
2469
|
+
fontSize: '12px',
|
|
2470
|
+
paddingLeft: '4px',
|
|
2471
|
+
position: 'relative',
|
|
2472
|
+
top: '2px'
|
|
2473
|
+
}
|
|
2474
|
+
}, "See console"));
|
|
2475
|
+
|
|
2476
|
+
const CopiedCopier = () => /*#__PURE__*/React__namespace.createElement("span", {
|
|
2477
|
+
"aria-label": "Object copied to clipboard",
|
|
2478
|
+
title: "Object copied to clipboard",
|
|
2479
|
+
style: {
|
|
2480
|
+
paddingLeft: '1em',
|
|
2481
|
+
display: 'inline-block',
|
|
2482
|
+
verticalAlign: 'middle'
|
|
2483
|
+
}
|
|
2484
|
+
}, /*#__PURE__*/React__namespace.createElement("svg", {
|
|
2485
|
+
height: "16",
|
|
2486
|
+
viewBox: "0 0 16 16",
|
|
2487
|
+
width: "16",
|
|
2488
|
+
display: "block"
|
|
2489
|
+
}, /*#__PURE__*/React__namespace.createElement("path", {
|
|
2490
|
+
fill: "green",
|
|
2491
|
+
d: "M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"
|
|
2492
|
+
})));
|
|
2493
|
+
|
|
2402
2494
|
/**
|
|
2403
2495
|
* Chunk elements in the array by size
|
|
2404
2496
|
*
|
|
@@ -2428,6 +2520,7 @@
|
|
|
2428
2520
|
subEntryPages = [],
|
|
2429
2521
|
type,
|
|
2430
2522
|
expanded = false,
|
|
2523
|
+
copyable = false,
|
|
2431
2524
|
toggleExpanded,
|
|
2432
2525
|
pageSize
|
|
2433
2526
|
}) => {
|
|
@@ -2438,7 +2531,9 @@
|
|
|
2438
2531
|
onClick: () => toggleExpanded()
|
|
2439
2532
|
}, /*#__PURE__*/React__namespace.createElement(Expander, {
|
|
2440
2533
|
expanded: expanded
|
|
2441
|
-
}), " ", label, ' ', /*#__PURE__*/React__namespace.createElement(Info, null, String(type).toLowerCase() === 'iterable' ? '(Iterable) ' : '', subEntries.length, " ", subEntries.length > 1 ? "items" : "item")),
|
|
2534
|
+
}), " ", label, ' ', /*#__PURE__*/React__namespace.createElement(Info, null, String(type).toLowerCase() === 'iterable' ? '(Iterable) ' : '', subEntries.length, " ", subEntries.length > 1 ? "items" : "item")), copyable ? /*#__PURE__*/React__namespace.createElement(CopyButton, {
|
|
2535
|
+
value: value
|
|
2536
|
+
}) : null, expanded ? subEntryPages.length === 1 ? /*#__PURE__*/React__namespace.createElement(SubEntries, null, subEntries.map(handleEntry)) : /*#__PURE__*/React__namespace.createElement(SubEntries, null, subEntryPages.map((entries, index) => /*#__PURE__*/React__namespace.createElement("div", {
|
|
2442
2537
|
key: index
|
|
2443
2538
|
}, /*#__PURE__*/React__namespace.createElement(Entry, null, /*#__PURE__*/React__namespace.createElement(LabelButton, {
|
|
2444
2539
|
onClick: () => setExpandedPages(old => old.includes(index) ? old.filter(d => d !== index) : [...old, index])
|
|
@@ -2456,6 +2551,7 @@
|
|
|
2456
2551
|
defaultExpanded,
|
|
2457
2552
|
renderer = DefaultRenderer,
|
|
2458
2553
|
pageSize = 100,
|
|
2554
|
+
copyable = false,
|
|
2459
2555
|
...rest
|
|
2460
2556
|
}) {
|
|
2461
2557
|
const [expanded, setExpanded] = React__namespace.useState(Boolean(defaultExpanded));
|
|
@@ -2497,13 +2593,15 @@
|
|
|
2497
2593
|
handleEntry: entry => /*#__PURE__*/React__namespace.createElement(Explorer, _extends({
|
|
2498
2594
|
key: entry.label,
|
|
2499
2595
|
value: value,
|
|
2500
|
-
renderer: renderer
|
|
2596
|
+
renderer: renderer,
|
|
2597
|
+
copyable: copyable
|
|
2501
2598
|
}, rest, entry)),
|
|
2502
2599
|
type,
|
|
2503
2600
|
subEntries,
|
|
2504
2601
|
subEntryPages,
|
|
2505
2602
|
value,
|
|
2506
2603
|
expanded,
|
|
2604
|
+
copyable,
|
|
2507
2605
|
toggleExpanded,
|
|
2508
2606
|
pageSize,
|
|
2509
2607
|
...rest
|
|
@@ -3180,7 +3278,8 @@
|
|
|
3180
3278
|
}, /*#__PURE__*/React__namespace.createElement(Explorer, {
|
|
3181
3279
|
label: "Data",
|
|
3182
3280
|
value: activeQueryState.data,
|
|
3183
|
-
defaultExpanded: {}
|
|
3281
|
+
defaultExpanded: {},
|
|
3282
|
+
copyable: true
|
|
3184
3283
|
})), /*#__PURE__*/React__namespace.createElement("div", {
|
|
3185
3284
|
style: {
|
|
3186
3285
|
background: defaultTheme.backgroundAlt,
|