@tanstack/router-devtools 0.0.1-beta.185 → 0.0.1-beta.186
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.
- package/build/cjs/devtools.js +41 -3
- package/build/cjs/devtools.js.map +1 -1
- package/build/esm/index.js +41 -3
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +133 -133
- package/build/umd/index.development.js +41 -3
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/devtools.tsx +56 -3
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
*
|
|
30
30
|
* @license MIT
|
|
31
31
|
*/
|
|
32
|
-
const
|
|
32
|
+
const c=l.createContext(null);function u(e,t){const[n,a]=o.default.useState();o.default.useEffect((()=>{const n=(e=>{try{const t=localStorage.getItem(e);return"string"==typeof t?JSON.parse(t):void 0}catch{return}})(e);a(null==n?"function"==typeof t?t():t:n)}),[t,e]);return[n,o.default.useCallback((t=>{a((n=>{let a=t;"function"==typeof t&&(a=t(n));try{localStorage.setItem(e,JSON.stringify(a))}catch{}return a}))}),[e])]}const s={background:"#0b1521",backgroundAlt:"#132337",foreground:"white",gray:"#3f4e60",grayAlt:"#222e3e",inputBackgroundColor:"#fff",inputTextColor:"#000",success:"#00ab52",danger:"#ff0085",active:"#006bff",warning:"#ffb200"},f=o.default.createContext(s);function m({theme:e,...t}){return o.default.createElement(f.Provider,i({value:e},t))}const p="undefined"==typeof window;function g(e,t){return"pending"===e.status||e.isFetching?t.active:function(e,t){const n=Date.now();return!!e.invalid||(t?.preload?!(e.preloadMaxAge<0)&&e.updatedAt+e.preloadMaxAge<n:!(e.maxAge<0)&&e.updatedAt+e.maxAge<n)}(e)?t.warning:"error"===e.status?t.danger:"success"===e.status?t.success:t.gray}function b(e,t,n){const a=e.find((e=>e.routeId===t.id));return a?g(a,n):n.gray}function y(e,t,n={}){return o.default.forwardRef((({style:a,...r},l)=>{const i=o.default.useContext(f),d=Object.entries(n).reduce(((e,[t,n])=>function(e){const[t,n]=o.default.useState((()=>{if("undefined"!=typeof window)return window.matchMedia&&window.matchMedia(e).matches}));return o.default.useEffect((()=>{if("undefined"!=typeof window){if(!window.matchMedia)return;const t=window.matchMedia(e),a=({matches:e})=>n(e);return t.addListener(a),()=>{t.removeListener(a)}}}),[t,e,n]),t}(t)?{...e,..."function"==typeof n?n(r,i):n}:e),{});return o.default.createElement(e,{...r,style:{..."function"==typeof t?t(r,i):t,...a,...d},ref:l})}))}function h(){const e=o.default.useRef(!1),t=o.default.useCallback((()=>e.current),[]);return o.default[p?"useEffect":"useLayoutEffect"]((()=>(e.current=!0,()=>{e.current=!1})),[]),t}function v(e){const t=h(),[n,a]=o.default.useState(e);return[n,o.default.useCallback((e=>{var n;n=()=>{t()&&a(e)},Promise.resolve().then(n).catch((e=>setTimeout((()=>{throw e}))))}),[t])]}const E=y("div",((e,t)=>({fontSize:"clamp(12px, 1.5vw, 14px)",fontFamily:"sans-serif",display:"flex",backgroundColor:t.background,color:t.foreground})),{"(max-width: 700px)":{flexDirection:"column"},"(max-width: 600px)":{fontSize:".9em"}}),x=y("div",(()=>({flex:"1 1 500px",display:"flex",flexDirection:"column",overflow:"auto",height:"100%"})),{"(max-width: 700px)":(e,t)=>({borderTop:`2px solid ${t.gray}`})}),k=y("button",((e,t)=>({appearance:"none",fontSize:".9em",fontWeight:"bold",background:t.gray,border:"0",borderRadius:".3em",color:"white",padding:".5em",opacity:e.disabled?".5":void 0,cursor:"pointer"}))),w=y("code",{fontSize:".9em"}),S=y("div",{fontFamily:"Menlo, monospace",fontSize:".7rem",lineHeight:"1.7",outline:"none",wordBreak:"break-word"}),I=y("span",{color:"white"}),R=y("button",{cursor:"pointer",color:"white"}),O=y("button",{cursor:"pointer",color:"inherit",font:"inherit",outline:"inherit",background:"transparent",border:"none",padding:0}),A=y("span",((e,t)=>({color:t.danger}))),D=y("div",{marginLeft:".1em",paddingLeft:"1em",borderLeft:"2px solid rgba(0,0,0,.15)"}),C=y("span",{color:"grey",fontSize:".7em"}),j=({expanded:e,style:t={}})=>l.createElement("span",{style:{display:"inline-block",transition:"all .1s ease",transform:`rotate(${e?90:0}deg) ${t.transform||""}`,...t}},"▶");const T=({handleEntry:e,label:t,value:n,subEntries:a=[],subEntryPages:r=[],type:o,expanded:i=!1,toggleExpanded:d,pageSize:c,renderer:u})=>{const[s,f]=l.useState([]),[m,p]=l.useState(void 0);return l.createElement(S,null,r.length?l.createElement(l.Fragment,null,l.createElement(O,{onClick:()=>d()},l.createElement(j,{expanded:i})," ",t," ",l.createElement(C,null,"iterable"===String(o).toLowerCase()?"(Iterable) ":"",a.length," ",a.length>1?"items":"item")),i?1===r.length?l.createElement(D,null,a.map(((t,n)=>e(t)))):l.createElement(D,null,r.map(((t,n)=>l.createElement("div",{key:n},l.createElement(S,null,l.createElement(R,{onClick:()=>f((e=>e.includes(n)?e.filter((e=>e!==n)):[...e,n]))},l.createElement(j,{expanded:i})," [",n*c," ..."," ",n*c+c-1,"]"),s.includes(n)?l.createElement(D,null,t.map((t=>e(t)))):null))))):null):"function"===o?l.createElement(l.Fragment,null,l.createElement(P,{renderer:u,label:l.createElement("button",{onClick:()=>{p(n())},style:{appearance:"none",border:"0",background:"transparent"}},l.createElement(I,null,t)," 🔄"," "),value:m,defaultExpanded:{}})):l.createElement(l.Fragment,null,l.createElement(I,null,t,":")," ",l.createElement(A,null,(e=>{const t=Object.getOwnPropertyNames(Object(e)),n="bigint"==typeof e?`${e.toString()}n`:e;return JSON.stringify(n,t)})(n))))};function P({value:e,defaultExpanded:t,renderer:n=T,pageSize:a=100,filterSubEntries:r,...o}){const[d,c]=l.useState(Boolean(t)),u=l.useCallback((()=>c((e=>!e))),[]);let s=typeof e,f=[];const m=e=>{const n=!0===t?{[e.label]:!0}:t?.[e.label];return{...e,defaultExpanded:n}};var p;Array.isArray(e)?(s="array",f=e.map(((e,t)=>m({label:t.toString(),value:e})))):null!==e&&"object"==typeof e&&(p=e,Symbol.iterator in p)&&"function"==typeof e[Symbol.iterator]?(s="Iterable",f=Array.from(e,((e,t)=>m({label:t.toString(),value:e})))):"object"==typeof e&&null!==e&&(s="object",f=Object.entries(e).map((([e,t])=>m({label:e,value:t})))),f=r?r(f):f;const g=function(e,t){if(t<1)return[];let n=0;const a=[];for(;n<e.length;)a.push(e.slice(n,n+t)),n+=t;return a}(f,a);return n({handleEntry:t=>l.createElement(P,i({key:t.label,value:e,renderer:n,filterSubEntries:r},o,t)),type:s,subEntries:f,subEntryPages:g,value:e,expanded:d,toggleExpanded:u,pageSize:a,...o})}const z="undefined"==typeof window;function L(e){return o.default.createElement("div",i({},e,{style:{...e.style??{},display:"flex",alignItems:"center",flexDirection:"column",fontSize:"0.8rem",fontWeight:"bolder",lineHeight:"1"}}),o.default.createElement("div",{style:{letterSpacing:"-0.05rem"}},"TANSTACK"),o.default.createElement("div",{style:{backgroundImage:"linear-gradient(to right, var(--tw-gradient-stops))","--tw-gradient-from":"#84cc16","--tw-gradient-stops":"var(--tw-gradient-from), var(--tw-gradient-to)","--tw-gradient-to":"#10b981",WebkitBackgroundClip:"text",color:"transparent",letterSpacing:"0.1rem",marginRight:"-0.2rem"}},"ROUTER"))}function M({route:e,isRoot:t,router:n,activeRouteId:a,activeMatchId:r,setActiveRouteId:l,setActiveMatchId:i}){const d=Object.values(n.state.matchesById),c=n.state.matches.find((t=>t.routeId===e.id));return o.default.createElement("div",null,o.default.createElement("div",{role:"button","aria-label":`Open match details for ${e.id}`,onClick:()=>{c&&(l(a===e.id?"":e.id),i(c.id))},style:{display:"flex",borderBottom:`solid 1px ${s.grayAlt}`,cursor:c?"pointer":"default",alignItems:"center",background:e.id===a?"rgba(255,255,255,.1)":void 0}},t?null:o.default.createElement("div",{style:{flex:"0 0 auto",width:".7rem",height:".7rem",margin:".5rem .75rem",alignItems:"center",justifyContent:"center",fontWeight:"bold",borderRadius:"100%",transition:"all .2s ease-out",background:b(d,e,s),opacity:c?1:.3}}),o.default.createElement(w,{style:{flex:"1 0 auto",display:"flex",justifyContent:"space-between",padding:".25rem .5rem .25rem 0",paddingLeft:t?".5rem":0,opacity:c?1:.7,fontSize:"0.7rem"}},o.default.createElement("span",null,e.path||function(e){return"/"===e?e:e.replace(/\/{1,}$/,"")}(
|
|
33
33
|
/**
|
|
34
34
|
* @tanstack/router-core/src/index.ts
|
|
35
35
|
*
|
|
@@ -40,5 +40,5 @@ const u=l.createContext(null);function c(e,t){const[n,a]=o.default.useState();o.
|
|
|
40
40
|
*
|
|
41
41
|
* @license MIT
|
|
42
42
|
*/
|
|
43
|
-
function(e){return"/"===e?e:e.replace(/^\/{1,}/,"")}(e.id))," "),u?o.default.createElement("span",{style:{opacity:.3}},u.id):null)),e.children?.length?o.default.createElement("div",{style:{marginLeft:t?0:"1rem",borderLeft:t?"":`solid 1px ${s.grayAlt}`}},[...e.children].sort(((e,t)=>e.rank-t.rank)).map((e=>o.default.createElement(M,{key:e.id,route:e,router:n,activeRouteId:a,activeMatchId:r,setActiveRouteId:l,setActiveMatchId:i})))):null)}const $=o.default.forwardRef((function(e,t){const{isOpen:a=!0,setIsOpen:r,handleDragStart:l,router:f,...p}=e,b=o.default.useContext(u),y=f??b;!function(e,t){if(!e)throw new Error("Invariant failed")}(y),function(e,t=(e=>e)){n.useSyncExternalStoreWithSelector(e.subscribe,(()=>e.state),(()=>e.state),t,d)}(y.__store);const[h,v]=c("tanstackRouterDevtoolsShowMatches",!0),[k,S]=c("tanstackRouterDevtoolsActiveRouteId",""),[I,R]=c("tanstackRouterDevtoolsActiveMatchId",""),O=o.default.useMemo((()=>y.state.matchesById[k]||y.state.matchesById[I]),[k,I]),A=Object.keys(y.state.location.search||{}).length,D=Object.values(y.state.matchesById).filter((e=>!y.state.matchIds.includes(e.id)&&!y.state.pendingMatchIds.includes(e.id)));return o.default.createElement(m,{theme:s},o.default.createElement(E,i({ref:t,className:"TanStackRouterDevtoolsPanel"},p),o.default.createElement("style",{dangerouslySetInnerHTML:{__html:`\n\n .TanStackRouterDevtoolsPanel * {\n scrollbar-color: ${s.backgroundAlt} ${s.gray};\n }\n\n .TanStackRouterDevtoolsPanel *::-webkit-scrollbar, .TanStackRouterDevtoolsPanel scrollbar {\n width: 1em;\n height: 1em;\n }\n\n .TanStackRouterDevtoolsPanel *::-webkit-scrollbar-track, .TanStackRouterDevtoolsPanel scrollbar-track {\n background: ${s.backgroundAlt};\n }\n\n .TanStackRouterDevtoolsPanel *::-webkit-scrollbar-thumb, .TanStackRouterDevtoolsPanel scrollbar-thumb {\n background: ${s.gray};\n border-radius: .5em;\n border: 3px solid ${s.backgroundAlt};\n }\n\n .TanStackRouterDevtoolsPanel table {\n width: 100%;\n }\n\n .TanStackRouterDevtoolsPanel table tr {\n border-bottom: 2px dotted rgba(255, 255, 255, .2);\n }\n\n .TanStackRouterDevtoolsPanel table tr:last-child {\n border-bottom: none\n }\n\n .TanStackRouterDevtoolsPanel table td {\n padding: .25rem .5rem;\n border-right: 2px dotted rgba(255, 255, 255, .05);\n }\n\n .TanStackRouterDevtoolsPanel table td:last-child {\n border-right: none\n }\n\n `}}),o.default.createElement("div",{style:{position:"absolute",left:0,top:0,width:"100%",height:"4px",marginBottom:"-4px",cursor:"row-resize",zIndex:1e5},onMouseDown:l}),o.default.createElement("div",{style:{flex:"1 1 500px",minHeight:"40%",maxHeight:"100%",overflow:"auto",borderRight:`1px solid ${s.grayAlt}`,display:"flex",flexDirection:"column"}},o.default.createElement("div",{style:{display:"flex",justifyContent:"start",gap:"1rem",padding:"1rem",alignItems:"center",background:s.backgroundAlt}},o.default.createElement(L,{"aria-hidden":!0}),o.default.createElement("div",{style:{fontSize:"clamp(.8rem, 2vw, 1.3rem)",fontWeight:"bold"}},o.default.createElement("span",{style:{fontWeight:100}},"Devtools"))),o.default.createElement("div",{style:{overflowY:"auto",flex:"1"}},o.default.createElement("div",{style:{padding:".5em"}},o.default.createElement(P,{label:"Router",value:y,defaultExpanded:{state:{},context:{}},filterSubEntries:e=>e.filter((e=>"function"!=typeof e.value))})))),o.default.createElement("div",{style:{flex:"1 1 500px",minHeight:"40%",maxHeight:"100%",overflow:"auto",borderRight:`1px solid ${s.grayAlt}`,display:"flex",flexDirection:"column"}},o.default.createElement("div",{style:{flex:"1 1 auto",overflowY:"auto"}},o.default.createElement("div",{style:{padding:".5em",background:s.backgroundAlt,position:"sticky",top:0,zIndex:1,display:"flex",alignItems:"center",gap:".5rem"}},o.default.createElement("button",{type:"button",onClick:()=>{v(!1)},disabled:!h,style:{appearance:"none",opacity:h?.5:1,border:0,background:"transparent",color:"inherit",cursor:"pointer"}},"Routes"),"/",o.default.createElement("button",{type:"button",onClick:()=>{v(!0)},disabled:h,style:{appearance:"none",opacity:h?1:.5,border:0,background:"transparent",color:"inherit",cursor:"pointer"}},"Matches")),h?o.default.createElement("div",null,y.state.matches.map(((e,t)=>o.default.createElement("div",{key:e.routeId||t,role:"button","aria-label":`Open match details for ${e.routeId}`,onClick:()=>S(k===e.routeId?"":e.routeId),style:{display:"flex",borderBottom:`solid 1px ${s.grayAlt}`,cursor:"pointer",alignItems:"center",background:e===O?"rgba(255,255,255,.1)":void 0}},o.default.createElement("div",{style:{flex:"0 0 auto",width:"1.3rem",height:"1.3rem",marginLeft:".25rem",background:g(e,s),alignItems:"center",justifyContent:"center",fontWeight:"bold",borderRadius:".25rem",transition:"all .2s ease-out"}}),o.default.createElement(w,{style:{padding:".5em",fontSize:"0.7rem"}},`${e.id}`))))):o.default.createElement(M,{route:y.routeTree,router:y,isRoot:!0,activeRouteId:k,activeMatchId:I,setActiveRouteId:S,setActiveMatchId:R})),D?.length?o.default.createElement("div",{style:{flex:"1 1 auto",overflowY:"auto",maxHeight:"50%"}},o.default.createElement("div",{style:{padding:".5em",background:s.backgroundAlt,position:"sticky",top:0,zIndex:1,display:"flex",alignItems:"center",gap:".5rem"}},"Preloaded Matches"),D.map((e=>o.default.createElement("div",{key:e.id,role:"button","aria-label":`Open match details for ${e.routeId}`,onClick:()=>R(I===e.id?"":e.id),style:{display:"flex",borderBottom:`solid 1px ${s.grayAlt}`,cursor:"pointer",alignItems:"center",background:e===O?"rgba(255,255,255,.1)":void 0}},o.default.createElement("div",{style:{flex:"0 0 auto",width:"1.3rem",height:"1.3rem",marginLeft:".25rem",background:g(e,s),alignItems:"center",justifyContent:"center",fontWeight:"bold",borderRadius:".25rem",transition:"all .2s ease-out"}}),o.default.createElement(w,{style:{padding:".5em",fontSize:"0.7rem"}},`${e.id}`))))):null),O?o.default.createElement(x,null,o.default.createElement("div",{style:{padding:".5em",background:s.backgroundAlt,position:"sticky",top:0,bottom:0,zIndex:1}},"Match Details"),o.default.createElement("div",null,o.default.createElement("table",null,o.default.createElement("tbody",null,o.default.createElement("tr",null,o.default.createElement("td",{style:{opacity:".5"}},"ID"),o.default.createElement("td",null,o.default.createElement(w,{style:{lineHeight:"1.8em"}},JSON.stringify(O.id,null,2)))),o.default.createElement("tr",null,o.default.createElement("td",{style:{opacity:".5"}},"Status"),o.default.createElement("td",null,O.status)),o.default.createElement("tr",null,o.default.createElement("td",{style:{opacity:".5"}},"Last Updated"),o.default.createElement("td",null,O.updatedAt?new Date(O.updatedAt).toLocaleTimeString():"N/A"))))),o.default.createElement("div",{style:{background:s.backgroundAlt,padding:".5em",position:"sticky",top:0,bottom:0,zIndex:1}},"Explorer"),o.default.createElement("div",{style:{padding:".5em"}},o.default.createElement(P,{label:"Match",value:O,defaultExpanded:{}}))):null,A?o.default.createElement("div",{style:{flex:"1 1 500px",minHeight:"40%",maxHeight:"100%",overflow:"auto",borderRight:`1px solid ${s.grayAlt}`,display:"flex",flexDirection:"column"}},o.default.createElement("div",{style:{padding:".5em",background:s.backgroundAlt,position:"sticky",top:0,bottom:0,zIndex:1}},"Search Params"),o.default.createElement("div",{style:{padding:".5em"}},o.default.createElement(P,{value:y.state.location.search||{},defaultExpanded:Object.keys(y.state.location.search||{}).reduce(((e,t)=>(e[t]={},e)),{})}))):null))}));e.TanStackRouterDevtools=function({initialIsOpen:e,panelProps:t={},closeButtonProps:n={},toggleButtonProps:a={},position:r="bottom-left",containerElement:l="footer",router:d}){const u=o.default.useRef(null),f=o.default.useRef(null),[p,g]=c("tanstackRouterDevtoolsOpen",e),[b,y]=c("tanstackRouterDevtoolsHeight",null),[E,x]=v(!1),[w,S]=v(!1),I=h();o.default.useEffect((()=>{x(p??!1)}),[p,E,x]),o.default.useEffect((()=>{const e=f.current;if(e){const t=()=>{e&&E&&(e.style.visibility="visible")},n=()=>{e&&!E&&(e.style.visibility="hidden")};return e.addEventListener("transitionstart",t),e.addEventListener("transitionend",n),()=>{e.removeEventListener("transitionstart",t),e.removeEventListener("transitionend",n)}}}),[E]),o.default[z?"useEffect":"useLayoutEffect"]((()=>{if(E){const e=u.current?.parentElement?.style.paddingBottom,t=()=>{const e=f.current?.getBoundingClientRect().height;u.current?.parentElement&&(u.current.parentElement.style.paddingBottom=`${e}px`)};if(t(),"undefined"!=typeof window)return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),u.current?.parentElement&&"string"==typeof e&&(u.current.parentElement.style.paddingBottom=e)}}}),[E]);const{style:R={},...O}=t,{style:A={},onClick:D,...C}=n,{style:j={},onClick:T,...P}=a;return I()?o.default.createElement(l,{ref:u,className:"TanStackRouterDevtools"},o.default.createElement(m,{theme:s},o.default.createElement($,i({ref:f},O,{router:d,style:{position:"fixed",bottom:"0",right:"0",zIndex:99999,width:"100%",height:b??500,maxHeight:"90%",boxShadow:"0 0 20px rgba(0,0,0,.3)",borderTop:`1px solid ${s.gray}`,transformOrigin:"top",visibility:p?"visible":"hidden",...R,...w?{transition:"none"}:{transition:"all .2s ease"},...E?{opacity:1,pointerEvents:"all",transform:"translateY(0) scale(1)"}:{opacity:0,pointerEvents:"none",transform:"translateY(15px) scale(1.02)"}},isOpen:E,setIsOpen:g,handleDragStart:e=>((e,t)=>{if(0!==t.button)return;S(!0);const n=e?.getBoundingClientRect().height??0,a=t.pageY,r=e=>{const t=a-e.pageY,r=n+t;y(r),g(!(r<70))},l=()=>{S(!1),document.removeEventListener("mousemove",r),document.removeEventListener("mouseUp",l)};document.addEventListener("mousemove",r),document.addEventListener("mouseup",l)})(f.current,e)})),E?o.default.createElement(k,i({type:"button","aria-label":"Close TanStack Router Devtools"},C,{onClick:e=>{g(!1),D&&D(e)},style:{position:"fixed",zIndex:99999,margin:".5em",bottom:0,..."top-right"===r?{right:"0"}:"top-left"===r?{left:"0"}:"bottom-right"===r?{right:"0"}:{left:"0"},...A}}),"Close"):null),E?null:o.default.createElement("button",i({type:"button"},P,{"aria-label":"Open TanStack Router Devtools",onClick:e=>{g(!0),T&&T(e)},style:{appearance:"none",background:"none",border:0,padding:0,position:"fixed",zIndex:99999,display:"inline-flex",fontSize:"1.5em",margin:".5em",cursor:"pointer",width:"fit-content",..."top-right"===r?{top:"0",right:"0"}:"top-left"===r?{top:"0",left:"0"}:"bottom-right"===r?{bottom:"0",right:"0"}:{bottom:"0",left:"0"},...j}}),o.default.createElement(L,{"aria-hidden":!0}))):null},e.TanStackRouterDevtoolsPanel=$,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
43
|
+
function(e){return"/"===e?e:e.replace(/^\/{1,}/,"")}(e.id))," "),c?o.default.createElement("span",{style:{opacity:.3}},c.id):null)),e.children?.length?o.default.createElement("div",{style:{marginLeft:t?0:"1rem",borderLeft:t?"":`solid 1px ${s.grayAlt}`}},[...e.children].sort(((e,t)=>e.rank-t.rank)).map((e=>o.default.createElement(M,{key:e.id,route:e,router:n,activeRouteId:a,activeMatchId:r,setActiveRouteId:l,setActiveMatchId:i})))):null)}const $=o.default.forwardRef((function(e,t){const{isOpen:a=!0,setIsOpen:r,handleDragStart:l,router:f,...p}=e,b=o.default.useContext(c),y=f??b;!function(e,t){if(!e)throw new Error("Invariant failed")}(y),function(e,t=(e=>e)){n.useSyncExternalStoreWithSelector(e.subscribe,(()=>e.state),(()=>e.state),t,d)}(y.__store);const[h,v]=u("tanstackRouterDevtoolsShowMatches",!0),[k,S]=u("tanstackRouterDevtoolsActiveRouteId",""),[I,R]=u("tanstackRouterDevtoolsActiveMatchId",""),O=o.default.useMemo((()=>y.state.matchesById[k]||y.state.matchesById[I]),[k,I]),A=Object.keys(y.state.location.search||{}).length,D=Object.values(y.state.matchesById).filter((e=>!y.state.matchIds.includes(e.id)&&!y.state.pendingMatchIds.includes(e.id)));return o.default.createElement(m,{theme:s},o.default.createElement(E,i({ref:t,className:"TanStackRouterDevtoolsPanel"},p),o.default.createElement("style",{dangerouslySetInnerHTML:{__html:`\n\n .TanStackRouterDevtoolsPanel * {\n scrollbar-color: ${s.backgroundAlt} ${s.gray};\n }\n\n .TanStackRouterDevtoolsPanel *::-webkit-scrollbar, .TanStackRouterDevtoolsPanel scrollbar {\n width: 1em;\n height: 1em;\n }\n\n .TanStackRouterDevtoolsPanel *::-webkit-scrollbar-track, .TanStackRouterDevtoolsPanel scrollbar-track {\n background: ${s.backgroundAlt};\n }\n\n .TanStackRouterDevtoolsPanel *::-webkit-scrollbar-thumb, .TanStackRouterDevtoolsPanel scrollbar-thumb {\n background: ${s.gray};\n border-radius: .5em;\n border: 3px solid ${s.backgroundAlt};\n }\n\n .TanStackRouterDevtoolsPanel table {\n width: 100%;\n }\n\n .TanStackRouterDevtoolsPanel table tr {\n border-bottom: 2px dotted rgba(255, 255, 255, .2);\n }\n\n .TanStackRouterDevtoolsPanel table tr:last-child {\n border-bottom: none\n }\n\n .TanStackRouterDevtoolsPanel table td {\n padding: .25rem .5rem;\n border-right: 2px dotted rgba(255, 255, 255, .05);\n }\n\n .TanStackRouterDevtoolsPanel table td:last-child {\n border-right: none\n }\n\n `}}),o.default.createElement("div",{style:{position:"absolute",left:0,top:0,width:"100%",height:"4px",marginBottom:"-4px",cursor:"row-resize",zIndex:1e5},onMouseDown:l}),o.default.createElement("div",{style:{flex:"1 1 500px",minHeight:"40%",maxHeight:"100%",overflow:"auto",borderRight:`1px solid ${s.grayAlt}`,display:"flex",flexDirection:"column"}},o.default.createElement("div",{style:{display:"flex",justifyContent:"start",gap:"1rem",padding:"1rem",alignItems:"center",background:s.backgroundAlt}},o.default.createElement(L,{"aria-hidden":!0}),o.default.createElement("div",{style:{fontSize:"clamp(.8rem, 2vw, 1.3rem)",fontWeight:"bold"}},o.default.createElement("span",{style:{fontWeight:100}},"Devtools"))),o.default.createElement("div",{style:{overflowY:"auto",flex:"1"}},o.default.createElement("div",{style:{padding:".5em"}},o.default.createElement(P,{label:"Router",value:y,defaultExpanded:{state:{},context:{}},filterSubEntries:e=>e.filter((e=>"function"!=typeof e.value))})))),o.default.createElement("div",{style:{flex:"1 1 500px",minHeight:"40%",maxHeight:"100%",overflow:"auto",borderRight:`1px solid ${s.grayAlt}`,display:"flex",flexDirection:"column"}},o.default.createElement("div",{style:{flex:"1 1 auto",overflowY:"auto"}},o.default.createElement("div",{style:{padding:".5em",background:s.backgroundAlt,position:"sticky",top:0,zIndex:1,display:"flex",alignItems:"center",gap:".5rem",fontWeight:"bold"}},"Pathname"," ",y.state.location.maskedLocation?o.default.createElement("div",{style:{padding:".1rem .5rem",background:s.warning,color:"black",borderRadius:".5rem"}},"Masked"):null),o.default.createElement("div",{style:{padding:".5rem",display:"flex",gap:".5rem",alignItems:"center"}},o.default.createElement("code",{style:{opacity:.6}},y.state.location.pathname),y.state.location.maskedLocation?o.default.createElement("code",{style:{color:s.warning,fontWeight:"bold"}},y.state.location.maskedLocation.pathname):null),o.default.createElement("div",{style:{padding:".5em",background:s.backgroundAlt,position:"sticky",top:0,zIndex:1,display:"flex",alignItems:"center",gap:".5rem",fontWeight:"bold"}},o.default.createElement("button",{type:"button",onClick:()=>{v(!1)},disabled:!h,style:{appearance:"none",opacity:h?.5:1,border:0,background:"transparent",color:"inherit",cursor:"pointer"}},"Routes"),"/",o.default.createElement("button",{type:"button",onClick:()=>{v(!0)},disabled:h,style:{appearance:"none",opacity:h?1:.5,border:0,background:"transparent",color:"inherit",cursor:"pointer"}},"Matches")),h?o.default.createElement("div",null,y.state.matches.map(((e,t)=>o.default.createElement("div",{key:e.routeId||t,role:"button","aria-label":`Open match details for ${e.routeId}`,onClick:()=>S(k===e.routeId?"":e.routeId),style:{display:"flex",borderBottom:`solid 1px ${s.grayAlt}`,cursor:"pointer",alignItems:"center",background:e===O?"rgba(255,255,255,.1)":void 0}},o.default.createElement("div",{style:{flex:"0 0 auto",width:"1.3rem",height:"1.3rem",marginLeft:".25rem",background:g(e,s),alignItems:"center",justifyContent:"center",fontWeight:"bold",borderRadius:".25rem",transition:"all .2s ease-out"}}),o.default.createElement(w,{style:{padding:".5em",fontSize:"0.7rem"}},`${e.id}`))))):o.default.createElement(M,{route:y.routeTree,router:y,isRoot:!0,activeRouteId:k,activeMatchId:I,setActiveRouteId:S,setActiveMatchId:R})),D?.length?o.default.createElement("div",{style:{flex:"1 1 auto",overflowY:"auto",maxHeight:"50%"}},o.default.createElement("div",{style:{padding:".5em",background:s.backgroundAlt,position:"sticky",top:0,zIndex:1,display:"flex",alignItems:"center",gap:".5rem",fontWeight:"bold"}},"Preloaded Matches"),D.map((e=>o.default.createElement("div",{key:e.id,role:"button","aria-label":`Open match details for ${e.routeId}`,onClick:()=>R(I===e.id?"":e.id),style:{display:"flex",borderBottom:`solid 1px ${s.grayAlt}`,cursor:"pointer",alignItems:"center",background:e===O?"rgba(255,255,255,.1)":void 0}},o.default.createElement("div",{style:{flex:"0 0 auto",width:"1.3rem",height:"1.3rem",marginLeft:".25rem",background:g(e,s),alignItems:"center",justifyContent:"center",fontWeight:"bold",borderRadius:".25rem",transition:"all .2s ease-out"}}),o.default.createElement(w,{style:{padding:".5em",fontSize:"0.7rem"}},`${e.id}`))))):null),O?o.default.createElement(x,null,o.default.createElement("div",{style:{padding:".5em",background:s.backgroundAlt,position:"sticky",top:0,bottom:0,zIndex:1}},"Match Details"),o.default.createElement("div",null,o.default.createElement("table",null,o.default.createElement("tbody",null,o.default.createElement("tr",null,o.default.createElement("td",{style:{opacity:".5"}},"ID"),o.default.createElement("td",null,o.default.createElement(w,{style:{lineHeight:"1.8em"}},JSON.stringify(O.id,null,2)))),o.default.createElement("tr",null,o.default.createElement("td",{style:{opacity:".5"}},"Status"),o.default.createElement("td",null,O.status)),o.default.createElement("tr",null,o.default.createElement("td",{style:{opacity:".5"}},"Last Updated"),o.default.createElement("td",null,O.updatedAt?new Date(O.updatedAt).toLocaleTimeString():"N/A"))))),o.default.createElement("div",{style:{background:s.backgroundAlt,padding:".5em",position:"sticky",top:0,bottom:0,zIndex:1}},"Explorer"),o.default.createElement("div",{style:{padding:".5em"}},o.default.createElement(P,{label:"Match",value:O,defaultExpanded:{}}))):null,A?o.default.createElement("div",{style:{flex:"1 1 500px",minHeight:"40%",maxHeight:"100%",overflow:"auto",borderRight:`1px solid ${s.grayAlt}`,display:"flex",flexDirection:"column"}},o.default.createElement("div",{style:{padding:".5em",background:s.backgroundAlt,position:"sticky",top:0,bottom:0,zIndex:1,fontWeight:"bold"}},"Search Params"),o.default.createElement("div",{style:{padding:".5em"}},o.default.createElement(P,{value:y.state.location.search||{},defaultExpanded:Object.keys(y.state.location.search||{}).reduce(((e,t)=>(e[t]={},e)),{})}))):null))}));e.TanStackRouterDevtools=function({initialIsOpen:e,panelProps:t={},closeButtonProps:n={},toggleButtonProps:a={},position:r="bottom-left",containerElement:l="footer",router:d}){const c=o.default.useRef(null),f=o.default.useRef(null),[p,g]=u("tanstackRouterDevtoolsOpen",e),[b,y]=u("tanstackRouterDevtoolsHeight",null),[E,x]=v(!1),[w,S]=v(!1),I=h();o.default.useEffect((()=>{x(p??!1)}),[p,E,x]),o.default.useEffect((()=>{const e=f.current;if(e){const t=()=>{e&&E&&(e.style.visibility="visible")},n=()=>{e&&!E&&(e.style.visibility="hidden")};return e.addEventListener("transitionstart",t),e.addEventListener("transitionend",n),()=>{e.removeEventListener("transitionstart",t),e.removeEventListener("transitionend",n)}}}),[E]),o.default[z?"useEffect":"useLayoutEffect"]((()=>{if(E){const e=c.current?.parentElement?.style.paddingBottom,t=()=>{const e=f.current?.getBoundingClientRect().height;c.current?.parentElement&&(c.current.parentElement.style.paddingBottom=`${e}px`)};if(t(),"undefined"!=typeof window)return window.addEventListener("resize",t),()=>{window.removeEventListener("resize",t),c.current?.parentElement&&"string"==typeof e&&(c.current.parentElement.style.paddingBottom=e)}}}),[E]);const{style:R={},...O}=t,{style:A={},onClick:D,...C}=n,{style:j={},onClick:T,...P}=a;return I()?o.default.createElement(l,{ref:c,className:"TanStackRouterDevtools"},o.default.createElement(m,{theme:s},o.default.createElement($,i({ref:f},O,{router:d,style:{position:"fixed",bottom:"0",right:"0",zIndex:99999,width:"100%",height:b??500,maxHeight:"90%",boxShadow:"0 0 20px rgba(0,0,0,.3)",borderTop:`1px solid ${s.gray}`,transformOrigin:"top",visibility:p?"visible":"hidden",...R,...w?{transition:"none"}:{transition:"all .2s ease"},...E?{opacity:1,pointerEvents:"all",transform:"translateY(0) scale(1)"}:{opacity:0,pointerEvents:"none",transform:"translateY(15px) scale(1.02)"}},isOpen:E,setIsOpen:g,handleDragStart:e=>((e,t)=>{if(0!==t.button)return;S(!0);const n=e?.getBoundingClientRect().height??0,a=t.pageY,r=e=>{const t=a-e.pageY,r=n+t;y(r),g(!(r<70))},l=()=>{S(!1),document.removeEventListener("mousemove",r),document.removeEventListener("mouseUp",l)};document.addEventListener("mousemove",r),document.addEventListener("mouseup",l)})(f.current,e)})),E?o.default.createElement(k,i({type:"button","aria-label":"Close TanStack Router Devtools"},C,{onClick:e=>{g(!1),D&&D(e)},style:{position:"fixed",zIndex:99999,margin:".5em",bottom:0,..."top-right"===r?{right:"0"}:"top-left"===r?{left:"0"}:"bottom-right"===r?{right:"0"}:{left:"0"},...A}}),"Close"):null),E?null:o.default.createElement("button",i({type:"button"},P,{"aria-label":"Open TanStack Router Devtools",onClick:e=>{g(!0),T&&T(e)},style:{appearance:"none",background:"none",border:0,padding:0,position:"fixed",zIndex:99999,display:"inline-flex",fontSize:"1.5em",margin:".5em",cursor:"pointer",width:"fit-content",..."top-right"===r?{top:"0",right:"0"}:"top-left"===r?{top:"0",left:"0"}:"bottom-right"===r?{bottom:"0",right:"0"}:{bottom:"0",left:"0"},...j}}),o.default.createElement(L,{"aria-hidden":!0}))):null},e.TanStackRouterDevtoolsPanel=$,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
44
44
|
//# sourceMappingURL=index.production.js.map
|