@tanstack/router-devtools 1.112.4 → 1.112.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/cjs/BaseTanStackRouterDevtoolsPanel.cjs +29 -12
  2. package/dist/cjs/BaseTanStackRouterDevtoolsPanel.cjs.map +1 -1
  3. package/dist/cjs/BaseTanStackRouterDevtoolsPanel.d.cts +3 -1
  4. package/dist/cjs/Explorer.cjs +1 -1
  5. package/dist/cjs/Explorer.cjs.map +1 -1
  6. package/dist/cjs/TanStackRouterDevtools.cjs +2 -2
  7. package/dist/cjs/TanStackRouterDevtools.cjs.map +1 -1
  8. package/dist/cjs/TanStackRouterDevtoolsPanel.cjs +7 -5
  9. package/dist/cjs/TanStackRouterDevtoolsPanel.cjs.map +1 -1
  10. package/dist/cjs/TanStackRouterDevtoolsPanel.d.cts +3 -1
  11. package/dist/cjs/context.cjs +1 -1
  12. package/dist/cjs/context.cjs.map +1 -1
  13. package/dist/cjs/useStyles.cjs +1 -1
  14. package/dist/cjs/useStyles.cjs.map +1 -1
  15. package/dist/cjs/utils.cjs.map +1 -1
  16. package/dist/cjs/utils.d.cts +3 -1
  17. package/dist/esm/BaseTanStackRouterDevtoolsPanel.d.ts +3 -1
  18. package/dist/esm/BaseTanStackRouterDevtoolsPanel.js +29 -12
  19. package/dist/esm/BaseTanStackRouterDevtoolsPanel.js.map +1 -1
  20. package/dist/esm/Explorer.js +1 -1
  21. package/dist/esm/Explorer.js.map +1 -1
  22. package/dist/esm/TanStackRouterDevtools.js +2 -2
  23. package/dist/esm/TanStackRouterDevtools.js.map +1 -1
  24. package/dist/esm/TanStackRouterDevtoolsPanel.d.ts +3 -1
  25. package/dist/esm/TanStackRouterDevtoolsPanel.js +7 -5
  26. package/dist/esm/TanStackRouterDevtoolsPanel.js.map +1 -1
  27. package/dist/esm/context.js +1 -1
  28. package/dist/esm/context.js.map +1 -1
  29. package/dist/esm/useStyles.js +1 -1
  30. package/dist/esm/useStyles.js.map +1 -1
  31. package/dist/esm/utils.d.ts +3 -1
  32. package/dist/esm/utils.js.map +1 -1
  33. package/package.json +1 -1
  34. package/src/BaseTanStackRouterDevtoolsPanel.tsx +322 -311
  35. package/src/Explorer.tsx +1 -1
  36. package/src/TanStackRouterDevtools.tsx +4 -4
  37. package/src/TanStackRouterDevtoolsPanel.tsx +18 -17
  38. package/src/context.ts +1 -1
  39. package/src/theme.tsx +2 -2
  40. package/src/useStyles.tsx +1 -1
  41. package/src/utils.ts +38 -31
package/src/Explorer.tsx CHANGED
@@ -356,7 +356,7 @@ const stylesFactory = (shadowDOMTarget?: ShadowRoot) => {
356
356
  }
357
357
 
358
358
  function useStyles() {
359
- const shadowDomTarget = React.useContext(ShadowDomTargetContext)
359
+ const shadowDomTarget = React.use(ShadowDomTargetContext)
360
360
  const [_styles] = React.useState(() => stylesFactory(shadowDomTarget))
361
361
  return _styles
362
362
  }
@@ -61,9 +61,9 @@ export function TanStackRouterDevtools(
61
61
  const { shadowDOMTarget } = props
62
62
 
63
63
  return (
64
- <ShadowDomTargetContext.Provider value={shadowDOMTarget}>
64
+ <ShadowDomTargetContext value={shadowDOMTarget}>
65
65
  <FloatingTanStackRouterDevtools {...props} />
66
- </ShadowDomTargetContext.Provider>
66
+ </ShadowDomTargetContext>
67
67
  )
68
68
  }
69
69
 
@@ -190,7 +190,7 @@ function FloatingTanStackRouterDevtools({
190
190
 
191
191
  return (
192
192
  <Container ref={setRootEl} className="TanStackRouterDevtools">
193
- <DevtoolsOnCloseContext.Provider
193
+ <DevtoolsOnCloseContext
194
194
  value={{
195
195
  onCloseClick: onCloseClick ?? (() => {}),
196
196
  }}
@@ -217,7 +217,7 @@ function FloatingTanStackRouterDevtools({
217
217
  handleDragStart={(e) => handleDragStart(panelRef.current, e)}
218
218
  shadowDOMTarget={shadowDOMTarget}
219
219
  />
220
- </DevtoolsOnCloseContext.Provider>
220
+ </DevtoolsOnCloseContext>
221
221
 
222
222
  <button
223
223
  type="button"
@@ -34,21 +34,22 @@ export interface DevtoolsPanelOptions {
34
34
  shadowDOMTarget?: ShadowRoot
35
35
  }
36
36
 
37
- export const TanStackRouterDevtoolsPanel = React.forwardRef<
38
- HTMLDivElement,
39
- DevtoolsPanelOptions
40
- >(function TanStackRouterDevtoolsPanel(props, ref) {
41
- const { shadowDOMTarget } = props
37
+ export const TanStackRouterDevtoolsPanel =
38
+ function TanStackRouterDevtoolsPanel({
39
+ ref,
40
+ ...props
41
+ }: DevtoolsPanelOptions & { ref?: React.RefObject<HTMLDivElement | null> }) {
42
+ const { shadowDOMTarget } = props
42
43
 
43
- return (
44
- <ShadowDomTargetContext.Provider value={shadowDOMTarget}>
45
- <DevtoolsOnCloseContext.Provider
46
- value={{
47
- onCloseClick: () => {},
48
- }}
49
- >
50
- <BaseTanStackRouterDevtoolsPanel ref={ref} {...props} />
51
- </DevtoolsOnCloseContext.Provider>
52
- </ShadowDomTargetContext.Provider>
53
- )
54
- })
44
+ return (
45
+ <ShadowDomTargetContext value={shadowDOMTarget}>
46
+ <DevtoolsOnCloseContext
47
+ value={{
48
+ onCloseClick: () => {},
49
+ }}
50
+ >
51
+ <BaseTanStackRouterDevtoolsPanel ref={ref} {...props} />
52
+ </DevtoolsOnCloseContext>
53
+ </ShadowDomTargetContext>
54
+ )
55
+ }
package/src/context.ts CHANGED
@@ -12,7 +12,7 @@ export const DevtoolsOnCloseContext = React.createContext<
12
12
  >(undefined)
13
13
 
14
14
  export const useDevtoolsOnClose = () => {
15
- const context = React.useContext(DevtoolsOnCloseContext)
15
+ const context = React.use(DevtoolsOnCloseContext)
16
16
  if (!context) {
17
17
  throw new Error(
18
18
  'useDevtoolsOnClose must be used within a TanStackRouterDevtools component',
package/src/theme.tsx CHANGED
@@ -23,9 +23,9 @@ interface ProviderProps {
23
23
  const ThemeContext = React.createContext(defaultTheme)
24
24
 
25
25
  export function ThemeProvider({ theme, ...rest }: ProviderProps) {
26
- return <ThemeContext.Provider value={theme} {...rest} />
26
+ return <ThemeContext value={theme} {...rest} />
27
27
  }
28
28
 
29
29
  export function useTheme() {
30
- return React.useContext(ThemeContext)
30
+ return React.use(ThemeContext)
31
31
  }
package/src/useStyles.tsx CHANGED
@@ -583,7 +583,7 @@ const stylesFactory = (shadowDOMTarget?: ShadowRoot) => {
583
583
  }
584
584
 
585
585
  export function useStyles() {
586
- const shadowDomTarget = React.useContext(ShadowDomTargetContext)
586
+ const shadowDomTarget = React.use(ShadowDomTargetContext)
587
587
  const [_styles] = React.useState(() => stylesFactory(shadowDomTarget))
588
588
  return _styles
589
589
  }
package/src/utils.ts CHANGED
@@ -63,37 +63,44 @@ export function styled<T extends keyof HTMLElementTagNameMap>(
63
63
  type: T,
64
64
  newStyles: Styles,
65
65
  queries: Record<string, Styles> = {},
66
- ) {
67
- return React.forwardRef<HTMLElementTagNameMap[T], StyledComponent<T>>(
68
- ({ style, ...rest }, ref) => {
69
- const theme = useTheme()
70
-
71
- const mediaStyles = Object.entries(queries).reduce(
72
- (current, [key, value]) => {
73
- // eslint-disable-next-line react-hooks/rules-of-hooks
74
- return useMediaQuery(key)
75
- ? {
76
- ...current,
77
- ...(typeof value === 'function' ? value(rest, theme) : value),
78
- }
79
- : current
80
- },
81
- {},
82
- )
83
-
84
- return React.createElement(type, {
85
- ...rest,
86
- style: {
87
- ...(typeof newStyles === 'function'
88
- ? newStyles(rest, theme)
89
- : newStyles),
90
- ...style,
91
- ...mediaStyles,
92
- },
93
- ref,
94
- })
95
- },
96
- )
66
+ ): (
67
+ props: StyledComponent<T> & {
68
+ ref?: React.RefObject<HTMLElementTagNameMap[T] | null>
69
+ },
70
+ ) => React.ReactElement {
71
+ return ({
72
+ ref,
73
+ style,
74
+ ...rest
75
+ }: StyledComponent<T> & {
76
+ ref?: React.RefObject<HTMLElementTagNameMap[T] | null>
77
+ }) => {
78
+ const theme = useTheme()
79
+
80
+ const mediaStyles = Object.entries(queries).reduce(
81
+ (current, [key, value]) => {
82
+ return useMediaQuery(key)
83
+ ? {
84
+ ...current,
85
+ ...(typeof value === 'function' ? value(rest, theme) : value),
86
+ }
87
+ : current
88
+ },
89
+ {},
90
+ )
91
+
92
+ return React.createElement(type, {
93
+ ...rest,
94
+ style: {
95
+ ...(typeof newStyles === 'function'
96
+ ? newStyles(rest, theme)
97
+ : newStyles),
98
+ ...style,
99
+ ...mediaStyles,
100
+ },
101
+ ref,
102
+ })
103
+ }
97
104
  }
98
105
 
99
106
  export function useIsMounted() {