@tempots/ui 0.9.0 → 0.11.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 -0
- package/index.d.ts +16 -0
- package/index.js +1793 -0
- package/package.json +2 -5
- package/renderables/anchor.d.ts +3 -0
- package/renderables/appearance.d.ts +31 -0
- package/renderables/async-result-view.d.ts +9 -0
- package/renderables/autofocus.d.ts +3 -0
- package/renderables/autoselect.d.ts +3 -0
- package/renderables/hidden-when-empty.d.ts +3 -0
- package/renderables/html-title.d.ts +3 -0
- package/renderables/inviewport.d.ts +5 -0
- package/renderables/pop-over.d.ts +13 -0
- package/renderables/result-view.d.ts +7 -0
- package/renderables/router/location.d.ts +16 -0
- package/renderables/router/match.d.ts +14 -0
- package/renderables/router/route-info.d.ts +27 -0
- package/renderables/router/router.d.ts +6 -0
- package/renderables/select-on-focus.d.ts +1 -0
- package/renderables/size.d.ts +6 -0
package/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Be=Object.defineProperty,Ue=(t,e,n)=>e in t?Be(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,d=(t,e,n)=>Ue(t,typeof e!="symbol"?e+"":e,n);const Yt="$__signal__",Nt="$__prop__",Ft="$__computed__";var Jt;Jt=Yt;const je=class F{constructor(e,n){d(this,Jt,!0),d(this,"_value"),d(this,"_derivatives",[]),d(this,"_onValueListeners",[]),d(this,"_onDisposeListeners",[]),d(this,"get",()=>this._value),d(this,"hasListeners",()=>this._onValueListeners.length>0),d(this,"on",o=>(o(this.get()),this._onValueListeners.push(o),()=>{this._onValueListeners.splice(this._onValueListeners.indexOf(o),1)})),d(this,"_setAndNotify",(o,i)=>{const s=this.equals(this._value,o);s||(this._value=o),(i||!s)&&this._onValueListeners.forEach(r=>r(o))}),d(this,"_disposed",!1),d(this,"isDisposed",()=>this._disposed),d(this,"onDispose",o=>{this._onDisposeListeners.push(o)}),d(this,"dispose",()=>{this._disposed||(this._disposed=!0,this._onDisposeListeners.forEach(o=>o()),this._onDisposeListeners.length=0,this._derivatives.length=0)}),d(this,"map",(o,i=(s,r)=>s===r)=>{const s=new ct(()=>{try{return o(this.get())}catch(r){throw console.error("Error in Signal.map:",r),r}},i);return this.setDerivative(s),s}),d(this,"flatMap",(o,i=(s,r)=>s===r)=>{const s=new ct(()=>{try{return o(this.get()).get()}catch(r){throw console.error("Error in Signal.flatMap:",r),r}},i);return this.setDerivative(s),s}),d(this,"tap",o=>this.map(i=>(o(i),i))),d(this,"at",o=>this.map(i=>i[o])),d(this,"$",new Proxy(this,{get:(o,i)=>this.at(i)})),d(this,"filter",(o,i)=>{let s=i??this.get();const r=new ct(()=>{try{const c=this.get();return s=o(c)?c:s}catch(c){throw console.error("Error in Signal.filter:",c),c}},this.equals);return this.setDerivative(r),r}),d(this,"filterMap",(o,i,s=(r,c)=>r===c)=>{let r=i;const c=new ct(()=>{try{const l=this.get();return r=o(l)??r}catch(l){throw console.error("Error in Signal.filterMap:",l),l}},s);return this.setDerivative(c),c}),d(this,"mapAsync",(o,i,s,r=(c,l)=>c===l)=>{const c=P(i,r);let l=0;return c.onDispose(this.on(a=>{const f=++l;try{o(a).then(u=>{f===l&&c.set(u)}).catch(u=>{f===l&&(s!=null?c.set(s(u)):console.error("Unhandled promise rejection in Signal.mapAsync:",u))})}catch(u){throw console.error("Error in Signal.mapAsync:",u),u}})),c}),d(this,"mapMaybe",(o,i)=>this.map(s=>o(s)??i)),d(this,"feedProp",(o,i=!1)=>{const s=this.on(o.set);return o.onDispose(s),i?this.onDispose(o.dispose):this.onDispose(s),o}),d(this,"deriveProp",(o=!0)=>this.feedProp(P(this.get()),o)),d(this,"count",()=>{let o=0;return this.map(()=>++o)}),d(this,"setDerivative",o=>{this._derivatives.push(o),o.onDispose(()=>{this._derivatives.splice(this._derivatives.indexOf(o),1)}),o.onDispose(this.on(o.setDirty)),this.onDispose(o.dispose)}),this.equals=n,this._value=e}static ofPromise(e,n,o,i=(s,r)=>s===r){const s=new F(n,i);return e.then(r=>s._setAndNotify(r,!1)).catch(r=>{o!=null?s._setAndNotify(o(r),!1):console.error("Unhandled promise rejection in Signal.ofPromise:",r)}),s}static is(e){return e!=null&&e[Yt]===!0}static wrap(e,n=(o,i)=>o===i){return F.is(e)?e:new F(e,n)}static maybeWrap(e){return e==null?e:F.wrap(e)}static unwrap(e){return F.is(e)?e.get():e}static map(e,n){return F.is(e)?e.map(n):n(e)}get value(){return this._value}};let S=je;const qe=typeof queueMicrotask=="function"?queueMicrotask:t=>Promise.resolve().then(t);var $t,Vt;class ct extends(Vt=S,$t=Ft,Vt){constructor(e,n){super(void 0,n),d(this,$t,!0),d(this,"_isDirty",!1),d(this,"setDirty",()=>{this._isDirty||this._disposed||(this._isDirty=!0,this._derivatives.forEach(o=>o.setDirty()),this.scheduleNotify())}),d(this,"_scheduleCount",0),d(this,"scheduleNotify",()=>{const o=++this._scheduleCount;qe(()=>{this._scheduleCount!==o||this._disposed!==!1||this._isDirty&&(this._isDirty=!1,this._setAndNotify(this._fn(),!1))})}),d(this,"get",()=>(this._isDirty&&(this._isDirty=!1,this._value=this._fn(),this._setAndNotify(this._value,!0)),this._value)),this._fn=e,this.setDirty()}static is(e){return e!=null&&e[Ft]===!0}get value(){return this.get()}}var Wt,Ht;class St extends(Ht=S,Wt=Nt,Ht){constructor(){super(...arguments),d(this,Wt,!0),d(this,"set",e=>{this._setAndNotify(e,!1)}),d(this,"update",e=>{this._setAndNotify(e(this.get()),!1)}),d(this,"reducer",(e,...n)=>{const o=this;return function i(s){const r=o.value;o.update(c=>e(c,s)),!o.equals(r,o.value)&&n.forEach(c=>c({previousState:r,state:o.value,action:s,dispatch:i}))}}),d(this,"iso",(e,n,o=(i,s)=>i===s)=>{const i=new St(e(this.get()),o);return i.onDispose(this.on(s=>i.set(e(s)))),i.on(s=>this._setAndNotify(n(s),!1)),i}),d(this,"atProp",e=>this.iso(n=>n[e],n=>({...this.value,[e]:n})))}static is(e){return e!=null&&e[Nt]===!0}get value(){return this.get()}set value(e){this._setAndNotify(e,!1)}}function P(t,e=(n,o)=>n===o){return new St(t,e)}function Xe(t,e=(n,o)=>n===o){return new S(t,e)}const Kt=new Set(["checked","disabled","hidden","selected"]),Gt=new Set(["rowSpan","colSpan","tabIndex","valueAsNumber"]),Qt=new Set(["valueAsDate"]),Zt=new Set(["value","textContent","innerText","innerHTML","outerHTML","className","classList"]),xt=new Map;function Q(t,e){if(xt.has(t))return xt.get(t);{const n=e(t);return xt.set(t,n),n}}function Ye(t){return(e,n)=>{n==null?e[t]=null:e[t]=!!n}}function Je(t){return(e,n)=>{n==null?e[t]=null:e[t]=Number(n)}}function Ke(t){return(e,n)=>{n==null?e[t]=null:e[t]=n}}function Ge(t){return(e,n)=>{n==null?e[t]=null:e[t]=String(n)}}function Qe(t){return(e,n)=>{n==null?e.removeAttribute(t):e.setAttribute(t,n)}}function te(t){return Kt.has(t)?Q(t,Ye):Gt.has(t)?Q(t,Je):Qt.has(t)?Q(t,Ke):Zt.has(t)?Q(t,Ge):Q(t,Qe)}function ee(t){return e=>Kt.has(t)?!!e[t]:Gt.has(t)?Number(e[t]):Qt.has(t)?e[t]:Zt.has(t)?String(e[t]):e.getAttribute(t)}function q(t){const e=t;e&&e.onblur&&(e.onblur=null),!(!t||t.ownerDocument===void 0)&&t.parentElement&&t.parentElement.removeChild(t)}function Ze(t,e,n){let o=t.target;for(;o!=null&&!(o instanceof HTMLAnchorElement);)o=o.parentElement;if(o==null)return!0;const i=o;if(t.button!==0||t.ctrlKey||t.metaKey||i.target!=="_self"&&i.target!==""||i.getAttribute("download")!=null)return!0;if(n){const{pathname:s,search:r,hash:c}=i,l=s+r+c;if(i.getAttribute("href")!==l||e&&!/\/[^/.]*$/.test(s))return!0}return!1}const tn=(t,e={checkExtension:!0,checkExternalUrl:!0})=>n=>{const{checkExtension:o,checkExternalUrl:i}=e;Ze(n,o===!0,i===!0)||t()&&n.preventDefault()},en=t=>e=>{le(e);const n=e.createText(t);return e.appendOrInsert(n),o=>{o&&q(n)}},nn=t=>e=>{le(e);const n=e.createText(t.value);e.appendOrInsert(n);const o=t.on(i=>n.data=i);return i=>{o(),i&&q(n)}},X=(...t)=>e=>{const n=t.map(o=>b(o)(e));return o=>{n.forEach(i=>i(o))}},tt=()=>()=>{},on=t=>e=>(re(e),e.element.classList.add(...t),n=>{n&&e.element.classList.remove(...t)}),sn=t=>e=>{re(e);const n=e.element;let o=[];const i=t.on(s=>{o.forEach(r=>n.classList.remove(r)),o=(s??"").split(" ").filter(r=>r.length>0),n.classList.add(...o)});return s=>{i(),s&&o.forEach(r=>n.classList.remove(r)),o.length=0}},nt=(t,e)=>{const n=te(t),o=ee(t);return i=>{se(i,t);const s=o(i.element);return n(i.element,e),r=>{r&&n(i.element,s)}}},ot=(t,e)=>{const n=te(t),o=ee(t);return i=>{se(i,t);const s=o(i.element);return e.on(r=>n(i.element,r)),r=>{r&&n(i.element,s)}}},Lt=new Proxy({},{get:(t,e)=>e==="class"?n=>S.is(n)?sn(n):on((n??"").split(" ").filter(o=>o.length>0)):n=>S.is(n)?ot(e,n):nt(e,n)});new Proxy({},{get:(t,e)=>n=>S.is(n)?ot(`data-${e}`,n):nt(`data-${e}`,n)});new Proxy({},{get:(t,e)=>n=>S.is(n)?ot(`aria-${e}`,n):nt(`aria-${e}`,n)});new Proxy({},{get:(t,e)=>n=>S.is(n)?ot(e,n):nt(e,n)});new Proxy({},{get:(t,e)=>n=>S.is(n)?ot(e,n):nt(e,n)});function b(t){return t==null?tt:Array.isArray(t)?X(...t.map(b)):typeof t=="string"?en(t):S.is(t)?nn(t):t}function ne(t,...e){return n=>{const o=n.createElement(t,void 0);n.isFirstLevel&&Y.isSSR()&&ce(o),n.appendOrInsert(o),n=n.withElement(o);const i=e.map(s=>b(s)(n));return s=>{i.forEach(r=>r(!1)),s&&q(o)}}}function oe(t,e,...n){return o=>{const i=o.createElement(t,e);o.isFirstLevel&&Y.isSSR()&&ce(i),o.appendOrInsert(i),o=o.withElement(i);const s=n.map(r=>b(r)(o));return r=>{s.forEach(c=>c(!1)),r&&q(i)}}}const ie=new Proxy({},{get:(t,e)=>(...n)=>ne(e,n.flatMap(b))});new Proxy({},{get:(t,e)=>(...n)=>ne("input",Lt.type(e),...n)});const rn="http://www.w3.org/2000/svg";new Proxy({},{get:(t,e)=>(...n)=>oe(e,rn,n.flatMap(b))});const cn="http://www.w3.org/1998/Math/MathML";new Proxy({},{get:(t,e)=>(...n)=>oe(e,cn,n.flatMap(b))});const zt="data-tempo-attr",ln="data-tempo-class",an="data-tempo-node",un="data-tempo-text";function fn(t,e){const n=t.getAttribute(e);if(n!=null){const o=t.getAttribute(zt)??"{}",i={...JSON.parse(o),name:n};t.setAttribute(zt,JSON.stringify(i))}}function se(t,e){Y.isSSR()&&t.isFirstLevel&&fn(t.element,e)}function hn(t){t.setAttribute(ln,t.className)}function re(t){Y.isSSR()&&t.isFirstLevel&&hn(t.element)}function ce(t){t.setAttribute(an,"")}function dn(t){t.setAttribute(un,t.textContent??"")}function le(t){Y.isSSR()&&t.isFirstLevel&&dn(t.element)}function ae(){const t=globalThis;return t.__tempoSSR__==null&&(t.__tempoSSR__={isSSR:!1,counter:0}),t.__tempoSSR__}function ue(t,e){const n=ae();n[t]=e}function fe(t){return ae()[t]}function pn(){return fe("isSSR")}function he(){return fe("counter")}function mn(){ue("counter",(he()??0)+1)}function gn(){ue("counter",(he()??0)-1)}const Y={useDone:t=>(mn(),b(t(gn))),isSSR:pn},wn=(t,e)=>n=>(n.element.addEventListener(t,e),o=>{o&&n.element.removeEventListener(t,e)}),de=new Proxy({},{get:(t,e)=>n=>wn(e,n)}),lt=(t,e)=>n=>{n=n.makeRef();let o,i;const s=t.map(l=>Object.keys(l)[0]);let r;const c=s.on(l=>{if(l!==r){i==null||i.dispose(),o==null||o(!0),i=t.map(f=>f[l]);const a=e[l](i);o=b(a)(n),r=l}});return l=>{c(),l&&n.reference!=null&&q(n.reference),o==null||o(!0)}},B={bool:(t,e)=>lt(t.map(n=>n?{true:!0}:{false:!0}),e),field:(t,e,n)=>lt(t.map(o=>({[o[e]]:o})),n),kind:(t,e)=>B.field(t,"kind",e),tuple:(t,e)=>{const n=t.map(([o,i])=>({[o]:i}));return lt(n,e)},type:(t,e)=>B.field(t,"type",e),value:(t,e)=>lt(t.map(n=>({[n]:!0})),e)},yn=(t,e)=>n=>{const o=Object.values(t).reduce((i,s)=>{const r=n.getProvider(s);if(r==null)throw new Error(`No provider found for mark: ${s.description}`);return i[s]=r,i},{});return b(e(o))(n)},pe=(t,e)=>yn([t],n=>b(e(n[t]))),vn=(t,e,n)=>o=>{o=o.makeRef();let i=null,s=!1;const r=P(null),c=t.on(l=>{l==null?(i==null||i(!0),i=b((n==null?void 0:n())??tt)(o),s=!1):(r.value=l,s||(i==null||i(!0),i=b(e(r))(o),s=!0))});return l=>{c(),i==null||i(l),l&&o.reference&&q(o.reference)}},it=t=>e=>n=>t(n,e),xn=(t,e,n)=>vn(t.map(o=>o?!0:null),()=>e,n!=null?()=>n:void 0),me=t=>e=>t(e.element)??(()=>{});function bn(t,e){const n=t(e);return()=>n(!0)}const ge=(t,e)=>n=>{const o=n.document.querySelector(t);if(o===null)throw new Error(`Cannot find element by selector for portal: ${t}`);return bn(b(e),n.withElement(o).withFirstLevel())};function we(t){return Symbol(t)}const An=(t,e)=>n=>b(e)(n.withProviders(t)),ye=(t,e,n)=>An({[t]:e},b(n)),Sn=(t,e)=>n=>{const o=n.element,i=o.style.getPropertyValue(t);return o.style.setProperty(t,e),s=>{s&&o.style.setProperty(t,i)}},Ln=(t,e)=>n=>{const o=n.element,i=o.style.getPropertyValue(t);return e.on(s=>o.style.setProperty(t,s)),s=>{s&&o.style.setProperty(t,i)}};new Proxy({},{get:(t,e)=>n=>S.is(n)?Ln(e,n):Sn(e,n)});const Rt=we("LocationProvider");function ve(){const t=(window==null?void 0:window.location.hash)===""?void 0:(window==null?void 0:window.location.hash.substring(1))??void 0;return{pathname:(window==null?void 0:window.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((window==null?void 0:window.location.search)??"").entries()),hash:t}}function xe(t,e){return t.pathname===e.pathname&&JSON.stringify(t.search)===JSON.stringify(e.search)&&t.hash===e.hash}function be(t){const e=new URL(t,(window==null?void 0:window.location.toString())??""),n=Object.fromEntries(e.searchParams.entries());return{pathname:e.pathname,search:n,hash:e.hash}}function Ae(t,e){const n=be(e);return t.set(n),t}function Rn(t){const n=new URLSearchParams(t.search).toString(),o=t.hash;return`${t.pathname}${n?`?${n}`:""}${o?`#${o}`:""}`}function Se(){const t=P(ve(),xe),e=()=>{const n={...t.value,pathname:(window==null?void 0:window.location.pathname)??""};t.set(n)};return window==null||window.addEventListener("popstate",e),t.onDispose(()=>{window==null||window.removeEventListener("popstate",e)}),t.on(n=>{const i=new URLSearchParams(n.search).toString(),s=n.hash,r=`${n.pathname}${i?`?${i}`:""}${s?`#${s}`:""}`;window==null||window.history.pushState({},"",r)}),t}function En(t){const e=Se();return X(it(e.dispose),ye(Rt,e,t))}function Et(t){return pe(Rt,e=>n=>{const o=P(e.value,e.equals);e.feedProp(o),o.on(e.set);const i=b(t(o))(n);return s=>{o.dispose(),i(s)}})}function _n(t,...e){return Et(n=>ie.a(de.click(tn(()=>(Ae(n,S.unwrap(t)),!0))),Lt.href(t),...e))}const _t=we("Appearance"),On=t=>{const e=window.matchMedia!=null&&window.matchMedia("(prefers-color-scheme: dark)").matches,n=P(e?"dark":"light"),o=s=>{n.set(s.matches?"dark":"light")},i=window.matchMedia!=null?window.matchMedia("(prefers-color-scheme: dark)"):void 0;return i==null||i.addEventListener("change",o),X(ye(_t,n,t),it(()=>i==null?void 0:i.removeEventListener("change",o)))},Pn=t=>pe(_t,t);function Le(t,e){if(typeof e=="function")return Le(t,{success:e});const n=e.failure??(r=>X(it(r.on(console.error)),r.map(c=>`Error: ${c}`))),o=e.success,i=e.loading??(()=>tt),s=e.notAsked??(()=>tt);return B.type(S.wrap(t),{AsyncSuccess:r=>o(r.$.value),AsyncFailure:r=>n(r.$.error),Loading:r=>i(r.$.previousValue??Xe(void 0)),NotAsked:s})}const Dn=(t=10)=>e=>{const n=setTimeout(()=>{var o;(o=e.element)==null||o.focus()},t);return o=>clearTimeout(n)},Tn=(t=10)=>e=>{const n=setTimeout(()=>{var o;(o=e.element)==null||o.select()},t);return o=>{clearTimeout(n)}},kn=t=>{const e=t.element,n=e.style.getPropertyValue(":empty");return e.style.setProperty(":empty","display:none"),o=>{o&&e.style.setProperty(":empty",n)}},Cn=t=>ge("head title",Lt.innerText(t)),Mn={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},ut={partial:new Map,full:new Map},Z={partial:null,full:null};function Nn(t){return Z[t]==null&&(Z[t]=new IntersectionObserver(e=>{e.forEach(n=>{const o=ut[t].get(n.target);o==null||o.set(n.isIntersecting)})},Mn[t])),Z[t]}function Re(t,e){const n=P(Y.isSSR());return X(me(o=>{const i=typeof IntersectionObserver<"u"?Nn(t):null;return ut[t].set(o,n),i==null||i.observe(o),()=>{var s;i==null||i.unobserve(o),ut[t].delete(o),ut[t].size===0&&((s=Z[t])==null||s.disconnect(),Z[t]=null)}}),it(n.dispose),b(e(n)))}const Fn=(t,e,n)=>Re(t,o=>xn(o,e,n??tt)),ft=Math.min,$=Math.max,ht=Math.round,at=Math.floor,C=t=>({x:t,y:t}),$n={left:"right",right:"left",bottom:"top",top:"bottom"},Vn={start:"end",end:"start"};function It(t,e,n){return $(t,ft(e,n))}function mt(t,e){return typeof t=="function"?t(e):t}function V(t){return t.split("-")[0]}function gt(t){return t.split("-")[1]}function Ee(t){return t==="x"?"y":"x"}function _e(t){return t==="y"?"height":"width"}function U(t){return["top","bottom"].includes(V(t))?"y":"x"}function Oe(t){return Ee(U(t))}function Wn(t,e,n){n===void 0&&(n=!1);const o=gt(t),i=Oe(t),s=_e(i);let r=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(r=dt(r)),[r,dt(r)]}function Hn(t){const e=dt(t);return[At(t),e,At(e)]}function At(t){return t.replace(/start|end/g,e=>Vn[e])}function zn(t,e,n){const o=["left","right"],i=["right","left"],s=["top","bottom"],r=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?s:r;default:return[]}}function In(t,e,n,o){const i=gt(t);let s=zn(V(t),n==="start",o);return i&&(s=s.map(r=>r+"-"+i),e&&(s=s.concat(s.map(At)))),s}function dt(t){return t.replace(/left|right|bottom|top/g,e=>$n[e])}function Bn(t){return{top:0,right:0,bottom:0,left:0,...t}}function Un(t){return typeof t!="number"?Bn(t):{top:t,right:t,bottom:t,left:t}}function pt(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function Bt(t,e,n){let{reference:o,floating:i}=t;const s=U(e),r=Oe(e),c=_e(r),l=V(e),a=s==="y",f=o.x+o.width/2-i.width/2,u=o.y+o.height/2-i.height/2,m=o[c]/2-i[c]/2;let h;switch(l){case"top":h={x:f,y:o.y-i.height};break;case"bottom":h={x:f,y:o.y+o.height};break;case"right":h={x:o.x+o.width,y:u};break;case"left":h={x:o.x-i.width,y:u};break;default:h={x:o.x,y:o.y}}switch(gt(e)){case"start":h[r]-=m*(n&&a?-1:1);break;case"end":h[r]+=m*(n&&a?-1:1);break}return h}const jn=async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:s=[],platform:r}=n,c=s.filter(Boolean),l=await(r.isRTL==null?void 0:r.isRTL(e));let a=await r.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=Bt(a,o,l),m=o,h={},g=0;for(let w=0;w<c.length;w++){const{name:y,fn:p}=c[w],{x:v,y:x,data:L,reset:A}=await p({x:f,y:u,initialPlacement:o,placement:m,strategy:i,middlewareData:h,rects:a,platform:r,elements:{reference:t,floating:e}});f=v??f,u=x??u,h={...h,[y]:{...h[y],...L}},A&&g<=50&&(g++,typeof A=="object"&&(A.placement&&(m=A.placement),A.rects&&(a=A.rects===!0?await r.getElementRects({reference:t,floating:e,strategy:i}):A.rects),{x:f,y:u}=Bt(a,m,l)),w=-1)}return{x:f,y:u,placement:m,strategy:i,middlewareData:h}};async function Pe(t,e){var n;e===void 0&&(e={});const{x:o,y:i,platform:s,rects:r,elements:c,strategy:l}=t,{boundary:a="clippingAncestors",rootBoundary:f="viewport",elementContext:u="floating",altBoundary:m=!1,padding:h=0}=mt(e,t),g=Un(h),y=c[m?u==="floating"?"reference":"floating":u],p=pt(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(y)))==null||n?y:y.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(c.floating)),boundary:a,rootBoundary:f,strategy:l})),v=u==="floating"?{x:o,y:i,width:r.floating.width,height:r.floating.height}:r.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(c.floating)),L=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},A=pt(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:x,strategy:l}):v);return{top:(p.top-A.top+g.top)/L.y,bottom:(A.bottom-p.bottom+g.bottom)/L.y,left:(p.left-A.left+g.left)/L.x,right:(A.right-p.right+g.right)/L.x}}const qn=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:s,rects:r,initialPlacement:c,platform:l,elements:a}=e,{mainAxis:f=!0,crossAxis:u=!0,fallbackPlacements:m,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:w=!0,...y}=mt(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const p=V(i),v=U(c),x=V(c)===c,L=await(l.isRTL==null?void 0:l.isRTL(a.floating)),A=m||(x||!w?[dt(c)]:Hn(c)),H=g!=="none";!m&&H&&A.push(...In(c,w,g,L));const ze=[c,...A],vt=await Pe(e,y),rt=[];let K=((o=s.flip)==null?void 0:o.overflows)||[];if(f&&rt.push(vt[p]),u){const N=Wn(i,r,L);rt.push(vt[N[0]],vt[N[1]])}if(K=[...K,{placement:i,overflows:rt}],!rt.every(N=>N<=0)){var Tt,kt;const N=(((Tt=s.flip)==null?void 0:Tt.index)||0)+1,Mt=ze[N];if(Mt)return{data:{index:N,overflows:K},reset:{placement:Mt}};let G=(kt=K.filter(z=>z.overflows[0]<=0).sort((z,T)=>z.overflows[1]-T.overflows[1])[0])==null?void 0:kt.placement;if(!G)switch(h){case"bestFit":{var Ct;const z=(Ct=K.filter(T=>{if(H){const k=U(T.placement);return k===v||k==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(k=>k>0).reduce((k,Ie)=>k+Ie,0)]).sort((T,k)=>T[1]-k[1])[0])==null?void 0:Ct[0];z&&(G=z);break}case"initialPlacement":G=c;break}if(i!==G)return{reset:{placement:G}}}return{}}}};async function Xn(t,e){const{placement:n,platform:o,elements:i}=t,s=await(o.isRTL==null?void 0:o.isRTL(i.floating)),r=V(n),c=gt(n),l=U(n)==="y",a=["left","top"].includes(r)?-1:1,f=s&&l?-1:1,u=mt(e,t);let{mainAxis:m,crossAxis:h,alignmentAxis:g}=typeof u=="number"?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...u};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),l?{x:h*f,y:m*a}:{x:m*a,y:h*f}}const Yn=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:s,placement:r,middlewareData:c}=e,l=await Xn(e,t);return r===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:r}}}}},Jn=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,{mainAxis:s=!0,crossAxis:r=!1,limiter:c={fn:y=>{let{x:p,y:v}=y;return{x:p,y:v}}},...l}=mt(t,e),a={x:n,y:o},f=await Pe(e,l),u=U(V(i)),m=Ee(u);let h=a[m],g=a[u];if(s){const y=m==="y"?"top":"left",p=m==="y"?"bottom":"right",v=h+f[y],x=h-f[p];h=It(v,h,x)}if(r){const y=u==="y"?"top":"left",p=u==="y"?"bottom":"right",v=g+f[y],x=g-f[p];g=It(v,g,x)}const w=c.fn({...e,[m]:h,[u]:g});return{...w,data:{x:w.x-n,y:w.y-o}}}}};function J(t){return De(t)?(t.nodeName||"").toLowerCase():"#document"}function R(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function D(t){var e;return(e=(De(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function De(t){return t instanceof Node||t instanceof R(t).Node}function _(t){return t instanceof Element||t instanceof R(t).Element}function O(t){return t instanceof HTMLElement||t instanceof R(t).HTMLElement}function Ut(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof R(t).ShadowRoot}function st(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=E(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function Kn(t){return["table","td","th"].includes(J(t))}function wt(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function Ot(t){const e=Pt(),n=E(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 Gn(t){let e=M(t);for(;O(e)&&!j(e);){if(wt(e))return null;if(Ot(e))return e;e=M(e)}return null}function Pt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function j(t){return["html","body","#document"].includes(J(t))}function E(t){return R(t).getComputedStyle(t)}function yt(t){return _(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function M(t){if(J(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Ut(t)&&t.host||D(t);return Ut(e)?e.host:e}function Te(t){const e=M(t);return j(e)?t.ownerDocument?t.ownerDocument.body:t.body:O(e)&&st(e)?e:Te(e)}function et(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=Te(t),s=i===((o=t.ownerDocument)==null?void 0:o.body),r=R(i);return s?e.concat(r,r.visualViewport||[],st(i)?i:[],r.frameElement&&n?et(r.frameElement):[]):e.concat(i,et(i,[],n))}function ke(t){const e=E(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=O(t),s=i?t.offsetWidth:n,r=i?t.offsetHeight:o,c=ht(n)!==s||ht(o)!==r;return c&&(n=s,o=r),{width:n,height:o,$:c}}function Dt(t){return _(t)?t:t.contextElement}function I(t){const e=Dt(t);if(!O(e))return C(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:s}=ke(e);let r=(s?ht(n.width):n.width)/o,c=(s?ht(n.height):n.height)/i;return(!r||!Number.isFinite(r))&&(r=1),(!c||!Number.isFinite(c))&&(c=1),{x:r,y:c}}const Qn=C(0);function Ce(t){const e=R(t);return!Pt()||!e.visualViewport?Qn:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Zn(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==R(t)?!1:e}function W(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=Dt(t);let r=C(1);e&&(o?_(o)&&(r=I(o)):r=I(t));const c=Zn(s,n,o)?Ce(s):C(0);let l=(i.left+c.x)/r.x,a=(i.top+c.y)/r.y,f=i.width/r.x,u=i.height/r.y;if(s){const m=R(s),h=o&&_(o)?R(o):o;let g=m,w=g.frameElement;for(;w&&o&&h!==g;){const y=I(w),p=w.getBoundingClientRect(),v=E(w),x=p.left+(w.clientLeft+parseFloat(v.paddingLeft))*y.x,L=p.top+(w.clientTop+parseFloat(v.paddingTop))*y.y;l*=y.x,a*=y.y,f*=y.x,u*=y.y,l+=x,a+=L,g=R(w),w=g.frameElement}}return pt({width:f,height:u,x:l,y:a})}function to(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const s=i==="fixed",r=D(o),c=e?wt(e.floating):!1;if(o===r||c&&s)return n;let l={scrollLeft:0,scrollTop:0},a=C(1);const f=C(0),u=O(o);if((u||!u&&!s)&&((J(o)!=="body"||st(r))&&(l=yt(o)),O(o))){const m=W(o);a=I(o),f.x=m.x+o.clientLeft,f.y=m.y+o.clientTop}return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-l.scrollLeft*a.x+f.x,y:n.y*a.y-l.scrollTop*a.y+f.y}}function eo(t){return Array.from(t.getClientRects())}function Me(t){return W(D(t)).left+yt(t).scrollLeft}function no(t){const e=D(t),n=yt(t),o=t.ownerDocument.body,i=$(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),s=$(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let r=-n.scrollLeft+Me(t);const c=-n.scrollTop;return E(o).direction==="rtl"&&(r+=$(e.clientWidth,o.clientWidth)-i),{width:i,height:s,x:r,y:c}}function oo(t,e){const n=R(t),o=D(t),i=n.visualViewport;let s=o.clientWidth,r=o.clientHeight,c=0,l=0;if(i){s=i.width,r=i.height;const a=Pt();(!a||a&&e==="fixed")&&(c=i.offsetLeft,l=i.offsetTop)}return{width:s,height:r,x:c,y:l}}function io(t,e){const n=W(t,!0,e==="fixed"),o=n.top+t.clientTop,i=n.left+t.clientLeft,s=O(t)?I(t):C(1),r=t.clientWidth*s.x,c=t.clientHeight*s.y,l=i*s.x,a=o*s.y;return{width:r,height:c,x:l,y:a}}function jt(t,e,n){let o;if(e==="viewport")o=oo(t,n);else if(e==="document")o=no(D(t));else if(_(e))o=io(e,n);else{const i=Ce(t);o={...e,x:e.x-i.x,y:e.y-i.y}}return pt(o)}function Ne(t,e){const n=M(t);return n===e||!_(n)||j(n)?!1:E(n).position==="fixed"||Ne(n,e)}function so(t,e){const n=e.get(t);if(n)return n;let o=et(t,[],!1).filter(c=>_(c)&&J(c)!=="body"),i=null;const s=E(t).position==="fixed";let r=s?M(t):t;for(;_(r)&&!j(r);){const c=E(r),l=Ot(r);!l&&c.position==="fixed"&&(i=null),(s?!l&&!i:!l&&c.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||st(r)&&!l&&Ne(t,r))?o=o.filter(f=>f!==r):i=c,r=M(r)}return e.set(t,o),o}function ro(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const r=[...n==="clippingAncestors"?wt(e)?[]:so(e,this._c):[].concat(n),o],c=r[0],l=r.reduce((a,f)=>{const u=jt(e,f,i);return a.top=$(u.top,a.top),a.right=ft(u.right,a.right),a.bottom=ft(u.bottom,a.bottom),a.left=$(u.left,a.left),a},jt(e,c,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function co(t){const{width:e,height:n}=ke(t);return{width:e,height:n}}function lo(t,e,n){const o=O(e),i=D(e),s=n==="fixed",r=W(t,!0,s,e);let c={scrollLeft:0,scrollTop:0};const l=C(0);if(o||!o&&!s)if((J(e)!=="body"||st(i))&&(c=yt(e)),o){const u=W(e,!0,s,e);l.x=u.x+e.clientLeft,l.y=u.y+e.clientTop}else i&&(l.x=Me(i));const a=r.left+c.scrollLeft-l.x,f=r.top+c.scrollTop-l.y;return{x:a,y:f,width:r.width,height:r.height}}function bt(t){return E(t).position==="static"}function qt(t,e){return!O(t)||E(t).position==="fixed"?null:e?e(t):t.offsetParent}function Fe(t,e){const n=R(t);if(wt(t))return n;if(!O(t)){let i=M(t);for(;i&&!j(i);){if(_(i)&&!bt(i))return i;i=M(i)}return n}let o=qt(t,e);for(;o&&Kn(o)&&bt(o);)o=qt(o,e);return o&&j(o)&&bt(o)&&!Ot(o)?n:o||Gn(t)||n}const ao=async function(t){const e=this.getOffsetParent||Fe,n=this.getDimensions,o=await n(t.floating);return{reference:lo(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function uo(t){return E(t).direction==="rtl"}const fo={convertOffsetParentRelativeRectToViewportRelativeRect:to,getDocumentElement:D,getClippingRect:ro,getOffsetParent:Fe,getElementRects:ao,getClientRects:eo,getDimensions:co,getScale:I,isElement:_,isRTL:uo};function ho(t,e){let n=null,o;const i=D(t);function s(){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),s();const{left:a,top:f,width:u,height:m}=t.getBoundingClientRect();if(c||e(),!u||!m)return;const h=at(f),g=at(i.clientWidth-(a+u)),w=at(i.clientHeight-(f+m)),y=at(a),v={rootMargin:-h+"px "+-g+"px "+-w+"px "+-y+"px",threshold:$(0,ft(1,l))||1};let x=!0;function L(A){const H=A[0].intersectionRatio;if(H!==l){if(!x)return r();H?r(!1,H):o=setTimeout(()=>{r(!1,1e-7)},1e3)}x=!1}try{n=new IntersectionObserver(L,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(L,v)}n.observe(t)}return r(!0),s}function po(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:r=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,a=Dt(t),f=i||s?[...a?et(a):[],...et(e)]:[];f.forEach(p=>{i&&p.addEventListener("scroll",n,{passive:!0}),s&&p.addEventListener("resize",n)});const u=a&&c?ho(a,n):null;let m=-1,h=null;r&&(h=new ResizeObserver(p=>{let[v]=p;v&&v.target===a&&h&&(h.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(e)})),n()}),a&&!l&&h.observe(a),h.observe(e));let g,w=l?W(t):null;l&&y();function y(){const p=W(t);w&&(p.x!==w.x||p.y!==w.y||p.width!==w.width||p.height!==w.height)&&n(),w=p,g=requestAnimationFrame(y)}return n(),()=>{var p;f.forEach(v=>{i&&v.removeEventListener("scroll",n),s&&v.removeEventListener("resize",n)}),u==null||u(),(p=h)==null||p.disconnect(),h=null,l&&cancelAnimationFrame(g)}}const mo=Yn,go=Jn,Xt=qn,wo=(t,e,n)=>{const o=new Map,i={platform:fo,...n},s={...i.platform,_c:o};return jn(t,e,{...i,platform:s})};function yo({content:t,open:e,placement:n,offset:{mainAxis:o,crossAxis:i}={mainAxis:0,crossAxis:0}}){return s=>{const r=s.element,c=S.wrap(e);return B.bool(c,{true:()=>ge("body",ie.div(me(l=>{const a=l;return a.style.position="absolute",po(r,a,()=>{wo(r,a,{placement:n,strategy:"absolute",middleware:[Xt(),mo({mainAxis:o,crossAxis:i}),go(),Xt()]}).then(({x:f,y:u})=>{a.style.top=`${u}px`,a.style.left=`${f}px`})})}),t())),false:()=>null})(s)}}function $e(t,e){if(typeof e=="function")return $e(t,{success:e});const n=e.failure??(i=>X(it(i.on(console.error)),i.map(s=>`Error: ${s}`))),o=e.success;return B.type(S.wrap(t),{Success:i=>o(i.$.value),Failure:i=>n(i.$.error)})}function vo(){return de.focus(t=>{var e;return(e=t.target)==null?void 0:e.select()})}const xo=t=>e=>{const n=e.element,o=P({width:n.clientWidth,height:n.clientHeight}),i=b(t(o))(e),s=()=>{o.set({width:n.clientWidth,height:n.clientHeight})};let r;return typeof ResizeObserver=="function"&&(r=new ResizeObserver(s),r.observe(n)),c=>{r==null||r.disconnect(),i(c)}},bo=t=>e=>{const n=P({width:(window==null?void 0:window.innerWidth)??0,height:(window==null?void 0:window.innerHeight)??0}),o=b(t(n))(e),i=()=>{n.set({width:(window==null?void 0:window.innerWidth)??0,height:(window==null?void 0:window.innerHeight)??0})};return window==null||window.addEventListener("resize",i),s=>{window==null||window.removeEventListener("resize",i),o(s)}},Ao={element:xo,window:bo};function Ve(t,e){const n=e.split("/").filter(i=>i!==""),o={};for(let i=0;i<t.length;i++){const s=t[i],r=n[i];if(!r&&s.type!=="catch-all")return null;if(s.type==="literal"){if(s.value!==r)return null}else if(s.type==="param")o[s.name]=r;else if(s.type==="catch-all")return{params:o,path:e}}return n.length!==t.length?null:{params:o,path:e}}function We(t){return 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!=="")}function He(t){const e=t.map(n=>{const o=We(n);return{route:n,segments:o}});return function(o){for(const{segments:i,route:s}of e){const r=Ve(i,o);if(r)return{...r,route:s}}return null}}function So(t){const e=He(Object.keys(t));return Et(n=>{const o=n.map(i=>{const s=e(i.pathname);if(s==null)throw console.error("No route found for",i),new Error("No route found");return{params:s.params,route:s.route,path:s.path,search:i.search,hash:i.hash}});return B.tuple(o.map(i=>[i.route,i]),t)})}exports.Anchor=_n;exports.AsyncResultView=Le;exports.AutoFocus=Dn;exports.AutoSelect=Tn;exports.HTMLTitle=Cn;exports.HiddenWhenEmpty=kn;exports.InViewport=Re;exports.LocationProviderMarker=Rt;exports.PopOver=yo;exports.ProvideAppearance=On;exports.ProvideLocation=En;exports.ResultView=$e;exports.Router=So;exports.SelectOnFocus=vo;exports.UseAppearance=Pn;exports.UseLocation=Et;exports.WhenInViewport=Fn;exports.appearanceMarker=_t;exports.equalsLocation=xe;exports.getFullURL=Rn;exports.locationFromURL=be;exports.makeLocation=ve;exports.makeLocationProp=Se;exports.makeRouteMatcher=He;exports.matchesRoute=Ve;exports.parseRouteSegments=We;exports.setLocationFromUrl=Ae;exports.size=Ao;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './renderables/anchor';
|
|
2
|
+
export * from './renderables/appearance';
|
|
3
|
+
export * from './renderables/async-result-view';
|
|
4
|
+
export * from './renderables/autofocus';
|
|
5
|
+
export * from './renderables/autoselect';
|
|
6
|
+
export * from './renderables/hidden-when-empty';
|
|
7
|
+
export * from './renderables/html-title';
|
|
8
|
+
export * from './renderables/inviewport';
|
|
9
|
+
export * from './renderables/pop-over';
|
|
10
|
+
export * from './renderables/result-view';
|
|
11
|
+
export * from './renderables/select-on-focus';
|
|
12
|
+
export * from './renderables/size';
|
|
13
|
+
export * from './renderables/router/location';
|
|
14
|
+
export * from './renderables/router/match';
|
|
15
|
+
export * from './renderables/router/route-info';
|
|
16
|
+
export * from './renderables/router/router';
|