@tanstack/router-devtools 0.0.1-beta.142 → 0.0.1-beta.144

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.
@@ -126,12 +126,15 @@ function useMediaQuery(query) {
126
126
  }
127
127
 
128
128
  const isServer$1 = typeof window === 'undefined';
129
- function getStatusColor(match, theme) {
130
- return match.status === 'pending' ? theme.active : match.status === 'error' ? theme.danger : match.status === 'success' ? theme.success : theme.gray;
129
+ function getStatusColor(match, theme, router) {
130
+ return match.status === 'pending' || match.isFetching ? theme.active : router.getIsInvalid({
131
+ matchId: match.id
132
+ }) ? theme.warning : match.status === 'error' ? theme.danger : match.status === 'success' ? theme.success : theme.gray;
131
133
  }
132
- function getRouteStatusColor(matches, route, theme) {
134
+ function getRouteStatusColor(matches, route, theme, router) {
133
135
  const found = matches.find(d => d.routeId === route.id);
134
- return found ? found.status === 'pending' ? theme.active : found.status === 'error' ? theme.danger : found.status === 'success' ? theme.success : theme.gray : theme.gray;
136
+ if (!found) return theme.gray;
137
+ return getStatusColor(found, theme, router);
135
138
  }
136
139
  function styled(type, newStyles, queries = {}) {
137
140
  return /*#__PURE__*/React__default.forwardRef(({
@@ -680,16 +683,22 @@ function TanStackRouterDevtools({
680
683
  function RouteComp({
681
684
  route,
682
685
  isRoot,
683
- matches,
686
+ router,
684
687
  activeRouteId,
685
- setActiveRouteId
688
+ activeMatchId,
689
+ setActiveRouteId,
690
+ setActiveMatchId
686
691
  }) {
687
- const match = matches.find(d => d.routeId === route.id);
692
+ const matches = Object.values(router.state.matchesById);
693
+ const match = router.state.matches.find(d => d.routeId === route.id);
688
694
  return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("div", {
689
695
  role: "button",
690
696
  "aria-label": `Open match details for ${route.id}`,
691
697
  onClick: () => {
692
- if (match) setActiveRouteId(activeRouteId === route.id ? '' : route.id);
698
+ if (match) {
699
+ setActiveRouteId(activeRouteId === route.id ? '' : route.id);
700
+ setActiveMatchId(match.id);
701
+ }
693
702
  },
694
703
  style: {
695
704
  display: 'flex',
@@ -709,7 +718,7 @@ function RouteComp({
709
718
  fontWeight: 'bold',
710
719
  borderRadius: '100%',
711
720
  transition: 'all .2s ease-out',
712
- background: getRouteStatusColor(matches, route, defaultTheme),
721
+ background: getRouteStatusColor(matches, route, defaultTheme, router),
713
722
  opacity: match ? 1 : 0.3
714
723
  }
715
724
  }), /*#__PURE__*/React__default.createElement(Code, {
@@ -719,7 +728,8 @@ function RouteComp({
719
728
  justifyContent: 'space-between',
720
729
  padding: '.25rem .5rem .25rem 0',
721
730
  paddingLeft: isRoot ? '.5rem' : 0,
722
- opacity: match ? 1 : 0.7
731
+ opacity: match ? 1 : 0.7,
732
+ fontSize: '0.7rem'
723
733
  }
724
734
  }, /*#__PURE__*/React__default.createElement("span", null, route.path || trimPath(route.id), " "), match ? /*#__PURE__*/React__default.createElement("span", {
725
735
  style: {
@@ -735,9 +745,11 @@ function RouteComp({
735
745
  }).map(r => /*#__PURE__*/React__default.createElement(RouteComp, {
736
746
  key: r.id,
737
747
  route: r,
738
- matches: matches,
748
+ router: router,
739
749
  activeRouteId: activeRouteId,
740
- setActiveRouteId: setActiveRouteId
750
+ activeMatchId: activeMatchId,
751
+ setActiveRouteId: setActiveRouteId,
752
+ setActiveMatchId: setActiveMatchId
741
753
  }))) : null);
742
754
  }
743
755
  const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(function TanStackRouterDevtoolsPanel(props, ref) {
@@ -754,9 +766,18 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
754
766
  useStore(router.__store);
755
767
  const [showMatches, setShowMatches] = useLocalStorage('tanstackRouterDevtoolsShowMatches', true);
756
768
  const [activeRouteId, setActiveRouteId] = useLocalStorage('tanstackRouterDevtoolsActiveRouteId', '');
757
- const allMatches = React__default.useMemo(() => [...Object.values(router.state.matches)], [router.state.matches]);
758
- const activeMatch = allMatches?.find(d => d.routeId === activeRouteId);
769
+ const [activeMatchId, setActiveMatchId] = useLocalStorage('tanstackRouterDevtoolsActiveMatchId', '');
770
+ const activeMatch = React__default.useMemo(() => router.state.matchesById[activeRouteId] || router.state.matchesById[activeMatchId], [activeRouteId, activeMatchId]);
759
771
  const hasSearch = Object.keys(router.state.location.search || {}).length;
772
+ const preloadMatches = Object.values(router.state.matchesById).filter(match => {
773
+ return !router.state.matchIds.includes(match.id) && !router.state.pendingMatchIds.includes(match.id);
774
+ });
775
+ React__default.useEffect(() => {
776
+ const interval = setInterval(() => {
777
+ router.cleanMatches();
778
+ }, 1000);
779
+ return () => clearInterval(interval);
780
+ }, [router]);
760
781
  return /*#__PURE__*/React__default.createElement(ThemeProvider, {
761
782
  theme: defaultTheme
762
783
  }, /*#__PURE__*/React__default.createElement(Panel, _extends({
@@ -879,6 +900,11 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
879
900
  display: 'flex',
880
901
  flexDirection: 'column'
881
902
  }
903
+ }, /*#__PURE__*/React__default.createElement("div", {
904
+ style: {
905
+ flex: '1 1 auto',
906
+ overflowY: 'auto'
907
+ }
882
908
  }, /*#__PURE__*/React__default.createElement("div", {
883
909
  style: {
884
910
  padding: '.5em',
@@ -920,10 +946,12 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
920
946
  }
921
947
  }, "Matches")), !showMatches ? /*#__PURE__*/React__default.createElement(RouteComp, {
922
948
  route: router.routeTree,
949
+ router: router,
923
950
  isRoot: true,
924
- matches: allMatches,
925
951
  activeRouteId: activeRouteId,
926
- setActiveRouteId: setActiveRouteId
952
+ activeMatchId: activeMatchId,
953
+ setActiveRouteId: setActiveRouteId,
954
+ setActiveMatchId: setActiveMatchId
927
955
  }) : /*#__PURE__*/React__default.createElement("div", null, router.state.matches.map((match, i) => {
928
956
  return /*#__PURE__*/React__default.createElement("div", {
929
957
  key: match.routeId || i,
@@ -943,7 +971,56 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
943
971
  width: '1.3rem',
944
972
  height: '1.3rem',
945
973
  marginLeft: '.25rem',
946
- background: getStatusColor(match, defaultTheme),
974
+ background: getStatusColor(match, defaultTheme, router),
975
+ alignItems: 'center',
976
+ justifyContent: 'center',
977
+ fontWeight: 'bold',
978
+ borderRadius: '.25rem',
979
+ transition: 'all .2s ease-out'
980
+ }
981
+ }), /*#__PURE__*/React__default.createElement(Code, {
982
+ style: {
983
+ padding: '.5em',
984
+ fontSize: '0.7rem'
985
+ }
986
+ }, `${match.id}`));
987
+ }))), preloadMatches?.length ? /*#__PURE__*/React__default.createElement("div", {
988
+ style: {
989
+ flex: '1 1 auto',
990
+ overflowY: 'auto',
991
+ maxHeight: '50%'
992
+ }
993
+ }, /*#__PURE__*/React__default.createElement("div", {
994
+ style: {
995
+ padding: '.5em',
996
+ background: defaultTheme.backgroundAlt,
997
+ position: 'sticky',
998
+ top: 0,
999
+ zIndex: 1,
1000
+ display: 'flex',
1001
+ alignItems: 'center',
1002
+ gap: '.5rem'
1003
+ }
1004
+ }, "Preloaded Matches"), preloadMatches.map(match => {
1005
+ return /*#__PURE__*/React__default.createElement("div", {
1006
+ key: match.id,
1007
+ role: "button",
1008
+ "aria-label": `Open match details for ${match.routeId}`,
1009
+ onClick: () => setActiveMatchId(activeMatchId === match.id ? '' : match.id),
1010
+ style: {
1011
+ display: 'flex',
1012
+ borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
1013
+ cursor: 'pointer',
1014
+ alignItems: 'center',
1015
+ background: match === activeMatch ? 'rgba(255,255,255,.1)' : undefined
1016
+ }
1017
+ }, /*#__PURE__*/React__default.createElement("div", {
1018
+ style: {
1019
+ flex: '0 0 auto',
1020
+ width: '1.3rem',
1021
+ height: '1.3rem',
1022
+ marginLeft: '.25rem',
1023
+ background: getStatusColor(match, defaultTheme, router),
947
1024
  alignItems: 'center',
948
1025
  justifyContent: 'center',
949
1026
  fontWeight: 'bold',
@@ -952,10 +1029,11 @@ const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default.forwardRef(funct
952
1029
  }
953
1030
  }), /*#__PURE__*/React__default.createElement(Code, {
954
1031
  style: {
955
- padding: '.5em'
1032
+ padding: '.5em',
1033
+ fontSize: '0.7rem'
956
1034
  }
957
1035
  }, `${match.id}`));
958
- }))), activeMatch ? /*#__PURE__*/React__default.createElement(ActivePanel, null, /*#__PURE__*/React__default.createElement("div", {
1036
+ })) : null), activeMatch ? /*#__PURE__*/React__default.createElement(ActivePanel, null, /*#__PURE__*/React__default.createElement("div", {
959
1037
  style: {
960
1038
  padding: '.5em',
961
1039
  background: defaultTheme.backgroundAlt,