@tanstack/react-query-devtools 5.0.0-alpha.7 → 5.0.0-alpha.70

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 (127) hide show
  1. package/build/lib/__tests__/devtools.test.d.ts +1 -1
  2. package/build/lib/__tests__/devtools.test.d.ts.map +1 -0
  3. package/build/lib/__tests__/utils.d.ts +2 -1
  4. package/build/lib/__tests__/utils.d.ts.map +1 -0
  5. package/build/lib/devtools.cjs +65 -0
  6. package/build/lib/devtools.cjs.map +1 -0
  7. package/build/lib/devtools.d.ts +11 -91
  8. package/build/lib/devtools.d.ts.map +1 -0
  9. package/build/lib/devtools.js +56 -913
  10. package/build/lib/devtools.js.map +1 -1
  11. package/build/lib/devtools.legacy.cjs +65 -0
  12. package/build/lib/devtools.legacy.cjs.map +1 -0
  13. package/build/lib/devtools.legacy.js +63 -0
  14. package/build/lib/devtools.legacy.js.map +1 -0
  15. package/build/lib/index.cjs +18 -0
  16. package/build/lib/index.cjs.map +1 -0
  17. package/build/lib/index.d.ts +1 -1
  18. package/build/lib/index.d.ts.map +1 -0
  19. package/build/lib/index.js +11 -9
  20. package/build/lib/index.js.map +1 -1
  21. package/build/lib/index.legacy.cjs +18 -0
  22. package/build/lib/index.legacy.cjs.map +1 -0
  23. package/build/lib/index.legacy.js +16 -0
  24. package/build/lib/index.legacy.js.map +1 -0
  25. package/build/lib/index.prod.cjs +70 -0
  26. package/build/lib/index.prod.cjs.map +1 -0
  27. package/build/lib/{index.prod.d.ts → index.prod.d.ts/index.d.ts} +1 -1
  28. package/build/lib/index.prod.js +59 -1571
  29. package/build/lib/index.prod.js.map +1 -1
  30. package/build/lib/index.prod.legacy.cjs +70 -0
  31. package/build/lib/index.prod.legacy.cjs.map +1 -0
  32. package/build/lib/index.prod.legacy.js +68 -0
  33. package/build/lib/index.prod.legacy.js.map +1 -0
  34. package/package.json +23 -24
  35. package/src/__tests__/devtools.test.tsx +1 -1009
  36. package/src/devtools.tsx +67 -1306
  37. package/src/index.ts +6 -6
  38. package/build/lib/Explorer.d.ts +0 -50
  39. package/build/lib/Explorer.esm.js +0 -253
  40. package/build/lib/Explorer.esm.js.map +0 -1
  41. package/build/lib/Explorer.js +0 -287
  42. package/build/lib/Explorer.js.map +0 -1
  43. package/build/lib/Explorer.mjs +0 -253
  44. package/build/lib/Explorer.mjs.map +0 -1
  45. package/build/lib/Logo.d.ts +0 -1
  46. package/build/lib/Logo.esm.js +0 -32
  47. package/build/lib/Logo.esm.js.map +0 -1
  48. package/build/lib/Logo.js +0 -55
  49. package/build/lib/Logo.js.map +0 -1
  50. package/build/lib/Logo.mjs +0 -32
  51. package/build/lib/Logo.mjs.map +0 -1
  52. package/build/lib/__tests__/Explorer.test.d.ts +0 -1
  53. package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +0 -17
  54. package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +0 -1
  55. package/build/lib/_virtual/_rollupPluginBabelHelpers.js +0 -19
  56. package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  57. package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +0 -17
  58. package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +0 -1
  59. package/build/lib/devtools.esm.js +0 -899
  60. package/build/lib/devtools.esm.js.map +0 -1
  61. package/build/lib/devtools.mjs +0 -868
  62. package/build/lib/devtools.mjs.map +0 -1
  63. package/build/lib/index.esm.js +0 -11
  64. package/build/lib/index.esm.js.map +0 -1
  65. package/build/lib/index.mjs +0 -11
  66. package/build/lib/index.mjs.map +0 -1
  67. package/build/lib/index.prod.esm.js +0 -1559
  68. package/build/lib/index.prod.esm.js.map +0 -1
  69. package/build/lib/index.prod.mjs +0 -1528
  70. package/build/lib/index.prod.mjs.map +0 -1
  71. package/build/lib/noop.d.ts +0 -2
  72. package/build/lib/screenreader.d.ts +0 -3
  73. package/build/lib/screenreader.esm.js +0 -17
  74. package/build/lib/screenreader.esm.js.map +0 -1
  75. package/build/lib/screenreader.js +0 -40
  76. package/build/lib/screenreader.js.map +0 -1
  77. package/build/lib/screenreader.mjs +0 -17
  78. package/build/lib/screenreader.mjs.map +0 -1
  79. package/build/lib/styledComponents.d.ts +0 -9
  80. package/build/lib/styledComponents.esm.js +0 -95
  81. package/build/lib/styledComponents.esm.js.map +0 -1
  82. package/build/lib/styledComponents.js +0 -104
  83. package/build/lib/styledComponents.js.map +0 -1
  84. package/build/lib/styledComponents.mjs +0 -95
  85. package/build/lib/styledComponents.mjs.map +0 -1
  86. package/build/lib/theme.d.ts +0 -36
  87. package/build/lib/theme.esm.js +0 -32
  88. package/build/lib/theme.esm.js.map +0 -1
  89. package/build/lib/theme.js +0 -55
  90. package/build/lib/theme.js.map +0 -1
  91. package/build/lib/theme.mjs +0 -32
  92. package/build/lib/theme.mjs.map +0 -1
  93. package/build/lib/useLocalStorage.d.ts +0 -1
  94. package/build/lib/useLocalStorage.esm.js +0 -40
  95. package/build/lib/useLocalStorage.esm.js.map +0 -1
  96. package/build/lib/useLocalStorage.js +0 -63
  97. package/build/lib/useLocalStorage.js.map +0 -1
  98. package/build/lib/useLocalStorage.mjs +0 -40
  99. package/build/lib/useLocalStorage.mjs.map +0 -1
  100. package/build/lib/useMediaQuery.d.ts +0 -1
  101. package/build/lib/useMediaQuery.esm.js +0 -36
  102. package/build/lib/useMediaQuery.esm.js.map +0 -1
  103. package/build/lib/useMediaQuery.js +0 -59
  104. package/build/lib/useMediaQuery.js.map +0 -1
  105. package/build/lib/useMediaQuery.mjs +0 -36
  106. package/build/lib/useMediaQuery.mjs.map +0 -1
  107. package/build/lib/utils.d.ts +0 -79
  108. package/build/lib/utils.esm.js +0 -184
  109. package/build/lib/utils.esm.js.map +0 -1
  110. package/build/lib/utils.js +0 -218
  111. package/build/lib/utils.js.map +0 -1
  112. package/build/lib/utils.mjs +0 -184
  113. package/build/lib/utils.mjs.map +0 -1
  114. package/build/umd/index.development.js +0 -3195
  115. package/build/umd/index.development.js.map +0 -1
  116. package/build/umd/index.production.js +0 -2
  117. package/build/umd/index.production.js.map +0 -1
  118. package/src/Explorer.tsx +0 -385
  119. package/src/Logo.tsx +0 -32
  120. package/src/__tests__/Explorer.test.tsx +0 -150
  121. package/src/noop.ts +0 -7
  122. package/src/screenreader.tsx +0 -16
  123. package/src/styledComponents.ts +0 -110
  124. package/src/theme.tsx +0 -33
  125. package/src/useLocalStorage.ts +0 -52
  126. package/src/useMediaQuery.ts +0 -34
  127. package/src/utils.ts +0 -319
@@ -1 +1 @@
1
- import '@testing-library/jest-dom';
1
+ //# sourceMappingURL=devtools.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtools.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/devtools.test.tsx"],"names":[],"mappings":""}
@@ -12,7 +12,7 @@ export declare function sleep(timeout: number): Promise<void>;
12
12
  * @param textToMatch The string that needs to be matched
13
13
  * @reference https://stackoverflow.com/a/56859650/8252081
14
14
  */
15
- declare type MatcherFunction = (content: string, element: Element | null) => boolean;
15
+ type MatcherFunction = (content: string, element: Element | null) => boolean;
16
16
  export declare const getByTextContent: (textToMatch: string) => MatcherFunction;
17
17
  interface CreateQueryClientResponse {
18
18
  queryClient: QueryClient;
@@ -20,3 +20,4 @@ interface CreateQueryClientResponse {
20
20
  }
21
21
  export declare const createQueryClient: () => CreateQueryClientResponse;
22
22
  export {};
23
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/__tests__/utils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAA;AACnE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAEhD,OAAO,EACL,WAAW,EAEX,UAAU,EACX,MAAM,uBAAuB,CAAA;AAE9B,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,WAAW,EACnB,EAAE,EAAE,KAAK,CAAC,YAAY,EACtB,eAAe,GAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAM,EACnE,aAAa,CAAC,EAAE,aAAa,GAC5B,UAAU,CAAC,OAAO,MAAM,CAAC,CAkB3B;AAED,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIpD;AAED;;;;;;;GAOG;AAEH,KAAK,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,OAAO,CAAA;AAE5E,eAAO,MAAM,gBAAgB,gBACb,MAAM,KAAG,eAatB,CAAA;AAEH,UAAU,yBAAyB;IACjC,WAAW,EAAE,WAAW,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;CACvB;AAED,eAAO,MAAM,iBAAiB,QAAO,yBAWpC,CAAA"}
@@ -0,0 +1,65 @@
1
+ 'use client';
2
+ 'use strict';
3
+
4
+ var React = require('react');
5
+ var reactQuery = require('@tanstack/react-query');
6
+ var queryDevtools = require('@tanstack/query-devtools');
7
+
8
+ function ReactQueryDevtoolsDev(props) {
9
+ const queryClient = reactQuery.useQueryClient();
10
+ const client = props.client || queryClient;
11
+ const ref = React.useRef(null);
12
+ const {
13
+ buttonPosition,
14
+ position,
15
+ initialIsOpen,
16
+ errorTypes
17
+ } = props;
18
+ const [devtools] = React.useState(new queryDevtools.TanstackQueryDevtools({
19
+ client: client,
20
+ queryFlavor: 'React Query',
21
+ version: '5',
22
+ onlineManager: reactQuery.onlineManager,
23
+ buttonPosition,
24
+ position,
25
+ initialIsOpen,
26
+ errorTypes
27
+ }));
28
+ React.useEffect(() => {
29
+ devtools.setClient(client);
30
+ }, [client, devtools]);
31
+ React.useEffect(() => {
32
+ if (buttonPosition) {
33
+ devtools.setButtonPosition(buttonPosition);
34
+ }
35
+ }, [buttonPosition, devtools]);
36
+ React.useEffect(() => {
37
+ if (position) {
38
+ devtools.setPosition(position);
39
+ }
40
+ }, [position, devtools]);
41
+ React.useEffect(() => {
42
+ devtools.setInitialIsOpen(initialIsOpen || false);
43
+ }, [initialIsOpen, devtools]);
44
+ React.useEffect(() => {
45
+ devtools.setErrorTypes(errorTypes || []);
46
+ }, [errorTypes, devtools]);
47
+ React.useEffect(() => {
48
+ if (ref.current) {
49
+ devtools.mount(ref.current);
50
+ }
51
+ return () => {
52
+ devtools.unmount();
53
+ };
54
+ }, [devtools]);
55
+ return /*#__PURE__*/React.createElement("div", {
56
+ ref: ref
57
+ });
58
+ }
59
+ function ReactQueryDevtoolsProd(_props) {
60
+ return null;
61
+ }
62
+ const ReactQueryDevtools = process.env.NODE_ENV !== 'development' ? ReactQueryDevtoolsProd : ReactQueryDevtoolsDev;
63
+
64
+ exports.ReactQueryDevtools = ReactQueryDevtools;
65
+ //# sourceMappingURL=devtools.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtools.cjs","sources":["../../src/devtools.tsx"],"sourcesContent":["'use client'\nimport { useRef, useState, useEffect } from 'react'\nimport type { QueryClient } from '@tanstack/react-query'\nimport { useQueryClient, onlineManager } from '@tanstack/react-query'\nimport type {\n DevtoolsButtonPosition,\n DevtoolsPosition,\n DevToolsErrorType,\n} from '@tanstack/query-devtools'\nimport { TanstackQueryDevtools } from '@tanstack/query-devtools'\nimport React from 'react'\n\nexport interface DevtoolsOptions {\n /**\n * Set this true if you want the dev tools to default to being open\n */\n initialIsOpen?: boolean\n /**\n * The position of the React Query logo to open and close the devtools panel.\n * 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n * Defaults to 'bottom-left'.\n */\n buttonPosition?: DevtoolsButtonPosition\n /**\n * The position of the React Query devtools panel.\n * 'top' | 'bottom' | 'left' | 'right'\n * Defaults to 'bottom'.\n */\n position?: DevtoolsPosition\n /**\n * Custom instance of QueryClient\n */\n client?: QueryClient\n /**\n * Use this so you can define custom errors that can be shown in the devtools.\n */\n errorTypes?: DevToolsErrorType[]\n}\n\nfunction ReactQueryDevtoolsDev(\n props: DevtoolsOptions,\n): React.ReactElement | null {\n const queryClient = useQueryClient()\n const client = props.client || queryClient\n const ref = useRef<HTMLDivElement>(null)\n const { buttonPosition, position, initialIsOpen, errorTypes } = props\n const [devtools] = useState(\n new TanstackQueryDevtools({\n client: client,\n queryFlavor: 'React Query',\n version: '5',\n onlineManager,\n buttonPosition,\n position,\n initialIsOpen,\n errorTypes,\n }),\n )\n\n useEffect(() => {\n devtools.setClient(client)\n }, [client, devtools])\n\n useEffect(() => {\n if (buttonPosition) {\n devtools.setButtonPosition(buttonPosition)\n }\n }, [buttonPosition, devtools])\n\n useEffect(() => {\n if (position) {\n devtools.setPosition(position)\n }\n }, [position, devtools])\n\n useEffect(() => {\n devtools.setInitialIsOpen(initialIsOpen || false)\n }, [initialIsOpen, devtools])\n\n useEffect(() => {\n devtools.setErrorTypes(errorTypes || [])\n }, [errorTypes, devtools])\n\n useEffect(() => {\n if (ref.current) {\n devtools.mount(ref.current)\n }\n\n return () => {\n devtools.unmount()\n }\n }, [devtools])\n\n return <div ref={ref}></div>\n}\n\nfunction ReactQueryDevtoolsProd(\n _props: DevtoolsOptions,\n): React.ReactElement | null {\n return null\n}\n\nexport const ReactQueryDevtools: typeof ReactQueryDevtoolsDev =\n process.env.NODE_ENV !== 'development'\n ? ReactQueryDevtoolsProd\n : ReactQueryDevtoolsDev\n"],"names":["errorTypes","client","queryFlavor","version","useEffect","devtools","ref","ReactQueryDevtools"],"mappings":";;;;;;;AAuCA;AAGE;AACA;AACA;;;;;AACiDA;AAAW;;AAGxDC;AACAC;AACAC;;;;;AAKAH;AACF;AAGFI;AACEC;AACF;AAEAD;AACE;AACEC;AACF;AACF;AAEAD;AACE;AACEC;AACF;AACF;AAEAD;AACEC;AACF;AAEAD;AACEC;AACF;AAEAD;;AAEIC;AACF;AAEA;;;AAGF;;AAEYC;AAAS;AACvB;AAEA;AAGE;AACF;AAEaC;;"}
@@ -1,113 +1,33 @@
1
- import * as React from 'react';
2
- import type { QueryClient, Query, DefaultError } from '@tanstack/react-query';
3
- import type { Corner, Side } from './utils';
4
- export interface DevToolsErrorType {
5
- /**
6
- * The name of the error.
7
- */
8
- name: string;
9
- /**
10
- * How the error is initialized.
11
- */
12
- initializer: (query: Query) => DefaultError;
13
- }
1
+ import type { QueryClient } from '@tanstack/react-query';
2
+ import type { DevtoolsButtonPosition, DevtoolsPosition, DevToolsErrorType } from '@tanstack/query-devtools';
3
+ import React from 'react';
14
4
  export interface DevtoolsOptions {
15
5
  /**
16
6
  * Set this true if you want the dev tools to default to being open
17
7
  */
18
8
  initialIsOpen?: boolean;
19
- /**
20
- * Use this to add props to the panel. For example, you can add className, style (merge and override default style), etc.
21
- */
22
- panelProps?: React.ComponentPropsWithoutRef<'div'>;
23
- /**
24
- * Use this to add props to the close button. For example, you can add className, style (merge and override default style), onClick (extend default handler), etc.
25
- */
26
- closeButtonProps?: React.ComponentPropsWithoutRef<'button'>;
27
- /**
28
- * Use this to add props to the toggle button. For example, you can add className, style (merge and override default style), onClick (extend default handler), etc.
29
- */
30
- toggleButtonProps?: React.ComponentPropsWithoutRef<'button'>;
31
9
  /**
32
10
  * The position of the React Query logo to open and close the devtools panel.
11
+ * 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
33
12
  * Defaults to 'bottom-left'.
34
13
  */
35
- position?: Corner;
14
+ buttonPosition?: DevtoolsButtonPosition;
36
15
  /**
37
16
  * The position of the React Query devtools panel.
17
+ * 'top' | 'bottom' | 'left' | 'right'
38
18
  * Defaults to 'bottom'.
39
19
  */
40
- panelPosition?: Side;
41
- /**
42
- * Use this to render the devtools inside a different type of container element for a11y purposes.
43
- * Any string which corresponds to a valid intrinsic JSX element is allowed.
44
- * Defaults to 'aside'.
45
- */
46
- containerElement?: string | any;
47
- /**
48
- * nonce for style element for CSP
49
- */
50
- styleNonce?: string;
51
- /**
52
- * Custom instance of QueryClient
53
- */
54
- queryClient?: QueryClient;
55
- /**
56
- * Use this so you can define custom errors that can be shown in the devtools.
57
- */
58
- errorTypes?: DevToolsErrorType[];
59
- }
60
- interface DevtoolsPanelOptions {
61
- /**
62
- * The standard React style object used to style a component with inline styles
63
- */
64
- style?: React.CSSProperties;
65
- /**
66
- * The standard React className property used to style a component with classes
67
- */
68
- className?: string;
69
- /**
70
- * A boolean variable indicating whether the panel is open or closed
71
- */
72
- isOpen?: boolean;
73
- /**
74
- * nonce for style element for CSP
75
- */
76
- styleNonce?: string;
77
- /**
78
- * A function that toggles the open and close state of the panel
79
- */
80
- setIsOpen: (isOpen: boolean) => void;
81
- /**
82
- * Handles the opening and closing the devtools panel
83
- */
84
- onDragStart: (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
85
- /**
86
- * The position of the React Query devtools panel.
87
- * Defaults to 'bottom'.
88
- */
89
- position?: Side;
90
- /**
91
- * Handles the panel position select change
92
- */
93
- onPositionChange?: (side: Side) => void;
94
- /**
95
- * Show a close button inside the panel
96
- */
97
- showCloseButton?: boolean;
98
- /**
99
- * Use this to add props to the close button. For example, you can add className, style (merge and override default style), onClick (extend default handler), etc.
100
- */
101
- closeButtonProps?: React.ComponentPropsWithoutRef<'button'>;
20
+ position?: DevtoolsPosition;
102
21
  /**
103
22
  * Custom instance of QueryClient
104
23
  */
105
- queryClient?: QueryClient;
24
+ client?: QueryClient;
106
25
  /**
107
26
  * Use this so you can define custom errors that can be shown in the devtools.
108
27
  */
109
28
  errorTypes?: DevToolsErrorType[];
110
29
  }
111
- export declare function ReactQueryDevtools({ initialIsOpen, panelProps, closeButtonProps, toggleButtonProps, position, containerElement: Container, queryClient, styleNonce, panelPosition: initialPanelPosition, errorTypes, }: DevtoolsOptions): React.ReactElement | null;
112
- export declare const ReactQueryDevtoolsPanel: React.ForwardRefExoticComponent<DevtoolsPanelOptions & React.RefAttributes<HTMLDivElement>>;
30
+ declare function ReactQueryDevtoolsDev(props: DevtoolsOptions): React.ReactElement | null;
31
+ export declare const ReactQueryDevtools: typeof ReactQueryDevtoolsDev;
113
32
  export {};
33
+ //# sourceMappingURL=devtools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"devtools.d.ts","sourceRoot":"","sources":["../../src/devtools.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,KAAK,EACV,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,0BAA0B,CAAA;AAEjC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB;;;;OAIG;IACH,cAAc,CAAC,EAAE,sBAAsB,CAAA;IACvC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,gBAAgB,CAAA;IAC3B;;OAEG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,iBAAiB,EAAE,CAAA;CACjC;AAED,iBAAS,qBAAqB,CAC5B,KAAK,EAAE,eAAe,GACrB,KAAK,CAAC,YAAY,GAAG,IAAI,CAqD3B;AAQD,eAAO,MAAM,kBAAkB,EAAE,OAAO,qBAGb,CAAA"}