@tempots/ui 3.1.0 → 4.1.0
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 +1 -1
- package/package.json +1 -1
- package/renderables/appearance.d.ts +1 -1
- package/renderables/autofocus.d.ts +57 -3
- package/renderables/autoselect.d.ts +63 -3
- package/renderables/hidden-when-empty.d.ts +0 -1
- package/renderables/inviewport.d.ts +116 -10
- package/renderables/resource.d.ts +115 -8
- package/renderables/router/location.d.ts +71 -3
- package/renderables/router/router.d.ts +93 -4
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var ge=Object.defineProperty;var ye=(t,e,n)=>e in t?ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ft=(t,e,n)=>ye(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@tempots/dom"),R=require("@tempots/std"),Ut=t=>{const e=t.split("/").pop();if(e==null||e.startsWith("."))return;const n=e.split(".")||[];return n.length>1?"."+n.pop():void 0},Bt=(t,e)=>{const n=Ut(e);return n!=null&&(t.length===0||!t.some(o=>n==o))},we=(t,e,n,o)=>{let s=t.target;for(;s!=null&&!(s instanceof HTMLAnchorElement);)s=s.parentElement;if(s==null)return!0;const i=s;if(t.button!==0||t.ctrlKey||t.metaKey||i.target!=="_self"&&i.target!==""||i.getAttribute("download")!=null)return!0;const{pathname:r,search:c,hash:l}=i;if(o){const a=r+c+l,d=i.getAttribute("href");if(!(d!=null&&d.startsWith("#"))&&d!==a)return!0}return e?!1:Bt(n,r)},Ht=(t,e={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const n=e.ignoreUrlWithExtension===!0&&Array.isArray(e.allowedExtensions)?e.allowedExtensions.map(o=>o.startsWith(".")?o:"."+o):[];return o=>{we(o,e.ignoreUrlWithExtension??!0,n,e.ignoreExternalUrl??!0)||t()&&o.preventDefault()}},$t=(t,e)=>t.pathname===e.pathname&&JSON.stringify(t.search)===JSON.stringify(e.search)&&t.hash===e.hash,wt=(t,e)=>{var i;const n=new URL(t,e??((i=u.getWindow())==null?void 0:i.location.toString())),o=Object.fromEntries(n.searchParams.entries());let s=n.hash;return s.startsWith("#")&&(s=s.substring(1)),{pathname:n.pathname,search:o,hash:s===""?void 0:s}},ht=(t,e)=>{const n=wt(e);return t.set(n),t},Z=t=>{const n=new URLSearchParams(t.search).toString(),o=t.hash;return`${t.pathname}${n?`?${n}`:""}${o?`#${o}`:""}`},xe=t=>t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//"),ve=t=>{const e=t.container.currentURL,n=e.iso(o=>wt(o),o=>{if(xe(o.pathname))return Z(o);const s=new URL(o.pathname,e.value),i=s.origin+s.pathname;return Z({...o,pathname:i})});return{value:n,dispose:n.dispose}},be=()=>{const t=u.getWindow(),e=(t==null?void 0:t.location.hash)===""?void 0:(t==null?void 0:t.location.hash.substring(1))??void 0;return{pathname:(t==null?void 0:t.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((t==null?void 0:t.location.search)??"").entries()),hash:e}},Re=()=>{const t=u.prop(be(),$t),e=u.getWindow(),n=()=>{let o=(e==null?void 0:e.location.hash)??"";o.startsWith("#")&&(o=o.substring(1));const s={pathname:(e==null?void 0:e.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((e==null?void 0:e.location.search)??"").entries()),hash:o===""?void 0:o};t.set(s)};return e==null||e.addEventListener("popstate",n),t.onDispose(()=>{e==null||e.removeEventListener("popstate",n)}),t.on(o=>{e==null||e.history.pushState({},"",Z(o))}),{value:t,dispose:t.dispose}},xt={mark:u.makeProviderMark("LocationProvider"),create:(t,e)=>{if(e.isBrowser())return Re();if(e.isHeadless())return ve(e);throw new Error("Unknown context")}},Ae=t=>{document.startViewTransition?document.startViewTransition(t):t()},zt=(t,...e)=>{if(typeof t=="string"||u.Signal.is(t))return zt({href:t},...e);const{href:n,withViewTransition:o,...s}=t;return u.Use(xt,i=>u.html.a(u.on.click(Ht(()=>(o==!0?Ae(()=>{ht(i,u.Value.get(n))}):ht(i,u.Value.get(n)),!0),s)),u.attr.href(n),...e))},Ee={mark:u.makeProviderMark("Appearance"),create:()=>{const t=_t();return{value:t,dispose:t.dispose}}};function _t(){const t=u.getWindow(),e=t!=null&&t.matchMedia!=null?t.matchMedia("(prefers-color-scheme: dark)"):void 0,n=(e==null?void 0:e.matches)??!1,o=u.prop(n?"dark":"light"),s=i=>o.set(i.matches?"dark":"light");return e==null||e.addEventListener("change",s),o.onDispose(()=>e==null?void 0:e.removeEventListener("change",s)),o}const vt=(t,e)=>{if(typeof e=="function")return vt(t,{success:e});const n=e.failure??(r=>r.map(c=>`Error: ${c}`)),o=e.success,s=e.loading??(()=>u.Empty),i=e.notAsked??(()=>u.Empty);return u.OneOfType(u.Value.toSignal(t),{AsyncSuccess:r=>o(r.$.value),AsyncFailure:r=>n(r.$.error),Loading:r=>s(r.map(c=>c.previousValue)),NotAsked:i})},Oe=(t=10)=>u.WithElement(e=>u.OnDispose(R.delayed(()=>e==null?void 0:e.focus(),t))),Le=(t=10)=>u.WithElement(e=>{const n=R.delayed(()=>e.select(),t);return u.OnDispose(n)}),Se=u.WithElement(t=>{const e=t.style.getPropertyValue(":empty");return t.style.setProperty(":empty","display:none"),u.OnDispose(n=>{n&&t.style.setProperty(":empty",e)})}),Te=t=>u.Portal("head > title",u.attr.innerText(t)),ke={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},Q={partial:new Map,full:new Map},j={partial:null,full:null};function Ce(t){return j[t]==null&&(j[t]=new IntersectionObserver(e=>{e.forEach(n=>{const o=Q[t].get(n.target);o==null||o.set(n.isIntersecting)})},ke[t])),j[t]}const It=({mode:t="partial",once:e=!1},n)=>{const o=u.prop(!1);return u.Fragment(u.WithElement(s=>{const i=typeof IntersectionObserver<"u"?Ce(t):null;Q[t].set(s,o),i==null||i.observe(s);function r(){var l;i==null||i.unobserve(s),Q[t].delete(s),Q[t].size===0&&((l=j[t])==null||l.disconnect(),j[t]=null)}let c=null;return e&&(c=o.on(l=>{l&&r()})),u.OnDispose(()=>{o.dispose(),r(),c==null||c()})}),u.renderableOfTNode(n(o)))},De=(t,e,n)=>It(t,o=>u.When(o,e,n??(()=>u.Empty))),tt=Math.min,F=Math.max,et=Math.round,G=Math.floor,S=t=>({x:t,y:t}),We={left:"right",right:"left",bottom:"top",top:"bottom"},Pe={start:"end",end:"start"};function kt(t,e,n){return F(t,tt(e,n))}function it(t,e){return typeof t=="function"?t(e):t}function V(t){return t.split("-")[0]}function rt(t){return t.split("-")[1]}function jt(t){return t==="x"?"y":"x"}function qt(t){return t==="y"?"height":"width"}function H(t){return["top","bottom"].includes(V(t))?"y":"x"}function Yt(t){return jt(H(t))}function Fe(t,e,n){n===void 0&&(n=!1);const o=rt(t),s=Yt(t),i=qt(s);let r=s==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(r=nt(r)),[r,nt(r)]}function Ve(t){const e=nt(t);return[pt(t),e,pt(e)]}function pt(t){return t.replace(/start|end/g,e=>Pe[e])}function Me(t,e,n){const o=["left","right"],s=["right","left"],i=["top","bottom"],r=["bottom","top"];switch(t){case"top":case"bottom":return n?e?s:o:e?o:s;case"left":case"right":return e?i:r;default:return[]}}function Ne(t,e,n,o){const s=rt(t);let i=Me(V(t),n==="start",o);return s&&(i=i.map(r=>r+"-"+s),e&&(i=i.concat(i.map(pt)))),i}function nt(t){return t.replace(/left|right|bottom|top/g,e=>We[e])}function Ue(t){return{top:0,right:0,bottom:0,left:0,...t}}function Be(t){return typeof t!="number"?Ue(t):{top:t,right:t,bottom:t,left:t}}function ot(t){const{x:e,y:n,width:o,height:s}=t;return{width:o,height:s,top:n,left:e,right:e+o,bottom:n+s,x:e,y:n}}function Ct(t,e,n){let{reference:o,floating:s}=t;const i=H(e),r=Yt(e),c=qt(r),l=V(e),a=i==="y",d=o.x+o.width/2-s.width/2,f=o.y+o.height/2-s.height/2,p=o[c]/2-s[c]/2;let h;switch(l){case"top":h={x:d,y:o.y-s.height};break;case"bottom":h={x:d,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:f};break;case"left":h={x:o.x-s.width,y:f};break;default:h={x:o.x,y:o.y}}switch(rt(e)){case"start":h[r]-=p*(n&&a?-1:1);break;case"end":h[r]+=p*(n&&a?-1:1);break}return h}const He=async(t,e,n)=>{const{placement:o="bottom",strategy:s="absolute",middleware:i=[],platform:r}=n,c=i.filter(Boolean),l=await(r.isRTL==null?void 0:r.isRTL(e));let a=await r.getElementRects({reference:t,floating:e,strategy:s}),{x:d,y:f}=Ct(a,o,l),p=o,h={},m=0;for(let y=0;y<c.length;y++){const{name:w,fn:g}=c[y],{x,y:v,data:A,reset:b}=await g({x:d,y:f,initialPlacement:o,placement:p,strategy:s,middlewareData:h,rects:a,platform:r,elements:{reference:t,floating:e}});d=x??d,f=v??f,h={...h,[w]:{...h[w],...A}},b&&m<=50&&(m++,typeof b=="object"&&(b.placement&&(p=b.placement),b.rects&&(a=b.rects===!0?await r.getElementRects({reference:t,floating:e,strategy:s}):b.rects),{x:d,y:f}=Ct(a,p,l)),y=-1)}return{x:d,y:f,placement:p,strategy:s,middlewareData:h}};async function Kt(t,e){var n;e===void 0&&(e={});const{x:o,y:s,platform:i,rects:r,elements:c,strategy:l}=t,{boundary:a="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=it(e,t),m=Be(h),w=c[p?f==="floating"?"reference":"floating":f],g=ot(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(w)))==null||n?w:w.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:a,rootBoundary:d,strategy:l})),x=f==="floating"?{x:o,y:s,width:r.floating.width,height:r.floating.height}:r.reference,v=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),A=await(i.isElement==null?void 0:i.isElement(v))?await(i.getScale==null?void 0:i.getScale(v))||{x:1,y:1}:{x:1,y:1},b=ot(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:x,offsetParent:v,strategy:l}):x);return{top:(g.top-b.top+m.top)/A.y,bottom:(b.bottom-g.bottom+m.bottom)/A.y,left:(g.left-b.left+m.left)/A.x,right:(b.right-g.right+m.right)/A.x}}const $e=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:s,middlewareData:i,rects:r,initialPlacement:c,platform:l,elements:a}=e,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:y=!0,...w}=it(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const g=V(s),x=H(c),v=V(c)===c,A=await(l.isRTL==null?void 0:l.isRTL(a.floating)),b=p||(v||!y?[nt(c)]:Ve(c)),N=m!=="none";!p&&N&&b.push(...Ne(c,y,m,A));const pe=[c,...b],ut=await Kt(e,w),J=[];let _=((o=i.flip)==null?void 0:o.overflows)||[];if(d&&J.push(ut[g]),f){const P=Fe(s,r,A);J.push(ut[P[0]],ut[P[1]])}if(_=[..._,{placement:s,overflows:J}],!J.every(P=>P<=0)){var Ot,Lt;const P=(((Ot=i.flip)==null?void 0:Ot.index)||0)+1,Tt=pe[P];if(Tt)return{data:{index:P,overflows:_},reset:{placement:Tt}};let I=(Lt=_.filter(U=>U.overflows[0]<=0).sort((U,C)=>U.overflows[1]-C.overflows[1])[0])==null?void 0:Lt.placement;if(!I)switch(h){case"bestFit":{var St;const U=(St=_.filter(C=>{if(N){const D=H(C.placement);return D===x||D==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(D=>D>0).reduce((D,me)=>D+me,0)]).sort((C,D)=>C[1]-D[1])[0])==null?void 0:St[0];U&&(I=U);break}case"initialPlacement":I=c;break}if(s!==I)return{reset:{placement:I}}}return{}}}};async function ze(t,e){const{placement:n,platform:o,elements:s}=t,i=await(o.isRTL==null?void 0:o.isRTL(s.floating)),r=V(n),c=rt(n),l=H(n)==="y",a=["left","top"].includes(r)?-1:1,d=i&&l?-1:1,f=it(e,t);let{mainAxis:p,crossAxis:h,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return c&&typeof m=="number"&&(h=c==="end"?m*-1:m),l?{x:h*d,y:p*a}:{x:p*a,y:h*d}}const _e=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:s,y:i,placement:r,middlewareData:c}=e,l=await ze(e,t);return r===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:r}}}}},Ie=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:s}=e,{mainAxis:i=!0,crossAxis:r=!1,limiter:c={fn:w=>{let{x:g,y:x}=w;return{x:g,y:x}}},...l}=it(t,e),a={x:n,y:o},d=await Kt(e,l),f=H(V(s)),p=jt(f);let h=a[p],m=a[f];if(i){const w=p==="y"?"top":"left",g=p==="y"?"bottom":"right",x=h+d[w],v=h-d[g];h=kt(x,h,v)}if(r){const w=f==="y"?"top":"left",g=f==="y"?"bottom":"right",x=m+d[w],v=m-d[g];m=kt(x,m,v)}const y=c.fn({...e,[p]:h,[f]:m});return{...y,data:{x:y.x-n,y:y.y-o,enabled:{[p]:i,[f]:r}}}}}};function ct(){return typeof window<"u"}function z(t){return Xt(t)?(t.nodeName||"").toLowerCase():"#document"}function E(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function k(t){var e;return(e=(Xt(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Xt(t){return ct()?t instanceof Node||t instanceof E(t).Node:!1}function O(t){return ct()?t instanceof Element||t instanceof E(t).Element:!1}function T(t){return ct()?t instanceof HTMLElement||t instanceof E(t).HTMLElement:!1}function Dt(t){return!ct()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof E(t).ShadowRoot}function K(t){const{overflow:e,overflowX:n,overflowY:o,display:s}=L(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(s)}function je(t){return["table","td","th"].includes(z(t))}function lt(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function bt(t){const e=Rt(),n=O(t)?L(t):t;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(o=>(n.willChange||"").includes(o))||["paint","layout","strict","content"].some(o=>(n.contain||"").includes(o))}function qe(t){let e=W(t);for(;T(e)&&!$(e);){if(bt(e))return e;if(lt(e))return null;e=W(e)}return null}function Rt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function $(t){return["html","body","#document"].includes(z(t))}function L(t){return E(t).getComputedStyle(t)}function at(t){return O(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function W(t){if(z(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Dt(t)&&t.host||k(t);return Dt(e)?e.host:e}function Jt(t){const e=W(t);return $(e)?t.ownerDocument?t.ownerDocument.body:t.body:T(e)&&K(e)?e:Jt(e)}function q(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=Jt(t),i=s===((o=t.ownerDocument)==null?void 0:o.body),r=E(s);if(i){const c=mt(r);return e.concat(r,r.visualViewport||[],K(s)?s:[],c&&n?q(c):[])}return e.concat(s,q(s,[],n))}function mt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Gt(t){const e=L(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const s=T(t),i=s?t.offsetWidth:n,r=s?t.offsetHeight:o,c=et(n)!==i||et(o)!==r;return c&&(n=i,o=r),{width:n,height:o,$:c}}function At(t){return O(t)?t:t.contextElement}function B(t){const e=At(t);if(!T(e))return S(1);const n=e.getBoundingClientRect(),{width:o,height:s,$:i}=Gt(e);let r=(i?et(n.width):n.width)/o,c=(i?et(n.height):n.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!c||!Number.isFinite(c))&&(c=1),{x:r,y:c}}const Ye=S(0);function Qt(t){const e=E(t);return!Rt()||!e.visualViewport?Ye:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Ke(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==E(t)?!1:e}function M(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=At(t);let r=S(1);e&&(o?O(o)&&(r=B(o)):r=B(t));const c=Ke(i,n,o)?Qt(i):S(0);let l=(s.left+c.x)/r.x,a=(s.top+c.y)/r.y,d=s.width/r.x,f=s.height/r.y;if(i){const p=E(i),h=o&&O(o)?E(o):o;let m=p,y=mt(m);for(;y&&o&&h!==m;){const w=B(y),g=y.getBoundingClientRect(),x=L(y),v=g.left+(y.clientLeft+parseFloat(x.paddingLeft))*w.x,A=g.top+(y.clientTop+parseFloat(x.paddingTop))*w.y;l*=w.x,a*=w.y,d*=w.x,f*=w.y,l+=v,a+=A,m=E(y),y=mt(m)}}return ot({width:d,height:f,x:l,y:a})}function Et(t,e){const n=at(t).scrollLeft;return e?e.left+n:M(k(t)).left+n}function Zt(t,e,n){n===void 0&&(n=!1);const o=t.getBoundingClientRect(),s=o.left+e.scrollLeft-(n?0:Et(t,o)),i=o.top+e.scrollTop;return{x:s,y:i}}function Xe(t){let{elements:e,rect:n,offsetParent:o,strategy:s}=t;const i=s==="fixed",r=k(o),c=e?lt(e.floating):!1;if(o===r||c&&i)return n;let l={scrollLeft:0,scrollTop:0},a=S(1);const d=S(0),f=T(o);if((f||!f&&!i)&&((z(o)!=="body"||K(r))&&(l=at(o)),T(o))){const h=M(o);a=B(o),d.x=h.x+o.clientLeft,d.y=h.y+o.clientTop}const p=r&&!f&&!i?Zt(r,l,!0):S(0);return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-l.scrollLeft*a.x+d.x+p.x,y:n.y*a.y-l.scrollTop*a.y+d.y+p.y}}function Je(t){return Array.from(t.getClientRects())}function Ge(t){const e=k(t),n=at(t),o=t.ownerDocument.body,s=F(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=F(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let r=-n.scrollLeft+Et(t);const c=-n.scrollTop;return L(o).direction==="rtl"&&(r+=F(e.clientWidth,o.clientWidth)-s),{width:s,height:i,x:r,y:c}}function Qe(t,e){const n=E(t),o=k(t),s=n.visualViewport;let i=o.clientWidth,r=o.clientHeight,c=0,l=0;if(s){i=s.width,r=s.height;const a=Rt();(!a||a&&e==="fixed")&&(c=s.offsetLeft,l=s.offsetTop)}return{width:i,height:r,x:c,y:l}}function Ze(t,e){const n=M(t,!0,e==="fixed"),o=n.top+t.clientTop,s=n.left+t.clientLeft,i=T(t)?B(t):S(1),r=t.clientWidth*i.x,c=t.clientHeight*i.y,l=s*i.x,a=o*i.y;return{width:r,height:c,x:l,y:a}}function Wt(t,e,n){let o;if(e==="viewport")o=Qe(t,n);else if(e==="document")o=Ge(k(t));else if(O(e))o=Ze(e,n);else{const s=Qt(t);o={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ot(o)}function te(t,e){const n=W(t);return n===e||!O(n)||$(n)?!1:L(n).position==="fixed"||te(n,e)}function tn(t,e){const n=e.get(t);if(n)return n;let o=q(t,[],!1).filter(c=>O(c)&&z(c)!=="body"),s=null;const i=L(t).position==="fixed";let r=i?W(t):t;for(;O(r)&&!$(r);){const c=L(r),l=bt(r);!l&&c.position==="fixed"&&(s=null),(i?!l&&!s:!l&&c.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||K(r)&&!l&&te(t,r))?o=o.filter(d=>d!==r):s=c,r=W(r)}return e.set(t,o),o}function en(t){let{element:e,boundary:n,rootBoundary:o,strategy:s}=t;const r=[...n==="clippingAncestors"?lt(e)?[]:tn(e,this._c):[].concat(n),o],c=r[0],l=r.reduce((a,d)=>{const f=Wt(e,d,s);return a.top=F(f.top,a.top),a.right=tt(f.right,a.right),a.bottom=tt(f.bottom,a.bottom),a.left=F(f.left,a.left),a},Wt(e,c,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function nn(t){const{width:e,height:n}=Gt(t);return{width:e,height:n}}function on(t,e,n){const o=T(e),s=k(e),i=n==="fixed",r=M(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const l=S(0);if(o||!o&&!i)if((z(e)!=="body"||K(s))&&(c=at(e)),o){const p=M(e,!0,i,e);l.x=p.x+e.clientLeft,l.y=p.y+e.clientTop}else s&&(l.x=Et(s));const a=s&&!o&&!i?Zt(s,c):S(0),d=r.left+c.scrollLeft-l.x-a.x,f=r.top+c.scrollTop-l.y-a.y;return{x:d,y:f,width:r.width,height:r.height}}function dt(t){return L(t).position==="static"}function Pt(t,e){if(!T(t)||L(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return k(t)===n&&(n=n.ownerDocument.body),n}function ee(t,e){const n=E(t);if(lt(t))return n;if(!T(t)){let s=W(t);for(;s&&!$(s);){if(O(s)&&!dt(s))return s;s=W(s)}return n}let o=Pt(t,e);for(;o&&je(o)&&dt(o);)o=Pt(o,e);return o&&$(o)&&dt(o)&&!bt(o)?n:o||qe(t)||n}const sn=async function(t){const e=this.getOffsetParent||ee,n=this.getDimensions,o=await n(t.floating);return{reference:on(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function rn(t){return L(t).direction==="rtl"}const cn={convertOffsetParentRelativeRectToViewportRelativeRect:Xe,getDocumentElement:k,getClippingRect:en,getOffsetParent:ee,getElementRects:sn,getClientRects:Je,getDimensions:nn,getScale:B,isElement:O,isRTL:rn};function ln(t,e){let n=null,o;const s=k(t);function i(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function r(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),i();const{left:a,top:d,width:f,height:p}=t.getBoundingClientRect();if(c||e(),!f||!p)return;const h=G(d),m=G(s.clientWidth-(a+f)),y=G(s.clientHeight-(d+p)),w=G(a),x={rootMargin:-h+"px "+-m+"px "+-y+"px "+-w+"px",threshold:F(0,tt(1,l))||1};let v=!0;function A(b){const N=b[0].intersectionRatio;if(N!==l){if(!v)return r();N?r(!1,N):o=setTimeout(()=>{r(!1,1e-7)},1e3)}v=!1}try{n=new IntersectionObserver(A,{...x,root:s.ownerDocument})}catch{n=new IntersectionObserver(A,x)}n.observe(t)}return r(!0),i}function an(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:r=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,a=At(t),d=s||i?[...a?q(a):[],...q(e)]:[];d.forEach(g=>{s&&g.addEventListener("scroll",n,{passive:!0}),i&&g.addEventListener("resize",n)});const f=a&&c?ln(a,n):null;let p=-1,h=null;r&&(h=new ResizeObserver(g=>{let[x]=g;x&&x.target===a&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var v;(v=h)==null||v.observe(e)})),n()}),a&&!l&&h.observe(a),h.observe(e));let m,y=l?M(t):null;l&&w();function w(){const g=M(t);y&&(g.x!==y.x||g.y!==y.y||g.width!==y.width||g.height!==y.height)&&n(),y=g,m=requestAnimationFrame(w)}return n(),()=>{var g;d.forEach(x=>{s&&x.removeEventListener("scroll",n),i&&x.removeEventListener("resize",n)}),f==null||f(),(g=h)==null||g.disconnect(),h=null,l&&cancelAnimationFrame(m)}}const un=_e,fn=Ie,Ft=$e,dn=(t,e,n)=>{const o=new Map,s={platform:cn,...n},i={...s.platform,_c:o};return He(t,e,{...s,platform:i})},hn=({content:t,open:e,placement:n,offset:{mainAxis:o,crossAxis:s}={mainAxis:0,crossAxis:0}})=>u.WithBrowserCtx(i=>{const r=u.Value.toSignal(e),c=i.element;return u.When(r,()=>u.Portal("body",u.html.div(u.WithElement(l=>{const a=l;return a.style.position="absolute",u.OnDispose(an(c,a,async()=>{const{x:d,y:f}=await dn(c,a,{placement:n,strategy:"absolute",middleware:[Ft(),un({mainAxis:o,crossAxis:s}),fn(),Ft()]});a.style.top=`${f}px`,a.style.left=`${d}px`}))}),t())))}),ne=(t,e,n)=>{const o=u.prop(R.AsyncResult.notAsked),s=o.map(f=>R.AsyncResult.isSuccess(f)?f.value:void 0),i=o.map(f=>R.AsyncResult.isFailure(f)?f.error:void 0),r=o.map(f=>R.AsyncResult.isLoading(f));let c;const l=async f=>{c==null||c.abort(),c=new AbortController;const p=c.signal,h=o.get();o.set(R.AsyncResult.loading(R.AsyncResult.getOrUndefined(h)));try{const m=await e({request:f,abortSignal:p,previous:h});await Promise.resolve(),c=void 0,o.set(R.AsyncResult.success(m))}catch(m){c=void 0,o.set(R.AsyncResult.failure(n(m)))}},a=()=>l(u.Value.get(t)),d=()=>{c==null||c.abort(),c=void 0,o.dispose()};return o.onDispose(u.Value.on(t,l)),{status:o,value:s,error:i,loading:r,reload:a,dispose:d}},oe=(t,e)=>{const{status:n,dispose:o,reload:s}=t,{loading:i,failure:r,success:c}=e;return u.Fragment(u.OnDispose(o),vt(n,{loading:i!=null?l=>i(l,s):void 0,failure:r!=null?l=>r(l,s):void 0,success:l=>c(l,s)}))},pn=({request:t,load:e,mapError:n=o=>o})=>{const o=ne(t,e,n);return s=>oe(o,s)},se=(t,e)=>{if(typeof e=="function")return se(t,{success:e});const n=e.failure??(s=>u.Fragment(u.OnDispose(s.on(console.error)),s.map(i=>`Error: ${i}`))),o=e.success;return u.OneOfType(u.Value.toSignal(t),{Success:s=>o(s.$.value),Failure:s=>n(s.$.error)})},mn=()=>u.on.focus(t=>{var e;return(e=t.target)==null?void 0:e.select()});class X{constructor(e,n,o,s){ft(this,"equals",e=>R.nearEquals(this.left,e.left)&&R.nearEquals(this.top,e.top)&&R.nearEquals(this.width,e.width)&&R.nearEquals(this.height,e.height));this.left=e,this.top=n,this.width=o,this.height=s}static of({left:e=0,top:n=0,width:o=0,height:s=0}){return new X(e,n,o,s)}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 size(){return{width:this.width,height:this.height}}}function gt(t){const e=t.getBoundingClientRect();return X.of({top:e.top+window.scrollY,left:e.left+window.scrollX,width:e.width,height:e.height})}const ie=t=>u.WithBrowserCtx(e=>{const{element:n}=e,o=u.prop(gt(n)),s=u.renderableOfTNode(t(o))(e),i=()=>{o.set(X.of(gt(n)))};let r;return typeof ResizeObserver=="function"&&(r=new ResizeObserver(i),r.observe(n)),u.OnDispose(c=>{r==null||r.disconnect(),s(c)})}),gn=t=>ie(t),yn=t=>e=>{const n=u.getWindow(),o=u.prop({width:(n==null?void 0:n.innerWidth)??0,height:(n==null?void 0:n.innerHeight)??0}),s=u.renderableOfTNode(t(o))(e),i=()=>{o.set({width:(n==null?void 0:n.innerWidth)??0,height:(n==null?void 0:n.innerHeight)??0})};return n==null||n.addEventListener("resize",i),r=>{n==null||n.removeEventListener("resize",i),s(r)}},re=(t,e)=>{const n=e.split("/").filter(s=>s!==""),o={};for(let s=0;s<t.length;s++){const i=t[s],r=n[s];if(!r&&i.type!=="catch-all")return null;if(i.type==="literal"){if(i.value!==r)return null}else if(i.type==="param")o[i.name]=r;else if(i.type==="catch-all")return{params:o,path:e}}return n.length!==t.length?null:{params:o,path:e}},ce=t=>t.split("/").map(e=>e.startsWith(":")?{type:"param",name:e.slice(1)}:e==="*"?{type:"catch-all"}:{type:"literal",value:e}).filter(e=>e.type!=="literal"||e.value!==""),le=t=>{const e=t.map(n=>{const o=ce(n);return{route:n,segments:o}});return function(o){for(const{segments:s,route:i}of e){const r=re(s,o);if(r)return{...r,route:i}}return null}},wn=t=>{const e=le(Object.keys(t));return u.Use(xt,n=>{const o=n.map(s=>{const i=e(s.pathname);if(i==null)throw console.error("No route found for",s),new Error("No route found");return{params:i.params,route:i.route,path:i.path,search:s.search,hash:s.hash}});return u.OneOfTuple(o.map(s=>[s.route,s]),t)})},st=60*1e3,yt=60*st,Y=24*yt,Vt=7*Y,Mt=30*Y,xn=365*Y,vn=[{max:st*90,value:st,name:"minute",past:{singular:"a minute ago",plural:"{} minutes ago"},future:{singular:"in a minute",plural:"in {} minutes"}},{max:yt*36,value:yt,name:"hour",past:{singular:"an hour ago",plural:"{} hours ago"},future:{singular:"in an hour",plural:"in {} hours"}},{max:Y*10,value:Y,name:"day",past:{singular:"yesterday",plural:"{} days ago"},future:{singular:"tomorrow",plural:"in {} days"}},{max:Vt*6,value:Vt,name:"week",past:{singular:"last week",plural:"{} weeks ago"},future:{singular:"in a week",plural:"in {} weeks"}},{max:Mt*18,value:Mt,name:"month",past:{singular:"last month",plural:"{} months ago"},future:{singular:"in a month",plural:"in {} months"}},{max:1/0,value:xn,name:"year",past:{singular:"last year",plural:"{} years ago"},future:{singular:"in a year",plural:"in {} years"}}];function Nt(t,e,n,o){const s=Math.round(t/e);return s<=1?n:o.replace("{}",s.toLocaleString(void 0,{maximumFractionDigits:0,minimumFractionDigits:0}))}const ae=(t=1e3)=>{const e=u.prop(new Date),n=R.interval(()=>e.set(new Date),t);return e.onDispose(n),e},ue=t=>{const e=Math.abs(t);if(e<st)return t<0?"just now":"in a moment";for(const n of vn)if(e<n.max)return t<0?Nt(e,n.value,n.past.singular,n.past.plural):Nt(e,n.value,n.future.singular,n.future.plural);throw new Error("unreachable")},fe=(t,{now:e,frequency:n=1e4}={})=>{const o=e!=null?u.Signal.is(e)?e.derive():u.prop(e):ae(n),s=u.computedOf(t,o)((i,r)=>i.getTime()-r.getTime());return s.onDispose(()=>u.Value.dispose(o)),s},de=(t,e={})=>{const n=fe(t,e),o=n.map(ue);return o.onDispose(n.dispose),o},bn=(t,e={})=>de(t,e);class he extends u.Prop{constructor(){super(...arguments);ft(this,"tick",()=>this.update(n=>n+1))}}const Rn=(t=0)=>new he(t,(e,n)=>e===n);exports.Anchor=zt;exports.Appearance=Ee;exports.AsyncResultView=vt;exports.AutoFocus=Oe;exports.AutoSelect=Le;exports.ElementRect=ie;exports.ElementSize=gn;exports.HTMLTitle=Te;exports.HiddenWhenEmpty=Se;exports.InViewport=It;exports.Location=xt;exports.PopOver=hn;exports.Rect=X;exports.Resource=pn;exports.ResourceDisplay=oe;exports.ResultView=se;exports.Router=wn;exports.SelectOnFocus=mn;exports.Ticker=he;exports.WhenInViewport=De;exports.WindowSize=yn;exports._checkExtensionCondition=Bt;exports._getExtension=Ut;exports._makeRouteMatcher=le;exports._parseRouteSegments=ce;exports.areLocationsEqual=$t;exports.getAbsoluteRect=gt;exports.handleAnchorClick=Ht;exports.locationFromURL=wt;exports.makeResource=ne;exports.matchesRoute=re;exports.nowSignal=ae;exports.relativeTime=bn;exports.relativeTimeMillisSignal=fe;exports.relativeTimeSignal=de;exports.setLocationFromUrl=ht;exports.ticker=Rn;exports.timeDiffToString=ue;exports.urlFromLocation=Z;exports.useAppearence=_t;
|
|
1
|
+
"use strict";var ge=Object.defineProperty;var ye=(t,e,n)=>e in t?ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ft=(t,e,n)=>ye(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@tempots/dom"),R=require("@tempots/std"),Ut=t=>{const e=t.split("/").pop();if(e==null||e.startsWith("."))return;const n=e.split(".")||[];return n.length>1?"."+n.pop():void 0},Bt=(t,e)=>{const n=Ut(e);return n!=null&&(t.length===0||!t.some(o=>n==o))},we=(t,e,n,o)=>{let s=t.target;for(;s!=null&&!(s instanceof HTMLAnchorElement);)s=s.parentElement;if(s==null)return!0;const i=s;if(t.button!==0||t.ctrlKey||t.metaKey||i.target!=="_self"&&i.target!==""||i.getAttribute("download")!=null)return!0;const{pathname:r,search:c,hash:l}=i;if(o){const a=r+c+l,h=i.getAttribute("href");if(!(h!=null&&h.startsWith("#"))&&h!==a)return!0}return e?!1:Bt(n,r)},Ht=(t,e={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const n=e.ignoreUrlWithExtension===!0&&Array.isArray(e.allowedExtensions)?e.allowedExtensions.map(o=>o.startsWith(".")?o:"."+o):[];return o=>{we(o,e.ignoreUrlWithExtension??!0,n,e.ignoreExternalUrl??!0)||t()&&o.preventDefault()}},$t=(t,e)=>t.pathname===e.pathname&&JSON.stringify(t.search)===JSON.stringify(e.search)&&t.hash===e.hash,wt=(t,e)=>{var i;const n=new URL(t,e??((i=u.getWindow())==null?void 0:i.location.toString())),o=Object.fromEntries(n.searchParams.entries());let s=n.hash;return s.startsWith("#")&&(s=s.substring(1)),{pathname:n.pathname,search:o,hash:s===""?void 0:s}},dt=(t,e)=>{const n=wt(e);return t.set(n),t},Z=t=>{const n=new URLSearchParams(t.search).toString(),o=t.hash;return`${t.pathname}${n?`?${n}`:""}${o?`#${o}`:""}`},ve=t=>t.startsWith("http://")||t.startsWith("https://")||t.startsWith("//"),xe=t=>{const e=t.container.currentURL,n=e.iso(o=>wt(o),o=>{if(ve(o.pathname))return Z(o);const s=new URL(o.pathname,e.value),i=s.origin+s.pathname;return Z({...o,pathname:i})});return{value:n,dispose:n.dispose}},be=()=>{const t=u.getWindow(),e=(t==null?void 0:t.location.hash)===""?void 0:(t==null?void 0:t.location.hash.substring(1))??void 0;return{pathname:(t==null?void 0:t.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((t==null?void 0:t.location.search)??"").entries()),hash:e}},Re=()=>{const t=u.prop(be(),$t),e=u.getWindow(),n=()=>{let o=(e==null?void 0:e.location.hash)??"";o.startsWith("#")&&(o=o.substring(1));const s={pathname:(e==null?void 0:e.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((e==null?void 0:e.location.search)??"").entries()),hash:o===""?void 0:o};t.set(s)};return e==null||e.addEventListener("popstate",n),t.onDispose(()=>{e==null||e.removeEventListener("popstate",n)}),t.on(o=>{e==null||e.history.pushState({},"",Z(o))}),{value:t,dispose:t.dispose}},vt={mark:u.makeProviderMark("LocationProvider"),create:(t,e)=>{if(e.isBrowser())return Re();if(e.isHeadless())return xe(e);throw new Error("Unknown context")}},Ae=t=>{document.startViewTransition?document.startViewTransition(t):t()},zt=(t,...e)=>{if(typeof t=="string"||u.Signal.is(t))return zt({href:t},...e);const{href:n,withViewTransition:o,...s}=t;return u.Use(vt,i=>u.html.a(u.on.click(Ht(()=>(o==!0?Ae(()=>{dt(i,u.Value.get(n))}):dt(i,u.Value.get(n)),!0),s)),u.attr.href(n),...e))},Ee={mark:u.makeProviderMark("Appearance"),create:()=>{const t=_t();return{value:t,dispose:t.dispose}}};function _t(){const t=u.getWindow(),e=t!=null&&t.matchMedia!=null?t.matchMedia("(prefers-color-scheme: dark)"):void 0,n=(e==null?void 0:e.matches)??!1,o=u.prop(n?"dark":"light"),s=i=>o.set(i.matches?"dark":"light");return e==null||e.addEventListener("change",s),o.onDispose(()=>e==null?void 0:e.removeEventListener("change",s)),o}const xt=(t,e)=>{if(typeof e=="function")return xt(t,{success:e});const n=e.failure??(r=>r.map(c=>`Error: ${c}`)),o=e.success,s=e.loading??(()=>u.Empty),i=e.notAsked??(()=>u.Empty);return u.OneOfType(u.Value.toSignal(t),{AsyncSuccess:r=>o(r.$.value),AsyncFailure:r=>n(r.$.error),Loading:r=>s(r.map(c=>c.previousValue)),NotAsked:i})},Oe=(t=10)=>u.WithElement(e=>u.OnDispose(R.delayed(()=>e==null?void 0:e.focus(),t))),Le=(t=10)=>u.WithElement(e=>{const n=R.delayed(()=>e.select(),t);return u.OnDispose(n)}),Se=u.WithElement(t=>{const e=t.style.getPropertyValue(":empty");return t.style.setProperty(":empty","display:none"),u.OnDispose(n=>{n&&t.style.setProperty(":empty",e)})}),Te=t=>u.Portal("head > title",u.attr.innerText(t)),ke={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},Q={partial:new Map,full:new Map},j={partial:null,full:null};function Ce(t){return j[t]==null&&(j[t]=new IntersectionObserver(e=>{e.forEach(n=>{const o=Q[t].get(n.target);o==null||o.set(n.isIntersecting)})},ke[t])),j[t]}const It=({mode:t="partial",once:e=!1},n)=>{const o=u.prop(!1);return u.Fragment(u.WithElement(s=>{const i=typeof IntersectionObserver<"u"?Ce(t):null;Q[t].set(s,o),i==null||i.observe(s);function r(){var l;i==null||i.unobserve(s),Q[t].delete(s),Q[t].size===0&&((l=j[t])==null||l.disconnect(),j[t]=null)}let c=null;return e&&(c=o.on(l=>{l&&r()})),u.OnDispose(()=>{o.dispose(),r(),c==null||c()})}),u.renderableOfTNode(n(o)))},De=(t,e,n)=>It(t,o=>u.When(o,e,n??(()=>u.Empty))),tt=Math.min,F=Math.max,et=Math.round,G=Math.floor,S=t=>({x:t,y:t}),We={left:"right",right:"left",bottom:"top",top:"bottom"},Pe={start:"end",end:"start"};function kt(t,e,n){return F(t,tt(e,n))}function it(t,e){return typeof t=="function"?t(e):t}function V(t){return t.split("-")[0]}function rt(t){return t.split("-")[1]}function jt(t){return t==="x"?"y":"x"}function qt(t){return t==="y"?"height":"width"}function H(t){return["top","bottom"].includes(V(t))?"y":"x"}function Yt(t){return jt(H(t))}function Fe(t,e,n){n===void 0&&(n=!1);const o=rt(t),s=Yt(t),i=qt(s);let r=s==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[i]>e.floating[i]&&(r=nt(r)),[r,nt(r)]}function Ve(t){const e=nt(t);return[pt(t),e,pt(e)]}function pt(t){return t.replace(/start|end/g,e=>Pe[e])}function Me(t,e,n){const o=["left","right"],s=["right","left"],i=["top","bottom"],r=["bottom","top"];switch(t){case"top":case"bottom":return n?e?s:o:e?o:s;case"left":case"right":return e?i:r;default:return[]}}function Ne(t,e,n,o){const s=rt(t);let i=Me(V(t),n==="start",o);return s&&(i=i.map(r=>r+"-"+s),e&&(i=i.concat(i.map(pt)))),i}function nt(t){return t.replace(/left|right|bottom|top/g,e=>We[e])}function Ue(t){return{top:0,right:0,bottom:0,left:0,...t}}function Be(t){return typeof t!="number"?Ue(t):{top:t,right:t,bottom:t,left:t}}function ot(t){const{x:e,y:n,width:o,height:s}=t;return{width:o,height:s,top:n,left:e,right:e+o,bottom:n+s,x:e,y:n}}function Ct(t,e,n){let{reference:o,floating:s}=t;const i=H(e),r=Yt(e),c=qt(r),l=V(e),a=i==="y",h=o.x+o.width/2-s.width/2,f=o.y+o.height/2-s.height/2,p=o[c]/2-s[c]/2;let d;switch(l){case"top":d={x:h,y:o.y-s.height};break;case"bottom":d={x:h,y:o.y+o.height};break;case"right":d={x:o.x+o.width,y:f};break;case"left":d={x:o.x-s.width,y:f};break;default:d={x:o.x,y:o.y}}switch(rt(e)){case"start":d[r]-=p*(n&&a?-1:1);break;case"end":d[r]+=p*(n&&a?-1:1);break}return d}const He=async(t,e,n)=>{const{placement:o="bottom",strategy:s="absolute",middleware:i=[],platform:r}=n,c=i.filter(Boolean),l=await(r.isRTL==null?void 0:r.isRTL(e));let a=await r.getElementRects({reference:t,floating:e,strategy:s}),{x:h,y:f}=Ct(a,o,l),p=o,d={},m=0;for(let y=0;y<c.length;y++){const{name:w,fn:g}=c[y],{x:v,y:x,data:A,reset:b}=await g({x:h,y:f,initialPlacement:o,placement:p,strategy:s,middlewareData:d,rects:a,platform:r,elements:{reference:t,floating:e}});h=v??h,f=x??f,d={...d,[w]:{...d[w],...A}},b&&m<=50&&(m++,typeof b=="object"&&(b.placement&&(p=b.placement),b.rects&&(a=b.rects===!0?await r.getElementRects({reference:t,floating:e,strategy:s}):b.rects),{x:h,y:f}=Ct(a,p,l)),y=-1)}return{x:h,y:f,placement:p,strategy:s,middlewareData:d}};async function Kt(t,e){var n;e===void 0&&(e={});const{x:o,y:s,platform:i,rects:r,elements:c,strategy:l}=t,{boundary:a="clippingAncestors",rootBoundary:h="viewport",elementContext:f="floating",altBoundary:p=!1,padding:d=0}=it(e,t),m=Be(d),w=c[p?f==="floating"?"reference":"floating":f],g=ot(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(w)))==null||n?w:w.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(c.floating)),boundary:a,rootBoundary:h,strategy:l})),v=f==="floating"?{x:o,y:s,width:r.floating.width,height:r.floating.height}:r.reference,x=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c.floating)),A=await(i.isElement==null?void 0:i.isElement(x))?await(i.getScale==null?void 0:i.getScale(x))||{x:1,y:1}:{x:1,y:1},b=ot(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:x,strategy:l}):v);return{top:(g.top-b.top+m.top)/A.y,bottom:(b.bottom-g.bottom+m.bottom)/A.y,left:(g.left-b.left+m.left)/A.x,right:(b.right-g.right+m.right)/A.x}}const $e=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:s,middlewareData:i,rects:r,initialPlacement:c,platform:l,elements:a}=e,{mainAxis:h=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:d="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:y=!0,...w}=it(t,e);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const g=V(s),v=H(c),x=V(c)===c,A=await(l.isRTL==null?void 0:l.isRTL(a.floating)),b=p||(x||!y?[nt(c)]:Ve(c)),N=m!=="none";!p&&N&&b.push(...Ne(c,y,m,A));const pe=[c,...b],ut=await Kt(e,w),J=[];let _=((o=i.flip)==null?void 0:o.overflows)||[];if(h&&J.push(ut[g]),f){const P=Fe(s,r,A);J.push(ut[P[0]],ut[P[1]])}if(_=[..._,{placement:s,overflows:J}],!J.every(P=>P<=0)){var Ot,Lt;const P=(((Ot=i.flip)==null?void 0:Ot.index)||0)+1,Tt=pe[P];if(Tt)return{data:{index:P,overflows:_},reset:{placement:Tt}};let I=(Lt=_.filter(U=>U.overflows[0]<=0).sort((U,C)=>U.overflows[1]-C.overflows[1])[0])==null?void 0:Lt.placement;if(!I)switch(d){case"bestFit":{var St;const U=(St=_.filter(C=>{if(N){const D=H(C.placement);return D===v||D==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(D=>D>0).reduce((D,me)=>D+me,0)]).sort((C,D)=>C[1]-D[1])[0])==null?void 0:St[0];U&&(I=U);break}case"initialPlacement":I=c;break}if(s!==I)return{reset:{placement:I}}}return{}}}};async function ze(t,e){const{placement:n,platform:o,elements:s}=t,i=await(o.isRTL==null?void 0:o.isRTL(s.floating)),r=V(n),c=rt(n),l=H(n)==="y",a=["left","top"].includes(r)?-1:1,h=i&&l?-1:1,f=it(e,t);let{mainAxis:p,crossAxis:d,alignmentAxis:m}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return c&&typeof m=="number"&&(d=c==="end"?m*-1:m),l?{x:d*h,y:p*a}:{x:p*a,y:d*h}}const _e=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:s,y:i,placement:r,middlewareData:c}=e,l=await ze(e,t);return r===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:s+l.x,y:i+l.y,data:{...l,placement:r}}}}},Ie=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:s}=e,{mainAxis:i=!0,crossAxis:r=!1,limiter:c={fn:w=>{let{x:g,y:v}=w;return{x:g,y:v}}},...l}=it(t,e),a={x:n,y:o},h=await Kt(e,l),f=H(V(s)),p=jt(f);let d=a[p],m=a[f];if(i){const w=p==="y"?"top":"left",g=p==="y"?"bottom":"right",v=d+h[w],x=d-h[g];d=kt(v,d,x)}if(r){const w=f==="y"?"top":"left",g=f==="y"?"bottom":"right",v=m+h[w],x=m-h[g];m=kt(v,m,x)}const y=c.fn({...e,[p]:d,[f]:m});return{...y,data:{x:y.x-n,y:y.y-o,enabled:{[p]:i,[f]:r}}}}}};function ct(){return typeof window<"u"}function z(t){return Xt(t)?(t.nodeName||"").toLowerCase():"#document"}function E(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function k(t){var e;return(e=(Xt(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Xt(t){return ct()?t instanceof Node||t instanceof E(t).Node:!1}function O(t){return ct()?t instanceof Element||t instanceof E(t).Element:!1}function T(t){return ct()?t instanceof HTMLElement||t instanceof E(t).HTMLElement:!1}function Dt(t){return!ct()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof E(t).ShadowRoot}function K(t){const{overflow:e,overflowX:n,overflowY:o,display:s}=L(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(s)}function je(t){return["table","td","th"].includes(z(t))}function lt(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function bt(t){const e=Rt(),n=O(t)?L(t):t;return n.transform!=="none"||n.perspective!=="none"||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","perspective","filter"].some(o=>(n.willChange||"").includes(o))||["paint","layout","strict","content"].some(o=>(n.contain||"").includes(o))}function qe(t){let e=W(t);for(;T(e)&&!$(e);){if(bt(e))return e;if(lt(e))return null;e=W(e)}return null}function Rt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function $(t){return["html","body","#document"].includes(z(t))}function L(t){return E(t).getComputedStyle(t)}function at(t){return O(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function W(t){if(z(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Dt(t)&&t.host||k(t);return Dt(e)?e.host:e}function Jt(t){const e=W(t);return $(e)?t.ownerDocument?t.ownerDocument.body:t.body:T(e)&&K(e)?e:Jt(e)}function q(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=Jt(t),i=s===((o=t.ownerDocument)==null?void 0:o.body),r=E(s);if(i){const c=mt(r);return e.concat(r,r.visualViewport||[],K(s)?s:[],c&&n?q(c):[])}return e.concat(s,q(s,[],n))}function mt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Gt(t){const e=L(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const s=T(t),i=s?t.offsetWidth:n,r=s?t.offsetHeight:o,c=et(n)!==i||et(o)!==r;return c&&(n=i,o=r),{width:n,height:o,$:c}}function At(t){return O(t)?t:t.contextElement}function B(t){const e=At(t);if(!T(e))return S(1);const n=e.getBoundingClientRect(),{width:o,height:s,$:i}=Gt(e);let r=(i?et(n.width):n.width)/o,c=(i?et(n.height):n.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!c||!Number.isFinite(c))&&(c=1),{x:r,y:c}}const Ye=S(0);function Qt(t){const e=E(t);return!Rt()||!e.visualViewport?Ye:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Ke(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==E(t)?!1:e}function M(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),i=At(t);let r=S(1);e&&(o?O(o)&&(r=B(o)):r=B(t));const c=Ke(i,n,o)?Qt(i):S(0);let l=(s.left+c.x)/r.x,a=(s.top+c.y)/r.y,h=s.width/r.x,f=s.height/r.y;if(i){const p=E(i),d=o&&O(o)?E(o):o;let m=p,y=mt(m);for(;y&&o&&d!==m;){const w=B(y),g=y.getBoundingClientRect(),v=L(y),x=g.left+(y.clientLeft+parseFloat(v.paddingLeft))*w.x,A=g.top+(y.clientTop+parseFloat(v.paddingTop))*w.y;l*=w.x,a*=w.y,h*=w.x,f*=w.y,l+=x,a+=A,m=E(y),y=mt(m)}}return ot({width:h,height:f,x:l,y:a})}function Et(t,e){const n=at(t).scrollLeft;return e?e.left+n:M(k(t)).left+n}function Zt(t,e,n){n===void 0&&(n=!1);const o=t.getBoundingClientRect(),s=o.left+e.scrollLeft-(n?0:Et(t,o)),i=o.top+e.scrollTop;return{x:s,y:i}}function Xe(t){let{elements:e,rect:n,offsetParent:o,strategy:s}=t;const i=s==="fixed",r=k(o),c=e?lt(e.floating):!1;if(o===r||c&&i)return n;let l={scrollLeft:0,scrollTop:0},a=S(1);const h=S(0),f=T(o);if((f||!f&&!i)&&((z(o)!=="body"||K(r))&&(l=at(o)),T(o))){const d=M(o);a=B(o),h.x=d.x+o.clientLeft,h.y=d.y+o.clientTop}const p=r&&!f&&!i?Zt(r,l,!0):S(0);return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-l.scrollLeft*a.x+h.x+p.x,y:n.y*a.y-l.scrollTop*a.y+h.y+p.y}}function Je(t){return Array.from(t.getClientRects())}function Ge(t){const e=k(t),n=at(t),o=t.ownerDocument.body,s=F(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),i=F(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let r=-n.scrollLeft+Et(t);const c=-n.scrollTop;return L(o).direction==="rtl"&&(r+=F(e.clientWidth,o.clientWidth)-s),{width:s,height:i,x:r,y:c}}function Qe(t,e){const n=E(t),o=k(t),s=n.visualViewport;let i=o.clientWidth,r=o.clientHeight,c=0,l=0;if(s){i=s.width,r=s.height;const a=Rt();(!a||a&&e==="fixed")&&(c=s.offsetLeft,l=s.offsetTop)}return{width:i,height:r,x:c,y:l}}function Ze(t,e){const n=M(t,!0,e==="fixed"),o=n.top+t.clientTop,s=n.left+t.clientLeft,i=T(t)?B(t):S(1),r=t.clientWidth*i.x,c=t.clientHeight*i.y,l=s*i.x,a=o*i.y;return{width:r,height:c,x:l,y:a}}function Wt(t,e,n){let o;if(e==="viewport")o=Qe(t,n);else if(e==="document")o=Ge(k(t));else if(O(e))o=Ze(e,n);else{const s=Qt(t);o={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ot(o)}function te(t,e){const n=W(t);return n===e||!O(n)||$(n)?!1:L(n).position==="fixed"||te(n,e)}function tn(t,e){const n=e.get(t);if(n)return n;let o=q(t,[],!1).filter(c=>O(c)&&z(c)!=="body"),s=null;const i=L(t).position==="fixed";let r=i?W(t):t;for(;O(r)&&!$(r);){const c=L(r),l=bt(r);!l&&c.position==="fixed"&&(s=null),(i?!l&&!s:!l&&c.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||K(r)&&!l&&te(t,r))?o=o.filter(h=>h!==r):s=c,r=W(r)}return e.set(t,o),o}function en(t){let{element:e,boundary:n,rootBoundary:o,strategy:s}=t;const r=[...n==="clippingAncestors"?lt(e)?[]:tn(e,this._c):[].concat(n),o],c=r[0],l=r.reduce((a,h)=>{const f=Wt(e,h,s);return a.top=F(f.top,a.top),a.right=tt(f.right,a.right),a.bottom=tt(f.bottom,a.bottom),a.left=F(f.left,a.left),a},Wt(e,c,s));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function nn(t){const{width:e,height:n}=Gt(t);return{width:e,height:n}}function on(t,e,n){const o=T(e),s=k(e),i=n==="fixed",r=M(t,!0,i,e);let c={scrollLeft:0,scrollTop:0};const l=S(0);if(o||!o&&!i)if((z(e)!=="body"||K(s))&&(c=at(e)),o){const p=M(e,!0,i,e);l.x=p.x+e.clientLeft,l.y=p.y+e.clientTop}else s&&(l.x=Et(s));const a=s&&!o&&!i?Zt(s,c):S(0),h=r.left+c.scrollLeft-l.x-a.x,f=r.top+c.scrollTop-l.y-a.y;return{x:h,y:f,width:r.width,height:r.height}}function ht(t){return L(t).position==="static"}function Pt(t,e){if(!T(t)||L(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return k(t)===n&&(n=n.ownerDocument.body),n}function ee(t,e){const n=E(t);if(lt(t))return n;if(!T(t)){let s=W(t);for(;s&&!$(s);){if(O(s)&&!ht(s))return s;s=W(s)}return n}let o=Pt(t,e);for(;o&&je(o)&&ht(o);)o=Pt(o,e);return o&&$(o)&&ht(o)&&!bt(o)?n:o||qe(t)||n}const sn=async function(t){const e=this.getOffsetParent||ee,n=this.getDimensions,o=await n(t.floating);return{reference:on(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function rn(t){return L(t).direction==="rtl"}const cn={convertOffsetParentRelativeRectToViewportRelativeRect:Xe,getDocumentElement:k,getClippingRect:en,getOffsetParent:ee,getElementRects:sn,getClientRects:Je,getDimensions:nn,getScale:B,isElement:O,isRTL:rn};function ln(t,e){let n=null,o;const s=k(t);function i(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function r(c,l){c===void 0&&(c=!1),l===void 0&&(l=1),i();const{left:a,top:h,width:f,height:p}=t.getBoundingClientRect();if(c||e(),!f||!p)return;const d=G(h),m=G(s.clientWidth-(a+f)),y=G(s.clientHeight-(h+p)),w=G(a),v={rootMargin:-d+"px "+-m+"px "+-y+"px "+-w+"px",threshold:F(0,tt(1,l))||1};let x=!0;function A(b){const N=b[0].intersectionRatio;if(N!==l){if(!x)return r();N?r(!1,N):o=setTimeout(()=>{r(!1,1e-7)},1e3)}x=!1}try{n=new IntersectionObserver(A,{...v,root:s.ownerDocument})}catch{n=new IntersectionObserver(A,v)}n.observe(t)}return r(!0),i}function an(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:r=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,a=At(t),h=s||i?[...a?q(a):[],...q(e)]:[];h.forEach(g=>{s&&g.addEventListener("scroll",n,{passive:!0}),i&&g.addEventListener("resize",n)});const f=a&&c?ln(a,n):null;let p=-1,d=null;r&&(d=new ResizeObserver(g=>{let[v]=g;v&&v.target===a&&d&&(d.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=d)==null||x.observe(e)})),n()}),a&&!l&&d.observe(a),d.observe(e));let m,y=l?M(t):null;l&&w();function w(){const g=M(t);y&&(g.x!==y.x||g.y!==y.y||g.width!==y.width||g.height!==y.height)&&n(),y=g,m=requestAnimationFrame(w)}return n(),()=>{var g;h.forEach(v=>{s&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),f==null||f(),(g=d)==null||g.disconnect(),d=null,l&&cancelAnimationFrame(m)}}const un=_e,fn=Ie,Ft=$e,hn=(t,e,n)=>{const o=new Map,s={platform:cn,...n},i={...s.platform,_c:o};return He(t,e,{...s,platform:i})},dn=({content:t,open:e,placement:n,offset:{mainAxis:o,crossAxis:s}={mainAxis:0,crossAxis:0}})=>u.WithBrowserCtx(i=>{const r=u.Value.toSignal(e),c=i.element;return u.When(r,()=>u.Portal("body",u.html.div(u.WithElement(l=>{const a=l;return a.style.position="absolute",u.OnDispose(an(c,a,async()=>{const{x:h,y:f}=await hn(c,a,{placement:n,strategy:"absolute",middleware:[Ft(),un({mainAxis:o,crossAxis:s}),fn(),Ft()]});a.style.top=`${f}px`,a.style.left=`${h}px`}))}),t())))}),ne=(t,e,n)=>{const o=u.prop(R.AsyncResult.notAsked),s=o.map(f=>R.AsyncResult.isSuccess(f)?f.value:void 0),i=o.map(f=>R.AsyncResult.isFailure(f)?f.error:void 0),r=o.map(f=>R.AsyncResult.isLoading(f));let c;const l=async f=>{c==null||c.abort(),c=new AbortController;const p=c.signal,d=o.get();o.set(R.AsyncResult.loading(R.AsyncResult.getOrUndefined(d)));try{const m=await e({request:f,abortSignal:p,previous:d});await Promise.resolve(),c=void 0,o.set(R.AsyncResult.success(m))}catch(m){c=void 0,o.set(R.AsyncResult.failure(n(m)))}},a=()=>l(u.Value.get(t)),h=()=>{c==null||c.abort(),c=void 0,o.dispose()};return o.onDispose(u.Value.on(t,l)),{status:o,value:s,error:i,loading:r,reload:a,dispose:h}},oe=(t,e)=>{const{status:n,dispose:o,reload:s}=t,{loading:i,failure:r,success:c}=e;return u.Fragment(u.OnDispose(o),xt(n,{loading:i!=null?l=>i(l,s):void 0,failure:r!=null?l=>r(l,s):void 0,success:l=>c(l,s)}))},pn=({request:t,load:e,mapError:n=o=>o})=>{const o=ne(t,e,n);return s=>oe(o,s)},se=(t,e)=>{if(typeof e=="function")return se(t,{success:e});const n=e.failure??(s=>u.Fragment(u.OnDispose(s.on(console.error)),s.map(i=>`Error: ${i}`))),o=e.success;return u.OneOfType(u.Value.toSignal(t),{Success:s=>o(s.$.value),Failure:s=>n(s.$.error)})},mn=()=>u.on.focus(t=>{var e;return(e=t.target)==null?void 0:e.select()});class X{constructor(e,n,o,s){ft(this,"equals",e=>R.nearEquals(this.left,e.left)&&R.nearEquals(this.top,e.top)&&R.nearEquals(this.width,e.width)&&R.nearEquals(this.height,e.height));this.left=e,this.top=n,this.width=o,this.height=s}static of({left:e=0,top:n=0,width:o=0,height:s=0}){return new X(e,n,o,s)}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 size(){return{width:this.width,height:this.height}}}function gt(t){const e=t.getBoundingClientRect();return X.of({top:e.top+window.scrollY,left:e.left+window.scrollX,width:e.width,height:e.height})}const ie=t=>u.WithBrowserCtx(e=>{const{element:n}=e,o=u.prop(gt(n)),s=u.renderableOfTNode(t(o))(e),i=()=>{o.set(X.of(gt(n)))};let r;return typeof ResizeObserver=="function"&&(r=new ResizeObserver(i),r.observe(n)),u.OnDispose(c=>{r==null||r.disconnect(),s(c)})}),gn=t=>ie(t),yn=t=>e=>{const n=u.getWindow(),o=u.prop({width:(n==null?void 0:n.innerWidth)??0,height:(n==null?void 0:n.innerHeight)??0}),s=u.renderableOfTNode(t(o))(e),i=()=>{o.set({width:(n==null?void 0:n.innerWidth)??0,height:(n==null?void 0:n.innerHeight)??0})};return n==null||n.addEventListener("resize",i),r=>{n==null||n.removeEventListener("resize",i),s(r)}},re=(t,e)=>{const n=e.split("/").filter(s=>s!==""),o={};for(let s=0;s<t.length;s++){const i=t[s],r=n[s];if(!r&&i.type!=="catch-all")return null;if(i.type==="literal"){if(i.value!==r)return null}else if(i.type==="param")o[i.name]=r;else if(i.type==="catch-all")return{params:o,path:e}}return n.length!==t.length?null:{params:o,path:e}},ce=t=>t.split("/").map(e=>e.startsWith(":")?{type:"param",name:e.slice(1)}:e==="*"?{type:"catch-all"}:{type:"literal",value:e}).filter(e=>e.type!=="literal"||e.value!==""),le=t=>{const e=t.map(n=>{const o=ce(n);return{route:n,segments:o}});return function(o){for(const{segments:s,route:i}of e){const r=re(s,o);if(r)return{...r,route:i}}return null}},wn=t=>{const e=le(Object.keys(t));return u.Use(vt,n=>{const o=n.map(s=>{const i=e(s.pathname);if(i==null)throw console.error("No route found for",s),new Error("No route found");return{params:i.params,route:i.route,path:i.path,search:s.search,hash:s.hash}});return u.OneOfTuple(o.map(s=>[s.route,s]),t)})},st=60*1e3,yt=60*st,Y=24*yt,Vt=7*Y,Mt=30*Y,vn=365*Y,xn=[{max:st*90,value:st,name:"minute",past:{singular:"a minute ago",plural:"{} minutes ago"},future:{singular:"in a minute",plural:"in {} minutes"}},{max:yt*36,value:yt,name:"hour",past:{singular:"an hour ago",plural:"{} hours ago"},future:{singular:"in an hour",plural:"in {} hours"}},{max:Y*10,value:Y,name:"day",past:{singular:"yesterday",plural:"{} days ago"},future:{singular:"tomorrow",plural:"in {} days"}},{max:Vt*6,value:Vt,name:"week",past:{singular:"last week",plural:"{} weeks ago"},future:{singular:"in a week",plural:"in {} weeks"}},{max:Mt*18,value:Mt,name:"month",past:{singular:"last month",plural:"{} months ago"},future:{singular:"in a month",plural:"in {} months"}},{max:1/0,value:vn,name:"year",past:{singular:"last year",plural:"{} years ago"},future:{singular:"in a year",plural:"in {} years"}}];function Nt(t,e,n,o){const s=Math.round(t/e);return s<=1?n:o.replace("{}",s.toLocaleString(void 0,{maximumFractionDigits:0,minimumFractionDigits:0}))}const ae=(t=1e3)=>{const e=u.prop(new Date),n=R.interval(()=>e.set(new Date),t);return e.onDispose(n),e},ue=t=>{const e=Math.abs(t);if(e<st)return t<0?"just now":"in a moment";for(const n of xn)if(e<n.max)return t<0?Nt(e,n.value,n.past.singular,n.past.plural):Nt(e,n.value,n.future.singular,n.future.plural);throw new Error("unreachable")},fe=(t,{now:e,frequency:n=1e4}={})=>{const o=e!=null?u.Signal.is(e)?e.derive():u.prop(e):ae(n),s=u.computedOf(t,o)((i,r)=>i.getTime()-r.getTime());return s.onDispose(()=>u.Value.dispose(o)),s},he=(t,e={})=>{const n=fe(t,e),o=n.map(ue);return o.onDispose(n.dispose),o},bn=(t,e={})=>he(t,e);class de extends u.Prop{constructor(){super(...arguments);ft(this,"tick",()=>this.update(n=>n+1))}}const Rn=(t=0)=>new de(t,(e,n)=>e===n);exports.Anchor=zt;exports.Appearance=Ee;exports.AsyncResultView=xt;exports.AutoFocus=Oe;exports.AutoSelect=Le;exports.ElementRect=ie;exports.ElementSize=gn;exports.HTMLTitle=Te;exports.HiddenWhenEmpty=Se;exports.InViewport=It;exports.Location=vt;exports.PopOver=dn;exports.Rect=X;exports.Resource=pn;exports.ResourceDisplay=oe;exports.ResultView=se;exports.Router=wn;exports.SelectOnFocus=mn;exports.Ticker=de;exports.WhenInViewport=De;exports.WindowSize=yn;exports._checkExtensionCondition=Bt;exports._getExtension=Ut;exports._makeRouteMatcher=le;exports._parseRouteSegments=ce;exports.areLocationsEqual=$t;exports.getAbsoluteRect=gt;exports.handleAnchorClick=Ht;exports.locationFromURL=wt;exports.makeResource=ne;exports.matchesRoute=re;exports.nowSignal=ae;exports.relativeTime=bn;exports.relativeTimeMillisSignal=fe;exports.relativeTimeSignal=he;exports.setLocationFromUrl=dt;exports.ticker=Rn;exports.timeDiffToString=ue;exports.urlFromLocation=Z;exports.useAppearance=_t;
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -28,4 +28,4 @@ export declare const Appearance: Provider<Signal<AppearanceType>>;
|
|
|
28
28
|
* @returns A signal representing the current appearance.
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
31
|
-
export declare function
|
|
31
|
+
export declare function useAppearance(): Signal<AppearanceType>;
|
|
@@ -1,9 +1,63 @@
|
|
|
1
1
|
import { Renderable } from '@tempots/dom';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Automatically focuses an element when it's rendered to the DOM.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* This utility is commonly used for form inputs, modals, or any interactive element
|
|
6
|
+
* that should receive focus immediately when it appears. The small default delay
|
|
7
|
+
* ensures the element is fully rendered before attempting to focus.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Auto-focus a text input
|
|
12
|
+
* html.input(
|
|
13
|
+
* AutoFocus(),
|
|
14
|
+
* attr.placeholder('Enter your name'),
|
|
15
|
+
* attr.type('text')
|
|
16
|
+
* )
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Auto-focus with custom delay
|
|
22
|
+
* html.textarea(
|
|
23
|
+
* AutoFocus(100), // Wait 100ms before focusing
|
|
24
|
+
* attr.placeholder('Enter your message')
|
|
25
|
+
* )
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* // Use in a modal dialog
|
|
31
|
+
* const showModal = prop(false)
|
|
32
|
+
*
|
|
33
|
+
* When(showModal,
|
|
34
|
+
* () => html.div(
|
|
35
|
+
* attr.class('modal'),
|
|
36
|
+
* html.input(
|
|
37
|
+
* AutoFocus(), // Focus when modal opens
|
|
38
|
+
* attr.placeholder('Search...')
|
|
39
|
+
* ),
|
|
40
|
+
* html.button(
|
|
41
|
+
* on.click(() => showModal.value = false),
|
|
42
|
+
* 'Close'
|
|
43
|
+
* )
|
|
44
|
+
* )
|
|
45
|
+
* )
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Combine with other input enhancements
|
|
51
|
+
* html.input(
|
|
52
|
+
* AutoFocus(),
|
|
53
|
+
* AutoSelect(), // Also select the text
|
|
54
|
+
* attr.value(searchTerm),
|
|
55
|
+
* on.input(emitValue(value => searchTerm.value = value))
|
|
56
|
+
* )
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @param delay - Delay in milliseconds before focusing (default: 10ms)
|
|
60
|
+
* @returns A renderable that focuses the element when rendered
|
|
7
61
|
* @public
|
|
8
62
|
*/
|
|
9
63
|
export declare const AutoFocus: (delay?: number) => Renderable;
|
|
@@ -1,8 +1,68 @@
|
|
|
1
1
|
import { Renderable } from '@tempots/dom';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* Automatically selects all text content in an input element when it's rendered.
|
|
4
|
+
*
|
|
5
|
+
* This utility is particularly useful for input fields where you want the user to be able
|
|
6
|
+
* to immediately start typing to replace the existing content, or easily copy the current value.
|
|
7
|
+
* The small default delay ensures the element is fully rendered before attempting to select.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Auto-select text in an input
|
|
12
|
+
* const username = prop('john_doe')
|
|
13
|
+
*
|
|
14
|
+
* html.input(
|
|
15
|
+
* AutoSelect(),
|
|
16
|
+
* attr.value(username),
|
|
17
|
+
* attr.type('text')
|
|
18
|
+
* )
|
|
19
|
+
* // When rendered, 'john_doe' will be automatically selected
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // Combine with AutoFocus for complete UX
|
|
25
|
+
* html.input(
|
|
26
|
+
* AutoFocus(), // Focus the input
|
|
27
|
+
* AutoSelect(), // Select all text
|
|
28
|
+
* attr.value(editableValue),
|
|
29
|
+
* attr.placeholder('Enter value')
|
|
30
|
+
* )
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // Use in an edit dialog
|
|
36
|
+
* const editMode = prop(false)
|
|
37
|
+
* const itemName = prop('Default Name')
|
|
38
|
+
*
|
|
39
|
+
* When(editMode,
|
|
40
|
+
* () => html.div(
|
|
41
|
+
* html.label('Edit name:'),
|
|
42
|
+
* html.input(
|
|
43
|
+
* AutoFocus(),
|
|
44
|
+
* AutoSelect(), // Select existing name for easy editing
|
|
45
|
+
* attr.value(itemName),
|
|
46
|
+
* on.keydown(e => {
|
|
47
|
+
* if (e.key === 'Enter') editMode.value = false
|
|
48
|
+
* if (e.key === 'Escape') editMode.value = false
|
|
49
|
+
* })
|
|
50
|
+
* )
|
|
51
|
+
* )
|
|
52
|
+
* )
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // Custom delay for specific timing needs
|
|
58
|
+
* html.input(
|
|
59
|
+
* AutoSelect(50), // Wait 50ms before selecting
|
|
60
|
+
* attr.value(sensitiveData)
|
|
61
|
+
* )
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @param delay - Delay in milliseconds before selecting text (default: 10ms)
|
|
65
|
+
* @returns A renderable that selects all text in the input element when rendered
|
|
6
66
|
* @public
|
|
7
67
|
*/
|
|
8
68
|
export declare const AutoSelect: (delay?: number) => Renderable;
|
|
@@ -2,7 +2,6 @@ import { Renderable } from '@tempots/dom';
|
|
|
2
2
|
/**
|
|
3
3
|
* Hides the element when it is empty and restores its initial state when necessary.
|
|
4
4
|
*
|
|
5
|
-
* @param ctx - The DOM context.
|
|
6
5
|
* @returns A function that can be used to restore the initial state of the element.
|
|
7
6
|
* @public
|
|
8
7
|
*/
|
|
@@ -13,22 +13,128 @@ export type InViewportOptions = {
|
|
|
13
13
|
once?: boolean;
|
|
14
14
|
};
|
|
15
15
|
/**
|
|
16
|
-
* Creates a
|
|
16
|
+
* Creates a component that tracks whether an element is visible in the viewport.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
18
|
+
* This component uses the Intersection Observer API to efficiently detect when an element
|
|
19
|
+
* enters or exits the viewport. It's perfect for implementing lazy loading, infinite scrolling,
|
|
20
|
+
* animations on scroll, and other viewport-based interactions.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // Basic viewport detection
|
|
25
|
+
* InViewport(
|
|
26
|
+
* { mode: 'partial' },
|
|
27
|
+
* (isVisible) => html.div(
|
|
28
|
+
* attr.class(isVisible.map(v => v ? 'visible' : 'hidden')),
|
|
29
|
+
* 'This element changes class when visible'
|
|
30
|
+
* )
|
|
31
|
+
* )
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
* // Lazy load images
|
|
37
|
+
* const imageUrl = 'https://example.com/large-image.jpg'
|
|
38
|
+
*
|
|
39
|
+
* InViewport(
|
|
40
|
+
* { mode: 'partial', once: true },
|
|
41
|
+
* (isVisible) => isVisible.value
|
|
42
|
+
* ? html.img(attr.src(imageUrl), attr.alt('Lazy loaded image'))
|
|
43
|
+
* : html.div(attr.class('placeholder'), 'Loading...')
|
|
44
|
+
* )
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* // Infinite scrolling trigger
|
|
50
|
+
* const loadMore = () => {
|
|
51
|
+
* // Load more data
|
|
52
|
+
* console.log('Loading more items...')
|
|
53
|
+
* }
|
|
54
|
+
*
|
|
55
|
+
* html.div(
|
|
56
|
+
* ForEach(items, item => ItemComponent(item)),
|
|
57
|
+
* InViewport(
|
|
58
|
+
* { mode: 'partial' },
|
|
59
|
+
* (isVisible) => {
|
|
60
|
+
* // Trigger load more when sentinel comes into view
|
|
61
|
+
* isVisible.on(visible => {
|
|
62
|
+
* if (visible) loadMore()
|
|
63
|
+
* })
|
|
64
|
+
* return html.div(attr.class('loading-sentinel'), 'Loading more...')
|
|
65
|
+
* }
|
|
66
|
+
* )
|
|
67
|
+
* )
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```typescript
|
|
72
|
+
* // Animation on scroll
|
|
73
|
+
* InViewport(
|
|
74
|
+
* { mode: 'full' }, // Only trigger when fully visible
|
|
75
|
+
* (isVisible) => html.div(
|
|
76
|
+
* attr.class(isVisible.map(v =>
|
|
77
|
+
* v ? 'animate-fade-in' : 'opacity-0'
|
|
78
|
+
* )),
|
|
79
|
+
* 'This animates when fully in view'
|
|
80
|
+
* )
|
|
81
|
+
* )
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @param options - Configuration options for viewport detection
|
|
85
|
+
* @param options.mode - 'partial' (any part visible) or 'full' (completely visible)
|
|
86
|
+
* @param options.once - If true, stops observing after first intersection
|
|
87
|
+
* @param fn - Function that receives the visibility signal and returns content to render
|
|
88
|
+
* @returns A renderable component that tracks viewport visibility
|
|
21
89
|
* @public
|
|
22
90
|
*/
|
|
23
91
|
export declare const InViewport: ({ mode, once }: InViewportOptions, fn: (value: Signal<boolean>) => TNode) => Renderable;
|
|
24
92
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
93
|
+
* Conditionally renders content based on whether an element is in the viewport.
|
|
94
|
+
*
|
|
95
|
+
* This is a convenience wrapper around `InViewport` that provides a simpler API
|
|
96
|
+
* for cases where you just want to show/hide content based on viewport visibility.
|
|
97
|
+
* It's perfect for simple lazy loading or reveal animations.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```typescript
|
|
101
|
+
* // Simple lazy loading
|
|
102
|
+
* WhenInViewport(
|
|
103
|
+
* { mode: 'partial', once: true },
|
|
104
|
+
* () => html.img(
|
|
105
|
+
* attr.src('https://example.com/image.jpg'),
|
|
106
|
+
* attr.alt('Lazy loaded image')
|
|
107
|
+
* ),
|
|
108
|
+
* () => html.div(attr.class('skeleton'), 'Loading...')
|
|
109
|
+
* )
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* // Reveal animation
|
|
115
|
+
* WhenInViewport(
|
|
116
|
+
* { mode: 'full' },
|
|
117
|
+
* () => html.div(
|
|
118
|
+
* attr.class('animate-slide-up'),
|
|
119
|
+
* 'This content slides up when visible'
|
|
120
|
+
* )
|
|
121
|
+
* )
|
|
122
|
+
* ```
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```typescript
|
|
126
|
+
* // Load expensive component only when needed
|
|
127
|
+
* WhenInViewport(
|
|
128
|
+
* { mode: 'partial', once: true },
|
|
129
|
+
* () => ExpensiveChart({ data: chartData }),
|
|
130
|
+
* () => html.div('Chart will load when visible')
|
|
131
|
+
* )
|
|
132
|
+
* ```
|
|
27
133
|
*
|
|
28
|
-
* @param options -
|
|
29
|
-
* @param then -
|
|
30
|
-
* @param otherwise -
|
|
31
|
-
* @returns
|
|
134
|
+
* @param options - Configuration options for viewport detection
|
|
135
|
+
* @param then - Function that returns content to render when element is in viewport
|
|
136
|
+
* @param otherwise - Optional function that returns content when element is not in viewport
|
|
137
|
+
* @returns A renderable component that conditionally shows content based on viewport visibility
|
|
32
138
|
* @public
|
|
33
139
|
*/
|
|
34
140
|
export declare const WhenInViewport: (options: InViewportOptions, then: () => TNode, otherwise?: () => TNode) => Renderable;
|
|
@@ -28,16 +28,123 @@ export interface ResourceDisplayOptions<V, E> {
|
|
|
28
28
|
*/
|
|
29
29
|
export declare const ResourceDisplay: <V, E>(resource: AsyncResource<V, E>, options: ResourceDisplayOptions<V, E>) => Renderable<import('@tempots/dom').DOMContext>;
|
|
30
30
|
/**
|
|
31
|
-
* Creates
|
|
31
|
+
* Creates a reactive resource component for handling asynchronous data loading.
|
|
32
32
|
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
33
|
+
* This component provides a declarative way to handle async operations with proper
|
|
34
|
+
* loading, success, and error states. It automatically manages the lifecycle of
|
|
35
|
+
* async requests and provides reload functionality.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* // Basic API data loading
|
|
40
|
+
* const userId = prop(1)
|
|
41
|
+
*
|
|
42
|
+
* const UserProfile = Resource({
|
|
43
|
+
* request: userId,
|
|
44
|
+
* load: async ({ request }) => {
|
|
45
|
+
* const response = await fetch(`/api/users/${request}`)
|
|
46
|
+
* if (!response.ok) throw new Error('Failed to load user')
|
|
47
|
+
* return response.json()
|
|
48
|
+
* }
|
|
49
|
+
* })({
|
|
50
|
+
* loading: () => html.div('Loading user...'),
|
|
51
|
+
* failure: (error, reload) => html.div(
|
|
52
|
+
* 'Error: ', error,
|
|
53
|
+
* html.button(on.click(reload), 'Retry')
|
|
54
|
+
* ),
|
|
55
|
+
* success: (user) => html.div(
|
|
56
|
+
* html.h2(user.map(u => u.name)),
|
|
57
|
+
* html.p(user.map(u => u.email))
|
|
58
|
+
* )
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* // Resource with dependencies
|
|
65
|
+
* const searchQuery = prop('')
|
|
66
|
+
* const filters = prop({ category: 'all', sort: 'name' })
|
|
67
|
+
*
|
|
68
|
+
* const SearchResults = Resource({
|
|
69
|
+
* request: computed(() => ({
|
|
70
|
+
* query: searchQuery.value,
|
|
71
|
+
* ...filters.value
|
|
72
|
+
* })),
|
|
73
|
+
* load: async ({ request, abortSignal }) => {
|
|
74
|
+
* const params = new URLSearchParams(request)
|
|
75
|
+
* const response = await fetch(`/api/search?${params}`, {
|
|
76
|
+
* signal: abortSignal
|
|
77
|
+
* })
|
|
78
|
+
* return response.json()
|
|
79
|
+
* },
|
|
80
|
+
* mapError: (error) => error instanceof Error ? error.message : 'Unknown error'
|
|
81
|
+
* })({
|
|
82
|
+
* loading: (previous) => html.div(
|
|
83
|
+
* 'Searching...',
|
|
84
|
+
* previous.value && html.div('Previous results:', previous.value.length)
|
|
85
|
+
* ),
|
|
86
|
+
* failure: (error, reload) => html.div(
|
|
87
|
+
* attr.class('error'),
|
|
88
|
+
* 'Search failed: ', error,
|
|
89
|
+
* html.button(on.click(reload), 'Try again')
|
|
90
|
+
* ),
|
|
91
|
+
* success: (results, reload) => html.div(
|
|
92
|
+
* html.button(on.click(reload), 'Refresh'),
|
|
93
|
+
* ForEach(results, result => SearchResultItem(result))
|
|
94
|
+
* )
|
|
95
|
+
* })
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* // File upload resource
|
|
101
|
+
* const selectedFile = prop<File | null>(null)
|
|
102
|
+
*
|
|
103
|
+
* const FileUpload = Resource({
|
|
104
|
+
* request: selectedFile,
|
|
105
|
+
* load: async ({ request }) => {
|
|
106
|
+
* if (!request) throw new Error('No file selected')
|
|
107
|
+
*
|
|
108
|
+
* const formData = new FormData()
|
|
109
|
+
* formData.append('file', request)
|
|
110
|
+
*
|
|
111
|
+
* const response = await fetch('/api/upload', {
|
|
112
|
+
* method: 'POST',
|
|
113
|
+
* body: formData
|
|
114
|
+
* })
|
|
115
|
+
*
|
|
116
|
+
* if (!response.ok) throw new Error('Upload failed')
|
|
117
|
+
* return response.json()
|
|
118
|
+
* }
|
|
119
|
+
* })({
|
|
120
|
+
* loading: () => html.div(
|
|
121
|
+
* attr.class('upload-progress'),
|
|
122
|
+
* 'Uploading file...'
|
|
123
|
+
* ),
|
|
124
|
+
* failure: (error, reload) => html.div(
|
|
125
|
+
* attr.class('upload-error'),
|
|
126
|
+
* 'Upload failed: ', error,
|
|
127
|
+
* html.button(on.click(reload), 'Retry upload')
|
|
128
|
+
* ),
|
|
129
|
+
* success: (result) => html.div(
|
|
130
|
+
* attr.class('upload-success'),
|
|
131
|
+
* 'File uploaded successfully!',
|
|
132
|
+
* html.a(
|
|
133
|
+
* attr.href(result.map(r => r.url)),
|
|
134
|
+
* 'View file'
|
|
135
|
+
* )
|
|
136
|
+
* )
|
|
137
|
+
* })
|
|
138
|
+
* ```
|
|
36
139
|
*
|
|
37
|
-
* @
|
|
38
|
-
* @
|
|
39
|
-
* @
|
|
40
|
-
* @
|
|
140
|
+
* @template R - The type of the request parameter
|
|
141
|
+
* @template V - The type of the successful result value
|
|
142
|
+
* @template E - The type of the error (defaults to unknown)
|
|
143
|
+
* @param config - Configuration object for the resource
|
|
144
|
+
* @param config.request - Signal or value representing the request parameters
|
|
145
|
+
* @param config.load - Async function that loads the resource
|
|
146
|
+
* @param config.mapError - Optional function to transform errors into a specific type
|
|
147
|
+
* @returns Function that takes display options and returns a renderable component
|
|
41
148
|
* @public
|
|
42
149
|
*/
|
|
43
150
|
export declare const Resource: <R, V, E = unknown>({ request, load, mapError, }: {
|
|
@@ -1,9 +1,77 @@
|
|
|
1
1
|
import { Prop, Provider } from '@tempots/dom';
|
|
2
2
|
import { LocationData } from './location-data';
|
|
3
3
|
/**
|
|
4
|
-
* Provider for
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Provider for browser location and navigation functionality.
|
|
5
|
+
*
|
|
6
|
+
* The Location provider gives components access to the current URL and provides
|
|
7
|
+
* methods for programmatic navigation. It automatically detects whether it's
|
|
8
|
+
* running in a browser or headless environment and provides the appropriate
|
|
9
|
+
* implementation.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Use location in a component
|
|
14
|
+
* const CurrentPath = () =>
|
|
15
|
+
* Use(Location, location => html.div(
|
|
16
|
+
* 'Current path: ', location.$.pathname,
|
|
17
|
+
* html.br(),
|
|
18
|
+
* 'Search params: ', location.$.search,
|
|
19
|
+
* html.br(),
|
|
20
|
+
* 'Hash: ', location.$.hash
|
|
21
|
+
* ))
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Navigation buttons
|
|
27
|
+
* const Navigation = () =>
|
|
28
|
+
* Use(Location, location => html.nav(
|
|
29
|
+
* html.button(
|
|
30
|
+
* on.click(() => location.navigate('/')),
|
|
31
|
+
* 'Home'
|
|
32
|
+
* ),
|
|
33
|
+
* html.button(
|
|
34
|
+
* on.click(() => location.navigate('/about')),
|
|
35
|
+
* 'About'
|
|
36
|
+
* ),
|
|
37
|
+
* html.button(
|
|
38
|
+
* on.click(() => location.back()),
|
|
39
|
+
* 'Back'
|
|
40
|
+
* ),
|
|
41
|
+
* html.button(
|
|
42
|
+
* on.click(() => location.forward()),
|
|
43
|
+
* 'Forward'
|
|
44
|
+
* )
|
|
45
|
+
* ))
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Conditional rendering based on path
|
|
51
|
+
* const ConditionalContent = () =>
|
|
52
|
+
* Use(Location, location =>
|
|
53
|
+
* When(location.map(loc => loc.pathname.startsWith('/admin')),
|
|
54
|
+
* () => AdminPanel(),
|
|
55
|
+
* () => PublicContent()
|
|
56
|
+
* )
|
|
57
|
+
* )
|
|
58
|
+
* ```
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* // URL parameter extraction
|
|
63
|
+
* const ProductPage = () =>
|
|
64
|
+
* Use(Location, location => {
|
|
65
|
+
* const searchParams = location.map(loc => new URLSearchParams(loc.search))
|
|
66
|
+
* const productId = searchParams.map(params => params.get('id'))
|
|
67
|
+
*
|
|
68
|
+
* return Ensure(productId,
|
|
69
|
+
* (id) => ProductDetail({ id }),
|
|
70
|
+
* () => html.div('Product ID required')
|
|
71
|
+
* )
|
|
72
|
+
* })
|
|
73
|
+
* ```
|
|
74
|
+
*
|
|
7
75
|
* @public
|
|
8
76
|
*/
|
|
9
77
|
export declare const Location: Provider<Prop<LocationData>>;
|
|
@@ -1,11 +1,100 @@
|
|
|
1
1
|
import { TNode, Renderable, Signal } from '@tempots/dom';
|
|
2
2
|
import { ExtractParams, MakeParams, RouteInfo } from './route-info';
|
|
3
3
|
/**
|
|
4
|
-
* Creates a router that maps
|
|
4
|
+
* Creates a client-side router that maps URL patterns to renderable components.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* The Router component provides declarative routing for single-page applications.
|
|
7
|
+
* It automatically extracts route parameters from URLs and passes them to the
|
|
8
|
+
* corresponding route handlers. The router integrates with the browser's history
|
|
9
|
+
* API and updates the UI when the URL changes.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // Basic routing setup
|
|
14
|
+
* const AppRouter = Router({
|
|
15
|
+
* '/': () => html.div('Home Page'),
|
|
16
|
+
* '/about': () => html.div('About Page'),
|
|
17
|
+
* '/contact': () => html.div('Contact Page'),
|
|
18
|
+
* '*': () => html.div('404 - Page Not Found')
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* render(AppRouter, document.body)
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* // Routes with parameters
|
|
27
|
+
* const BlogRouter = Router({
|
|
28
|
+
* '/': () => html.div('Blog Home'),
|
|
29
|
+
* '/posts/:id': (info) => {
|
|
30
|
+
* const postId = info.$.params.$.id
|
|
31
|
+
* return html.div(
|
|
32
|
+
* html.h1('Post ID: ', postId),
|
|
33
|
+
* html.p('Loading post...')
|
|
34
|
+
* )
|
|
35
|
+
* },
|
|
36
|
+
* '/users/:userId/posts/:postId': (info) => {
|
|
37
|
+
* const userId = info.$.params.$.userId
|
|
38
|
+
* const postId = info.$.params.$.postId
|
|
39
|
+
* return html.div(
|
|
40
|
+
* html.h1('User ', userId, ' - Post ', postId),
|
|
41
|
+
* UserPost({ userId, postId })
|
|
42
|
+
* )
|
|
43
|
+
* },
|
|
44
|
+
* '*': () => html.div('Page not found')
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Using route info for navigation and data
|
|
51
|
+
* const ProductRouter = Router({
|
|
52
|
+
* '/products': () => ProductList(),
|
|
53
|
+
* '/products/:id': (info) => {
|
|
54
|
+
* const productId = info.$.params.$.id
|
|
55
|
+
* const searchParams = info.$.search
|
|
56
|
+
*
|
|
57
|
+
* return html.div(
|
|
58
|
+
* html.h1('Product ', productId),
|
|
59
|
+
* html.p('Search params: ', searchParams),
|
|
60
|
+
* ProductDetail({
|
|
61
|
+
* id: productId,
|
|
62
|
+
* variant: new URLSearchParams(searchParams.value).get('variant')
|
|
63
|
+
* })
|
|
64
|
+
* )
|
|
65
|
+
* },
|
|
66
|
+
* '/products/:id/reviews': (info) => {
|
|
67
|
+
* const productId = info.$.params.$.id
|
|
68
|
+
* return ProductReviews({ productId })
|
|
69
|
+
* }
|
|
70
|
+
* })
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* // Programmatic navigation
|
|
76
|
+
* import { Location } from '@tempots/ui'
|
|
77
|
+
*
|
|
78
|
+
* const Navigation = () => html.nav(
|
|
79
|
+
* html.button(
|
|
80
|
+
* on.click(() => Location.navigate('/')),
|
|
81
|
+
* 'Home'
|
|
82
|
+
* ),
|
|
83
|
+
* html.button(
|
|
84
|
+
* on.click(() => Location.navigate('/about')),
|
|
85
|
+
* 'About'
|
|
86
|
+
* ),
|
|
87
|
+
* html.button(
|
|
88
|
+
* on.click(() => Location.navigate('/products/123')),
|
|
89
|
+
* 'Product 123'
|
|
90
|
+
* )
|
|
91
|
+
* )
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @template T - The type of the routes configuration object
|
|
95
|
+
* @param routes - Object mapping route patterns to handler functions
|
|
96
|
+
* @returns A renderable router component that handles URL routing
|
|
97
|
+
* @throws {Error} When no matching route is found for the current URL
|
|
9
98
|
* @public
|
|
10
99
|
*/
|
|
11
100
|
export declare const Router: <T extends { [K in keyof T]: (info: K extends string ? Signal<RouteInfo<MakeParams<ExtractParams<K>>, K>> : never) => TNode; }>(routes: T) => Renderable;
|