@tempots/ui 16.0.4 → 16.0.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.
- package/index.cjs +1 -1
- package/index.js +74 -74
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@tempots/dom"),f=require("@tempots/std"),P=require("@floating-ui/dom"),at=e=>{const t=e.split("/").pop();if(t==null||t.startsWith("."))return;const n=t.split(".")||[];return n.length>1?"."+n.pop():void 0},ot=(e,t)=>{const n=at(t);return n!=null&&(e.length===0||!e.some(s=>n==s))},bt=(e,t,n,s)=>{let a=e.target;for(;a!=null&&!(a instanceof HTMLAnchorElement);)a=a.parentElement;if(a==null)return!0;const o=a;if(e.button!==0||e.ctrlKey||e.metaKey||o.target!=="_self"&&o.target!==""||o.getAttribute("download")!=null)return!0;const{pathname:r,search:c,hash:l}=o;if(s){const h=r+c+l,d=o.getAttribute("href");if(!d?.startsWith("#")&&d!==h)return!0}return t?!1:ot(n,r)},it=(e,t={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const n=t.ignoreUrlWithExtension===!0&&Array.isArray(t.allowedExtensions)?t.allowedExtensions.map(s=>s.startsWith(".")?s:"."+s):[];return s=>{bt(s,t.ignoreUrlWithExtension??!0,n,t.ignoreExternalUrl??!0)||e()&&s.preventDefault()}},ct=(e,t)=>e.pathname===t.pathname&&JSON.stringify(e.search)===JSON.stringify(t.search)&&e.hash===t.hash,V=(e,t)=>{const n=new URL(e,t??i.getWindow()?.location.toString()),s=Object.fromEntries(n.searchParams?.entries()??[]);let a=n.hash;return a.startsWith("#")&&(a=a.substring(1)),{pathname:n.pathname,search:s,hash:a===""?void 0:a}},b=e=>{const n=new URLSearchParams(e.search).toString(),s=e.hash;return`${e.pathname}${n?`?${n}`:""}${s?`#${s}`:""}`},xt=e=>{document.startViewTransition?document.startViewTransition(e):e()},X=()=>{const e=i.getWindow(),t=e?.location.hash??"";return{pathname:e?.location.pathname??"",search:Object.fromEntries(new URLSearchParams(e?.location.search??"").entries()),hash:t.startsWith("#")?t.substring(1)||void 0:t===""?void 0:t}},G=e=>{if(e?.scroll!=="auto")return;const t=i.getWindow();t&&t.requestAnimationFrame(()=>t.scrollTo({top:0,left:0,behavior:"auto"}))},Z=(e,t)=>{t?.viewTransition?xt(e):e()},Lt=()=>{const e=i.prop(X(),ct),t=i.getWindow(),n=()=>{e.set(X())};t?.addEventListener("popstate",n),t?.addEventListener("hashchange",n);const s=(l,h,d)=>{Z(()=>{if(t){const w=b(l),R=h?.state??{};d==="replaceState"||h?.replace?t.history.replaceState(R,"",w):t.history.pushState(R,"",w)}e.set(l)},h),G(h)},a=(l,h)=>{Z(()=>{t?.history.go(l)},h),G(h)};return{location:e,commit:s,go:a,back:l=>a(-1,l),forward:l=>a(1,l),resolve:l=>V(l),dispose:()=>{t?.removeEventListener("popstate",n),t?.removeEventListener("hashchange",n),e.dispose()}}},Wt=e=>e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//"),Tt=e=>{const t=e.container.currentURL,n=t.iso(r=>V(r,t.value),r=>{if(Wt(r.pathname))return b(r);const c=new URL(r.pathname,t.value),l=c.origin+c.pathname;return b({...r,pathname:l})});return{location:n,dispose:()=>{n.dispose()},commit:(r,c,l)=>{n.set(r)},go:(r,c)=>{},back:r=>{},forward:r=>{},resolve:r=>V(r,t.value)}},L=e=>({pathname:e.pathname,search:{...e.search},hash:e.hash??void 0}),N=e=>{if(e==null)return;const t=`${e}`;return t===""?void 0:t},lt=(e,t)=>{const n={...e};for(const[s,a]of Object.entries(t))a==null?delete n[s]:n[s]=a;return n},Ht=(e,t)=>{const n=t?.includeSearch??!0,s=t?.includeHash??!0,a=t?.ignoreSearchParams??[];let o;if(!n)o={};else if(a.length===0)o={...e.search};else{const r=new Set(a);o={};for(const[c,l]of Object.entries(e.search))r.has(c)||(o[c]=l)}return{pathname:e.pathname,search:o,hash:s?e.hash:void 0}},z=(e,t,n)=>{const s=Ht(e,n);return typeof t=="string"?b(s)===t:t instanceof RegExp?((t.global||t.sticky)&&(t.lastIndex=0),t.test(b(s))):t(s)};class Dt{constructor(t){this.current=t}get location(){return this.current}setLocation(t){return this.current=L(t),this}setPathname(t){return this.current={...this.current,pathname:t},this}setHash(t){const n=N(t);if(n==null){const{hash:s,...a}=this.current;this.current=a}else this.current={...this.current,hash:n};return this}clearHash(){const{hash:t,...n}=this.current;return this.current=n,this}setSearch(t){return this.current={...this.current,search:lt(this.current.search,t)},this}setSearchParam(t,n){return this.setSearch({[t]:n})}updateSearch(t){return this.current={...this.current,search:{...t({...this.current.search})}},this}}const Mt=(e,t)=>e?.replace?"replaceState":t,Vt=e=>{const t=e.location,n=t.map(b),s=t.map(u=>u.pathname),a=t.map(u=>({...u.search})),o=t.map(u=>u.hash),r=(u,p)=>z(e.location.value,u,p),c=(u,p)=>i.computedOf(t,u)((m,k)=>z(m,k,p)),l=(u,p,m)=>{const k=L({...u,hash:N(u.hash??void 0)});e.commit(k,p,m)},h=(u,p)=>{const m=Mt(p,"pushState");l(u,p,m)},d=(u,p)=>{const m=u(L(e.location.value));h(m,p)},w=(u,p)=>{const m=e.resolve(u);h(m,p)},R=(u,p)=>{const m={...p,replace:!0};w(u,m)},O=(u,p)=>{e.go(u,p)},g=u=>{e.back(u)},E=u=>{e.forward(u)},v=(u,p)=>d(m=>({...m,pathname:u}),p),S=(u,p)=>d(m=>{const k={...m},J=N(u);return J==null?delete k.hash:k.hash=J,k},p),A=u=>S(void 0,u),y=(u,p)=>d(m=>({...m,search:lt(m.search,u)}),p);return{handle:{location:t,url:n,pathname:s,search:a,hash:o,setLocation:h,updateLocation:d,navigate:w,replace:R,go:O,back:g,forward:E,setPathname:v,setHash:S,clearHash:A,setSearch:y,setSearchParam:(u,p,m)=>y({[u]:p},m),updateSearch:(u,p)=>d(m=>({...m,search:{...u({...m.search})}}),p),queryParam:u=>t.map(p=>p.search[u]),run:(u,p)=>{const m=new Dt(L(e.location.value));u(m),h(L(m.location),p)},match:r,matchSignal:c},dispose:()=>{e.dispose(),n.dispose(),s.dispose(),a.dispose(),o.dispose()}}},Ft=e=>{if(e.isBrowser())return Lt();if(e.isHeadless())return Tt(e);throw new Error("Unknown context")},K={mark:i.makeProviderMark("Location"),create:(e,t)=>{const n=Ft(t),{handle:s,dispose:a}=Vt(n);return{value:s,dispose:a}}},ut=(e,...t)=>{if(typeof e=="string"||i.Signal.is(e))return ut({href:e},...t);const{href:n,state:s,scroll:a,viewTransition:o,replace:r,...c}=e;return i.Use(K,l=>i.html.a(i.on.click(it(()=>{let h=!1;const d={};return s!==void 0&&(d.state=s,h=!0),a!==void 0&&(d.scroll=a,h=!0),o!==void 0&&(d.viewTransition=o,h=!0),r!==void 0&&(d.replace=r,h=!0),l.navigate(i.Value.get(n),h?d:void 0),!0},c)),i.attr.href(n),...t))},Ut={mark:i.makeProviderMark("Appearance"),create:()=>{const e=ht();return{value:e,dispose:()=>e.dispose()}}};function ht(){const e=i.getWindow(),t=e!=null&&e.matchMedia!=null?e.matchMedia("(prefers-color-scheme: dark)"):void 0,n=t?.matches??!1,s=i.prop(n?"dark":"light"),a=o=>s.set(o.matches?"dark":"light");return t?.addEventListener("change",a),s.onDispose(()=>t?.removeEventListener("change",a)),s}const j=(e,t)=>{if(typeof t=="function")return j(e,{success:t});const n=t.failure??(r=>r.map(c=>`Error: ${c}`)),s=t.success,a=t.loading??(()=>i.Empty),o=t.notAsked??(()=>i.Empty);return i.OneOfType(i.Value.toSignal(e),{AsyncSuccess:r=>s(r.$.value),AsyncFailure:r=>n(r.$.error),Loading:r=>a(r.map(c=>c.previousValue)),NotAsked:o})},Kt=(e=10)=>i.WithElement(t=>i.OnDispose(f.delayed(()=>t?.focus(),e))),Ct=(e=10)=>i.WithElement(t=>{const n=f.delayed(()=>t.select(),e);return i.OnDispose(n)});function Nt(e){const t=Object.entries(e);return i.Fragment(...t.map(([n,s])=>i.attr.class(i.Value.map(s,a=>a?n:void 0))))}const zt=i.WithElement(e=>{const t=e.style.getPropertyValue(":empty");return e.style.setProperty(":empty","display:none"),i.OnDispose(n=>{n&&e.style.setProperty(":empty",t)})}),_t=e=>i.Portal("head > title",i.attr.innerText(e)),$t={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},M={partial:new Map,full:new Map},W={partial:null,full:null};function jt(e){return W[e]==null&&(W[e]=new IntersectionObserver(t=>{t.forEach(n=>{M[e].get(n.target)?.set(n.isIntersecting)})},$t[e])),W[e]}const pt=({mode:e="partial",once:t=!1},n)=>{const s=i.prop(!1);return i.Fragment(i.WithElement(a=>{const o=typeof IntersectionObserver<"u"?jt(e):null;M[e].set(a,s),o?.observe(a);function r(){o?.unobserve(a),M[e].delete(a),M[e].size===0&&(W[e]?.disconnect(),W[e]=null)}let c=null;return t&&(c=s.on(l=>{l&&r()})),i.OnDispose(()=>{s.dispose(),r(),c?.()})}),i.renderableOfTNode(n(s)))},It=(e,t,n)=>pt(e,s=>i.When(s,t,n??(()=>i.Empty)));function dt(e){return i.WithElement(t=>{const n=s=>{t.contains(s.target)||e(s)};return document.addEventListener("click",n),i.OnDispose(()=>{document.removeEventListener("click",n)})})}const x=(e,t)=>e===void 0||e===t,tt=(e,t)=>e===void 0||e===t;function mt(e,t){return typeof e=="string"?t.key===e:tt(e.key,t.key)&&tt(e.code,t.code)&&x(e.ctrlKey,t.ctrlKey)&&x(e.altKey,t.altKey)&&x(e.shiftKey,t.shiftKey)&&x(e.metaKey,t.metaKey)&&x(e.repeat,t.repeat)&&x(e.commandOrControlKey,t.metaKey||t.ctrlKey)}function I({allowedKeys:e,handler:t}){return i.WithElement(n=>{const s=a=>{if(n.contains(a.target)){for(const o of e)if(mt(o,a)){t(a);break}}};return document.addEventListener("keydown",s),i.OnDispose(()=>{document.removeEventListener("keydown",s)})})}function qt(e){return I({allowedKeys:["Enter"],handler:e})}function Qt(e){return I({allowedKeys:["Escape"],handler:e})}const ft=({mutate:e,convertError:t,onSuccess:n,onError:s,onSettled:a})=>{let o;const r=i.prop(f.AsyncResult.notAsked),c=r.map(g=>f.AsyncResult.isSuccess(g)?g.value:void 0),l=r.map(g=>f.AsyncResult.isFailure(g)?g.error:void 0),h=r.map(g=>f.AsyncResult.isLoading(g)),d=()=>{o?.abort(),o=void 0};return{status:r,value:c,error:l,pending:h,execute:async(g,E)=>{d(),o=new AbortController;const v=o.signal,S=r.get(),A=E?.optimisticValue??(E?.optimisticFromRequest!=null?E.optimisticFromRequest(g):void 0);A!=null?r.set(f.AsyncResult.loading(A)):r.set(f.AsyncResult.loading(f.AsyncResult.getOrUndefined(S)));try{const y=await e({request:g,abortSignal:v,previous:S});o=void 0,r.set(f.AsyncResult.success(y)),n?.(y,g)}catch(y){o=void 0,r.set(f.AsyncResult.failure(t(y))),s?.(t(y),g)}a?.(r.get(),g)},cancel:g=>{d(),r.set(g??f.AsyncResult.notAsked)},dispose:()=>{o?.abort(),o=void 0,r.dispose()}}},gt=(e,t)=>{const{status:n,dispose:s,execute:a,cancel:o,pending:r,error:c,value:l}=e,{content:h}=t,d=i.previousSignal(l);return i.Fragment(i.OnDispose(s),h({previous:d,execute:a,cancel:o,pending:r,error:c,value:l,status:n}))},Bt=({mutate:e,convertError:t=r=>r,onSuccess:n,onError:s,onSettled:a,content:o})=>{const r=ft({mutate:e,convertError:t,onSuccess:n,onError:s,onSettled:a});return gt(r,{content:o})},Yt=["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],Jt=(e,t={isOpen:!1})=>{const n=[];let s=null;const a=i.Value.deriveProp(t.isOpen);function o(c){s=c,a.set(!0)}function r(){a.set(!1),n.forEach(c=>c()),n.length=0}return i.Fragment(e(o,r),i.When(a,()=>i.Fragment(s?.onClickOutside!=null?dt(s.onClickOutside):null,i.WithElement(c=>i.Portal("body",i.html.div(i.WithElement(l=>{l.style.position="absolute";const h=typeof s?.target=="string"?c.querySelector(s.target):s?.target??c;if(h==null)throw new Error(`Target not found: ${s?.target}`);let d=null;const w=i.Value.toSignal(s?.mainAxisOffset??0),R=i.Value.toSignal(s?.crossAxisOffset??0),O=i.Value.toSignal(s?.placement??"top"),g=i.Value.toSignal(s?.arrowPadding??0),E=s?.arrow,v=i.prop({centerOffset:0,alignmentOffset:0,containerWidth:0,containerHeight:0,x:void 0,y:void 0});async function S(){const y=[P.flip(),P.offset({mainAxis:w.get(),crossAxis:R.get()}),P.shift(),P.flip()];E!=null&&d!=null&&y.push(P.arrow({element:d,padding:g.get()}));const D=await P.computePosition(h,l,{placement:O.get(),strategy:"absolute",middleware:y}),{x:Q,y:B,middlewareData:C}=D;if(l.style.top=`${B}px`,l.style.left=`${Q}px`,d!=null&&C.arrow!=null){const{x:Y,y:u,centerOffset:p,alignmentOffset:m}=C.arrow;v.set({x:Y,y:u,centerOffset:p,alignmentOffset:m,containerWidth:l.offsetWidth,containerHeight:l.offsetHeight})}}const A=i.effectOf(w,R,O)(S);return i.Fragment(s?.content,s?.arrow!=null?i.html.div(s?.arrow(i.computedOf(v,O)((y,D)=>({...y,placement:D}))),i.WithElement(y=>{d=y,S()})):null,i.OnDispose(P.autoUpdate(h,l,S),A))})))))))},vt=({request:e,load:t,convertError:n,onSuccess:s,onError:a,onSettled:o})=>{let r;const c=i.prop(f.AsyncResult.notAsked),l=c.map(v=>f.AsyncResult.isSuccess(v)?v.value:void 0),h=c.map(v=>f.AsyncResult.isFailure(v)?v.error:void 0),d=c.map(v=>f.AsyncResult.isLoading(v)),w=()=>{r?.abort(),r=void 0},R=v=>{w(),c.set(v??f.AsyncResult.notAsked)},O=async v=>{w(),r=new AbortController;const S=r.signal,A=c.get();c.set(f.AsyncResult.loading(f.AsyncResult.getOrUndefined(A)));try{const y=await t({request:v,abortSignal:S,previous:A});await Promise.resolve(),r=void 0,c.set(f.AsyncResult.success(y)),s?.(y,v)}catch(y){r=void 0,c.set(f.AsyncResult.failure(n(y))),a?.(n(y),v)}o?.(c.get(),v)},g=()=>O(i.Value.get(e)),E=()=>{r?.abort(),r=void 0,c.dispose()};return c.onDispose(i.Value.on(e,O)),{status:c,value:l,error:h,loading:d,cancel:R,reload:g,dispose:E}},yt=(e,t)=>{const{status:n,dispose:s,reload:a}=e,{pending:o,failure:r,success:c}=t;return i.Fragment(i.OnDispose(s),j(n,{loading:o!=null?l=>o({previous:l,reload:a,cancel:e.cancel}):void 0,failure:r!=null?l=>r({error:l,reload:a}):void 0,success:l=>c({value:l,reload:a})}))},Xt=({request:e,load:t,convertError:n=h=>h,onSuccess:s,onError:a,onSettled:o,success:r,pending:c,failure:l})=>{const h=vt({request:e,load:t,convertError:n,onSuccess:s,onError:a,onSettled:o});return yt(h,{success:r,pending:c,failure:l})},wt=(e,t)=>{if(typeof t=="function")return wt(e,{success:t});const n=t.failure??(a=>(a.on(console.error),a.map(o=>`Error: ${o}`))),s=t.success;return i.OneOfType(i.Value.toSignal(e),{Success:a=>s(a.$.value),Failure:a=>n(a.$.error)})},Gt=()=>i.on.focus(e=>e.target?.select());class H{constructor(t,n,s,a,o,r){this.left=t,this.top=n,this.width=s,this.height=a,this.localLeft=o,this.localTop=r}static of({left:t=0,top:n=0,width:s=0,height:a=0,localLeft:o=0,localTop:r=0}){return new H(t,n,s,a,o,r)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return{x:this.left+this.width/2,y:this.top+this.height/2}}get localCenter(){return{x:this.localLeft+this.width/2,y:this.localTop+this.height/2}}get localBottom(){return this.localTop+this.height}get localRight(){return this.localLeft+this.width}get size(){return{width:this.width,height:this.height}}equals=t=>f.nearEqual(this.left,t.left)&&f.nearEqual(this.top,t.top)&&f.nearEqual(this.width,t.width)&&f.nearEqual(this.height,t.height)}function _(e){const t=e.getBoundingClientRect();return H.of({top:t.top+window.scrollY,left:t.left+window.scrollX,width:t.width,height:t.height,localLeft:e.offsetLeft,localTop:e.offsetTop})}const Zt=e=>i.WithBrowserCtx(t=>{const{element:n}=t,s=i.prop(_(n),(c,l)=>c.equals(l)),a=i.renderableOfTNode(e(s)).render(t),o=()=>s.set(H.of(_(n)));let r=null;return typeof ResizeObserver<"u"&&(r=new ResizeObserver(o)),r?.observe(n),i.OnDispose(c=>{r?.disconnect(),a(c)})});function et(e){return{width:e?.innerWidth??0,height:e?.innerHeight??0}}const te=e=>i.WithCtx(()=>{const t=i.getWindow(),n=i.prop(et(t),(a,o)=>a.width===o.width&&a.height===o.height),s=()=>n.set(et(t));return t?.addEventListener("resize",s),i.Fragment(i.OnDispose(()=>{t?.removeEventListener("resize",s)}),e(n))}),St=(e,t)=>{const n=t.split("/").filter(o=>o!==""),s=o=>{try{return decodeURIComponent(o)}catch{return o}},a={};for(let o=0;o<e.length;o++){const r=e[o],c=n[o];if(!c&&r.type!=="catch-all")return null;if(r.type==="literal"){if(r.value!==c)return null}else if(r.type==="param")a[r.name]=s(c);else if(r.type==="catch-all"){if(r.name){const l=n.slice(o).join("/");a[r.name]=s(l)}return{params:a,path:t}}}return n.length!==e.length?null:{params:a,path:t}},q=e=>e.split("/").map(t=>{if(t.startsWith(":"))return{type:"param",name:t.slice(1)};if(t.startsWith("*")){const n=t.slice(1);return n!=""?{type:"catch-all",name:n}:{type:"catch-all"}}else return{type:"literal",value:t}}).filter(t=>t.type!=="literal"||t.value!==""),ee=e=>{const t=e.map(n=>{const s=q(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of t){const r=St(a,s);if(r)return{...r,route:o}}return null}},ne=e=>{if(e==null)throw new Error("NavigationService: no Location handle attached. Make sure to attach one before calling navigation helpers.");return e};class se{handles=[];attach(t){const n=this.handles.lastIndexOf(t);return n!==-1&&this.handles.splice(n,1),this.handles.push(t),()=>this.detach(t)}detach(t){for(let n=this.handles.length-1;n>=0;n--)if(this.handles[n]===t){this.handles.splice(n,1);break}}get current(){return this.handles[this.handles.length-1]}getHandle(){return ne(this.current)}navigate(t,n){this.getHandle().navigate(t,n)}replace(t,n){this.getHandle().replace(t,n)}go(t,n){this.getHandle().go(t,n)}back(t){this.getHandle().back(t)}forward(t){this.getHandle().forward(t)}setPathname(t,n){this.getHandle().setPathname(t,n)}setSearch(t,n){this.getHandle().setSearch(t,n)}setSearchParam(t,n,s){this.getHandle().setSearchParam(t,n,s)}updateSearch(t,n){this.getHandle().updateSearch(t,n)}setHash(t,n){this.getHandle().setHash(t,n)}clearHash(t){this.getHandle().clearHash(t)}run(t,n){this.getHandle().run(t,n)}}const re=new se,F={mark:i.makeProviderMark("RouterContext"),create:()=>{const e=i.prop([]);return{value:e,dispose:()=>e.dispose()}}},ae=(e,t,n)=>{const s=n.split("/").filter(r=>r!==""),a={};let o=0;for(let r=0;r<e.length;r++){const c=e[r],l=s[r];if(!l&&c.type!=="catch-all")return null;if(c.type==="literal"){if(c.value!==l)return null;o++}else if(c.type==="param")a[c.name]=l,o++;else if(c.type==="catch-all"){c.name&&(a[c.name]=s.slice(o).join("/"));const h="/"+s.slice(0,o).join("/"),d="/"+s.slice(o).join("/");return{params:a,matchedPath:h==="/"?"":h,remainingPath:d==="/"?"":d,route:t}}}if(s.length===e.length){const r="/"+s.join("/");return{params:a,matchedPath:r==="/"?"":r,remainingPath:"",route:t}}return null},Rt=e=>{const t=e.map(n=>{const s=q(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of t){const r=ae(a,o,s);if(r)return r}return null}},oe=e=>{const t=Rt(Object.keys(e));return i.Provide(F,{},()=>i.Use(K,n=>i.Use(F,s=>{const a=n.location.map(o=>{const r=t(o.pathname);if(r==null)throw console.error("No route found for",o),new Error("No route found");const c={matchedPath:r.matchedPath,remainingPath:r.remainingPath,fullPath:o.pathname,params:r.params};return s.value=[...s.value,c],{params:r.params,route:r.route,path:r.matchedPath||o.pathname,search:o.search,hash:o.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),e)})))},ie=e=>{const t=Rt(Object.keys(e));return i.Use(F,n=>i.Use(K,s=>{const a=n.map(o=>{const r=o[o.length-1];if(r==null)throw console.error("No router context available for ChildRouter",o),new Error("No router context available for ChildRouter");const c=r.remainingPath??"",l=t(c);if(l==null)throw console.error("No route found for remaining path",c),new Error("No route found");return{params:l.params,route:l.route,path:l.matchedPath,search:s.location.value.search,hash:s.location.value.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),e)}))},U=60*1e3,$=60*U,T=24*$,nt=7*T,st=30*T,ce=365*T,le=[{max:U*90,value:U,name:"minute",past:{singular:"a minute ago",plural:"{} minutes ago"},future:{singular:"in a minute",plural:"in {} minutes"}},{max:$*36,value:$,name:"hour",past:{singular:"an hour ago",plural:"{} hours ago"},future:{singular:"in an hour",plural:"in {} hours"}},{max:T*10,value:T,name:"day",past:{singular:"yesterday",plural:"{} days ago"},future:{singular:"tomorrow",plural:"in {} days"}},{max:nt*6,value:nt,name:"week",past:{singular:"last week",plural:"{} weeks ago"},future:{singular:"in a week",plural:"in {} weeks"}},{max:st*18,value:st,name:"month",past:{singular:"last month",plural:"{} months ago"},future:{singular:"in a month",plural:"in {} months"}},{max:1/0,value:ce,name:"year",past:{singular:"last year",plural:"{} years ago"},future:{singular:"in a year",plural:"in {} years"}}];function rt(e,t,n,s){const a=Math.round(e/t);return a<=1?n:s.replace("{}",a.toLocaleString(void 0,{maximumFractionDigits:0,minimumFractionDigits:0}))}const Ot=(e=1e3)=>{const t=i.prop(new Date),n=f.interval(()=>t.set(new Date),e);return t.onDispose(n),t},Et=e=>{const t=Math.abs(e);if(t<U)return e<0?"just now":"in a moment";for(const n of le)if(t<n.max)return e<0?rt(t,n.value,n.past.singular,n.past.plural):rt(t,n.value,n.future.singular,n.future.plural);throw new Error("unreachable")},At=(e,{now:t,frequency:n=1e4}={})=>{const s=t!=null?i.Signal.is(t)?t.derive():i.prop(t):Ot(n),a=i.computedOf(e,s)((o,r)=>o.getTime()-r.getTime());return a.onDispose(()=>i.Value.dispose(s)),a},kt=(e,t={})=>{const n=At(e,t),s=n.map(Et);return s.onDispose(()=>n.dispose()),s},ue=(e,t={})=>kt(e,t);class Pt extends i.Prop{tick=()=>this.update(t=>t+1)}const he=(e=0)=>new Pt(e,i.strictEquals);exports.Anchor=ut;exports.Appearance=Ut;exports.AsyncResultView=j;exports.AutoFocus=Kt;exports.AutoSelect=Ct;exports.ChildRouter=ie;exports.ElementRect=Zt;exports.HTMLTitle=_t;exports.HiddenWhenEmpty=zt;exports.InViewport=pt;exports.Location=K;exports.Mutation=Bt;exports.MutationDisplay=gt;exports.NavigationService=re;exports.OnClickOutside=dt;exports.OnEnterKey=qt;exports.OnEscapeKey=Qt;exports.OnKeyPressed=I;exports.PopOver=Jt;exports.Query=Xt;exports.QueryDisplay=yt;exports.Rect=H;exports.ResultView=wt;exports.RootRouter=oe;exports.RouterContextProvider=F;exports.SelectOnFocus=Gt;exports.Ticker=Pt;exports.WhenInViewport=It;exports.WindowSize=te;exports._checkExtensionCondition=ot;exports._getExtension=at;exports._makeRouteMatcher=ee;exports._parseRouteSegments=q;exports.allPlacements=Yt;exports.areLocationsEqual=ct;exports.classes=Nt;exports.evaluateLocationMatch=z;exports.getAbsoluteRect=_;exports.handleAnchorClick=it;exports.locationFromURL=V;exports.makeMutationResource=ft;exports.makeQueryResource=vt;exports.matchesKeyCombo=mt;exports.matchesRoute=St;exports.nowSignal=Ot;exports.relativeTime=ue;exports.relativeTimeMillisSignal=At;exports.relativeTimeSignal=kt;exports.ticker=he;exports.timeDiffToString=Et;exports.urlFromLocation=b;exports.useAppearance=ht;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("@tempots/dom"),f=require("@tempots/std"),P=require("@floating-ui/dom"),at=e=>{const t=e.split("/").pop();if(t==null||t.startsWith("."))return;const n=t.split(".")||[];return n.length>1?"."+n.pop():void 0},ot=(e,t)=>{const n=at(t);return n!=null&&(e.length===0||!e.some(s=>n==s))},bt=(e,t,n,s)=>{let a=e.target;for(;a!=null&&!(a instanceof HTMLAnchorElement);)a=a.parentElement;if(a==null)return!0;const o=a;if(e.button!==0||e.ctrlKey||e.metaKey||o.target!=="_self"&&o.target!==""||o.getAttribute("download")!=null)return!0;const{pathname:r,search:c,hash:l}=o;if(s){const h=r+c+l,d=o.getAttribute("href");if(!d?.startsWith("#")&&d!==h)return!0}return t?!1:ot(n,r)},it=(e,t={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const n=t.ignoreUrlWithExtension===!0&&Array.isArray(t.allowedExtensions)?t.allowedExtensions.map(s=>s.startsWith(".")?s:"."+s):[];return s=>{bt(s,t.ignoreUrlWithExtension??!0,n,t.ignoreExternalUrl??!0)||e()&&s.preventDefault()}},ct=(e,t)=>e.pathname===t.pathname&&JSON.stringify(e.search)===JSON.stringify(t.search)&&e.hash===t.hash,V=(e,t)=>{const n=new URL(e,t??i.getWindow()?.location.toString()),s=Object.fromEntries(n.searchParams?.entries()??[]);let a=n.hash;return a.startsWith("#")&&(a=a.substring(1)),{pathname:n.pathname,search:s,hash:a===""?void 0:a}},b=e=>{const n=new URLSearchParams(e.search).toString(),s=e.hash;return`${e.pathname}${n?`?${n}`:""}${s?`#${s}`:""}`},xt=e=>{document.startViewTransition?document.startViewTransition(e):e()},X=()=>{const e=i.getWindow(),t=e?.location.hash??"";return{pathname:e?.location.pathname??"",search:Object.fromEntries(new URLSearchParams(e?.location.search??"").entries()),hash:t.startsWith("#")?t.substring(1)||void 0:t===""?void 0:t}},G=e=>{if(e?.scroll!=="auto")return;const t=i.getWindow();t&&t.requestAnimationFrame(()=>t.scrollTo({top:0,left:0,behavior:"auto"}))},Z=(e,t)=>{t?.viewTransition?xt(e):e()},Lt=()=>{const e=i.prop(X(),ct),t=i.getWindow(),n=()=>{e.set(X())};t?.addEventListener("popstate",n),t?.addEventListener("hashchange",n);const s=(l,h,d)=>{Z(()=>{if(t){const w=b(l),R=h?.state??{};d==="replaceState"||h?.replace?t.history.replaceState(R,"",w):t.history.pushState(R,"",w)}e.set(l)},h),G(h)},a=(l,h)=>{Z(()=>{t?.history.go(l)},h),G(h)};return{location:e,commit:s,go:a,back:l=>a(-1,l),forward:l=>a(1,l),resolve:l=>V(l),dispose:()=>{t?.removeEventListener("popstate",n),t?.removeEventListener("hashchange",n),e.dispose()}}},Wt=e=>e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//"),Tt=e=>{const t=e.container.currentURL,n=t.iso(r=>V(r,t.value),r=>{if(Wt(r.pathname))return b(r);const c=new URL(r.pathname,t.value),l=c.origin+c.pathname;return b({...r,pathname:l})});return{location:n,dispose:()=>{n.dispose()},commit:(r,c,l)=>{n.set(r)},go:(r,c)=>{},back:r=>{},forward:r=>{},resolve:r=>V(r,t.value)}},L=e=>({pathname:e.pathname,search:{...e.search},hash:e.hash??void 0}),N=e=>{if(e==null)return;const t=`${e}`;return t===""?void 0:t},lt=(e,t)=>{const n={...e};for(const[s,a]of Object.entries(t))a==null?delete n[s]:n[s]=a;return n},Ht=(e,t)=>{const n=t?.includeSearch??!0,s=t?.includeHash??!0,a=t?.ignoreSearchParams??[];let o;if(!n)o={};else if(a.length===0)o={...e.search};else{const r=new Set(a);o={};for(const[c,l]of Object.entries(e.search))r.has(c)||(o[c]=l)}return{pathname:e.pathname,search:o,hash:s?e.hash:void 0}},z=(e,t,n)=>{const s=Ht(e,n);return typeof t=="string"?b(s)===t:t instanceof RegExp?((t.global||t.sticky)&&(t.lastIndex=0),t.test(b(s))):t(s)};class Dt{constructor(t){this.current=t}get location(){return this.current}setLocation(t){return this.current=L(t),this}setPathname(t){return this.current={...this.current,pathname:t},this}setHash(t){const n=N(t);if(n==null){const{hash:s,...a}=this.current;this.current=a}else this.current={...this.current,hash:n};return this}clearHash(){const{hash:t,...n}=this.current;return this.current=n,this}setSearch(t){return this.current={...this.current,search:lt(this.current.search,t)},this}setSearchParam(t,n){return this.setSearch({[t]:n})}updateSearch(t){return this.current={...this.current,search:{...t({...this.current.search})}},this}}const Mt=(e,t)=>e?.replace?"replaceState":t,Vt=e=>{const t=e.location,n=t.map(b),s=t.map(u=>u.pathname),a=t.map(u=>({...u.search})),o=t.map(u=>u.hash),r=(u,p)=>z(e.location.value,u,p),c=(u,p)=>i.computedOf(t,u)((m,k)=>z(m,k,p)),l=(u,p,m)=>{const k=L({...u,hash:N(u.hash??void 0)});e.commit(k,p,m)},h=(u,p)=>{const m=Mt(p,"pushState");l(u,p,m)},d=(u,p)=>{const m=u(L(e.location.value));h(m,p)},w=(u,p)=>{const m=e.resolve(u);h(m,p)},R=(u,p)=>{const m={...p,replace:!0};w(u,m)},O=(u,p)=>{e.go(u,p)},g=u=>{e.back(u)},E=u=>{e.forward(u)},v=(u,p)=>d(m=>({...m,pathname:u}),p),S=(u,p)=>d(m=>{const k={...m},J=N(u);return J==null?delete k.hash:k.hash=J,k},p),A=u=>S(void 0,u),y=(u,p)=>d(m=>({...m,search:lt(m.search,u)}),p);return{handle:{location:t,url:n,pathname:s,search:a,hash:o,setLocation:h,updateLocation:d,navigate:w,replace:R,go:O,back:g,forward:E,setPathname:v,setHash:S,clearHash:A,setSearch:y,setSearchParam:(u,p,m)=>y({[u]:p},m),updateSearch:(u,p)=>d(m=>({...m,search:{...u({...m.search})}}),p),queryParam:u=>t.map(p=>p.search[u]),run:(u,p)=>{const m=new Dt(L(e.location.value));u(m),h(L(m.location),p)},match:r,matchSignal:c},dispose:()=>{e.dispose(),n.dispose(),s.dispose(),a.dispose(),o.dispose()}}},Ft=e=>{if(e.isBrowser())return Lt();if(e.isHeadless())return Tt(e);throw new Error("Unknown context")},K={mark:i.makeProviderMark("Location"),create:(e,t)=>{const n=Ft(t),{handle:s,dispose:a}=Vt(n);return{value:s,dispose:a}}},ut=(e,...t)=>{if(typeof e=="string"||i.Signal.is(e))return ut({href:e},...t);const{href:n,state:s,scroll:a,viewTransition:o,replace:r,...c}=e;return i.Use(K,l=>i.html.a(i.on.click(it(()=>{let h=!1;const d={};return s!==void 0&&(d.state=s,h=!0),a!==void 0&&(d.scroll=a,h=!0),o!==void 0&&(d.viewTransition=o,h=!0),r!==void 0&&(d.replace=r,h=!0),l.navigate(i.Value.get(n),h?d:void 0),!0},c)),i.attr.href(n),...t))},Ut={mark:i.makeProviderMark("Appearance"),create:()=>{const e=ht();return{value:e,dispose:()=>e.dispose()}}};function ht(){const e=i.getWindow(),t=e!=null&&e.matchMedia!=null?e.matchMedia("(prefers-color-scheme: dark)"):void 0,n=t?.matches??!1,s=i.prop(n?"dark":"light"),a=o=>s.set(o.matches?"dark":"light");return t?.addEventListener("change",a),s.onDispose(()=>t?.removeEventListener("change",a)),s}const j=(e,t)=>{if(typeof t=="function")return j(e,{success:t});const n=t.failure??(r=>r.map(c=>`Error: ${c}`)),s=t.success,a=t.loading??(()=>i.Empty),o=t.notAsked??(()=>i.Empty);return i.OneOfType(i.Value.toSignal(e),{AsyncSuccess:r=>s(r.$.value),AsyncFailure:r=>n(r.$.error),Loading:r=>a(r.map(c=>c.previousValue)),NotAsked:o})},Kt=(e=10)=>i.WithElement(t=>i.OnDispose(f.delayed(()=>t?.focus(),e))),Ct=(e=10)=>i.WithElement(t=>{const n=f.delayed(()=>t.select(),e);return i.OnDispose(n)});function Nt(e){const t=Object.entries(e);return i.Fragment(...t.map(([n,s])=>i.attr.class(i.Value.map(s,a=>a?n:void 0))))}const zt=i.WithElement(e=>{const t=e.style.getPropertyValue(":empty");return e.style.setProperty(":empty","display:none"),i.OnDispose(n=>{n&&e.style.setProperty(":empty",t)})}),_t=e=>i.Portal("head > title",i.attr.innerText(e)),$t={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},M={partial:new Map,full:new Map},W={partial:null,full:null};function jt(e){return W[e]==null&&(W[e]=new IntersectionObserver(t=>{t.forEach(n=>{M[e].get(n.target)?.set(n.isIntersecting)})},$t[e])),W[e]}const pt=({mode:e="partial",once:t=!1},n)=>{const s=i.prop(!1);return i.Fragment(i.WithElement(a=>{const o=typeof IntersectionObserver<"u"?jt(e):null;M[e].set(a,s),o?.observe(a);function r(){o?.unobserve(a),M[e].delete(a),M[e].size===0&&(W[e]?.disconnect(),W[e]=null)}let c=null;return t&&(c=s.on(l=>{l&&r()})),i.OnDispose(()=>{s.dispose(),r(),c?.()})}),i.renderableOfTNode(n(s)))},It=(e,t,n)=>pt(e,s=>i.When(s,t,n??(()=>i.Empty)));function dt(e){return i.WithElement(t=>{const n=s=>{t.contains(s.target)||e(s)};return document.addEventListener("click",n),i.OnDispose(()=>{document.removeEventListener("click",n)})})}const x=(e,t)=>e===void 0||e===t,tt=(e,t)=>e===void 0||e===t;function mt(e,t){return typeof e=="string"?t.key===e:tt(e.key,t.key)&&tt(e.code,t.code)&&x(e.ctrlKey,t.ctrlKey)&&x(e.altKey,t.altKey)&&x(e.shiftKey,t.shiftKey)&&x(e.metaKey,t.metaKey)&&x(e.repeat,t.repeat)&&x(e.commandOrControlKey,t.metaKey||t.ctrlKey)}function I({allowedKeys:e,handler:t}){return i.WithElement(n=>{const s=a=>{if(n.contains(a.target)){for(const o of e)if(mt(o,a)){t(a);break}}};return document.addEventListener("keydown",s),i.OnDispose(()=>{document.removeEventListener("keydown",s)})})}function qt(e){return I({allowedKeys:["Enter"],handler:e})}function Qt(e){return I({allowedKeys:["Escape"],handler:e})}const ft=({mutate:e,convertError:t,onSuccess:n,onError:s,onSettled:a})=>{let o;const r=i.prop(f.AsyncResult.notAsked),c=r.map(g=>f.AsyncResult.isSuccess(g)?g.value:void 0),l=r.map(g=>f.AsyncResult.isFailure(g)?g.error:void 0),h=r.map(g=>f.AsyncResult.isLoading(g)),d=()=>{o?.abort(),o=void 0};return{status:r,value:c,error:l,pending:h,execute:async(g,E)=>{d(),o=new AbortController;const v=o.signal,S=r.get(),A=E?.optimisticValue??(E?.optimisticFromRequest!=null?E.optimisticFromRequest(g):void 0);A!=null?r.set(f.AsyncResult.loading(A)):r.set(f.AsyncResult.loading(f.AsyncResult.getOrUndefined(S)));try{const y=await e({request:g,abortSignal:v,previous:S});o=void 0,r.set(f.AsyncResult.success(y)),n?.(y,g)}catch(y){o=void 0,r.set(f.AsyncResult.failure(t(y))),s?.(t(y),g)}a?.(r.get(),g)},cancel:g=>{d(),r.set(g??f.AsyncResult.notAsked)},dispose:()=>{o?.abort(),o=void 0,r.dispose()}}},gt=(e,t)=>{const{status:n,dispose:s,execute:a,cancel:o,pending:r,error:c,value:l}=e,{content:h}=t,d=i.previousSignal(l);return i.Fragment(i.OnDispose(s),h({previous:d,execute:a,cancel:o,pending:r,error:c,value:l,status:n}))},Bt=({mutate:e,convertError:t=r=>r,onSuccess:n,onError:s,onSettled:a,content:o})=>{const r=ft({mutate:e,convertError:t,onSuccess:n,onError:s,onSettled:a});return gt(r,{content:o})},Yt=["top","top-start","top-end","right","right-start","right-end","bottom","bottom-start","bottom-end","left","left-start","left-end"],Jt=(e,t={isOpen:!1})=>{const n=[];let s=null;const a=i.Value.deriveProp(t.isOpen);function o(c){s=c,a.set(!0)}function r(){a.set(!1),n.forEach(c=>c()),n.length=0}return i.Fragment(e(o,r),i.When(a,()=>i.Fragment(s?.onClickOutside!=null?dt(s.onClickOutside):null,i.WithElement(c=>i.Portal("body",i.html.div(i.WithElement(l=>{l.style.position="absolute",l.style.width="max-content",l.style.maxWidth="100vw";const h=typeof s?.target=="string"?c.querySelector(s.target):s?.target??c;if(h==null)throw new Error(`Target not found: ${s?.target}`);let d=null;const w=i.Value.toSignal(s?.mainAxisOffset??0),R=i.Value.toSignal(s?.crossAxisOffset??0),O=i.Value.toSignal(s?.placement??"top"),g=i.Value.toSignal(s?.arrowPadding??0),E=s?.arrow,v=i.prop({centerOffset:0,alignmentOffset:0,containerWidth:0,containerHeight:0,x:void 0,y:void 0});async function S(){const y=[P.flip(),P.offset({mainAxis:w.get(),crossAxis:R.get()}),P.shift(),P.flip()];E!=null&&d!=null&&y.push(P.arrow({element:d,padding:g.get()}));const D=await P.computePosition(h,l,{placement:O.get(),strategy:"absolute",middleware:y}),{x:Q,y:B,middlewareData:C}=D;if(l.style.top=`${B}px`,l.style.left=`${Q}px`,d!=null&&C.arrow!=null){const{x:Y,y:u,centerOffset:p,alignmentOffset:m}=C.arrow;v.set({x:Y,y:u,centerOffset:p,alignmentOffset:m,containerWidth:l.offsetWidth,containerHeight:l.offsetHeight})}}const A=i.effectOf(w,R,O)(S);return i.Fragment(s?.content,s?.arrow!=null?i.html.div(s?.arrow(i.computedOf(v,O)((y,D)=>({...y,placement:D}))),i.WithElement(y=>{d=y,S()})):null,i.OnDispose(P.autoUpdate(h,l,S),A))})))))))},vt=({request:e,load:t,convertError:n,onSuccess:s,onError:a,onSettled:o})=>{let r;const c=i.prop(f.AsyncResult.notAsked),l=c.map(v=>f.AsyncResult.isSuccess(v)?v.value:void 0),h=c.map(v=>f.AsyncResult.isFailure(v)?v.error:void 0),d=c.map(v=>f.AsyncResult.isLoading(v)),w=()=>{r?.abort(),r=void 0},R=v=>{w(),c.set(v??f.AsyncResult.notAsked)},O=async v=>{w(),r=new AbortController;const S=r.signal,A=c.get();c.set(f.AsyncResult.loading(f.AsyncResult.getOrUndefined(A)));try{const y=await t({request:v,abortSignal:S,previous:A});await Promise.resolve(),r=void 0,c.set(f.AsyncResult.success(y)),s?.(y,v)}catch(y){r=void 0,c.set(f.AsyncResult.failure(n(y))),a?.(n(y),v)}o?.(c.get(),v)},g=()=>O(i.Value.get(e)),E=()=>{r?.abort(),r=void 0,c.dispose()};return c.onDispose(i.Value.on(e,O)),{status:c,value:l,error:h,loading:d,cancel:R,reload:g,dispose:E}},yt=(e,t)=>{const{status:n,dispose:s,reload:a}=e,{pending:o,failure:r,success:c}=t;return i.Fragment(i.OnDispose(s),j(n,{loading:o!=null?l=>o({previous:l,reload:a,cancel:e.cancel}):void 0,failure:r!=null?l=>r({error:l,reload:a}):void 0,success:l=>c({value:l,reload:a})}))},Xt=({request:e,load:t,convertError:n=h=>h,onSuccess:s,onError:a,onSettled:o,success:r,pending:c,failure:l})=>{const h=vt({request:e,load:t,convertError:n,onSuccess:s,onError:a,onSettled:o});return yt(h,{success:r,pending:c,failure:l})},wt=(e,t)=>{if(typeof t=="function")return wt(e,{success:t});const n=t.failure??(a=>(a.on(console.error),a.map(o=>`Error: ${o}`))),s=t.success;return i.OneOfType(i.Value.toSignal(e),{Success:a=>s(a.$.value),Failure:a=>n(a.$.error)})},Gt=()=>i.on.focus(e=>e.target?.select());class H{constructor(t,n,s,a,o,r){this.left=t,this.top=n,this.width=s,this.height=a,this.localLeft=o,this.localTop=r}static of({left:t=0,top:n=0,width:s=0,height:a=0,localLeft:o=0,localTop:r=0}){return new H(t,n,s,a,o,r)}get right(){return this.left+this.width}get bottom(){return this.top+this.height}get center(){return{x:this.left+this.width/2,y:this.top+this.height/2}}get localCenter(){return{x:this.localLeft+this.width/2,y:this.localTop+this.height/2}}get localBottom(){return this.localTop+this.height}get localRight(){return this.localLeft+this.width}get size(){return{width:this.width,height:this.height}}equals=t=>f.nearEqual(this.left,t.left)&&f.nearEqual(this.top,t.top)&&f.nearEqual(this.width,t.width)&&f.nearEqual(this.height,t.height)}function _(e){const t=e.getBoundingClientRect();return H.of({top:t.top+window.scrollY,left:t.left+window.scrollX,width:t.width,height:t.height,localLeft:e.offsetLeft,localTop:e.offsetTop})}const Zt=e=>i.WithBrowserCtx(t=>{const{element:n}=t,s=i.prop(_(n),(c,l)=>c.equals(l)),a=i.renderableOfTNode(e(s)).render(t),o=()=>s.set(H.of(_(n)));let r=null;return typeof ResizeObserver<"u"&&(r=new ResizeObserver(o)),r?.observe(n),i.OnDispose(c=>{r?.disconnect(),a(c)})});function et(e){return{width:e?.innerWidth??0,height:e?.innerHeight??0}}const te=e=>i.WithCtx(()=>{const t=i.getWindow(),n=i.prop(et(t),(a,o)=>a.width===o.width&&a.height===o.height),s=()=>n.set(et(t));return t?.addEventListener("resize",s),i.Fragment(i.OnDispose(()=>{t?.removeEventListener("resize",s)}),e(n))}),St=(e,t)=>{const n=t.split("/").filter(o=>o!==""),s=o=>{try{return decodeURIComponent(o)}catch{return o}},a={};for(let o=0;o<e.length;o++){const r=e[o],c=n[o];if(!c&&r.type!=="catch-all")return null;if(r.type==="literal"){if(r.value!==c)return null}else if(r.type==="param")a[r.name]=s(c);else if(r.type==="catch-all"){if(r.name){const l=n.slice(o).join("/");a[r.name]=s(l)}return{params:a,path:t}}}return n.length!==e.length?null:{params:a,path:t}},q=e=>e.split("/").map(t=>{if(t.startsWith(":"))return{type:"param",name:t.slice(1)};if(t.startsWith("*")){const n=t.slice(1);return n!=""?{type:"catch-all",name:n}:{type:"catch-all"}}else return{type:"literal",value:t}}).filter(t=>t.type!=="literal"||t.value!==""),ee=e=>{const t=e.map(n=>{const s=q(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of t){const r=St(a,s);if(r)return{...r,route:o}}return null}},ne=e=>{if(e==null)throw new Error("NavigationService: no Location handle attached. Make sure to attach one before calling navigation helpers.");return e};class se{handles=[];attach(t){const n=this.handles.lastIndexOf(t);return n!==-1&&this.handles.splice(n,1),this.handles.push(t),()=>this.detach(t)}detach(t){for(let n=this.handles.length-1;n>=0;n--)if(this.handles[n]===t){this.handles.splice(n,1);break}}get current(){return this.handles[this.handles.length-1]}getHandle(){return ne(this.current)}navigate(t,n){this.getHandle().navigate(t,n)}replace(t,n){this.getHandle().replace(t,n)}go(t,n){this.getHandle().go(t,n)}back(t){this.getHandle().back(t)}forward(t){this.getHandle().forward(t)}setPathname(t,n){this.getHandle().setPathname(t,n)}setSearch(t,n){this.getHandle().setSearch(t,n)}setSearchParam(t,n,s){this.getHandle().setSearchParam(t,n,s)}updateSearch(t,n){this.getHandle().updateSearch(t,n)}setHash(t,n){this.getHandle().setHash(t,n)}clearHash(t){this.getHandle().clearHash(t)}run(t,n){this.getHandle().run(t,n)}}const re=new se,F={mark:i.makeProviderMark("RouterContext"),create:()=>{const e=i.prop([]);return{value:e,dispose:()=>e.dispose()}}},ae=(e,t,n)=>{const s=n.split("/").filter(r=>r!==""),a={};let o=0;for(let r=0;r<e.length;r++){const c=e[r],l=s[r];if(!l&&c.type!=="catch-all")return null;if(c.type==="literal"){if(c.value!==l)return null;o++}else if(c.type==="param")a[c.name]=l,o++;else if(c.type==="catch-all"){c.name&&(a[c.name]=s.slice(o).join("/"));const h="/"+s.slice(0,o).join("/"),d="/"+s.slice(o).join("/");return{params:a,matchedPath:h==="/"?"":h,remainingPath:d==="/"?"":d,route:t}}}if(s.length===e.length){const r="/"+s.join("/");return{params:a,matchedPath:r==="/"?"":r,remainingPath:"",route:t}}return null},Rt=e=>{const t=e.map(n=>{const s=q(n);return{route:n,segments:s}});return function(s){for(const{segments:a,route:o}of t){const r=ae(a,o,s);if(r)return r}return null}},oe=e=>{const t=Rt(Object.keys(e));return i.Provide(F,{},()=>i.Use(K,n=>i.Use(F,s=>{const a=n.location.map(o=>{const r=t(o.pathname);if(r==null)throw console.error("No route found for",o),new Error("No route found");const c={matchedPath:r.matchedPath,remainingPath:r.remainingPath,fullPath:o.pathname,params:r.params};return s.value=[...s.value,c],{params:r.params,route:r.route,path:r.matchedPath||o.pathname,search:o.search,hash:o.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),e)})))},ie=e=>{const t=Rt(Object.keys(e));return i.Use(F,n=>i.Use(K,s=>{const a=n.map(o=>{const r=o[o.length-1];if(r==null)throw console.error("No router context available for ChildRouter",o),new Error("No router context available for ChildRouter");const c=r.remainingPath??"",l=t(c);if(l==null)throw console.error("No route found for remaining path",c),new Error("No route found");return{params:l.params,route:l.route,path:l.matchedPath,search:s.location.value.search,hash:s.location.value.hash}});return i.OneOfTuple(a.map(o=>[o.route,o]),e)}))},U=60*1e3,$=60*U,T=24*$,nt=7*T,st=30*T,ce=365*T,le=[{max:U*90,value:U,name:"minute",past:{singular:"a minute ago",plural:"{} minutes ago"},future:{singular:"in a minute",plural:"in {} minutes"}},{max:$*36,value:$,name:"hour",past:{singular:"an hour ago",plural:"{} hours ago"},future:{singular:"in an hour",plural:"in {} hours"}},{max:T*10,value:T,name:"day",past:{singular:"yesterday",plural:"{} days ago"},future:{singular:"tomorrow",plural:"in {} days"}},{max:nt*6,value:nt,name:"week",past:{singular:"last week",plural:"{} weeks ago"},future:{singular:"in a week",plural:"in {} weeks"}},{max:st*18,value:st,name:"month",past:{singular:"last month",plural:"{} months ago"},future:{singular:"in a month",plural:"in {} months"}},{max:1/0,value:ce,name:"year",past:{singular:"last year",plural:"{} years ago"},future:{singular:"in a year",plural:"in {} years"}}];function rt(e,t,n,s){const a=Math.round(e/t);return a<=1?n:s.replace("{}",a.toLocaleString(void 0,{maximumFractionDigits:0,minimumFractionDigits:0}))}const Ot=(e=1e3)=>{const t=i.prop(new Date),n=f.interval(()=>t.set(new Date),e);return t.onDispose(n),t},Et=e=>{const t=Math.abs(e);if(t<U)return e<0?"just now":"in a moment";for(const n of le)if(t<n.max)return e<0?rt(t,n.value,n.past.singular,n.past.plural):rt(t,n.value,n.future.singular,n.future.plural);throw new Error("unreachable")},At=(e,{now:t,frequency:n=1e4}={})=>{const s=t!=null?i.Signal.is(t)?t.derive():i.prop(t):Ot(n),a=i.computedOf(e,s)((o,r)=>o.getTime()-r.getTime());return a.onDispose(()=>i.Value.dispose(s)),a},kt=(e,t={})=>{const n=At(e,t),s=n.map(Et);return s.onDispose(()=>n.dispose()),s},ue=(e,t={})=>kt(e,t);class Pt extends i.Prop{tick=()=>this.update(t=>t+1)}const he=(e=0)=>new Pt(e,i.strictEquals);exports.Anchor=ut;exports.Appearance=Ut;exports.AsyncResultView=j;exports.AutoFocus=Kt;exports.AutoSelect=Ct;exports.ChildRouter=ie;exports.ElementRect=Zt;exports.HTMLTitle=_t;exports.HiddenWhenEmpty=zt;exports.InViewport=pt;exports.Location=K;exports.Mutation=Bt;exports.MutationDisplay=gt;exports.NavigationService=re;exports.OnClickOutside=dt;exports.OnEnterKey=qt;exports.OnEscapeKey=Qt;exports.OnKeyPressed=I;exports.PopOver=Jt;exports.Query=Xt;exports.QueryDisplay=yt;exports.Rect=H;exports.ResultView=wt;exports.RootRouter=oe;exports.RouterContextProvider=F;exports.SelectOnFocus=Gt;exports.Ticker=Pt;exports.WhenInViewport=It;exports.WindowSize=te;exports._checkExtensionCondition=ot;exports._getExtension=at;exports._makeRouteMatcher=ee;exports._parseRouteSegments=q;exports.allPlacements=Yt;exports.areLocationsEqual=ct;exports.classes=Nt;exports.evaluateLocationMatch=z;exports.getAbsoluteRect=_;exports.handleAnchorClick=it;exports.locationFromURL=V;exports.makeMutationResource=ft;exports.makeQueryResource=vt;exports.matchesKeyCombo=mt;exports.matchesRoute=St;exports.nowSignal=Ot;exports.relativeTime=ue;exports.relativeTimeMillisSignal=At;exports.relativeTimeSignal=kt;exports.ticker=he;exports.timeDiffToString=Et;exports.urlFromLocation=b;exports.useAppearance=ht;
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getWindow as
|
|
2
|
-
import { delayed as
|
|
1
|
+
import { getWindow as T, prop as x, makeProviderMark as Q, computedOf as J, Signal as ft, Use as M, html as V, on as mt, Value as y, attr as X, Empty as _, OneOfType as gt, WithElement as L, OnDispose as b, Fragment as R, Portal as vt, renderableOfTNode as wt, When as yt, previousSignal as Lt, effectOf as Rt, WithBrowserCtx as At, WithCtx as Ht, OneOfTuple as St, Provide as Wt, Prop as Tt, strictEquals as Ut } from "@tempots/dom";
|
|
2
|
+
import { delayed as xt, AsyncResult as v, nearEqual as C, interval as Kt } from "@tempots/std";
|
|
3
3
|
import { autoUpdate as Mt, flip as st, offset as Dt, shift as Nt, computePosition as Ct, arrow as Ft } from "@floating-ui/dom";
|
|
4
4
|
const zt = (e) => {
|
|
5
5
|
const t = e.split("/").pop();
|
|
@@ -42,20 +42,20 @@ const zt = (e) => {
|
|
|
42
42
|
) || e() && s.preventDefault();
|
|
43
43
|
};
|
|
44
44
|
}, _t = (e, t) => e.pathname === t.pathname && JSON.stringify(e.search) === JSON.stringify(t.search) && e.hash === t.hash, I = (e, t) => {
|
|
45
|
-
const n = new URL(e, t ??
|
|
45
|
+
const n = new URL(e, t ?? T()?.location.toString()), s = Object.fromEntries(n.searchParams?.entries() ?? []);
|
|
46
46
|
let a = n.hash;
|
|
47
47
|
return a.startsWith("#") && (a = a.substring(1)), {
|
|
48
48
|
pathname: n.pathname,
|
|
49
49
|
search: s,
|
|
50
50
|
hash: a === "" ? void 0 : a
|
|
51
51
|
};
|
|
52
|
-
},
|
|
52
|
+
}, W = (e) => {
|
|
53
53
|
const n = new URLSearchParams(e.search).toString(), s = e.hash;
|
|
54
54
|
return `${e.pathname}${n ? `?${n}` : ""}${s ? `#${s}` : ""}`;
|
|
55
55
|
}, It = (e) => {
|
|
56
56
|
document.startViewTransition ? document.startViewTransition(e) : e();
|
|
57
57
|
}, rt = () => {
|
|
58
|
-
const e =
|
|
58
|
+
const e = T(), t = e?.location.hash ?? "";
|
|
59
59
|
return {
|
|
60
60
|
pathname: e?.location.pathname ?? "",
|
|
61
61
|
search: Object.fromEntries(
|
|
@@ -66,21 +66,21 @@ const zt = (e) => {
|
|
|
66
66
|
}, at = (e) => {
|
|
67
67
|
if (e?.scroll !== "auto")
|
|
68
68
|
return;
|
|
69
|
-
const t =
|
|
69
|
+
const t = T();
|
|
70
70
|
t && t.requestAnimationFrame(
|
|
71
71
|
() => t.scrollTo({ top: 0, left: 0, behavior: "auto" })
|
|
72
72
|
);
|
|
73
73
|
}, ot = (e, t) => {
|
|
74
74
|
t?.viewTransition ? It(e) : e();
|
|
75
75
|
}, Bt = () => {
|
|
76
|
-
const e =
|
|
76
|
+
const e = x(rt(), _t), t = T(), n = () => {
|
|
77
77
|
e.set(rt());
|
|
78
78
|
};
|
|
79
79
|
t?.addEventListener("popstate", n), t?.addEventListener("hashchange", n);
|
|
80
80
|
const s = (c, u, d) => {
|
|
81
81
|
ot(() => {
|
|
82
82
|
if (t) {
|
|
83
|
-
const w =
|
|
83
|
+
const w = W(c), P = u?.state ?? {};
|
|
84
84
|
d === "replaceState" || u?.replace ? t.history.replaceState(P, "", w) : t.history.pushState(P, "", w);
|
|
85
85
|
}
|
|
86
86
|
e.set(c);
|
|
@@ -106,9 +106,9 @@ const zt = (e) => {
|
|
|
106
106
|
(r) => I(r, t.value),
|
|
107
107
|
(r) => {
|
|
108
108
|
if (qt(r.pathname))
|
|
109
|
-
return
|
|
109
|
+
return W(r);
|
|
110
110
|
const i = new URL(r.pathname, t.value), c = i.origin + i.pathname;
|
|
111
|
-
return
|
|
111
|
+
return W({ ...r, pathname: c });
|
|
112
112
|
}
|
|
113
113
|
);
|
|
114
114
|
return {
|
|
@@ -137,7 +137,7 @@ const zt = (e) => {
|
|
|
137
137
|
if (e == null) return;
|
|
138
138
|
const t = `${e}`;
|
|
139
139
|
return t === "" ? void 0 : t;
|
|
140
|
-
},
|
|
140
|
+
}, bt = (e, t) => {
|
|
141
141
|
const n = { ...e };
|
|
142
142
|
for (const [s, a] of Object.entries(t))
|
|
143
143
|
a == null ? delete n[s] : n[s] = a;
|
|
@@ -162,7 +162,7 @@ const zt = (e) => {
|
|
|
162
162
|
};
|
|
163
163
|
}, it = (e, t, n) => {
|
|
164
164
|
const s = Qt(e, n);
|
|
165
|
-
return typeof t == "string" ?
|
|
165
|
+
return typeof t == "string" ? W(s) === t : t instanceof RegExp ? ((t.global || t.sticky) && (t.lastIndex = 0), t.test(W(s))) : t(s);
|
|
166
166
|
};
|
|
167
167
|
class Jt {
|
|
168
168
|
constructor(t) {
|
|
@@ -199,7 +199,7 @@ class Jt {
|
|
|
199
199
|
setSearch(t) {
|
|
200
200
|
return this.current = {
|
|
201
201
|
...this.current,
|
|
202
|
-
search:
|
|
202
|
+
search: bt(this.current.search, t)
|
|
203
203
|
}, this;
|
|
204
204
|
}
|
|
205
205
|
setSearchParam(t, n) {
|
|
@@ -213,7 +213,7 @@ class Jt {
|
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
215
|
const Xt = (e, t) => e?.replace ? "replaceState" : t, Gt = (e) => {
|
|
216
|
-
const t = e.location, n = t.map(
|
|
216
|
+
const t = e.location, n = t.map(W), s = t.map((l) => l.pathname), a = t.map((l) => ({ ...l.search })), o = t.map((l) => l.hash), r = (l, h) => it(e.location.value, l, h), i = (l, h) => J(
|
|
217
217
|
t,
|
|
218
218
|
l
|
|
219
219
|
)(
|
|
@@ -240,15 +240,15 @@ const Xt = (e, t) => e?.replace ? "replaceState" : t, Gt = (e) => {
|
|
|
240
240
|
e.go(l, h);
|
|
241
241
|
}, f = (l) => {
|
|
242
242
|
e.back(l);
|
|
243
|
-
},
|
|
243
|
+
}, O = (l) => {
|
|
244
244
|
e.forward(l);
|
|
245
245
|
}, m = (l, h) => d((p) => ({ ...p, pathname: l }), h), S = (l, h) => d((p) => {
|
|
246
246
|
const A = { ...p }, nt = B(l);
|
|
247
247
|
return nt == null ? delete A.hash : A.hash = nt, A;
|
|
248
|
-
}, h),
|
|
248
|
+
}, h), E = (l) => S(void 0, l), g = (l, h) => d(
|
|
249
249
|
(p) => ({
|
|
250
250
|
...p,
|
|
251
|
-
search:
|
|
251
|
+
search: bt(p.search, l)
|
|
252
252
|
}),
|
|
253
253
|
h
|
|
254
254
|
);
|
|
@@ -265,10 +265,10 @@ const Xt = (e, t) => e?.replace ? "replaceState" : t, Gt = (e) => {
|
|
|
265
265
|
replace: P,
|
|
266
266
|
go: k,
|
|
267
267
|
back: f,
|
|
268
|
-
forward:
|
|
268
|
+
forward: O,
|
|
269
269
|
setPathname: m,
|
|
270
270
|
setHash: S,
|
|
271
|
-
clearHash:
|
|
271
|
+
clearHash: E,
|
|
272
272
|
setSearch: g,
|
|
273
273
|
setSearchParam: (l, h, p) => g({ [l]: h }, p),
|
|
274
274
|
updateSearch: (l, h) => d(
|
|
@@ -326,7 +326,7 @@ const Xt = (e, t) => e?.replace ? "replaceState" : t, Gt = (e) => {
|
|
|
326
326
|
...t
|
|
327
327
|
/* c8 ignore next 2 */
|
|
328
328
|
));
|
|
329
|
-
},
|
|
329
|
+
}, Ee = {
|
|
330
330
|
mark: Q("Appearance"),
|
|
331
331
|
create: () => {
|
|
332
332
|
const e = ee();
|
|
@@ -337,7 +337,7 @@ const Xt = (e, t) => e?.replace ? "replaceState" : t, Gt = (e) => {
|
|
|
337
337
|
}
|
|
338
338
|
};
|
|
339
339
|
function ee() {
|
|
340
|
-
const e =
|
|
340
|
+
const e = T(), t = e != null && e.matchMedia != null ? e.matchMedia("(prefers-color-scheme: dark)") : void 0, n = t?.matches ?? !1, s = x(n ? "dark" : "light"), a = (o) => s.set(o.matches ? "dark" : "light");
|
|
341
341
|
return t?.addEventListener("change", a), s.onDispose(() => t?.removeEventListener("change", a)), s;
|
|
342
342
|
}
|
|
343
343
|
const Pt = (e, t) => {
|
|
@@ -350,9 +350,9 @@ const Pt = (e, t) => {
|
|
|
350
350
|
Loading: (r) => a(r.map((i) => i.previousValue)),
|
|
351
351
|
NotAsked: o
|
|
352
352
|
});
|
|
353
|
-
}, Le = (e = 10) => L((t) =>
|
|
354
|
-
const n =
|
|
355
|
-
return
|
|
353
|
+
}, Le = (e = 10) => L((t) => b(xt(() => t?.focus(), e))), Re = (e = 10) => L((t) => {
|
|
354
|
+
const n = xt(() => t.select(), e);
|
|
355
|
+
return b(n);
|
|
356
356
|
});
|
|
357
357
|
function Ae(e) {
|
|
358
358
|
const t = Object.entries(e);
|
|
@@ -364,10 +364,10 @@ function Ae(e) {
|
|
|
364
364
|
}
|
|
365
365
|
const He = L((e) => {
|
|
366
366
|
const t = e.style.getPropertyValue(":empty");
|
|
367
|
-
return e.style.setProperty(":empty", "display:none"),
|
|
367
|
+
return e.style.setProperty(":empty", "display:none"), b((n) => {
|
|
368
368
|
n && e.style.setProperty(":empty", t);
|
|
369
369
|
});
|
|
370
|
-
}),
|
|
370
|
+
}), We = (e) => vt("head > title", X.innerText(e)), ne = {
|
|
371
371
|
partial: {
|
|
372
372
|
root: null,
|
|
373
373
|
rootMargin: "0px",
|
|
@@ -393,7 +393,7 @@ function se(e) {
|
|
|
393
393
|
}, ne[e])), K[e];
|
|
394
394
|
}
|
|
395
395
|
const re = ({ mode: e = "partial", once: t = !1 }, n) => {
|
|
396
|
-
const s =
|
|
396
|
+
const s = x(!1);
|
|
397
397
|
return R(
|
|
398
398
|
L((a) => {
|
|
399
399
|
const o = typeof IntersectionObserver < "u" ? se(e) : null;
|
|
@@ -404,19 +404,19 @@ const re = ({ mode: e = "partial", once: t = !1 }, n) => {
|
|
|
404
404
|
let i = null;
|
|
405
405
|
return t && (i = s.on((c) => {
|
|
406
406
|
c && r();
|
|
407
|
-
})),
|
|
407
|
+
})), b(() => {
|
|
408
408
|
s.dispose(), r(), i?.();
|
|
409
409
|
});
|
|
410
410
|
}),
|
|
411
411
|
wt(n(s))
|
|
412
412
|
);
|
|
413
|
-
},
|
|
413
|
+
}, Te = (e, t, n) => re(e, (s) => yt(s, t, n ?? (() => _)));
|
|
414
414
|
function ae(e) {
|
|
415
415
|
return L((t) => {
|
|
416
416
|
const n = (s) => {
|
|
417
417
|
t.contains(s.target) || e(s);
|
|
418
418
|
};
|
|
419
|
-
return document.addEventListener("click", n),
|
|
419
|
+
return document.addEventListener("click", n), b(() => {
|
|
420
420
|
document.removeEventListener("click", n);
|
|
421
421
|
});
|
|
422
422
|
});
|
|
@@ -442,7 +442,7 @@ function kt({
|
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
};
|
|
445
|
-
return document.addEventListener("keydown", s),
|
|
445
|
+
return document.addEventListener("keydown", s), b(() => {
|
|
446
446
|
document.removeEventListener("keydown", s);
|
|
447
447
|
});
|
|
448
448
|
});
|
|
@@ -461,7 +461,7 @@ const ie = ({
|
|
|
461
461
|
onSettled: a
|
|
462
462
|
}) => {
|
|
463
463
|
let o;
|
|
464
|
-
const r =
|
|
464
|
+
const r = x(v.notAsked), i = r.map(
|
|
465
465
|
(f) => v.isSuccess(f) ? f.value : void 0
|
|
466
466
|
), c = r.map(
|
|
467
467
|
(f) => v.isFailure(f) ? f.error : void 0
|
|
@@ -473,10 +473,10 @@ const ie = ({
|
|
|
473
473
|
value: i,
|
|
474
474
|
error: c,
|
|
475
475
|
pending: u,
|
|
476
|
-
execute: async (f,
|
|
476
|
+
execute: async (f, O) => {
|
|
477
477
|
d(), o = new AbortController();
|
|
478
|
-
const m = o.signal, S = r.get(),
|
|
479
|
-
|
|
478
|
+
const m = o.signal, S = r.get(), E = O?.optimisticValue ?? (O?.optimisticFromRequest != null ? O.optimisticFromRequest(f) : void 0);
|
|
479
|
+
E != null ? r.set(v.loading(E)) : r.set(v.loading(v.getOrUndefined(S)));
|
|
480
480
|
try {
|
|
481
481
|
const g = await e({ request: f, abortSignal: m, previous: S });
|
|
482
482
|
o = void 0, r.set(v.success(g)), n?.(g, f);
|
|
@@ -495,7 +495,7 @@ const ie = ({
|
|
|
495
495
|
}, ce = (e, t) => {
|
|
496
496
|
const { status: n, dispose: s, execute: a, cancel: o, pending: r, error: i, value: c } = e, { content: u } = t, d = Lt(c);
|
|
497
497
|
return R(
|
|
498
|
-
|
|
498
|
+
b(s),
|
|
499
499
|
u({
|
|
500
500
|
previous: d,
|
|
501
501
|
execute: a,
|
|
@@ -556,7 +556,7 @@ const ie = ({
|
|
|
556
556
|
"body",
|
|
557
557
|
V.div(
|
|
558
558
|
L((c) => {
|
|
559
|
-
c.style.position = "absolute";
|
|
559
|
+
c.style.position = "absolute", c.style.width = "max-content", c.style.maxWidth = "100vw";
|
|
560
560
|
const u = typeof s?.target == "string" ? i.querySelector(
|
|
561
561
|
s.target
|
|
562
562
|
) : s?.target ?? i;
|
|
@@ -570,7 +570,7 @@ const ie = ({
|
|
|
570
570
|
s?.placement ?? "top"
|
|
571
571
|
), f = y.toSignal(
|
|
572
572
|
s?.arrowPadding ?? 0
|
|
573
|
-
),
|
|
573
|
+
), O = s?.arrow, m = x({
|
|
574
574
|
centerOffset: 0,
|
|
575
575
|
alignmentOffset: 0,
|
|
576
576
|
containerWidth: 0,
|
|
@@ -588,7 +588,7 @@ const ie = ({
|
|
|
588
588
|
Nt(),
|
|
589
589
|
st()
|
|
590
590
|
];
|
|
591
|
-
|
|
591
|
+
O != null && d != null && g.push(
|
|
592
592
|
Ft({
|
|
593
593
|
element: d,
|
|
594
594
|
padding: f.get()
|
|
@@ -616,7 +616,7 @@ const ie = ({
|
|
|
616
616
|
});
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
|
-
const
|
|
619
|
+
const E = Rt(
|
|
620
620
|
w,
|
|
621
621
|
P,
|
|
622
622
|
k
|
|
@@ -640,9 +640,9 @@ const ie = ({
|
|
|
640
640
|
})
|
|
641
641
|
) : null,
|
|
642
642
|
// arrowSignal is automatically disposed by the scope
|
|
643
|
-
|
|
643
|
+
b(
|
|
644
644
|
Mt(u, c, S),
|
|
645
|
-
|
|
645
|
+
E
|
|
646
646
|
)
|
|
647
647
|
);
|
|
648
648
|
})
|
|
@@ -661,7 +661,7 @@ const ie = ({
|
|
|
661
661
|
onSettled: o
|
|
662
662
|
}) => {
|
|
663
663
|
let r;
|
|
664
|
-
const i =
|
|
664
|
+
const i = x(v.notAsked), c = i.map(
|
|
665
665
|
(m) => v.isSuccess(m) ? m.value : void 0
|
|
666
666
|
), u = i.map(
|
|
667
667
|
(m) => v.isFailure(m) ? m.error : void 0
|
|
@@ -671,16 +671,16 @@ const ie = ({
|
|
|
671
671
|
w(), i.set(m ?? v.notAsked);
|
|
672
672
|
}, k = async (m) => {
|
|
673
673
|
w(), r = new AbortController();
|
|
674
|
-
const S = r.signal,
|
|
675
|
-
i.set(v.loading(v.getOrUndefined(
|
|
674
|
+
const S = r.signal, E = i.get();
|
|
675
|
+
i.set(v.loading(v.getOrUndefined(E)));
|
|
676
676
|
try {
|
|
677
|
-
const g = await t({ request: m, abortSignal: S, previous:
|
|
677
|
+
const g = await t({ request: m, abortSignal: S, previous: E });
|
|
678
678
|
await Promise.resolve(), r = void 0, i.set(v.success(g)), s?.(g, m);
|
|
679
679
|
} catch (g) {
|
|
680
680
|
r = void 0, i.set(v.failure(n(g))), a?.(n(g), m);
|
|
681
681
|
}
|
|
682
682
|
o?.(i.get(), m);
|
|
683
|
-
}, f = () => k(y.get(e)),
|
|
683
|
+
}, f = () => k(y.get(e)), O = () => {
|
|
684
684
|
r?.abort(), r = void 0, i.dispose();
|
|
685
685
|
};
|
|
686
686
|
return i.onDispose(y.on(e, k)), {
|
|
@@ -690,12 +690,12 @@ const ie = ({
|
|
|
690
690
|
loading: d,
|
|
691
691
|
cancel: P,
|
|
692
692
|
reload: f,
|
|
693
|
-
dispose:
|
|
693
|
+
dispose: O
|
|
694
694
|
};
|
|
695
695
|
}, ue = (e, t) => {
|
|
696
696
|
const { status: n, dispose: s, reload: a } = e, { pending: o, failure: r, success: i } = t;
|
|
697
697
|
return R(
|
|
698
|
-
|
|
698
|
+
b(s),
|
|
699
699
|
Pt(n, {
|
|
700
700
|
loading: o != null ? (c) => o({ previous: c, reload: a, cancel: e.cancel }) : void 0,
|
|
701
701
|
failure: r != null ? (c) => r({ error: c, reload: a }) : void 0,
|
|
@@ -931,9 +931,9 @@ function lt(e) {
|
|
|
931
931
|
});
|
|
932
932
|
}
|
|
933
933
|
const ze = (e) => At((t) => {
|
|
934
|
-
const { element: n } = t, s =
|
|
934
|
+
const { element: n } = t, s = x(lt(n), (i, c) => i.equals(c)), a = wt(e(s)).render(t), o = () => s.set($.of(lt(n)));
|
|
935
935
|
let r = null;
|
|
936
|
-
return typeof ResizeObserver < "u" && (r = new ResizeObserver(o)), r?.observe(n),
|
|
936
|
+
return typeof ResizeObserver < "u" && (r = new ResizeObserver(o)), r?.observe(n), b((i) => {
|
|
937
937
|
r?.disconnect(), a(i);
|
|
938
938
|
});
|
|
939
939
|
});
|
|
@@ -945,12 +945,12 @@ function ut(e) {
|
|
|
945
945
|
};
|
|
946
946
|
}
|
|
947
947
|
const $e = (e) => Ht(() => {
|
|
948
|
-
const t =
|
|
948
|
+
const t = T(), n = x(
|
|
949
949
|
ut(t),
|
|
950
950
|
(a, o) => a.width === o.width && a.height === o.height
|
|
951
951
|
), s = () => n.set(ut(t));
|
|
952
952
|
return t?.addEventListener("resize", s), R(
|
|
953
|
-
|
|
953
|
+
b(() => {
|
|
954
954
|
t?.removeEventListener("resize", s);
|
|
955
955
|
}),
|
|
956
956
|
e(n)
|
|
@@ -981,7 +981,7 @@ const $e = (e) => Ht(() => {
|
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
983
|
return n.length !== e.length ? null : { params: a, path: t };
|
|
984
|
-
},
|
|
984
|
+
}, Ot = (e) => e.split("/").map((t) => {
|
|
985
985
|
if (t.startsWith(":"))
|
|
986
986
|
return { type: "param", name: t.slice(1) };
|
|
987
987
|
if (t.startsWith("*")) {
|
|
@@ -991,7 +991,7 @@ const $e = (e) => Ht(() => {
|
|
|
991
991
|
return { type: "literal", value: t };
|
|
992
992
|
}).filter((t) => t.type !== "literal" || t.value !== ""), je = (e) => {
|
|
993
993
|
const t = e.map((n) => {
|
|
994
|
-
const s =
|
|
994
|
+
const s = Ot(n);
|
|
995
995
|
return { route: n, segments: s };
|
|
996
996
|
});
|
|
997
997
|
return function(s) {
|
|
@@ -1068,7 +1068,7 @@ class fe {
|
|
|
1068
1068
|
const Ve = new fe(), q = {
|
|
1069
1069
|
mark: Q("RouterContext"),
|
|
1070
1070
|
create: () => {
|
|
1071
|
-
const e =
|
|
1071
|
+
const e = x([]);
|
|
1072
1072
|
return {
|
|
1073
1073
|
value: e,
|
|
1074
1074
|
dispose: () => e.dispose()
|
|
@@ -1108,9 +1108,9 @@ const Ve = new fe(), q = {
|
|
|
1108
1108
|
};
|
|
1109
1109
|
}
|
|
1110
1110
|
return null;
|
|
1111
|
-
},
|
|
1111
|
+
}, Et = (e) => {
|
|
1112
1112
|
const t = e.map((n) => {
|
|
1113
|
-
const s =
|
|
1113
|
+
const s = Ot(n);
|
|
1114
1114
|
return { route: n, segments: s };
|
|
1115
1115
|
});
|
|
1116
1116
|
return function(s) {
|
|
@@ -1122,8 +1122,8 @@ const Ve = new fe(), q = {
|
|
|
1122
1122
|
return null;
|
|
1123
1123
|
};
|
|
1124
1124
|
}, _e = (e) => {
|
|
1125
|
-
const t =
|
|
1126
|
-
return
|
|
1125
|
+
const t = Et(Object.keys(e));
|
|
1126
|
+
return Wt(
|
|
1127
1127
|
q,
|
|
1128
1128
|
{},
|
|
1129
1129
|
() => M(G, (n) => M(q, (s) => {
|
|
@@ -1153,7 +1153,7 @@ const Ve = new fe(), q = {
|
|
|
1153
1153
|
}))
|
|
1154
1154
|
);
|
|
1155
1155
|
}, Ie = (e) => {
|
|
1156
|
-
const t =
|
|
1156
|
+
const t = Et(Object.keys(e));
|
|
1157
1157
|
return M(q, (n) => M(G, (s) => {
|
|
1158
1158
|
const a = n.map((o) => {
|
|
1159
1159
|
const r = o[o.length - 1];
|
|
@@ -1232,7 +1232,7 @@ function pt(e, t, n, s) {
|
|
|
1232
1232
|
);
|
|
1233
1233
|
}
|
|
1234
1234
|
const we = (e = 1e3) => {
|
|
1235
|
-
const t =
|
|
1235
|
+
const t = x(/* @__PURE__ */ new Date()), n = Kt(() => t.set(/* @__PURE__ */ new Date()), e);
|
|
1236
1236
|
return t.onDispose(n), t;
|
|
1237
1237
|
}, ye = (e) => {
|
|
1238
1238
|
const t = Math.abs(e);
|
|
@@ -1243,32 +1243,32 @@ const we = (e = 1e3) => {
|
|
|
1243
1243
|
return e < 0 ? pt(t, n.value, n.past.singular, n.past.plural) : pt(t, n.value, n.future.singular, n.future.plural);
|
|
1244
1244
|
throw new Error("unreachable");
|
|
1245
1245
|
}, Se = (e, { now: t, frequency: n = 1e4 } = {}) => {
|
|
1246
|
-
const s = t != null ? ft.is(t) ? t.derive() :
|
|
1246
|
+
const s = t != null ? ft.is(t) ? t.derive() : x(t) : we(n), a = J(
|
|
1247
1247
|
e,
|
|
1248
1248
|
s
|
|
1249
1249
|
)((o, r) => o.getTime() - r.getTime());
|
|
1250
1250
|
return a.onDispose(() => y.dispose(s)), a;
|
|
1251
|
-
},
|
|
1251
|
+
}, xe = (e, t = {}) => {
|
|
1252
1252
|
const n = Se(e, t), s = n.map(ye);
|
|
1253
1253
|
return s.onDispose(() => n.dispose()), s;
|
|
1254
|
-
}, Be = (e, t = {}) =>
|
|
1255
|
-
class
|
|
1254
|
+
}, Be = (e, t = {}) => xe(e, t);
|
|
1255
|
+
class be extends Tt {
|
|
1256
1256
|
/**
|
|
1257
1257
|
* Triggers an update of the Ticker by incrementing its internal value.
|
|
1258
1258
|
* @returns void
|
|
1259
1259
|
*/
|
|
1260
1260
|
tick = () => this.update((t) => t + 1);
|
|
1261
1261
|
}
|
|
1262
|
-
const qe = (e = 0) => new
|
|
1262
|
+
const qe = (e = 0) => new be(e, Ut);
|
|
1263
1263
|
export {
|
|
1264
1264
|
te as Anchor,
|
|
1265
|
-
|
|
1265
|
+
Ee as Appearance,
|
|
1266
1266
|
Pt as AsyncResultView,
|
|
1267
1267
|
Le as AutoFocus,
|
|
1268
1268
|
Re as AutoSelect,
|
|
1269
1269
|
Ie as ChildRouter,
|
|
1270
1270
|
ze as ElementRect,
|
|
1271
|
-
|
|
1271
|
+
We as HTMLTitle,
|
|
1272
1272
|
He as HiddenWhenEmpty,
|
|
1273
1273
|
re as InViewport,
|
|
1274
1274
|
G as Location,
|
|
@@ -1287,13 +1287,13 @@ export {
|
|
|
1287
1287
|
_e as RootRouter,
|
|
1288
1288
|
q as RouterContextProvider,
|
|
1289
1289
|
Fe as SelectOnFocus,
|
|
1290
|
-
|
|
1291
|
-
|
|
1290
|
+
be as Ticker,
|
|
1291
|
+
Te as WhenInViewport,
|
|
1292
1292
|
$e as WindowSize,
|
|
1293
1293
|
$t as _checkExtensionCondition,
|
|
1294
1294
|
zt as _getExtension,
|
|
1295
1295
|
je as _makeRouteMatcher,
|
|
1296
|
-
|
|
1296
|
+
Ot as _parseRouteSegments,
|
|
1297
1297
|
De as allPlacements,
|
|
1298
1298
|
_t as areLocationsEqual,
|
|
1299
1299
|
Ae as classes,
|
|
@@ -1308,9 +1308,9 @@ export {
|
|
|
1308
1308
|
we as nowSignal,
|
|
1309
1309
|
Be as relativeTime,
|
|
1310
1310
|
Se as relativeTimeMillisSignal,
|
|
1311
|
-
|
|
1311
|
+
xe as relativeTimeSignal,
|
|
1312
1312
|
qe as ticker,
|
|
1313
1313
|
ye as timeDiffToString,
|
|
1314
|
-
|
|
1314
|
+
W as urlFromLocation,
|
|
1315
1315
|
ee as useAppearance
|
|
1316
1316
|
};
|