@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.
@@ -216,12 +216,15 @@
216
216
  }
217
217
 
218
218
  const isServer$1 = typeof window === 'undefined';
219
- function getStatusColor(match, theme) {
220
- return match.status === 'pending' ? theme.active : match.status === 'error' ? theme.danger : match.status === 'success' ? theme.success : theme.gray;
219
+ function getStatusColor(match, theme, router) {
220
+ return match.status === 'pending' || match.isFetching ? theme.active : router.getIsInvalid({
221
+ matchId: match.id
222
+ }) ? theme.warning : match.status === 'error' ? theme.danger : match.status === 'success' ? theme.success : theme.gray;
221
223
  }
222
- function getRouteStatusColor(matches, route, theme) {
224
+ function getRouteStatusColor(matches, route, theme, router) {
223
225
  const found = matches.find(d => d.routeId === route.id);
224
- return found ? found.status === 'pending' ? theme.active : found.status === 'error' ? theme.danger : found.status === 'success' ? theme.success : theme.gray : theme.gray;
226
+ if (!found) return theme.gray;
227
+ return getStatusColor(found, theme, router);
225
228
  }
226
229
  function styled(type, newStyles, queries = {}) {
227
230
  return /*#__PURE__*/React__default["default"].forwardRef(({
@@ -770,16 +773,22 @@
770
773
  function RouteComp({
771
774
  route,
772
775
  isRoot,
773
- matches,
776
+ router,
774
777
  activeRouteId,
775
- setActiveRouteId
778
+ activeMatchId,
779
+ setActiveRouteId,
780
+ setActiveMatchId
776
781
  }) {
777
- const match = matches.find(d => d.routeId === route.id);
782
+ const matches = Object.values(router.state.matchesById);
783
+ const match = router.state.matches.find(d => d.routeId === route.id);
778
784
  return /*#__PURE__*/React__default["default"].createElement("div", null, /*#__PURE__*/React__default["default"].createElement("div", {
779
785
  role: "button",
780
786
  "aria-label": `Open match details for ${route.id}`,
781
787
  onClick: () => {
782
- if (match) setActiveRouteId(activeRouteId === route.id ? '' : route.id);
788
+ if (match) {
789
+ setActiveRouteId(activeRouteId === route.id ? '' : route.id);
790
+ setActiveMatchId(match.id);
791
+ }
783
792
  },
784
793
  style: {
785
794
  display: 'flex',
@@ -799,7 +808,7 @@
799
808
  fontWeight: 'bold',
800
809
  borderRadius: '100%',
801
810
  transition: 'all .2s ease-out',
802
- background: getRouteStatusColor(matches, route, defaultTheme),
811
+ background: getRouteStatusColor(matches, route, defaultTheme, router),
803
812
  opacity: match ? 1 : 0.3
804
813
  }
805
814
  }), /*#__PURE__*/React__default["default"].createElement(Code, {
@@ -809,7 +818,8 @@
809
818
  justifyContent: 'space-between',
810
819
  padding: '.25rem .5rem .25rem 0',
811
820
  paddingLeft: isRoot ? '.5rem' : 0,
812
- opacity: match ? 1 : 0.7
821
+ opacity: match ? 1 : 0.7,
822
+ fontSize: '0.7rem'
813
823
  }
814
824
  }, /*#__PURE__*/React__default["default"].createElement("span", null, route.path || trimPath(route.id), " "), match ? /*#__PURE__*/React__default["default"].createElement("span", {
815
825
  style: {
@@ -825,9 +835,11 @@
825
835
  }).map(r => /*#__PURE__*/React__default["default"].createElement(RouteComp, {
826
836
  key: r.id,
827
837
  route: r,
828
- matches: matches,
838
+ router: router,
829
839
  activeRouteId: activeRouteId,
830
- setActiveRouteId: setActiveRouteId
840
+ activeMatchId: activeMatchId,
841
+ setActiveRouteId: setActiveRouteId,
842
+ setActiveMatchId: setActiveMatchId
831
843
  }))) : null);
832
844
  }
833
845
  const TanStackRouterDevtoolsPanel = /*#__PURE__*/React__default["default"].forwardRef(function TanStackRouterDevtoolsPanel(props, ref) {
@@ -844,9 +856,18 @@
844
856
  useStore(router.__store);
845
857
  const [showMatches, setShowMatches] = useLocalStorage('tanstackRouterDevtoolsShowMatches', true);
846
858
  const [activeRouteId, setActiveRouteId] = useLocalStorage('tanstackRouterDevtoolsActiveRouteId', '');
847
- const allMatches = React__default["default"].useMemo(() => [...Object.values(router.state.matches)], [router.state.matches]);
848
- const activeMatch = allMatches?.find(d => d.routeId === activeRouteId);
859
+ const [activeMatchId, setActiveMatchId] = useLocalStorage('tanstackRouterDevtoolsActiveMatchId', '');
860
+ const activeMatch = React__default["default"].useMemo(() => router.state.matchesById[activeRouteId] || router.state.matchesById[activeMatchId], [activeRouteId, activeMatchId]);
849
861
  const hasSearch = Object.keys(router.state.location.search || {}).length;
862
+ const preloadMatches = Object.values(router.state.matchesById).filter(match => {
863
+ return !router.state.matchIds.includes(match.id) && !router.state.pendingMatchIds.includes(match.id);
864
+ });
865
+ React__default["default"].useEffect(() => {
866
+ const interval = setInterval(() => {
867
+ router.cleanMatches();
868
+ }, 1000);
869
+ return () => clearInterval(interval);
870
+ }, [router]);
850
871
  return /*#__PURE__*/React__default["default"].createElement(ThemeProvider, {
851
872
  theme: defaultTheme
852
873
  }, /*#__PURE__*/React__default["default"].createElement(Panel, _extends({
@@ -969,6 +990,11 @@
969
990
  display: 'flex',
970
991
  flexDirection: 'column'
971
992
  }
993
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
994
+ style: {
995
+ flex: '1 1 auto',
996
+ overflowY: 'auto'
997
+ }
972
998
  }, /*#__PURE__*/React__default["default"].createElement("div", {
973
999
  style: {
974
1000
  padding: '.5em',
@@ -1010,10 +1036,12 @@
1010
1036
  }
1011
1037
  }, "Matches")), !showMatches ? /*#__PURE__*/React__default["default"].createElement(RouteComp, {
1012
1038
  route: router.routeTree,
1039
+ router: router,
1013
1040
  isRoot: true,
1014
- matches: allMatches,
1015
1041
  activeRouteId: activeRouteId,
1016
- setActiveRouteId: setActiveRouteId
1042
+ activeMatchId: activeMatchId,
1043
+ setActiveRouteId: setActiveRouteId,
1044
+ setActiveMatchId: setActiveMatchId
1017
1045
  }) : /*#__PURE__*/React__default["default"].createElement("div", null, router.state.matches.map((match, i) => {
1018
1046
  return /*#__PURE__*/React__default["default"].createElement("div", {
1019
1047
  key: match.routeId || i,
@@ -1033,7 +1061,56 @@
1033
1061
  width: '1.3rem',
1034
1062
  height: '1.3rem',
1035
1063
  marginLeft: '.25rem',
1036
- background: getStatusColor(match, defaultTheme),
1064
+ background: getStatusColor(match, defaultTheme, router),
1065
+ alignItems: 'center',
1066
+ justifyContent: 'center',
1067
+ fontWeight: 'bold',
1068
+ borderRadius: '.25rem',
1069
+ transition: 'all .2s ease-out'
1070
+ }
1071
+ }), /*#__PURE__*/React__default["default"].createElement(Code, {
1072
+ style: {
1073
+ padding: '.5em',
1074
+ fontSize: '0.7rem'
1075
+ }
1076
+ }, `${match.id}`));
1077
+ }))), preloadMatches?.length ? /*#__PURE__*/React__default["default"].createElement("div", {
1078
+ style: {
1079
+ flex: '1 1 auto',
1080
+ overflowY: 'auto',
1081
+ maxHeight: '50%'
1082
+ }
1083
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
1084
+ style: {
1085
+ padding: '.5em',
1086
+ background: defaultTheme.backgroundAlt,
1087
+ position: 'sticky',
1088
+ top: 0,
1089
+ zIndex: 1,
1090
+ display: 'flex',
1091
+ alignItems: 'center',
1092
+ gap: '.5rem'
1093
+ }
1094
+ }, "Preloaded Matches"), preloadMatches.map(match => {
1095
+ return /*#__PURE__*/React__default["default"].createElement("div", {
1096
+ key: match.id,
1097
+ role: "button",
1098
+ "aria-label": `Open match details for ${match.routeId}`,
1099
+ onClick: () => setActiveMatchId(activeMatchId === match.id ? '' : match.id),
1100
+ style: {
1101
+ display: 'flex',
1102
+ borderBottom: `solid 1px ${defaultTheme.grayAlt}`,
1103
+ cursor: 'pointer',
1104
+ alignItems: 'center',
1105
+ background: match === activeMatch ? 'rgba(255,255,255,.1)' : undefined
1106
+ }
1107
+ }, /*#__PURE__*/React__default["default"].createElement("div", {
1108
+ style: {
1109
+ flex: '0 0 auto',
1110
+ width: '1.3rem',
1111
+ height: '1.3rem',
1112
+ marginLeft: '.25rem',
1113
+ background: getStatusColor(match, defaultTheme, router),
1037
1114
  alignItems: 'center',
1038
1115
  justifyContent: 'center',
1039
1116
  fontWeight: 'bold',
@@ -1042,10 +1119,11 @@
1042
1119
  }
1043
1120
  }), /*#__PURE__*/React__default["default"].createElement(Code, {
1044
1121
  style: {
1045
- padding: '.5em'
1122
+ padding: '.5em',
1123
+ fontSize: '0.7rem'
1046
1124
  }
1047
1125
  }, `${match.id}`));
1048
- }))), activeMatch ? /*#__PURE__*/React__default["default"].createElement(ActivePanel, null, /*#__PURE__*/React__default["default"].createElement("div", {
1126
+ })) : null), activeMatch ? /*#__PURE__*/React__default["default"].createElement(ActivePanel, null, /*#__PURE__*/React__default["default"].createElement("div", {
1049
1127
  style: {
1050
1128
  padding: '.5em',
1051
1129
  background: defaultTheme.backgroundAlt,