@tanstack/react-query-devtools 5.0.0-alpha.2 → 5.0.0-alpha.21

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.
Files changed (88) hide show
  1. package/build/lib/CachePanel/ActiveQuery.d.ts +18 -0
  2. package/build/lib/CachePanel/ActiveQuery.esm.js +271 -0
  3. package/build/lib/CachePanel/ActiveQuery.esm.js.map +1 -0
  4. package/build/lib/CachePanel/ActiveQuery.js +275 -0
  5. package/build/lib/CachePanel/ActiveQuery.js.map +1 -0
  6. package/build/lib/CachePanel/ActiveQuery.mjs +257 -0
  7. package/build/lib/CachePanel/ActiveQuery.mjs.map +1 -0
  8. package/build/lib/CachePanel/CachePanel.d.ts +57 -0
  9. package/build/lib/CachePanel/CachePanel.esm.js +310 -0
  10. package/build/lib/CachePanel/CachePanel.esm.js.map +1 -0
  11. package/build/lib/CachePanel/CachePanel.js +315 -0
  12. package/build/lib/CachePanel/CachePanel.js.map +1 -0
  13. package/build/lib/CachePanel/CachePanel.mjs +310 -0
  14. package/build/lib/CachePanel/CachePanel.mjs.map +1 -0
  15. package/build/lib/CachePanel/Header/QueryStatusCount.d.ts +7 -0
  16. package/build/lib/CachePanel/Header/QueryStatusCount.esm.js +49 -0
  17. package/build/lib/CachePanel/Header/QueryStatusCount.esm.js.map +1 -0
  18. package/build/lib/CachePanel/Header/QueryStatusCount.js +53 -0
  19. package/build/lib/CachePanel/Header/QueryStatusCount.js.map +1 -0
  20. package/build/lib/CachePanel/Header/QueryStatusCount.mjs +49 -0
  21. package/build/lib/CachePanel/Header/QueryStatusCount.mjs.map +1 -0
  22. package/build/lib/CachePanel/QueryRow.d.ts +13 -0
  23. package/build/lib/CachePanel/QueryRow.esm.js +98 -0
  24. package/build/lib/CachePanel/QueryRow.esm.js.map +1 -0
  25. package/build/lib/CachePanel/QueryRow.js +102 -0
  26. package/build/lib/CachePanel/QueryRow.js.map +1 -0
  27. package/build/lib/CachePanel/QueryRow.mjs +82 -0
  28. package/build/lib/CachePanel/QueryRow.mjs.map +1 -0
  29. package/build/lib/Explorer.esm.js +2 -1
  30. package/build/lib/Explorer.esm.js.map +1 -1
  31. package/build/lib/Explorer.js +2 -1
  32. package/build/lib/Explorer.js.map +1 -1
  33. package/build/lib/Explorer.mjs +1 -0
  34. package/build/lib/Explorer.mjs.map +1 -1
  35. package/build/lib/devtools.d.ts +5 -48
  36. package/build/lib/devtools.esm.js +11 -550
  37. package/build/lib/devtools.esm.js.map +1 -1
  38. package/build/lib/devtools.js +12 -551
  39. package/build/lib/devtools.js.map +1 -1
  40. package/build/lib/devtools.mjs +7 -547
  41. package/build/lib/devtools.mjs.map +1 -1
  42. package/build/lib/index.esm.js +3 -1
  43. package/build/lib/index.esm.js.map +1 -1
  44. package/build/lib/index.js +3 -1
  45. package/build/lib/index.js.map +1 -1
  46. package/build/lib/index.mjs +3 -1
  47. package/build/lib/index.mjs.map +1 -1
  48. package/build/lib/index.prod.esm.js +821 -651
  49. package/build/lib/index.prod.esm.js.map +1 -1
  50. package/build/lib/index.prod.js +819 -650
  51. package/build/lib/index.prod.js.map +1 -1
  52. package/build/lib/index.prod.mjs +764 -625
  53. package/build/lib/index.prod.mjs.map +1 -1
  54. package/build/lib/styledComponents.d.ts +0 -1
  55. package/build/lib/styledComponents.esm.js +11 -1
  56. package/build/lib/styledComponents.esm.js.map +1 -1
  57. package/build/lib/styledComponents.js +11 -1
  58. package/build/lib/styledComponents.js.map +1 -1
  59. package/build/lib/styledComponents.mjs +11 -1
  60. package/build/lib/styledComponents.mjs.map +1 -1
  61. package/build/lib/theme.esm.js +1 -0
  62. package/build/lib/theme.esm.js.map +1 -1
  63. package/build/lib/theme.js +1 -0
  64. package/build/lib/theme.js.map +1 -1
  65. package/build/lib/theme.mjs +1 -0
  66. package/build/lib/theme.mjs.map +1 -1
  67. package/build/lib/types.d.ts +11 -0
  68. package/build/lib/useSubscribeToQueryCache.d.ts +3 -0
  69. package/build/lib/useSubscribeToQueryCache.esm.js +15 -0
  70. package/build/lib/useSubscribeToQueryCache.esm.js.map +1 -0
  71. package/build/lib/useSubscribeToQueryCache.js +19 -0
  72. package/build/lib/useSubscribeToQueryCache.js.map +1 -0
  73. package/build/lib/useSubscribeToQueryCache.mjs +15 -0
  74. package/build/lib/useSubscribeToQueryCache.mjs.map +1 -0
  75. package/build/umd/index.development.js +1667 -1529
  76. package/build/umd/index.development.js.map +1 -1
  77. package/build/umd/index.production.js.map +1 -1
  78. package/package.json +4 -4
  79. package/src/CachePanel/ActiveQuery.tsx +380 -0
  80. package/src/CachePanel/CachePanel.tsx +439 -0
  81. package/src/CachePanel/Header/QueryStatusCount.tsx +93 -0
  82. package/src/CachePanel/QueryRow.tsx +125 -0
  83. package/src/__tests__/Explorer.test.tsx +3 -2
  84. package/src/__tests__/devtools.test.tsx +229 -9
  85. package/src/devtools.tsx +10 -865
  86. package/src/styledComponents.ts +19 -1
  87. package/src/types.ts +12 -0
  88. package/src/useSubscribeToQueryCache.ts +26 -0
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var React = require('react');
4
+ var SuperJSON = require('superjson');
4
5
  var reactQuery = require('@tanstack/react-query');
5
6
  var matchSorterUtils = require('@tanstack/match-sorter-utils');
6
- var SuperJSON = require('superjson');
7
7
 
8
8
  function _interopNamespaceDefault(e) {
9
9
  var n = Object.create(null);
@@ -311,6 +311,46 @@ function getResizeHandleStyle(position = 'bottom') {
311
311
  };
312
312
  }
313
313
 
314
+ function ScreenReader({
315
+ text
316
+ }) {
317
+ return /*#__PURE__*/React__namespace.createElement("span", {
318
+ style: {
319
+ position: 'absolute',
320
+ width: '0.1px',
321
+ height: '0.1px',
322
+ overflow: 'hidden'
323
+ }
324
+ }, text);
325
+ }
326
+
327
+ function Logo(props) {
328
+ return /*#__PURE__*/React__namespace.createElement("svg", _extends({
329
+ width: "40px",
330
+ height: "40px",
331
+ viewBox: "0 0 190 190",
332
+ version: "1.1"
333
+ }, props), /*#__PURE__*/React__namespace.createElement("g", {
334
+ stroke: "none",
335
+ strokeWidth: "1",
336
+ fill: "none",
337
+ fillRule: "evenodd"
338
+ }, /*#__PURE__*/React__namespace.createElement("g", {
339
+ transform: "translate(-33.000000, 0.000000)"
340
+ }, /*#__PURE__*/React__namespace.createElement("path", {
341
+ d: "M72.7239712,61.3436237 C69.631224,46.362877 68.9675112,34.8727722 70.9666331,26.5293551 C72.1555965,21.5671678 74.3293088,17.5190846 77.6346064,14.5984631 C81.1241394,11.5150478 85.5360327,10.0020122 90.493257,10.0020122 C98.6712013,10.0020122 107.26826,13.7273214 116.455725,20.8044264 C120.20312,23.6910458 124.092437,27.170411 128.131651,31.2444746 C128.45314,30.8310265 128.816542,30.4410453 129.22143,30.0806152 C140.64098,19.9149716 150.255245,13.5989272 158.478408,11.1636507 C163.367899,9.715636 167.958526,9.57768202 172.138936,10.983031 C176.551631,12.4664684 180.06766,15.5329489 182.548314,19.8281091 C186.642288,26.9166735 187.721918,36.2310983 186.195595,47.7320243 C185.573451,52.4199112 184.50985,57.5263831 183.007094,63.0593153 C183.574045,63.1277086 184.142416,63.2532808 184.705041,63.4395297 C199.193932,68.2358678 209.453582,73.3937462 215.665021,79.2882839 C219.360669,82.7953831 221.773972,86.6998434 222.646365,91.0218204 C223.567176,95.5836746 222.669313,100.159332 220.191548,104.451297 C216.105211,111.529614 208.591643,117.11221 197.887587,121.534031 C193.589552,123.309539 188.726579,124.917559 183.293259,126.363748 C183.541176,126.92292 183.733521,127.516759 183.862138,128.139758 C186.954886,143.120505 187.618598,154.61061 185.619477,162.954027 C184.430513,167.916214 182.256801,171.964297 178.951503,174.884919 C175.46197,177.968334 171.050077,179.48137 166.092853,179.48137 C157.914908,179.48137 149.31785,175.756061 140.130385,168.678956 C136.343104,165.761613 132.410866,162.238839 128.325434,158.108619 C127.905075,158.765474 127.388968,159.376011 126.77857,159.919385 C115.35902,170.085028 105.744755,176.401073 97.5215915,178.836349 C92.6321009,180.284364 88.0414736,180.422318 83.8610636,179.016969 C79.4483686,177.533532 75.9323404,174.467051 73.4516862,170.171891 C69.3577116,163.083327 68.2780823,153.768902 69.8044053,142.267976 C70.449038,137.410634 71.56762,132.103898 73.1575891,126.339009 C72.5361041,126.276104 71.9120754,126.144816 71.2949591,125.940529 C56.8060684,121.144191 46.5464184,115.986312 40.3349789,110.091775 C36.6393312,106.584675 34.2260275,102.680215 33.3536352,98.3582381 C32.4328237,93.7963839 33.3306866,89.2207269 35.8084524,84.9287618 C39.8947886,77.8504443 47.4083565,72.2678481 58.1124133,67.8460273 C62.5385143,66.0176154 67.5637208,64.366822 73.1939394,62.8874674 C72.9933393,62.3969171 72.8349374,61.8811235 72.7239712,61.3436237 Z",
342
+ fill: "#002C4B",
343
+ fillRule: "nonzero",
344
+ transform: "translate(128.000000, 95.000000) scale(-1, 1) translate(-128.000000, -95.000000) "
345
+ }), /*#__PURE__*/React__namespace.createElement("path", {
346
+ d: "M113.396882,64 L142.608177,64 C144.399254,64 146.053521,64.958025 146.944933,66.5115174 L161.577138,92.0115174 C162.461464,93.5526583 162.461464,95.4473417 161.577138,96.9884826 L146.944933,122.488483 C146.053521,124.041975 144.399254,125 142.608177,125 L113.396882,125 C111.605806,125 109.951539,124.041975 109.060126,122.488483 L94.4279211,96.9884826 C93.543596,95.4473417 93.543596,93.5526583 94.4279211,92.0115174 L109.060126,66.5115174 C109.951539,64.958025 111.605806,64 113.396882,64 Z M138.987827,70.2765273 C140.779849,70.2765273 142.434839,71.2355558 143.325899,72.7903404 L154.343038,92.0138131 C155.225607,93.5537825 155.225607,95.4462175 154.343038,96.9861869 L143.325899,116.20966 C142.434839,117.764444 140.779849,118.723473 138.987827,118.723473 L117.017233,118.723473 C115.225211,118.723473 113.570221,117.764444 112.67916,116.20966 L101.662022,96.9861869 C100.779452,95.4462175 100.779452,93.5537825 101.662022,92.0138131 L112.67916,72.7903404 C113.570221,71.2355558 115.225211,70.2765273 117.017233,70.2765273 L138.987827,70.2765273 Z M135.080648,77.1414791 L120.924411,77.1414791 C119.134228,77.1414791 117.480644,78.0985567 116.5889,79.6508285 L116.5889,79.6508285 L109.489217,92.0093494 C108.603232,93.5515958 108.603232,95.4484042 109.489217,96.9906506 L109.489217,96.9906506 L116.5889,109.349172 C117.480644,110.901443 119.134228,111.858521 120.924411,111.858521 L120.924411,111.858521 L135.080648,111.858521 C136.870831,111.858521 138.524416,110.901443 139.41616,109.349172 L139.41616,109.349172 L146.515843,96.9906506 C147.401828,95.4484042 147.401828,93.5515958 146.515843,92.0093494 L146.515843,92.0093494 L139.41616,79.6508285 C138.524416,78.0985567 136.870831,77.1414791 135.080648,77.1414791 L135.080648,77.1414791 Z M131.319186,83.7122186 C133.108028,83.7122186 134.760587,84.6678753 135.652827,86.2183156 L138.983552,92.0060969 C139.87203,93.5500005 139.87203,95.4499995 138.983552,96.9939031 L135.652827,102.781684 C134.760587,104.332125 133.108028,105.287781 131.319186,105.287781 L124.685874,105.287781 C122.897032,105.287781 121.244473,104.332125 120.352233,102.781684 L117.021508,96.9939031 C116.13303,95.4499995 116.13303,93.5500005 117.021508,92.0060969 L120.352233,86.2183156 C121.244473,84.6678753 122.897032,83.7122186 124.685874,83.7122186 L131.319186,83.7122186 Z M128.003794,90.1848875 C126.459294,90.1848875 125.034382,91.0072828 124.263005,92.3424437 C123.491732,93.6774232 123.491732,95.3225768 124.263005,96.6575563 C125.034382,97.9927172 126.459294,98.8151125 128.001266,98.8151125 L128.001266,98.8151125 C129.545766,98.8151125 130.970678,97.9927172 131.742055,96.6575563 C132.513327,95.3225768 132.513327,93.6774232 131.742055,92.3424437 C130.970678,91.0072828 129.545766,90.1848875 128.003794,90.1848875 L128.003794,90.1848875 Z M93,94.5009646 L100.767764,94.5009646",
347
+ fill: "#FFD94C"
348
+ }), /*#__PURE__*/React__namespace.createElement("path", {
349
+ d: "M87.8601729,108.357758 C89.1715224,107.608286 90.8360246,108.074601 91.5779424,109.399303 L91.5779424,109.399303 L92.0525843,110.24352 C95.8563392,116.982993 99.8190116,123.380176 103.940602,129.435068 C108.807881,136.585427 114.28184,143.82411 120.362479,151.151115 C121.316878,152.30114 121.184944,154.011176 120.065686,154.997937 L120.065686,154.997937 L119.454208,155.534625 C99.3465389,173.103314 86.2778188,176.612552 80.2480482,166.062341 C74.3500652,155.742717 76.4844915,136.982888 86.6513274,109.782853 C86.876818,109.179582 87.3045861,108.675291 87.8601729,108.357758 Z M173.534177,129.041504 C174.986131,128.785177 176.375496,129.742138 176.65963,131.194242 L176.65963,131.194242 L176.812815,131.986376 C181.782365,157.995459 178.283348,171 166.315764,171 C154.609745,171 139.708724,159.909007 121.612702,137.727022 C121.211349,137.235047 120.994572,136.617371 121,135.981509 C121.013158,134.480686 122.235785,133.274651 123.730918,133.287756 L123.730918,133.287756 L124.684654,133.294531 C132.305698,133.335994 139.714387,133.071591 146.910723,132.501323 C155.409039,131.82788 164.283523,130.674607 173.534177,129.041504 Z M180.408726,73.8119663 C180.932139,72.4026903 182.508386,71.6634537 183.954581,72.149012 L183.954581,72.149012 L184.742552,72.4154854 C210.583763,81.217922 220.402356,90.8916805 214.198332,101.436761 C208.129904,111.751366 190.484347,119.260339 161.26166,123.963678 C160.613529,124.067994 159.948643,123.945969 159.382735,123.618843 C158.047025,122.846729 157.602046,121.158214 158.388848,119.847438 L158.388848,119.847438 L158.889328,119.0105 C162.877183,112.31633 166.481358,105.654262 169.701854,99.0242957 C173.50501,91.1948179 177.073967,82.7907081 180.408726,73.8119663 Z M94.7383398,66.0363218 C95.3864708,65.9320063 96.0513565,66.0540315 96.6172646,66.3811573 C97.9529754,67.153271 98.3979538,68.8417862 97.6111517,70.1525615 L97.6111517,70.1525615 L97.1106718,70.9895001 C93.1228168,77.6836699 89.5186416,84.3457379 86.2981462,90.9757043 C82.49499,98.8051821 78.9260328,107.209292 75.5912744,116.188034 C75.0678608,117.59731 73.4916142,118.336546 72.045419,117.850988 L72.045419,117.850988 L71.2574475,117.584515 C45.4162372,108.782078 35.597644,99.1083195 41.8016679,88.5632391 C47.8700957,78.2486335 65.515653,70.7396611 94.7383398,66.0363218 Z M136.545792,34.4653746 C156.653461,16.8966864 169.722181,13.3874478 175.751952,23.9376587 C181.649935,34.2572826 179.515508,53.0171122 169.348673,80.2171474 C169.123182,80.8204179 168.695414,81.324709 168.139827,81.6422422 C166.828478,82.3917144 165.163975,81.9253986 164.422058,80.6006966 L164.422058,80.6006966 L163.947416,79.7564798 C160.143661,73.0170065 156.180988,66.6198239 152.059398,60.564932 C147.192119,53.4145727 141.71816,46.1758903 135.637521,38.8488847 C134.683122,37.6988602 134.815056,35.9888243 135.934314,35.0020629 L135.934314,35.0020629 Z M90.6842361,18 C102.390255,18 117.291276,29.0909926 135.387298,51.2729777 C135.788651,51.7649527 136.005428,52.3826288 136,53.0184911 C135.986842,54.5193144 134.764215,55.7253489 133.269082,55.7122445 L133.269082,55.7122445 L132.315346,55.7054689 C124.694302,55.6640063 117.285613,55.9284091 110.089277,56.4986773 C101.590961,57.17212 92.7164767,58.325393 83.4658235,59.9584962 C82.0138691,60.2148231 80.6245044,59.2578618 80.3403697,57.805758 L80.3403697,57.805758 L80.1871846,57.0136235 C75.2176347,31.0045412 78.7166519,18 90.6842361,18 Z",
350
+ fill: "#FF4154"
351
+ }))));
352
+ }
353
+
314
354
  const Panel = styled('div', (_props, theme) => ({
315
355
  fontSize: 'clamp(12px, 1.5vw, 14px)',
316
356
  fontFamily: `sans-serif`,
@@ -327,6 +367,7 @@ const Panel = styled('div', (_props, theme) => ({
327
367
  }
328
368
  });
329
369
 
370
+ Panel.displayName = 'Panel';
330
371
  const ActiveQueryPanel = styled('div', () => ({
331
372
  flex: '1 1 500px',
332
373
  display: 'flex',
@@ -338,6 +379,7 @@ const ActiveQueryPanel = styled('div', () => ({
338
379
  borderTop: `2px solid ${theme.gray}`
339
380
  })
340
381
  });
382
+ ActiveQueryPanel.displayName = 'ActiveQueryPanel';
341
383
  const Button = styled('button', (props, theme) => ({
342
384
  appearance: 'none',
343
385
  fontSize: '.9em',
@@ -350,10 +392,14 @@ const Button = styled('button', (props, theme) => ({
350
392
  opacity: props.disabled ? '.5' : undefined,
351
393
  cursor: 'pointer'
352
394
  }));
395
+ Button.displayName = 'Button';
353
396
  const QueryKeys = styled('span', {
354
- display: 'inline-block',
397
+ display: 'flex',
398
+ flexWrap: 'wrap',
399
+ gap: '0.5em',
355
400
  fontSize: '0.9em'
356
401
  });
402
+ QueryKeys.displayName = 'QueryKeys';
357
403
  const QueryKey = styled('span', {
358
404
  display: 'inline-flex',
359
405
  alignItems: 'center',
@@ -362,11 +408,13 @@ const QueryKey = styled('span', {
362
408
  textShadow: '0 0 10px black',
363
409
  borderRadius: '.2em'
364
410
  });
411
+ QueryKey.displayName = 'QueryKey';
365
412
  const Code = styled('code', {
366
413
  fontSize: '.9em',
367
414
  color: 'inherit',
368
415
  background: 'inherit'
369
416
  });
417
+ Code.displayName = 'Code';
370
418
  const Input = styled('input', (_props, theme) => ({
371
419
  backgroundColor: theme.inputBackgroundColor,
372
420
  border: 0,
@@ -376,6 +424,7 @@ const Input = styled('input', (_props, theme) => ({
376
424
  lineHeight: `1.3`,
377
425
  padding: '.3em .4em'
378
426
  }));
427
+ Input.displayName = 'Input';
379
428
  const Select = styled('select', (_props, theme) => ({
380
429
  display: `inline-block`,
381
430
  fontSize: `.9em`,
@@ -399,20 +448,149 @@ const Select = styled('select', (_props, theme) => ({
399
448
  display: 'none'
400
449
  }
401
450
  });
451
+ Select.displayName = 'Select';
402
452
 
403
- function ScreenReader({
404
- text
453
+ const useSubscribeToQueryCache = (queryCache, getSnapshot, skip = false) => {
454
+ return React.useSyncExternalStore(React.useCallback(onStoreChange => {
455
+ if (!skip) return queryCache.subscribe(reactQuery.notifyManager.batchCalls(onStoreChange));
456
+ return () => {
457
+ return;
458
+ };
459
+ }, [queryCache, skip]), getSnapshot, getSnapshot);
460
+ };
461
+ var useSubscribeToQueryCache$1 = useSubscribeToQueryCache;
462
+
463
+ /**
464
+ * Displays the number of queries for each status
465
+ */
466
+ function QueryStatusCount({
467
+ queryCache
405
468
  }) {
406
- return /*#__PURE__*/React__namespace.createElement("span", {
469
+ const hasFresh = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fresh').length);
470
+ const hasFetching = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fetching').length);
471
+ const hasPaused = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'paused').length);
472
+ const hasStale = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'stale').length);
473
+ const hasInactive = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'inactive').length);
474
+ return /*#__PURE__*/React.createElement(QueryKeys, null, /*#__PURE__*/React.createElement(QueryKey, {
407
475
  style: {
408
- position: 'absolute',
409
- width: '0.1px',
410
- height: '0.1px',
411
- overflow: 'hidden'
476
+ background: defaultTheme.success,
477
+ opacity: hasFresh ? 1 : 0.3
412
478
  }
413
- }, text);
479
+ }, "fresh ", /*#__PURE__*/React.createElement(Code, null, "(", hasFresh, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
480
+ style: {
481
+ background: defaultTheme.active,
482
+ opacity: hasFetching ? 1 : 0.3
483
+ }
484
+ }, "fetching ", /*#__PURE__*/React.createElement(Code, null, "(", hasFetching, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
485
+ style: {
486
+ background: defaultTheme.paused,
487
+ opacity: hasPaused ? 1 : 0.3
488
+ }
489
+ }, "paused ", /*#__PURE__*/React.createElement(Code, null, "(", hasPaused, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
490
+ style: {
491
+ background: defaultTheme.warning,
492
+ color: 'black',
493
+ textShadow: '0',
494
+ opacity: hasStale ? 1 : 0.3
495
+ }
496
+ }, "stale ", /*#__PURE__*/React.createElement(Code, null, "(", hasStale, ")")), ' ', /*#__PURE__*/React.createElement(QueryKey, {
497
+ style: {
498
+ background: defaultTheme.gray,
499
+ opacity: hasInactive ? 1 : 0.3
500
+ }
501
+ }, "inactive ", /*#__PURE__*/React.createElement(Code, null, "(", hasInactive, ")")));
414
502
  }
415
503
 
504
+ /**
505
+ * Row for a query in the query list
506
+ */
507
+ const QueryRow = /*#__PURE__*/React.memo(({
508
+ queryKey,
509
+ setActiveQueryHash,
510
+ activeQueryHash,
511
+ queryCache
512
+ }) => {
513
+ var _useSubscribeToQueryC, _useSubscribeToQueryC2, _useSubscribeToQueryC3, _useSubscribeToQueryC4;
514
+ const queryHash = (_useSubscribeToQueryC = useSubscribeToQueryCache$1(queryCache, () => {
515
+ var _queryCache$find;
516
+ return (_queryCache$find = queryCache.find({
517
+ queryKey
518
+ })) == null ? void 0 : _queryCache$find.queryHash;
519
+ })) != null ? _useSubscribeToQueryC : '';
520
+ const queryState = useSubscribeToQueryCache$1(queryCache, () => {
521
+ var _queryCache$find2;
522
+ return (_queryCache$find2 = queryCache.find({
523
+ queryKey
524
+ })) == null ? void 0 : _queryCache$find2.state;
525
+ });
526
+ const isStale = (_useSubscribeToQueryC2 = useSubscribeToQueryCache$1(queryCache, () => {
527
+ var _queryCache$find3;
528
+ return (_queryCache$find3 = queryCache.find({
529
+ queryKey
530
+ })) == null ? void 0 : _queryCache$find3.isStale();
531
+ })) != null ? _useSubscribeToQueryC2 : false;
532
+ const isDisabled = (_useSubscribeToQueryC3 = useSubscribeToQueryCache$1(queryCache, () => {
533
+ var _queryCache$find4;
534
+ return (_queryCache$find4 = queryCache.find({
535
+ queryKey
536
+ })) == null ? void 0 : _queryCache$find4.isDisabled();
537
+ })) != null ? _useSubscribeToQueryC3 : false;
538
+ const observerCount = (_useSubscribeToQueryC4 = useSubscribeToQueryCache$1(queryCache, () => {
539
+ var _queryCache$find5;
540
+ return (_queryCache$find5 = queryCache.find({
541
+ queryKey
542
+ })) == null ? void 0 : _queryCache$find5.getObserversCount();
543
+ })) != null ? _useSubscribeToQueryC4 : 0;
544
+ if (!queryState) {
545
+ return null;
546
+ }
547
+ return /*#__PURE__*/React.createElement("div", {
548
+ role: "button",
549
+ "aria-label": `Open query details for ${queryHash}`,
550
+ onClick: () => setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash),
551
+ style: {
552
+ display: 'flex',
553
+ borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
554
+ cursor: 'pointer',
555
+ background: queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined
556
+ }
557
+ }, /*#__PURE__*/React.createElement("div", {
558
+ style: {
559
+ flex: '0 0 auto',
560
+ width: '2em',
561
+ height: '2em',
562
+ background: getQueryStatusColor({
563
+ queryState,
564
+ isStale,
565
+ observerCount,
566
+ theme: defaultTheme
567
+ }),
568
+ display: 'flex',
569
+ alignItems: 'center',
570
+ justifyContent: 'center',
571
+ fontWeight: 'bold',
572
+ textShadow: isStale ? '0' : '0 0 10px black',
573
+ color: isStale ? 'black' : 'white'
574
+ }
575
+ }, observerCount), isDisabled ? /*#__PURE__*/React.createElement("div", {
576
+ style: {
577
+ flex: '0 0 auto',
578
+ height: '2em',
579
+ background: defaultTheme.gray,
580
+ display: 'flex',
581
+ alignItems: 'center',
582
+ fontWeight: 'bold',
583
+ padding: '0 0.5em'
584
+ }
585
+ }, "disabled") : null, /*#__PURE__*/React.createElement(Code, {
586
+ style: {
587
+ padding: '.5em'
588
+ }
589
+ }, `${queryHash}`));
590
+ });
591
+ QueryRow.displayName = 'QueryRow';
592
+ var QueryRow$1 = QueryRow;
593
+
416
594
  const Entry = styled('div', {
417
595
  fontFamily: 'Menlo, monospace',
418
596
  fontSize: '1em',
@@ -614,7 +792,7 @@ function Explorer({
614
792
  const makeProperty = sub => {
615
793
  const subDefaultExpanded = defaultExpanded === true ? {
616
794
  [sub.label]: true
617
- } : defaultExpanded?.[sub.label];
795
+ } : defaultExpanded == null ? void 0 : defaultExpanded[sub.label];
618
796
  return {
619
797
  ...sub,
620
798
  defaultExpanded: subDefaultExpanded
@@ -659,419 +837,430 @@ function Explorer({
659
837
  });
660
838
  }
661
839
 
662
- function Logo(props) {
663
- return /*#__PURE__*/React__namespace.createElement("svg", _extends({
664
- width: "40px",
665
- height: "40px",
666
- viewBox: "0 0 190 190",
667
- version: "1.1"
668
- }, props), /*#__PURE__*/React__namespace.createElement("g", {
669
- stroke: "none",
670
- strokeWidth: "1",
671
- fill: "none",
672
- fillRule: "evenodd"
673
- }, /*#__PURE__*/React__namespace.createElement("g", {
674
- transform: "translate(-33.000000, 0.000000)"
675
- }, /*#__PURE__*/React__namespace.createElement("path", {
676
- d: "M72.7239712,61.3436237 C69.631224,46.362877 68.9675112,34.8727722 70.9666331,26.5293551 C72.1555965,21.5671678 74.3293088,17.5190846 77.6346064,14.5984631 C81.1241394,11.5150478 85.5360327,10.0020122 90.493257,10.0020122 C98.6712013,10.0020122 107.26826,13.7273214 116.455725,20.8044264 C120.20312,23.6910458 124.092437,27.170411 128.131651,31.2444746 C128.45314,30.8310265 128.816542,30.4410453 129.22143,30.0806152 C140.64098,19.9149716 150.255245,13.5989272 158.478408,11.1636507 C163.367899,9.715636 167.958526,9.57768202 172.138936,10.983031 C176.551631,12.4664684 180.06766,15.5329489 182.548314,19.8281091 C186.642288,26.9166735 187.721918,36.2310983 186.195595,47.7320243 C185.573451,52.4199112 184.50985,57.5263831 183.007094,63.0593153 C183.574045,63.1277086 184.142416,63.2532808 184.705041,63.4395297 C199.193932,68.2358678 209.453582,73.3937462 215.665021,79.2882839 C219.360669,82.7953831 221.773972,86.6998434 222.646365,91.0218204 C223.567176,95.5836746 222.669313,100.159332 220.191548,104.451297 C216.105211,111.529614 208.591643,117.11221 197.887587,121.534031 C193.589552,123.309539 188.726579,124.917559 183.293259,126.363748 C183.541176,126.92292 183.733521,127.516759 183.862138,128.139758 C186.954886,143.120505 187.618598,154.61061 185.619477,162.954027 C184.430513,167.916214 182.256801,171.964297 178.951503,174.884919 C175.46197,177.968334 171.050077,179.48137 166.092853,179.48137 C157.914908,179.48137 149.31785,175.756061 140.130385,168.678956 C136.343104,165.761613 132.410866,162.238839 128.325434,158.108619 C127.905075,158.765474 127.388968,159.376011 126.77857,159.919385 C115.35902,170.085028 105.744755,176.401073 97.5215915,178.836349 C92.6321009,180.284364 88.0414736,180.422318 83.8610636,179.016969 C79.4483686,177.533532 75.9323404,174.467051 73.4516862,170.171891 C69.3577116,163.083327 68.2780823,153.768902 69.8044053,142.267976 C70.449038,137.410634 71.56762,132.103898 73.1575891,126.339009 C72.5361041,126.276104 71.9120754,126.144816 71.2949591,125.940529 C56.8060684,121.144191 46.5464184,115.986312 40.3349789,110.091775 C36.6393312,106.584675 34.2260275,102.680215 33.3536352,98.3582381 C32.4328237,93.7963839 33.3306866,89.2207269 35.8084524,84.9287618 C39.8947886,77.8504443 47.4083565,72.2678481 58.1124133,67.8460273 C62.5385143,66.0176154 67.5637208,64.366822 73.1939394,62.8874674 C72.9933393,62.3969171 72.8349374,61.8811235 72.7239712,61.3436237 Z",
677
- fill: "#002C4B",
678
- fillRule: "nonzero",
679
- transform: "translate(128.000000, 95.000000) scale(-1, 1) translate(-128.000000, -95.000000) "
680
- }), /*#__PURE__*/React__namespace.createElement("path", {
681
- d: "M113.396882,64 L142.608177,64 C144.399254,64 146.053521,64.958025 146.944933,66.5115174 L161.577138,92.0115174 C162.461464,93.5526583 162.461464,95.4473417 161.577138,96.9884826 L146.944933,122.488483 C146.053521,124.041975 144.399254,125 142.608177,125 L113.396882,125 C111.605806,125 109.951539,124.041975 109.060126,122.488483 L94.4279211,96.9884826 C93.543596,95.4473417 93.543596,93.5526583 94.4279211,92.0115174 L109.060126,66.5115174 C109.951539,64.958025 111.605806,64 113.396882,64 Z M138.987827,70.2765273 C140.779849,70.2765273 142.434839,71.2355558 143.325899,72.7903404 L154.343038,92.0138131 C155.225607,93.5537825 155.225607,95.4462175 154.343038,96.9861869 L143.325899,116.20966 C142.434839,117.764444 140.779849,118.723473 138.987827,118.723473 L117.017233,118.723473 C115.225211,118.723473 113.570221,117.764444 112.67916,116.20966 L101.662022,96.9861869 C100.779452,95.4462175 100.779452,93.5537825 101.662022,92.0138131 L112.67916,72.7903404 C113.570221,71.2355558 115.225211,70.2765273 117.017233,70.2765273 L138.987827,70.2765273 Z M135.080648,77.1414791 L120.924411,77.1414791 C119.134228,77.1414791 117.480644,78.0985567 116.5889,79.6508285 L116.5889,79.6508285 L109.489217,92.0093494 C108.603232,93.5515958 108.603232,95.4484042 109.489217,96.9906506 L109.489217,96.9906506 L116.5889,109.349172 C117.480644,110.901443 119.134228,111.858521 120.924411,111.858521 L120.924411,111.858521 L135.080648,111.858521 C136.870831,111.858521 138.524416,110.901443 139.41616,109.349172 L139.41616,109.349172 L146.515843,96.9906506 C147.401828,95.4484042 147.401828,93.5515958 146.515843,92.0093494 L146.515843,92.0093494 L139.41616,79.6508285 C138.524416,78.0985567 136.870831,77.1414791 135.080648,77.1414791 L135.080648,77.1414791 Z M131.319186,83.7122186 C133.108028,83.7122186 134.760587,84.6678753 135.652827,86.2183156 L138.983552,92.0060969 C139.87203,93.5500005 139.87203,95.4499995 138.983552,96.9939031 L135.652827,102.781684 C134.760587,104.332125 133.108028,105.287781 131.319186,105.287781 L124.685874,105.287781 C122.897032,105.287781 121.244473,104.332125 120.352233,102.781684 L117.021508,96.9939031 C116.13303,95.4499995 116.13303,93.5500005 117.021508,92.0060969 L120.352233,86.2183156 C121.244473,84.6678753 122.897032,83.7122186 124.685874,83.7122186 L131.319186,83.7122186 Z M128.003794,90.1848875 C126.459294,90.1848875 125.034382,91.0072828 124.263005,92.3424437 C123.491732,93.6774232 123.491732,95.3225768 124.263005,96.6575563 C125.034382,97.9927172 126.459294,98.8151125 128.001266,98.8151125 L128.001266,98.8151125 C129.545766,98.8151125 130.970678,97.9927172 131.742055,96.6575563 C132.513327,95.3225768 132.513327,93.6774232 131.742055,92.3424437 C130.970678,91.0072828 129.545766,90.1848875 128.003794,90.1848875 L128.003794,90.1848875 Z M93,94.5009646 L100.767764,94.5009646",
682
- fill: "#FFD94C"
683
- }), /*#__PURE__*/React__namespace.createElement("path", {
684
- d: "M87.8601729,108.357758 C89.1715224,107.608286 90.8360246,108.074601 91.5779424,109.399303 L91.5779424,109.399303 L92.0525843,110.24352 C95.8563392,116.982993 99.8190116,123.380176 103.940602,129.435068 C108.807881,136.585427 114.28184,143.82411 120.362479,151.151115 C121.316878,152.30114 121.184944,154.011176 120.065686,154.997937 L120.065686,154.997937 L119.454208,155.534625 C99.3465389,173.103314 86.2778188,176.612552 80.2480482,166.062341 C74.3500652,155.742717 76.4844915,136.982888 86.6513274,109.782853 C86.876818,109.179582 87.3045861,108.675291 87.8601729,108.357758 Z M173.534177,129.041504 C174.986131,128.785177 176.375496,129.742138 176.65963,131.194242 L176.65963,131.194242 L176.812815,131.986376 C181.782365,157.995459 178.283348,171 166.315764,171 C154.609745,171 139.708724,159.909007 121.612702,137.727022 C121.211349,137.235047 120.994572,136.617371 121,135.981509 C121.013158,134.480686 122.235785,133.274651 123.730918,133.287756 L123.730918,133.287756 L124.684654,133.294531 C132.305698,133.335994 139.714387,133.071591 146.910723,132.501323 C155.409039,131.82788 164.283523,130.674607 173.534177,129.041504 Z M180.408726,73.8119663 C180.932139,72.4026903 182.508386,71.6634537 183.954581,72.149012 L183.954581,72.149012 L184.742552,72.4154854 C210.583763,81.217922 220.402356,90.8916805 214.198332,101.436761 C208.129904,111.751366 190.484347,119.260339 161.26166,123.963678 C160.613529,124.067994 159.948643,123.945969 159.382735,123.618843 C158.047025,122.846729 157.602046,121.158214 158.388848,119.847438 L158.388848,119.847438 L158.889328,119.0105 C162.877183,112.31633 166.481358,105.654262 169.701854,99.0242957 C173.50501,91.1948179 177.073967,82.7907081 180.408726,73.8119663 Z M94.7383398,66.0363218 C95.3864708,65.9320063 96.0513565,66.0540315 96.6172646,66.3811573 C97.9529754,67.153271 98.3979538,68.8417862 97.6111517,70.1525615 L97.6111517,70.1525615 L97.1106718,70.9895001 C93.1228168,77.6836699 89.5186416,84.3457379 86.2981462,90.9757043 C82.49499,98.8051821 78.9260328,107.209292 75.5912744,116.188034 C75.0678608,117.59731 73.4916142,118.336546 72.045419,117.850988 L72.045419,117.850988 L71.2574475,117.584515 C45.4162372,108.782078 35.597644,99.1083195 41.8016679,88.5632391 C47.8700957,78.2486335 65.515653,70.7396611 94.7383398,66.0363218 Z M136.545792,34.4653746 C156.653461,16.8966864 169.722181,13.3874478 175.751952,23.9376587 C181.649935,34.2572826 179.515508,53.0171122 169.348673,80.2171474 C169.123182,80.8204179 168.695414,81.324709 168.139827,81.6422422 C166.828478,82.3917144 165.163975,81.9253986 164.422058,80.6006966 L164.422058,80.6006966 L163.947416,79.7564798 C160.143661,73.0170065 156.180988,66.6198239 152.059398,60.564932 C147.192119,53.4145727 141.71816,46.1758903 135.637521,38.8488847 C134.683122,37.6988602 134.815056,35.9888243 135.934314,35.0020629 L135.934314,35.0020629 Z M90.6842361,18 C102.390255,18 117.291276,29.0909926 135.387298,51.2729777 C135.788651,51.7649527 136.005428,52.3826288 136,53.0184911 C135.986842,54.5193144 134.764215,55.7253489 133.269082,55.7122445 L133.269082,55.7122445 L132.315346,55.7054689 C124.694302,55.6640063 117.285613,55.9284091 110.089277,56.4986773 C101.590961,57.17212 92.7164767,58.325393 83.4658235,59.9584962 C82.0138691,60.2148231 80.6245044,59.2578618 80.3403697,57.805758 L80.3403697,57.805758 L80.1871846,57.0136235 C75.2176347,31.0045412 78.7166519,18 90.6842361,18 Z",
685
- fill: "#FF4154"
686
- }))));
687
- }
840
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
841
+ function noop() {}
688
842
 
689
- function ReactQueryDevtools$1({
690
- initialIsOpen,
691
- panelProps = {},
692
- closeButtonProps = {},
693
- toggleButtonProps = {},
694
- position = 'bottom-left',
695
- containerElement: Container = 'aside',
843
+ /**
844
+ * Panel for the query currently being inspected
845
+ *
846
+ * It displays query details (key, observers...), query actions,
847
+ * the data explorer and the query explorer
848
+ */
849
+ const ActiveQuery = ({
850
+ queryCache,
851
+ activeQueryHash,
696
852
  queryClient,
697
- styleNonce,
698
- panelPosition: initialPanelPosition = 'bottom'
699
- }) {
700
- const rootRef = React__namespace.useRef(null);
701
- const panelRef = React__namespace.useRef(null);
702
- const [isOpen, setIsOpen] = useLocalStorage('reactQueryDevtoolsOpen', initialIsOpen);
703
- const [devtoolsHeight, setDevtoolsHeight] = useLocalStorage('reactQueryDevtoolsHeight', defaultPanelSize);
704
- const [devtoolsWidth, setDevtoolsWidth] = useLocalStorage('reactQueryDevtoolsWidth', defaultPanelSize);
705
- const [panelPosition = 'bottom', setPanelPosition] = useLocalStorage('reactQueryDevtoolsPanelPosition', initialPanelPosition);
706
- const [isResolvedOpen, setIsResolvedOpen] = React__namespace.useState(false);
707
- const [isResizing, setIsResizing] = React__namespace.useState(false);
708
- const isMounted = useIsMounted();
709
- const handleDragStart = (panelElement, startEvent) => {
710
- if (!panelElement) return;
711
- if (startEvent.button !== 0) return; // Only allow left click for drag
712
- const isVertical = isVerticalSide(panelPosition);
713
- setIsResizing(true);
714
- const {
715
- height,
716
- width
717
- } = panelElement.getBoundingClientRect();
718
- const startX = startEvent.clientX;
719
- const startY = startEvent.clientY;
720
- let newSize = 0;
721
- const run = moveEvent => {
722
- // prevent mouse selecting stuff with mouse drag
723
- moveEvent.preventDefault();
724
-
725
- // calculate the correct size based on mouse position and current panel position
726
- // hint: it is different formula for the opposite sides
727
- if (isVertical) {
728
- newSize = width + (panelPosition === 'right' ? startX - moveEvent.clientX : moveEvent.clientX - startX);
729
- setDevtoolsWidth(newSize);
730
- } else {
731
- newSize = height + (panelPosition === 'bottom' ? startY - moveEvent.clientY : moveEvent.clientY - startY);
732
- setDevtoolsHeight(newSize);
733
- }
734
- if (newSize < minPanelSize) {
735
- setIsOpen(false);
736
- } else {
737
- setIsOpen(true);
738
- }
739
- };
740
- const unsub = () => {
741
- if (isResizing) {
742
- setIsResizing(false);
743
- }
744
- document.removeEventListener('mousemove', run, false);
745
- document.removeEventListener('mouseUp', unsub, false);
746
- };
747
- document.addEventListener('mousemove', run, false);
748
- document.addEventListener('mouseup', unsub, false);
853
+ errorTypes
854
+ }) => {
855
+ var _useSubscribeToQueryC, _useSubscribeToQueryC2;
856
+ const activeQuery = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash));
857
+ const activeQueryState = useSubscribeToQueryCache$1(queryCache, () => {
858
+ var _queryCache$getAll$fi;
859
+ return (_queryCache$getAll$fi = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi.state;
860
+ });
861
+ const isStale = (_useSubscribeToQueryC = useSubscribeToQueryCache$1(queryCache, () => {
862
+ var _queryCache$getAll$fi2;
863
+ return (_queryCache$getAll$fi2 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi2.isStale();
864
+ })) != null ? _useSubscribeToQueryC : false;
865
+ const observerCount = (_useSubscribeToQueryC2 = useSubscribeToQueryCache$1(queryCache, () => {
866
+ var _queryCache$getAll$fi3;
867
+ return (_queryCache$getAll$fi3 = queryCache.getAll().find(query => query.queryHash === activeQueryHash)) == null ? void 0 : _queryCache$getAll$fi3.getObserversCount();
868
+ })) != null ? _useSubscribeToQueryC2 : 0;
869
+ const handleRefetch = () => {
870
+ const promise = activeQuery == null ? void 0 : activeQuery.fetch();
871
+ promise == null ? void 0 : promise.catch(noop);
749
872
  };
750
- React__namespace.useEffect(() => {
751
- setIsResolvedOpen(isOpen ?? false);
752
- }, [isOpen, isResolvedOpen, setIsResolvedOpen]);
753
-
754
- // Toggle panel visibility before/after transition (depending on direction).
755
- // Prevents focusing in a closed panel.
756
- React__namespace.useEffect(() => {
757
- const ref = panelRef.current;
758
- if (ref) {
759
- const handlePanelTransitionStart = () => {
760
- if (isResolvedOpen) {
761
- ref.style.visibility = 'visible';
762
- }
763
- };
764
- const handlePanelTransitionEnd = () => {
765
- if (!isResolvedOpen) {
766
- ref.style.visibility = 'hidden';
767
- }
768
- };
769
- ref.addEventListener('transitionstart', handlePanelTransitionStart);
770
- ref.addEventListener('transitionend', handlePanelTransitionEnd);
771
- return () => {
772
- ref.removeEventListener('transitionstart', handlePanelTransitionStart);
773
- ref.removeEventListener('transitionend', handlePanelTransitionEnd);
774
- };
873
+ const currentErrorTypeName = React.useMemo(() => {
874
+ if (activeQuery && activeQueryState != null && activeQueryState.error) {
875
+ const errorType = errorTypes.find(type => {
876
+ var _activeQueryState$err;
877
+ return type.initializer(activeQuery).toString() === ((_activeQueryState$err = activeQueryState.error) == null ? void 0 : _activeQueryState$err.toString());
878
+ });
879
+ return errorType == null ? void 0 : errorType.name;
775
880
  }
776
- return;
777
- }, [isResolvedOpen]);
778
- React__namespace.useEffect(() => {
779
- if (isResolvedOpen && rootRef.current?.parentElement) {
780
- const {
781
- parentElement
782
- } = rootRef.current;
783
- const styleProp = getSidedProp('padding', panelPosition);
784
- const isVertical = isVerticalSide(panelPosition);
785
- const previousPaddings = (({
786
- padding,
787
- paddingTop,
788
- paddingBottom,
789
- paddingLeft,
790
- paddingRight
791
- }) => ({
792
- padding,
793
- paddingTop,
794
- paddingBottom,
795
- paddingLeft,
796
- paddingRight
797
- }))(parentElement.style);
798
- const run = () => {
799
- // reset the padding
800
- parentElement.style.padding = '0px';
801
- parentElement.style.paddingTop = '0px';
802
- parentElement.style.paddingBottom = '0px';
803
- parentElement.style.paddingLeft = '0px';
804
- parentElement.style.paddingRight = '0px';
805
- // set the new padding based on the new panel position
806
-
807
- parentElement.style[styleProp] = `${isVertical ? devtoolsWidth : devtoolsHeight}px`;
808
- };
809
- run();
810
- if (typeof window !== 'undefined') {
811
- window.addEventListener('resize', run);
812
- return () => {
813
- window.removeEventListener('resize', run);
814
- Object.entries(previousPaddings).forEach(([property, previousValue]) => {
815
- parentElement.style[property] = previousValue;
816
- });
817
- };
881
+ return undefined;
882
+ }, [activeQuery, activeQueryState == null ? void 0 : activeQueryState.error, errorTypes]);
883
+ if (!activeQuery || !activeQueryState) {
884
+ return null;
885
+ }
886
+ const triggerError = errorType => {
887
+ var _errorType$initialize;
888
+ const error = (_errorType$initialize = errorType == null ? void 0 : errorType.initializer(activeQuery)) != null ? _errorType$initialize : new Error('Unknown error from devtools');
889
+ const __previousQueryOptions = activeQuery.options;
890
+ activeQuery.setState({
891
+ status: 'error',
892
+ error,
893
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
894
+ fetchMeta: {
895
+ ...activeQuery.state.fetchMeta,
896
+ __previousQueryOptions
818
897
  }
819
- }
820
- return;
821
- }, [isResolvedOpen, panelPosition, devtoolsHeight, devtoolsWidth]);
822
- const {
823
- style: panelStyle = {},
824
- ...otherPanelProps
825
- } = panelProps;
826
- const {
827
- style: toggleButtonStyle = {},
828
- onClick: onToggleClick,
829
- ...otherToggleButtonProps
830
- } = toggleButtonProps;
831
-
832
- // get computed style based on panel position
833
- const style = getSidePanelStyle({
834
- position: panelPosition,
835
- devtoolsTheme: defaultTheme,
836
- isOpen: isResolvedOpen,
837
- height: devtoolsHeight,
838
- width: devtoolsWidth,
839
- isResizing,
840
- panelStyle
841
- });
842
-
843
- // Do not render on the server
844
- if (!isMounted()) return null;
845
- return /*#__PURE__*/React__namespace.createElement(Container, {
846
- ref: rootRef,
847
- className: "ReactQueryDevtools",
848
- "aria-label": "React Query Devtools"
849
- }, /*#__PURE__*/React__namespace.createElement(ThemeProvider, {
850
- theme: defaultTheme
851
- }, /*#__PURE__*/React__namespace.createElement(ReactQueryDevtoolsPanel$1, _extends({
852
- ref: panelRef,
853
- queryClient: queryClient,
854
- styleNonce: styleNonce,
855
- position: panelPosition,
856
- onPositionChange: setPanelPosition,
857
- showCloseButton: true,
858
- closeButtonProps: closeButtonProps
859
- }, otherPanelProps, {
860
- style: style,
861
- isOpen: isResolvedOpen,
862
- setIsOpen: setIsOpen,
863
- onDragStart: e => handleDragStart(panelRef.current, e)
864
- }))), !isResolvedOpen ? /*#__PURE__*/React__namespace.createElement("button", _extends({
865
- type: "button"
866
- }, otherToggleButtonProps, {
867
- "aria-label": "Open React Query Devtools",
868
- "aria-controls": "ReactQueryDevtoolsPanel",
869
- "aria-haspopup": "true",
870
- "aria-expanded": "false",
871
- onClick: e => {
872
- setIsOpen(true);
873
- onToggleClick?.(e);
874
- },
898
+ });
899
+ };
900
+ const restoreQueryAfterLoadingOrError = () => {
901
+ activeQuery.fetch(activeQuery.state.fetchMeta.__previousQueryOptions, {
902
+ // Make sure this fetch will cancel the previous one
903
+ cancelRefetch: true
904
+ });
905
+ };
906
+ return /*#__PURE__*/React.createElement(ActiveQueryPanel, null, /*#__PURE__*/React.createElement("div", {
875
907
  style: {
876
- background: 'none',
877
- border: 0,
878
- padding: 0,
879
- position: 'fixed',
880
- zIndex: 99999,
881
- display: 'inline-flex',
882
- fontSize: '1.5em',
883
- margin: '.5em',
884
- cursor: 'pointer',
885
- width: 'fit-content',
886
- ...(position === 'top-right' ? {
887
- top: '0',
888
- right: '0'
889
- } : position === 'top-left' ? {
890
- top: '0',
891
- left: '0'
892
- } : position === 'bottom-right' ? {
893
- bottom: '0',
894
- right: '0'
895
- } : {
896
- bottom: '0',
897
- left: '0'
898
- }),
899
- ...toggleButtonStyle
900
- }
901
- }), /*#__PURE__*/React__namespace.createElement(Logo, {
902
- "aria-hidden": true
903
- }), /*#__PURE__*/React__namespace.createElement(ScreenReader, {
904
- text: "Open React Query Devtools"
905
- })) : null);
906
- }
907
- const useSubscribeToQueryCache = (queryCache, getSnapshot, skip = false) => {
908
- return React__namespace.useSyncExternalStore(React__namespace.useCallback(onStoreChange => {
909
- if (!skip) return queryCache.subscribe(reactQuery.notifyManager.batchCalls(onStoreChange));
910
- return () => {
911
- return;
912
- };
913
- }, [queryCache, skip]), getSnapshot, getSnapshot);
914
- };
915
- const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
916
- const {
917
- isOpen = true,
918
- styleNonce,
919
- setIsOpen,
920
- queryClient,
921
- onDragStart,
922
- onPositionChange,
923
- showCloseButton,
924
- position,
925
- closeButtonProps = {},
926
- ...panelProps
927
- } = props;
928
- const {
929
- onClick: onCloseClick,
930
- ...otherCloseButtonProps
931
- } = closeButtonProps;
932
- const client = reactQuery.useQueryClient(queryClient);
933
- const queryCache = client.getQueryCache();
934
- const [sort, setSort] = useLocalStorage('reactQueryDevtoolsSortFn', Object.keys(sortFns)[0]);
935
- const [filter, setFilter] = useLocalStorage('reactQueryDevtoolsFilter', '');
936
- const [baseSort, setBaseSort] = useLocalStorage('reactQueryDevtoolsBaseSort', 1);
937
- const sortFn = React__namespace.useMemo(() => sortFns[sort], [sort]);
938
- const queriesCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().length, !isOpen);
939
- const [activeQueryHash, setActiveQueryHash] = useLocalStorage('reactQueryDevtoolsActiveQueryHash', '');
940
- const queries = React__namespace.useMemo(() => {
941
- const unsortedQueries = queryCache.getAll();
942
- if (queriesCount === 0) {
943
- return [];
908
+ padding: '.5em',
909
+ background: defaultTheme.backgroundAlt,
910
+ position: 'sticky',
911
+ top: 0,
912
+ zIndex: 1
944
913
  }
945
- const filtered = filter ? unsortedQueries.filter(item => matchSorterUtils.rankItem(item.queryHash, filter).passed) : [...unsortedQueries];
946
- const sorted = sortFn ? filtered.sort((a, b) => sortFn(a, b) * baseSort) : filtered;
947
- return sorted;
948
- }, [baseSort, sortFn, filter, queriesCount, queryCache]);
949
- const [isMockOffline, setMockOffline] = React__namespace.useState(false);
950
- return /*#__PURE__*/React__namespace.createElement(ThemeProvider, {
951
- theme: defaultTheme
952
- }, /*#__PURE__*/React__namespace.createElement(Panel, _extends({
953
- ref: ref,
954
- className: "ReactQueryDevtoolsPanel",
955
- "aria-label": "React Query Devtools Panel",
956
- id: "ReactQueryDevtoolsPanel"
957
- }, panelProps, {
914
+ }, "Query Details"), /*#__PURE__*/React.createElement("div", {
958
915
  style: {
959
- height: defaultPanelSize,
960
- position: 'relative',
961
- ...panelProps.style
962
- }
963
- }), /*#__PURE__*/React__namespace.createElement("style", {
964
- nonce: styleNonce,
965
- dangerouslySetInnerHTML: {
966
- __html: `
967
- .ReactQueryDevtoolsPanel * {
968
- scrollbar-color: ${defaultTheme.backgroundAlt} ${defaultTheme.gray};
969
- }
970
-
971
- .ReactQueryDevtoolsPanel *::-webkit-scrollbar, .ReactQueryDevtoolsPanel scrollbar {
972
- width: 1em;
973
- height: 1em;
974
- }
975
-
976
- .ReactQueryDevtoolsPanel *::-webkit-scrollbar-track, .ReactQueryDevtoolsPanel scrollbar-track {
977
- background: ${defaultTheme.backgroundAlt};
978
- }
979
-
980
- .ReactQueryDevtoolsPanel *::-webkit-scrollbar-thumb, .ReactQueryDevtoolsPanel scrollbar-thumb {
981
- background: ${defaultTheme.gray};
982
- border-radius: .5em;
983
- border: 3px solid ${defaultTheme.backgroundAlt};
984
- }
985
- `
916
+ padding: '.5em'
986
917
  }
987
- }), /*#__PURE__*/React__namespace.createElement("div", {
988
- style: getResizeHandleStyle(position),
989
- onMouseDown: onDragStart
990
- }), isOpen && /*#__PURE__*/React__namespace.createElement("div", {
918
+ }, /*#__PURE__*/React.createElement("div", {
991
919
  style: {
992
- flex: '1 1 500px',
993
- minHeight: '40%',
994
- maxHeight: '100%',
995
- overflow: 'auto',
996
- borderRight: `1px solid ${defaultTheme.grayAlt}`,
920
+ marginBottom: '.5em',
997
921
  display: 'flex',
998
- flexDirection: 'column'
922
+ alignItems: 'flex-start',
923
+ justifyContent: 'space-between'
999
924
  }
1000
- }, /*#__PURE__*/React__namespace.createElement("div", {
925
+ }, /*#__PURE__*/React.createElement(Code, {
1001
926
  style: {
1002
- padding: '.5em',
1003
- background: defaultTheme.backgroundAlt,
1004
- display: 'flex',
1005
- justifyContent: 'space-between',
1006
- alignItems: 'center'
927
+ lineHeight: '1.8em'
1007
928
  }
1008
- }, /*#__PURE__*/React__namespace.createElement("button", {
1009
- type: "button",
1010
- "aria-label": "Close React Query Devtools",
1011
- "aria-controls": "ReactQueryDevtoolsPanel",
1012
- "aria-haspopup": "true",
1013
- "aria-expanded": "true",
1014
- onClick: () => setIsOpen(false),
929
+ }, /*#__PURE__*/React.createElement("pre", {
1015
930
  style: {
1016
- display: 'inline-flex',
1017
- background: 'none',
1018
- border: 0,
931
+ margin: 0,
1019
932
  padding: 0,
1020
- marginRight: '.5em',
1021
- cursor: 'pointer'
933
+ overflow: 'auto'
1022
934
  }
1023
- }, /*#__PURE__*/React__namespace.createElement(Logo, {
1024
- "aria-hidden": true
1025
- }), /*#__PURE__*/React__namespace.createElement(ScreenReader, {
1026
- text: "Close React Query Devtools"
1027
- })), /*#__PURE__*/React__namespace.createElement("div", {
935
+ }, displayValue(activeQuery.queryKey, true))), /*#__PURE__*/React.createElement("span", {
1028
936
  style: {
1029
- display: 'flex',
1030
- flexDirection: 'column'
937
+ padding: '0.3em .6em',
938
+ borderRadius: '0.4em',
939
+ fontWeight: 'bold',
940
+ textShadow: '0 2px 10px black',
941
+ background: getQueryStatusColor({
942
+ queryState: activeQueryState,
943
+ isStale: isStale,
944
+ observerCount: observerCount,
945
+ theme: defaultTheme
946
+ }),
947
+ flexShrink: 0
1031
948
  }
1032
- }, /*#__PURE__*/React__namespace.createElement("div", {
949
+ }, getQueryStatusLabel(activeQuery))), /*#__PURE__*/React.createElement("div", {
1033
950
  style: {
951
+ marginBottom: '.5em',
1034
952
  display: 'flex',
1035
- justifyContent: 'space-between',
1036
953
  alignItems: 'center',
1037
- marginBottom: '.5em'
954
+ justifyContent: 'space-between'
1038
955
  }
1039
- }, /*#__PURE__*/React__namespace.createElement(QueryStatusCount, {
1040
- queryCache: queryCache
1041
- }), position && onPositionChange ? /*#__PURE__*/React__namespace.createElement(Select, {
956
+ }, "Observers: ", /*#__PURE__*/React.createElement(Code, null, observerCount)), /*#__PURE__*/React.createElement("div", {
957
+ style: {
958
+ display: 'flex',
959
+ alignItems: 'center',
960
+ justifyContent: 'space-between'
961
+ }
962
+ }, "Last Updated:", ' ', /*#__PURE__*/React.createElement(Code, null, new Date(activeQueryState.dataUpdatedAt).toLocaleTimeString()))), /*#__PURE__*/React.createElement("div", {
963
+ style: {
964
+ background: defaultTheme.backgroundAlt,
965
+ padding: '.5em',
966
+ position: 'sticky',
967
+ top: 0,
968
+ zIndex: 1
969
+ }
970
+ }, "Actions"), /*#__PURE__*/React.createElement("div", {
971
+ style: {
972
+ padding: '0.5em',
973
+ display: 'flex',
974
+ flexWrap: 'wrap',
975
+ gap: '0.5em',
976
+ alignItems: 'flex-end'
977
+ }
978
+ }, /*#__PURE__*/React.createElement(Button, {
979
+ type: "button",
980
+ onClick: handleRefetch,
981
+ disabled: activeQueryState.fetchStatus === 'fetching',
982
+ style: {
983
+ background: defaultTheme.active
984
+ }
985
+ }, "Refetch"), ' ', /*#__PURE__*/React.createElement(Button, {
986
+ type: "button",
987
+ onClick: () => queryClient.invalidateQueries(activeQuery),
988
+ style: {
989
+ background: defaultTheme.warning,
990
+ color: defaultTheme.inputTextColor
991
+ }
992
+ }, "Invalidate"), ' ', /*#__PURE__*/React.createElement(Button, {
993
+ type: "button",
994
+ onClick: () => queryClient.resetQueries(activeQuery),
995
+ style: {
996
+ background: defaultTheme.gray
997
+ }
998
+ }, "Reset"), ' ', /*#__PURE__*/React.createElement(Button, {
999
+ type: "button",
1000
+ onClick: () => queryClient.removeQueries(activeQuery),
1001
+ style: {
1002
+ background: defaultTheme.danger
1003
+ }
1004
+ }, "Remove"), ' ', /*#__PURE__*/React.createElement(Button, {
1005
+ type: "button",
1006
+ onClick: () => {
1007
+ if (activeQuery.state.data === undefined) {
1008
+ restoreQueryAfterLoadingOrError();
1009
+ } else {
1010
+ const __previousQueryOptions = activeQuery.options;
1011
+ // Trigger a fetch in order to trigger suspense as well.
1012
+ activeQuery.fetch({
1013
+ ...__previousQueryOptions,
1014
+ queryFn: () => {
1015
+ return new Promise(() => {
1016
+ // Never resolve
1017
+ });
1018
+ },
1019
+ gcTime: -1
1020
+ });
1021
+ activeQuery.setState({
1022
+ data: undefined,
1023
+ status: 'pending',
1024
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
1025
+ fetchMeta: {
1026
+ ...activeQuery.state.fetchMeta,
1027
+ __previousQueryOptions
1028
+ }
1029
+ });
1030
+ }
1031
+ },
1032
+ style: {
1033
+ background: defaultTheme.paused
1034
+ }
1035
+ }, activeQuery.state.status === 'pending' ? 'Restore' : 'Trigger', ' ', "loading"), ' ', errorTypes.length === 0 || activeQuery.state.status === 'error' ? /*#__PURE__*/React.createElement(Button, {
1036
+ type: "button",
1037
+ onClick: () => {
1038
+ if (!activeQuery.state.error) {
1039
+ triggerError();
1040
+ } else {
1041
+ queryClient.resetQueries(activeQuery);
1042
+ }
1043
+ },
1044
+ style: {
1045
+ background: defaultTheme.danger
1046
+ }
1047
+ }, activeQuery.state.status === 'error' ? 'Restore' : 'Trigger', " error") : /*#__PURE__*/React.createElement("label", null, "Trigger error:", /*#__PURE__*/React.createElement(Select, {
1048
+ value: currentErrorTypeName != null ? currentErrorTypeName : '',
1049
+ style: {
1050
+ marginInlineStart: '.5em'
1051
+ },
1052
+ onChange: e => {
1053
+ const errorType = errorTypes.find(t => t.name === e.target.value);
1054
+ triggerError(errorType);
1055
+ }
1056
+ }, /*#__PURE__*/React.createElement("option", {
1057
+ key: "",
1058
+ value: ""
1059
+ }), errorTypes.map(errorType => /*#__PURE__*/React.createElement("option", {
1060
+ key: errorType.name,
1061
+ value: errorType.name
1062
+ }, errorType.name))))), /*#__PURE__*/React.createElement("div", {
1063
+ style: {
1064
+ background: defaultTheme.backgroundAlt,
1065
+ padding: '.5em',
1066
+ position: 'sticky',
1067
+ top: 0,
1068
+ zIndex: 1
1069
+ }
1070
+ }, "Data Explorer"), /*#__PURE__*/React.createElement("div", {
1071
+ style: {
1072
+ padding: '.5em'
1073
+ }
1074
+ }, /*#__PURE__*/React.createElement(Explorer, {
1075
+ label: "Data",
1076
+ value: activeQueryState.data,
1077
+ defaultExpanded: {},
1078
+ copyable: true
1079
+ })), /*#__PURE__*/React.createElement("div", {
1080
+ style: {
1081
+ background: defaultTheme.backgroundAlt,
1082
+ padding: '.5em',
1083
+ position: 'sticky',
1084
+ top: 0,
1085
+ zIndex: 1
1086
+ }
1087
+ }, "Query Explorer"), /*#__PURE__*/React.createElement("div", {
1088
+ style: {
1089
+ padding: '.5em'
1090
+ }
1091
+ }, /*#__PURE__*/React.createElement(Explorer, {
1092
+ label: "Query",
1093
+ value: activeQuery,
1094
+ defaultExpanded: {
1095
+ queryKey: true
1096
+ }
1097
+ })));
1098
+ };
1099
+ ActiveQuery.displayName = 'ActiveQuery';
1100
+ var ActiveQuery$1 = ActiveQuery;
1101
+
1102
+ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React.forwardRef(function ReactQueryDevtoolsPanel(props, ref) {
1103
+ const {
1104
+ isOpen = true,
1105
+ styleNonce,
1106
+ setIsOpen,
1107
+ queryClient,
1108
+ onDragStart,
1109
+ onPositionChange,
1110
+ showCloseButton,
1111
+ position,
1112
+ closeButtonProps = {},
1113
+ errorTypes = [],
1114
+ ...panelProps
1115
+ } = props;
1116
+ const {
1117
+ onClick: onCloseClick,
1118
+ ...otherCloseButtonProps
1119
+ } = closeButtonProps;
1120
+ const client = reactQuery.useQueryClient(queryClient);
1121
+ const queryCache = client.getQueryCache();
1122
+ const [sort, setSort] = useLocalStorage('reactQueryDevtoolsSortFn', Object.keys(sortFns)[0]);
1123
+ const [filter, setFilter] = useLocalStorage('reactQueryDevtoolsFilter', '');
1124
+ const [baseSort, setBaseSort] = useLocalStorage('reactQueryDevtoolsBaseSort', 1);
1125
+ const sortFn = React.useMemo(() => sortFns[sort], [sort]);
1126
+ const queriesCount = useSubscribeToQueryCache$1(queryCache, () => queryCache.getAll().length, !isOpen);
1127
+ const [activeQueryHash, setActiveQueryHash] = useLocalStorage('reactQueryDevtoolsActiveQueryHash', '');
1128
+ const queries = React.useMemo(() => {
1129
+ const unsortedQueries = queryCache.getAll();
1130
+ if (queriesCount === 0) {
1131
+ return [];
1132
+ }
1133
+ const filtered = filter ? unsortedQueries.filter(item => matchSorterUtils.rankItem(item.queryHash, filter).passed) : [...unsortedQueries];
1134
+ const sorted = sortFn ? filtered.sort((a, b) => sortFn(a, b) * baseSort) : filtered;
1135
+ return sorted;
1136
+ }, [baseSort, sortFn, filter, queriesCount, queryCache]);
1137
+ const [isMockOffline, setMockOffline] = React.useState(false);
1138
+ return /*#__PURE__*/React.createElement(ThemeProvider, {
1139
+ theme: defaultTheme
1140
+ }, /*#__PURE__*/React.createElement(Panel, _extends({
1141
+ ref: ref,
1142
+ className: "ReactQueryDevtoolsPanel",
1143
+ "aria-label": "React Query Devtools Panel",
1144
+ id: "ReactQueryDevtoolsPanel"
1145
+ }, panelProps, {
1146
+ style: {
1147
+ height: defaultPanelSize,
1148
+ position: 'relative',
1149
+ ...panelProps.style
1150
+ }
1151
+ }), /*#__PURE__*/React.createElement("style", {
1152
+ nonce: styleNonce,
1153
+ dangerouslySetInnerHTML: {
1154
+ __html: `
1155
+ .ReactQueryDevtoolsPanel * {
1156
+ scrollbar-color: ${defaultTheme.backgroundAlt} ${defaultTheme.gray};
1157
+ }
1158
+
1159
+ .ReactQueryDevtoolsPanel *::-webkit-scrollbar, .ReactQueryDevtoolsPanel scrollbar {
1160
+ width: 1em;
1161
+ height: 1em;
1162
+ }
1163
+
1164
+ .ReactQueryDevtoolsPanel *::-webkit-scrollbar-track, .ReactQueryDevtoolsPanel scrollbar-track {
1165
+ background: ${defaultTheme.backgroundAlt};
1166
+ }
1167
+
1168
+ .ReactQueryDevtoolsPanel *::-webkit-scrollbar-thumb, .ReactQueryDevtoolsPanel scrollbar-thumb {
1169
+ background: ${defaultTheme.gray};
1170
+ border-radius: .5em;
1171
+ border: 3px solid ${defaultTheme.backgroundAlt};
1172
+ }
1173
+ `
1174
+ }
1175
+ }), /*#__PURE__*/React.createElement("div", {
1176
+ style: getResizeHandleStyle(position),
1177
+ onMouseDown: onDragStart
1178
+ }), isOpen && /*#__PURE__*/React.createElement("div", {
1179
+ style: {
1180
+ flex: '1 1 500px',
1181
+ minHeight: '40%',
1182
+ maxHeight: '100%',
1183
+ overflow: 'auto',
1184
+ borderRight: `1px solid ${defaultTheme.grayAlt}`,
1185
+ display: 'flex',
1186
+ flexDirection: 'column'
1187
+ }
1188
+ }, /*#__PURE__*/React.createElement("div", {
1189
+ style: {
1190
+ padding: '.5em',
1191
+ background: defaultTheme.backgroundAlt,
1192
+ display: 'flex',
1193
+ justifyContent: 'space-between',
1194
+ alignItems: 'center'
1195
+ }
1196
+ }, /*#__PURE__*/React.createElement("button", {
1197
+ type: "button",
1198
+ "aria-label": "Close React Query Devtools",
1199
+ "aria-controls": "ReactQueryDevtoolsPanel",
1200
+ "aria-haspopup": "true",
1201
+ "aria-expanded": "true",
1202
+ onClick: () => setIsOpen(false),
1203
+ style: {
1204
+ display: 'inline-flex',
1205
+ background: 'none',
1206
+ border: 0,
1207
+ padding: 0,
1208
+ marginRight: '.5em',
1209
+ cursor: 'pointer'
1210
+ }
1211
+ }, /*#__PURE__*/React.createElement(Logo, {
1212
+ "aria-hidden": true
1213
+ }), /*#__PURE__*/React.createElement(ScreenReader, {
1214
+ text: "Close React Query Devtools"
1215
+ })), /*#__PURE__*/React.createElement("div", {
1216
+ style: {
1217
+ display: 'flex',
1218
+ flexDirection: 'column'
1219
+ }
1220
+ }, /*#__PURE__*/React.createElement("div", {
1221
+ style: {
1222
+ display: 'flex',
1223
+ justifyContent: 'space-between',
1224
+ alignItems: 'center',
1225
+ marginBottom: '.5em'
1226
+ }
1227
+ }, /*#__PURE__*/React.createElement(QueryStatusCount, {
1228
+ queryCache: queryCache
1229
+ }), position && onPositionChange ? /*#__PURE__*/React.createElement(Select, {
1042
1230
  "aria-label": "Panel position",
1043
1231
  value: position,
1044
1232
  style: {
1045
1233
  marginInlineStart: '.5em'
1046
1234
  },
1047
1235
  onChange: e => onPositionChange(e.target.value)
1048
- }, /*#__PURE__*/React__namespace.createElement("option", {
1236
+ }, /*#__PURE__*/React.createElement("option", {
1049
1237
  value: "left"
1050
- }, "Left"), /*#__PURE__*/React__namespace.createElement("option", {
1238
+ }, "Left"), /*#__PURE__*/React.createElement("option", {
1051
1239
  value: "right"
1052
- }, "Right"), /*#__PURE__*/React__namespace.createElement("option", {
1240
+ }, "Right"), /*#__PURE__*/React.createElement("option", {
1053
1241
  value: "top"
1054
- }, "Top"), /*#__PURE__*/React__namespace.createElement("option", {
1242
+ }, "Top"), /*#__PURE__*/React.createElement("option", {
1055
1243
  value: "bottom"
1056
- }, "Bottom")) : null), /*#__PURE__*/React__namespace.createElement("div", {
1244
+ }, "Bottom")) : null), /*#__PURE__*/React.createElement("div", {
1057
1245
  style: {
1058
1246
  display: 'flex',
1059
- alignItems: 'center'
1247
+ alignItems: 'center',
1248
+ flexWrap: 'wrap',
1249
+ gap: '0.5em'
1060
1250
  }
1061
- }, /*#__PURE__*/React__namespace.createElement(Input, {
1251
+ }, /*#__PURE__*/React.createElement(Input, {
1062
1252
  placeholder: "Filter",
1063
1253
  "aria-label": "Filter by queryhash",
1064
- value: filter ?? '',
1254
+ value: filter != null ? filter : '',
1065
1255
  onChange: e => setFilter(e.target.value),
1066
1256
  onKeyDown: e => {
1067
1257
  if (e.key === 'Escape') setFilter('');
1068
1258
  },
1069
1259
  style: {
1070
1260
  flex: '1',
1071
- marginRight: '.5em',
1072
1261
  width: '100%'
1073
1262
  }
1074
- }), /*#__PURE__*/React__namespace.createElement(Select, {
1263
+ }), /*#__PURE__*/React.createElement(Select, {
1075
1264
  "aria-label": "Sort queries",
1076
1265
  value: sort,
1077
1266
  onChange: e => setSort(e.target.value),
@@ -1080,17 +1269,26 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
1080
1269
  minWidth: 75,
1081
1270
  marginRight: '.5em'
1082
1271
  }
1083
- }, Object.keys(sortFns).map(key => /*#__PURE__*/React__namespace.createElement("option", {
1272
+ }, Object.keys(sortFns).map(key => /*#__PURE__*/React.createElement("option", {
1084
1273
  key: key,
1085
1274
  value: key
1086
- }, "Sort by ", key))), /*#__PURE__*/React__namespace.createElement(Button, {
1275
+ }, "Sort by ", key))), /*#__PURE__*/React.createElement(Button, {
1087
1276
  type: "button",
1088
1277
  onClick: () => setBaseSort(old => old * -1),
1089
1278
  style: {
1090
1279
  padding: '.3em .4em',
1091
1280
  marginRight: '.5em'
1092
1281
  }
1093
- }, baseSort === 1 ? '⬆ Asc' : '⬇ Desc'), /*#__PURE__*/React__namespace.createElement(Button, {
1282
+ }, baseSort === 1 ? '⬆ Asc' : '⬇ Desc'), /*#__PURE__*/React.createElement(Button, {
1283
+ title: "Clear cache",
1284
+ "aria-label": "Clear cache",
1285
+ type: "button",
1286
+ onClick: () => queryCache.clear(),
1287
+ style: {
1288
+ padding: '.3em .4em',
1289
+ marginRight: '.5em'
1290
+ }
1291
+ }, "Clear"), /*#__PURE__*/React.createElement(Button, {
1094
1292
  type: "button",
1095
1293
  onClick: () => {
1096
1294
  if (isMockOffline) {
@@ -1100,6 +1298,7 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
1100
1298
  } else {
1101
1299
  reactQuery.onlineManager.setOnline(false);
1102
1300
  setMockOffline(true);
1301
+ window.dispatchEvent(new Event('offline'));
1103
1302
  }
1104
1303
  },
1105
1304
  "aria-label": isMockOffline ? 'Restore offline mock' : 'Mock offline behavior',
@@ -1108,68 +1307,69 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
1108
1307
  padding: '0',
1109
1308
  height: '2em'
1110
1309
  }
1111
- }, /*#__PURE__*/React__namespace.createElement("svg", {
1310
+ }, /*#__PURE__*/React.createElement("svg", {
1112
1311
  xmlns: "http://www.w3.org/2000/svg",
1113
1312
  width: "2em",
1114
1313
  height: "2em",
1115
1314
  viewBox: "0 0 24 24",
1116
1315
  stroke: isMockOffline ? defaultTheme.danger : 'currentColor',
1117
1316
  fill: "none"
1118
- }, isMockOffline ? /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("path", {
1317
+ }, isMockOffline ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("path", {
1119
1318
  stroke: "none",
1120
1319
  d: "M0 0h24v24H0z",
1121
1320
  fill: "none"
1122
- }), /*#__PURE__*/React__namespace.createElement("line", {
1321
+ }), /*#__PURE__*/React.createElement("line", {
1123
1322
  x1: "12",
1124
1323
  y1: "18",
1125
1324
  x2: "12.01",
1126
1325
  y2: "18"
1127
- }), /*#__PURE__*/React__namespace.createElement("path", {
1326
+ }), /*#__PURE__*/React.createElement("path", {
1128
1327
  d: "M9.172 15.172a4 4 0 0 1 5.656 0"
1129
- }), /*#__PURE__*/React__namespace.createElement("path", {
1328
+ }), /*#__PURE__*/React.createElement("path", {
1130
1329
  d: "M6.343 12.343a7.963 7.963 0 0 1 3.864 -2.14m4.163 .155a7.965 7.965 0 0 1 3.287 2"
1131
- }), /*#__PURE__*/React__namespace.createElement("path", {
1330
+ }), /*#__PURE__*/React.createElement("path", {
1132
1331
  d: "M3.515 9.515a12 12 0 0 1 3.544 -2.455m3.101 -.92a12 12 0 0 1 10.325 3.374"
1133
- }), /*#__PURE__*/React__namespace.createElement("line", {
1332
+ }), /*#__PURE__*/React.createElement("line", {
1134
1333
  x1: "3",
1135
1334
  y1: "3",
1136
1335
  x2: "21",
1137
1336
  y2: "21"
1138
- })) : /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("path", {
1337
+ })) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("path", {
1139
1338
  stroke: "none",
1140
1339
  d: "M0 0h24v24H0z",
1141
1340
  fill: "none"
1142
- }), /*#__PURE__*/React__namespace.createElement("line", {
1341
+ }), /*#__PURE__*/React.createElement("line", {
1143
1342
  x1: "12",
1144
1343
  y1: "18",
1145
1344
  x2: "12.01",
1146
1345
  y2: "18"
1147
- }), /*#__PURE__*/React__namespace.createElement("path", {
1346
+ }), /*#__PURE__*/React.createElement("path", {
1148
1347
  d: "M9.172 15.172a4 4 0 0 1 5.656 0"
1149
- }), /*#__PURE__*/React__namespace.createElement("path", {
1348
+ }), /*#__PURE__*/React.createElement("path", {
1150
1349
  d: "M6.343 12.343a8 8 0 0 1 11.314 0"
1151
- }), /*#__PURE__*/React__namespace.createElement("path", {
1350
+ }), /*#__PURE__*/React.createElement("path", {
1152
1351
  d: "M3.515 9.515c4.686 -4.687 12.284 -4.687 17 0"
1153
- }))), /*#__PURE__*/React__namespace.createElement(ScreenReader, {
1352
+ }))), /*#__PURE__*/React.createElement(ScreenReader, {
1154
1353
  text: isMockOffline ? 'Restore offline mock' : 'Mock offline behavior'
1155
- }))))), /*#__PURE__*/React__namespace.createElement("div", {
1354
+ }))))), /*#__PURE__*/React.createElement("div", {
1156
1355
  style: {
1157
1356
  overflowY: 'auto',
1158
1357
  flex: '1'
1159
1358
  }
1160
1359
  }, queries.map(query => {
1161
- return /*#__PURE__*/React__namespace.createElement(QueryRow, {
1360
+ return /*#__PURE__*/React.createElement(QueryRow$1, {
1162
1361
  queryKey: query.queryKey,
1163
1362
  activeQueryHash: activeQueryHash,
1164
1363
  setActiveQueryHash: setActiveQueryHash,
1165
1364
  key: query.queryHash,
1166
1365
  queryCache: queryCache
1167
1366
  });
1168
- }))), activeQueryHash && isOpen ? /*#__PURE__*/React__namespace.createElement(ActiveQuery, {
1367
+ }))), activeQueryHash && isOpen ? /*#__PURE__*/React.createElement(ActiveQuery$1, {
1169
1368
  activeQueryHash: activeQueryHash,
1170
1369
  queryCache: queryCache,
1171
- queryClient: client
1172
- }) : null, showCloseButton ? /*#__PURE__*/React__namespace.createElement(Button, _extends({
1370
+ queryClient: client,
1371
+ errorTypes: errorTypes
1372
+ }) : null, showCloseButton ? /*#__PURE__*/React.createElement(Button, _extends({
1173
1373
  type: "button",
1174
1374
  "aria-controls": "ReactQueryDevtoolsPanel",
1175
1375
  "aria-haspopup": "true",
@@ -1185,268 +1385,237 @@ const ReactQueryDevtoolsPanel$1 = /*#__PURE__*/React__namespace.forwardRef(funct
1185
1385
  },
1186
1386
  onClick: e => {
1187
1387
  setIsOpen(false);
1188
- onCloseClick?.(e);
1388
+ onCloseClick == null ? void 0 : onCloseClick(e);
1189
1389
  }
1190
1390
  }), "Close") : null));
1191
1391
  });
1192
- const ActiveQuery = ({
1193
- queryCache,
1194
- activeQueryHash,
1195
- queryClient
1196
- }) => {
1197
- const activeQuery = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash));
1198
- const activeQueryState = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.state);
1199
- const isStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.isStale()) ?? false;
1200
- const observerCount = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().find(query => query.queryHash === activeQueryHash)?.getObserversCount()) ?? 0;
1201
- const handleRefetch = () => {
1202
- const promise = activeQuery?.fetch();
1203
- promise?.catch(noop);
1204
- };
1205
- if (!activeQuery || !activeQueryState) {
1206
- return null;
1207
- }
1208
- return /*#__PURE__*/React__namespace.createElement(ActiveQueryPanel, null, /*#__PURE__*/React__namespace.createElement("div", {
1209
- style: {
1210
- padding: '.5em',
1211
- background: defaultTheme.backgroundAlt,
1212
- position: 'sticky',
1213
- top: 0,
1214
- zIndex: 1
1215
- }
1216
- }, "Query Details"), /*#__PURE__*/React__namespace.createElement("div", {
1217
- style: {
1218
- padding: '.5em'
1219
- }
1220
- }, /*#__PURE__*/React__namespace.createElement("div", {
1221
- style: {
1222
- marginBottom: '.5em',
1223
- display: 'flex',
1224
- alignItems: 'flex-start',
1225
- justifyContent: 'space-between'
1226
- }
1227
- }, /*#__PURE__*/React__namespace.createElement(Code, {
1228
- style: {
1229
- lineHeight: '1.8em'
1230
- }
1231
- }, /*#__PURE__*/React__namespace.createElement("pre", {
1232
- style: {
1233
- margin: 0,
1234
- padding: 0,
1235
- overflow: 'auto'
1236
- }
1237
- }, displayValue(activeQuery.queryKey, true))), /*#__PURE__*/React__namespace.createElement("span", {
1238
- style: {
1239
- padding: '0.3em .6em',
1240
- borderRadius: '0.4em',
1241
- fontWeight: 'bold',
1242
- textShadow: '0 2px 10px black',
1243
- background: getQueryStatusColor({
1244
- queryState: activeQueryState,
1245
- isStale: isStale,
1246
- observerCount: observerCount,
1247
- theme: defaultTheme
1248
- }),
1249
- flexShrink: 0
1250
- }
1251
- }, getQueryStatusLabel(activeQuery))), /*#__PURE__*/React__namespace.createElement("div", {
1252
- style: {
1253
- marginBottom: '.5em',
1254
- display: 'flex',
1255
- alignItems: 'center',
1256
- justifyContent: 'space-between'
1257
- }
1258
- }, "Observers: ", /*#__PURE__*/React__namespace.createElement(Code, null, observerCount)), /*#__PURE__*/React__namespace.createElement("div", {
1259
- style: {
1260
- display: 'flex',
1261
- alignItems: 'center',
1262
- justifyContent: 'space-between'
1263
- }
1264
- }, "Last Updated:", ' ', /*#__PURE__*/React__namespace.createElement(Code, null, new Date(activeQueryState.dataUpdatedAt).toLocaleTimeString()))), /*#__PURE__*/React__namespace.createElement("div", {
1265
- style: {
1266
- background: defaultTheme.backgroundAlt,
1267
- padding: '.5em',
1268
- position: 'sticky',
1269
- top: 0,
1270
- zIndex: 1
1271
- }
1272
- }, "Actions"), /*#__PURE__*/React__namespace.createElement("div", {
1273
- style: {
1274
- padding: '0.5em'
1275
- }
1276
- }, /*#__PURE__*/React__namespace.createElement(Button, {
1277
- type: "button",
1278
- onClick: handleRefetch,
1279
- disabled: activeQueryState.fetchStatus === 'fetching',
1280
- style: {
1281
- background: defaultTheme.active
1282
- }
1283
- }, "Refetch"), ' ', /*#__PURE__*/React__namespace.createElement(Button, {
1284
- type: "button",
1285
- onClick: () => queryClient.invalidateQueries(activeQuery),
1286
- style: {
1287
- background: defaultTheme.warning,
1288
- color: defaultTheme.inputTextColor
1289
- }
1290
- }, "Invalidate"), ' ', /*#__PURE__*/React__namespace.createElement(Button, {
1291
- type: "button",
1292
- onClick: () => queryClient.resetQueries(activeQuery),
1293
- style: {
1294
- background: defaultTheme.gray
1295
- }
1296
- }, "Reset"), ' ', /*#__PURE__*/React__namespace.createElement(Button, {
1297
- type: "button",
1298
- onClick: () => queryClient.removeQueries(activeQuery),
1299
- style: {
1300
- background: defaultTheme.danger
1301
- }
1302
- }, "Remove")), /*#__PURE__*/React__namespace.createElement("div", {
1303
- style: {
1304
- background: defaultTheme.backgroundAlt,
1305
- padding: '.5em',
1306
- position: 'sticky',
1307
- top: 0,
1308
- zIndex: 1
1309
- }
1310
- }, "Data Explorer"), /*#__PURE__*/React__namespace.createElement("div", {
1311
- style: {
1312
- padding: '.5em'
1313
- }
1314
- }, /*#__PURE__*/React__namespace.createElement(Explorer, {
1315
- label: "Data",
1316
- value: activeQueryState.data,
1317
- defaultExpanded: {},
1318
- copyable: true
1319
- })), /*#__PURE__*/React__namespace.createElement("div", {
1320
- style: {
1321
- background: defaultTheme.backgroundAlt,
1322
- padding: '.5em',
1323
- position: 'sticky',
1324
- top: 0,
1325
- zIndex: 1
1326
- }
1327
- }, "Query Explorer"), /*#__PURE__*/React__namespace.createElement("div", {
1328
- style: {
1329
- padding: '.5em'
1330
- }
1331
- }, /*#__PURE__*/React__namespace.createElement(Explorer, {
1332
- label: "Query",
1333
- value: activeQuery,
1334
- defaultExpanded: {
1335
- queryKey: true
1336
- }
1337
- })));
1338
- };
1339
- const QueryStatusCount = ({
1340
- queryCache
1341
- }) => {
1342
- const hasFresh = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fresh').length);
1343
- const hasFetching = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'fetching').length);
1344
- const hasPaused = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'paused').length);
1345
- const hasStale = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'stale').length);
1346
- const hasInactive = useSubscribeToQueryCache(queryCache, () => queryCache.getAll().filter(q => getQueryStatusLabel(q) === 'inactive').length);
1347
- return /*#__PURE__*/React__namespace.createElement(QueryKeys, null, /*#__PURE__*/React__namespace.createElement(QueryKey, {
1348
- style: {
1349
- background: defaultTheme.success,
1350
- opacity: hasFresh ? 1 : 0.3
1351
- }
1352
- }, "fresh ", /*#__PURE__*/React__namespace.createElement(Code, null, "(", hasFresh, ")")), ' ', /*#__PURE__*/React__namespace.createElement(QueryKey, {
1353
- style: {
1354
- background: defaultTheme.active,
1355
- opacity: hasFetching ? 1 : 0.3
1356
- }
1357
- }, "fetching ", /*#__PURE__*/React__namespace.createElement(Code, null, "(", hasFetching, ")")), ' ', /*#__PURE__*/React__namespace.createElement(QueryKey, {
1358
- style: {
1359
- background: defaultTheme.paused,
1360
- opacity: hasPaused ? 1 : 0.3
1361
- }
1362
- }, "paused ", /*#__PURE__*/React__namespace.createElement(Code, null, "(", hasPaused, ")")), ' ', /*#__PURE__*/React__namespace.createElement(QueryKey, {
1363
- style: {
1364
- background: defaultTheme.warning,
1365
- color: 'black',
1366
- textShadow: '0',
1367
- opacity: hasStale ? 1 : 0.3
1392
+ ReactQueryDevtoolsPanel$1.displayName = 'ReactQueryDevtoolsPanel';
1393
+ var ReactQueryDevtoolsPanel$2 = ReactQueryDevtoolsPanel$1;
1394
+
1395
+ function ReactQueryDevtools$1({
1396
+ initialIsOpen,
1397
+ panelProps = {},
1398
+ closeButtonProps = {},
1399
+ toggleButtonProps = {},
1400
+ position = 'bottom-left',
1401
+ containerElement: Container = 'aside',
1402
+ queryClient,
1403
+ styleNonce,
1404
+ panelPosition: initialPanelPosition = 'bottom',
1405
+ errorTypes = []
1406
+ }) {
1407
+ const rootRef = React__namespace.useRef(null);
1408
+ const panelRef = React__namespace.useRef(null);
1409
+ const [isOpen, setIsOpen] = useLocalStorage('reactQueryDevtoolsOpen', initialIsOpen);
1410
+ const [devtoolsHeight, setDevtoolsHeight] = useLocalStorage('reactQueryDevtoolsHeight', defaultPanelSize);
1411
+ const [devtoolsWidth, setDevtoolsWidth] = useLocalStorage('reactQueryDevtoolsWidth', defaultPanelSize);
1412
+ const [panelPosition = 'bottom', setPanelPosition] = useLocalStorage('reactQueryDevtoolsPanelPosition', initialPanelPosition);
1413
+ const [isResolvedOpen, setIsResolvedOpen] = React__namespace.useState(false);
1414
+ const [isResizing, setIsResizing] = React__namespace.useState(false);
1415
+ const isMounted = useIsMounted();
1416
+ const handleDragStart = (panelElement, startEvent) => {
1417
+ if (!panelElement) return;
1418
+ if (startEvent.button !== 0) return; // Only allow left click for drag
1419
+ const isVertical = isVerticalSide(panelPosition);
1420
+ setIsResizing(true);
1421
+ const {
1422
+ height,
1423
+ width
1424
+ } = panelElement.getBoundingClientRect();
1425
+ const startX = startEvent.clientX;
1426
+ const startY = startEvent.clientY;
1427
+ let newSize = 0;
1428
+ const run = moveEvent => {
1429
+ // prevent mouse selecting stuff with mouse drag
1430
+ moveEvent.preventDefault();
1431
+
1432
+ // calculate the correct size based on mouse position and current panel position
1433
+ // hint: it is different formula for the opposite sides
1434
+ if (isVertical) {
1435
+ newSize = width + (panelPosition === 'right' ? startX - moveEvent.clientX : moveEvent.clientX - startX);
1436
+ setDevtoolsWidth(newSize);
1437
+ } else {
1438
+ newSize = height + (panelPosition === 'bottom' ? startY - moveEvent.clientY : moveEvent.clientY - startY);
1439
+ setDevtoolsHeight(newSize);
1440
+ }
1441
+ if (newSize < minPanelSize) {
1442
+ setIsOpen(false);
1443
+ } else {
1444
+ setIsOpen(true);
1445
+ }
1446
+ };
1447
+ const unsub = () => {
1448
+ if (isResizing) {
1449
+ setIsResizing(false);
1450
+ }
1451
+ document.removeEventListener('mousemove', run, false);
1452
+ document.removeEventListener('mouseUp', unsub, false);
1453
+ };
1454
+ document.addEventListener('mousemove', run, false);
1455
+ document.addEventListener('mouseup', unsub, false);
1456
+ };
1457
+ React__namespace.useEffect(() => {
1458
+ setIsResolvedOpen(isOpen != null ? isOpen : false);
1459
+ }, [isOpen, isResolvedOpen, setIsResolvedOpen]);
1460
+
1461
+ // Toggle panel visibility before/after transition (depending on direction).
1462
+ // Prevents focusing in a closed panel.
1463
+ React__namespace.useEffect(() => {
1464
+ const ref = panelRef.current;
1465
+ if (ref) {
1466
+ const handlePanelTransitionStart = () => {
1467
+ if (isResolvedOpen) {
1468
+ ref.style.visibility = 'visible';
1469
+ }
1470
+ };
1471
+ const handlePanelTransitionEnd = () => {
1472
+ if (!isResolvedOpen) {
1473
+ ref.style.visibility = 'hidden';
1474
+ }
1475
+ };
1476
+ ref.addEventListener('transitionstart', handlePanelTransitionStart);
1477
+ ref.addEventListener('transitionend', handlePanelTransitionEnd);
1478
+ return () => {
1479
+ ref.removeEventListener('transitionstart', handlePanelTransitionStart);
1480
+ ref.removeEventListener('transitionend', handlePanelTransitionEnd);
1481
+ };
1368
1482
  }
1369
- }, "stale ", /*#__PURE__*/React__namespace.createElement(Code, null, "(", hasStale, ")")), ' ', /*#__PURE__*/React__namespace.createElement(QueryKey, {
1370
- style: {
1371
- background: defaultTheme.gray,
1372
- opacity: hasInactive ? 1 : 0.3
1483
+ return;
1484
+ }, [isResolvedOpen]);
1485
+ React__namespace.useEffect(() => {
1486
+ var _rootRef$current;
1487
+ if (isResolvedOpen && (_rootRef$current = rootRef.current) != null && _rootRef$current.parentElement) {
1488
+ const {
1489
+ parentElement
1490
+ } = rootRef.current;
1491
+ const styleProp = getSidedProp('padding', panelPosition);
1492
+ const isVertical = isVerticalSide(panelPosition);
1493
+ const previousPaddings = (({
1494
+ padding,
1495
+ paddingTop,
1496
+ paddingBottom,
1497
+ paddingLeft,
1498
+ paddingRight
1499
+ }) => ({
1500
+ padding,
1501
+ paddingTop,
1502
+ paddingBottom,
1503
+ paddingLeft,
1504
+ paddingRight
1505
+ }))(parentElement.style);
1506
+ const run = () => {
1507
+ // reset the padding
1508
+ parentElement.style.padding = '0px';
1509
+ parentElement.style.paddingTop = '0px';
1510
+ parentElement.style.paddingBottom = '0px';
1511
+ parentElement.style.paddingLeft = '0px';
1512
+ parentElement.style.paddingRight = '0px';
1513
+ // set the new padding based on the new panel position
1514
+
1515
+ parentElement.style[styleProp] = `${isVertical ? devtoolsWidth : devtoolsHeight}px`;
1516
+ };
1517
+ run();
1518
+ if (typeof window !== 'undefined') {
1519
+ window.addEventListener('resize', run);
1520
+ return () => {
1521
+ window.removeEventListener('resize', run);
1522
+ Object.entries(previousPaddings).forEach(([property, previousValue]) => {
1523
+ parentElement.style[property] = previousValue;
1524
+ });
1525
+ };
1526
+ }
1373
1527
  }
1374
- }, "inactive ", /*#__PURE__*/React__namespace.createElement(Code, null, "(", hasInactive, ")")));
1375
- };
1376
- const QueryRow = /*#__PURE__*/React__namespace.memo(({
1377
- queryKey,
1378
- setActiveQueryHash,
1379
- activeQueryHash,
1380
- queryCache
1381
- }) => {
1382
- const queryHash = useSubscribeToQueryCache(queryCache, () => queryCache.find({
1383
- queryKey
1384
- })?.queryHash) ?? '';
1385
- const queryState = useSubscribeToQueryCache(queryCache, () => queryCache.find({
1386
- queryKey
1387
- })?.state);
1388
- const isStale = useSubscribeToQueryCache(queryCache, () => queryCache.find({
1389
- queryKey
1390
- })?.isStale()) ?? false;
1391
- const isDisabled = useSubscribeToQueryCache(queryCache, () => queryCache.find({
1392
- queryKey
1393
- })?.isDisabled()) ?? false;
1394
- const observerCount = useSubscribeToQueryCache(queryCache, () => queryCache.find({
1395
- queryKey
1396
- })?.getObserversCount()) ?? 0;
1397
- if (!queryState) {
1398
- return null;
1399
- }
1400
- return /*#__PURE__*/React__namespace.createElement("div", {
1401
- role: "button",
1402
- "aria-label": `Open query details for ${queryHash}`,
1403
- onClick: () => setActiveQueryHash(activeQueryHash === queryHash ? '' : queryHash),
1528
+ return;
1529
+ }, [isResolvedOpen, panelPosition, devtoolsHeight, devtoolsWidth]);
1530
+ const {
1531
+ style: panelStyle = {},
1532
+ ...otherPanelProps
1533
+ } = panelProps;
1534
+ const {
1535
+ style: toggleButtonStyle = {},
1536
+ onClick: onToggleClick,
1537
+ ...otherToggleButtonProps
1538
+ } = toggleButtonProps;
1539
+
1540
+ // get computed style based on panel position
1541
+ const style = getSidePanelStyle({
1542
+ position: panelPosition,
1543
+ devtoolsTheme: defaultTheme,
1544
+ isOpen: isResolvedOpen,
1545
+ height: devtoolsHeight,
1546
+ width: devtoolsWidth,
1547
+ isResizing,
1548
+ panelStyle
1549
+ });
1550
+
1551
+ // Do not render on the server
1552
+ if (!isMounted()) return null;
1553
+ return /*#__PURE__*/React__namespace.createElement(Container, {
1554
+ ref: rootRef,
1555
+ className: "ReactQueryDevtools",
1556
+ "aria-label": "React Query Devtools"
1557
+ }, /*#__PURE__*/React__namespace.createElement(ThemeProvider, {
1558
+ theme: defaultTheme
1559
+ }, /*#__PURE__*/React__namespace.createElement(ReactQueryDevtoolsPanel$2, _extends({
1560
+ ref: panelRef,
1561
+ queryClient: queryClient,
1562
+ styleNonce: styleNonce,
1563
+ position: panelPosition,
1564
+ onPositionChange: setPanelPosition,
1565
+ showCloseButton: true,
1566
+ closeButtonProps: closeButtonProps
1567
+ }, otherPanelProps, {
1568
+ style: style,
1569
+ isOpen: isResolvedOpen,
1570
+ setIsOpen: setIsOpen,
1571
+ onDragStart: e => handleDragStart(panelRef.current, e),
1572
+ errorTypes: errorTypes
1573
+ }))), !isResolvedOpen ? /*#__PURE__*/React__namespace.createElement("button", _extends({
1574
+ type: "button"
1575
+ }, otherToggleButtonProps, {
1576
+ "aria-label": "Open React Query Devtools",
1577
+ "aria-controls": "ReactQueryDevtoolsPanel",
1578
+ "aria-haspopup": "true",
1579
+ "aria-expanded": "false",
1580
+ onClick: e => {
1581
+ setIsOpen(true);
1582
+ onToggleClick == null ? void 0 : onToggleClick(e);
1583
+ },
1404
1584
  style: {
1405
- display: 'flex',
1406
- borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
1585
+ background: 'none',
1586
+ border: 0,
1587
+ padding: 0,
1588
+ position: 'fixed',
1589
+ zIndex: 99999,
1590
+ display: 'inline-flex',
1591
+ fontSize: '1.5em',
1592
+ margin: '.5em',
1407
1593
  cursor: 'pointer',
1408
- background: queryHash === activeQueryHash ? 'rgba(255,255,255,.1)' : undefined
1409
- }
1410
- }, /*#__PURE__*/React__namespace.createElement("div", {
1411
- style: {
1412
- flex: '0 0 auto',
1413
- width: '2em',
1414
- height: '2em',
1415
- background: getQueryStatusColor({
1416
- queryState,
1417
- isStale,
1418
- observerCount,
1419
- theme: defaultTheme
1594
+ width: 'fit-content',
1595
+ ...(position === 'top-right' ? {
1596
+ top: '0',
1597
+ right: '0'
1598
+ } : position === 'top-left' ? {
1599
+ top: '0',
1600
+ left: '0'
1601
+ } : position === 'bottom-right' ? {
1602
+ bottom: '0',
1603
+ right: '0'
1604
+ } : {
1605
+ bottom: '0',
1606
+ left: '0'
1420
1607
  }),
1421
- display: 'flex',
1422
- alignItems: 'center',
1423
- justifyContent: 'center',
1424
- fontWeight: 'bold',
1425
- textShadow: isStale ? '0' : '0 0 10px black',
1426
- color: isStale ? 'black' : 'white'
1427
- }
1428
- }, observerCount), isDisabled ? /*#__PURE__*/React__namespace.createElement("div", {
1429
- style: {
1430
- flex: '0 0 auto',
1431
- height: '2em',
1432
- background: defaultTheme.gray,
1433
- display: 'flex',
1434
- alignItems: 'center',
1435
- fontWeight: 'bold',
1436
- padding: '0 0.5em'
1437
- }
1438
- }, "disabled") : null, /*#__PURE__*/React__namespace.createElement(Code, {
1439
- style: {
1440
- padding: '.5em'
1608
+ ...toggleButtonStyle
1441
1609
  }
1442
- }, `${queryHash}`));
1443
- });
1444
-
1445
- // eslint-disable-next-line @typescript-eslint/no-empty-function
1446
- function noop() {}
1610
+ }), /*#__PURE__*/React__namespace.createElement(Logo, {
1611
+ "aria-hidden": true
1612
+ }), /*#__PURE__*/React__namespace.createElement(ScreenReader, {
1613
+ text: "Open React Query Devtools"
1614
+ })) : null);
1615
+ }
1447
1616
 
1448
1617
  const ReactQueryDevtools = ReactQueryDevtools$1;
1449
- const ReactQueryDevtoolsPanel = ReactQueryDevtoolsPanel$1;
1618
+ const ReactQueryDevtoolsPanel = ReactQueryDevtoolsPanel$2;
1450
1619
 
1451
1620
  exports.ReactQueryDevtools = ReactQueryDevtools;
1452
1621
  exports.ReactQueryDevtoolsPanel = ReactQueryDevtoolsPanel;