@tempots/ui 0.15.2 → 0.16.1
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/dom/animatable.d.ts +79 -0
- package/dom/handle-anchor-click.d.ts +50 -0
- package/index.cjs +1 -1
- package/index.d.ts +1 -0
- package/index.js +319 -271
- package/package.json +2 -2
- package/renderables/anchor.d.ts +26 -3
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export type AnimatableProps = {
|
|
2
|
+
width?: number;
|
|
3
|
+
maxWidth?: number;
|
|
4
|
+
minWidth?: number;
|
|
5
|
+
height?: number;
|
|
6
|
+
maxHeight?: number;
|
|
7
|
+
minHeight?: number;
|
|
8
|
+
lineHeight?: number;
|
|
9
|
+
opacity?: number;
|
|
10
|
+
top?: number;
|
|
11
|
+
left?: number;
|
|
12
|
+
right?: number;
|
|
13
|
+
bottom?: number;
|
|
14
|
+
padding?: number;
|
|
15
|
+
paddingTop?: number;
|
|
16
|
+
paddingBottom?: number;
|
|
17
|
+
paddingLeft?: number;
|
|
18
|
+
paddingRight?: number;
|
|
19
|
+
margin?: number;
|
|
20
|
+
marginTop?: number;
|
|
21
|
+
marginBottom?: number;
|
|
22
|
+
marginLeft?: number;
|
|
23
|
+
marginRight?: number;
|
|
24
|
+
fontSize?: number;
|
|
25
|
+
letterSpacing?: number;
|
|
26
|
+
color?: string;
|
|
27
|
+
backgroundColor?: string;
|
|
28
|
+
borderColor?: string;
|
|
29
|
+
borderWidth?: number;
|
|
30
|
+
borderRadius?: number;
|
|
31
|
+
boxShadow?: string;
|
|
32
|
+
textShadow?: string;
|
|
33
|
+
outlineWidth?: number;
|
|
34
|
+
outlineColor?: string;
|
|
35
|
+
translateX?: number;
|
|
36
|
+
translateY?: number;
|
|
37
|
+
translateZ?: number;
|
|
38
|
+
rotateX?: number;
|
|
39
|
+
rotateY?: number;
|
|
40
|
+
rotateZ?: number;
|
|
41
|
+
scaleX?: number;
|
|
42
|
+
scaleY?: number;
|
|
43
|
+
scaleZ?: number;
|
|
44
|
+
skewX?: number;
|
|
45
|
+
skewY?: number;
|
|
46
|
+
grayScale?: number;
|
|
47
|
+
sepia?: number;
|
|
48
|
+
saturate?: number;
|
|
49
|
+
hueRotate?: number;
|
|
50
|
+
invert?: number;
|
|
51
|
+
brightness?: number;
|
|
52
|
+
contrast?: number;
|
|
53
|
+
blur?: number;
|
|
54
|
+
};
|
|
55
|
+
export type ColorChannels = [
|
|
56
|
+
number,
|
|
57
|
+
number,
|
|
58
|
+
number,
|
|
59
|
+
number,
|
|
60
|
+
'rgba' | 'hex' | 'hsla'
|
|
61
|
+
];
|
|
62
|
+
export declare const parseColorChannels: (color: string) => ColorChannels;
|
|
63
|
+
export interface BoxShadow {
|
|
64
|
+
inset: boolean;
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
blur: number;
|
|
68
|
+
spread: number;
|
|
69
|
+
color: string;
|
|
70
|
+
}
|
|
71
|
+
export declare const colorChannelsToString: (channels: ColorChannels) => string;
|
|
72
|
+
export declare const interpolateColor: (startColor: string, endColor: string) => ((t: number) => string);
|
|
73
|
+
export declare const interpolateShadow: (startShadow: string, endShadow: string) => ((t: number) => string);
|
|
74
|
+
export declare const getComputedAnimatableProp: (styles: CSSStyleDeclaration, key: keyof AnimatableProps) => AnimatableProps[typeof key];
|
|
75
|
+
export declare const getComputedAnimatable: (el: HTMLElement, styles: AnimatableProps) => AnimatableProps;
|
|
76
|
+
export declare const applyAnimatableProp: (el: HTMLElement, key: keyof AnimatableProps, value: AnimatableProps[typeof key]) => void;
|
|
77
|
+
export declare const applyInterpolatedAnimatableProp: (el: HTMLElement, key: keyof AnimatableProps, from: AnimatableProps[typeof key], to: AnimatableProps[typeof key], progress: number) => void;
|
|
78
|
+
export declare const applyInterpolatedAnimatable: (el: HTMLElement, from: AnimatableProps, to: AnimatableProps, progress: number) => void;
|
|
79
|
+
export declare const applyAnimatable: (el: HTMLElement, styles: AnimatableProps) => void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Merge } from '@tempots/std';
|
|
2
|
+
/**
|
|
3
|
+
* Get the extension of a pathname. If the pathname has no extension, return undefined.
|
|
4
|
+
* The path should not have query parameters or fragments.
|
|
5
|
+
*
|
|
6
|
+
* @param pathname - The pathname to get the extension from.
|
|
7
|
+
* @returns The extension of the pathname or undefined if there is no extension.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const _getExtension: (pathname: string) => string | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
export declare const _checkExtensionCondition: (allowedExtensions: string[], pathname: string) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Options for handling anchor click events.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export type HandleAnchorClickOptions = Merge<{
|
|
20
|
+
/**
|
|
21
|
+
* A boolean indicating whether to check the anchor's href for a file extension.
|
|
22
|
+
* If `true`, the click handler will be applied only if the anchor's href doesn't have a file extension or if the anchor's href has a file extension that is in the `allowedExtensions` array.
|
|
23
|
+
*/
|
|
24
|
+
ignoreUrlWithExtension?: true;
|
|
25
|
+
/**
|
|
26
|
+
* An array of allowed extensions to check for. If the anchor's href has a file extension that is not in the `allowedExtensions` array, the click handler will not be applied.
|
|
27
|
+
* If the `allowedExtensions` array is empty, the click handler will only be applied if the anchor's href doesn't have a file extension.
|
|
28
|
+
*/
|
|
29
|
+
allowedExtensions?: string[];
|
|
30
|
+
} | {
|
|
31
|
+
/**
|
|
32
|
+
* A boolean indicating whether to check the anchor's href for a file extension.
|
|
33
|
+
* If `true`, the click handler will be applied only if the anchor's href doesn't have a file extension or if the anchor's href has a file extension that is in the `allowedExtensions` array.
|
|
34
|
+
*/
|
|
35
|
+
ignoreUrlWithExtension: false;
|
|
36
|
+
}, {
|
|
37
|
+
/**
|
|
38
|
+
* A boolean indicating whether to check if the anchor's href points to an external URL.
|
|
39
|
+
*/
|
|
40
|
+
ignoreExternalUrl?: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Handles anchor click events, optionally checking for external URLs and file extensions.
|
|
44
|
+
*
|
|
45
|
+
* @param callback - A function that is called when the anchor click should be handled. The function should return a boolean indicating whether the default anchor click behavior should be prevented.
|
|
46
|
+
* @param options - An optional object of type `HandleAnchorClickOptions`.
|
|
47
|
+
* @returns A function that handles the anchor click event, calling the provided callback and preventing the default behavior if the callback returns `true`.
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
export declare const handleAnchorClick: (callback: () => boolean, options?: HandleAnchorClickOptions) => (e: MouseEvent) => void;
|
package/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@tempots/dom"),ct=u.makeProviderMark("LocationProvider"),At=()=>{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}},Rt=(t,e)=>t.pathname===e.pathname&&JSON.stringify(t.search)===JSON.stringify(e.search)&&t.hash===e.hash,Lt=t=>{const e=new URL(t,(window==null?void 0:window.location.toString())??""),o=Object.fromEntries(e.searchParams.entries());let n=e.hash;return n.startsWith("#")&&(n=n.substring(1)),{pathname:e.pathname,search:o,hash:n===""?void 0:n}},Et=(t,e)=>{const o=Lt(e);return t.set(o),t},St=t=>{const o=new URLSearchParams(t.search).toString(),n=t.hash;return`${t.pathname}${o?`?${o}`:""}${n?`#${n}`:""}`},Tt=()=>{const t=u.makeProp(At(),Rt),e=()=>{let o=(window==null?void 0:window.location.hash)??"";o.startsWith("#")&&(o=o.substring(1));const n={pathname:(window==null?void 0:window.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((window==null?void 0:window.location.search)??"").entries()),hash:o===""?void 0:o};t.set(n)};return window==null||window.addEventListener("popstate",e),t.onDispose(()=>{window==null||window.removeEventListener("popstate",e)}),t.on(o=>{window==null||window.history.pushState({},"",St(o))}),t},Yt=t=>{const e=Tt();return u.Fragment(u.OnUnmount(e.dispose),u.WithProvider(ct,e,t))},lt=t=>u.UseProvider(ct,e=>o=>{const n=u.makeProp(e.value,e.equals);e.feedProp(n),n.on(e.set);const i=u.renderableOfTNode(t(n))(o);return r=>{n.dispose(),i(r)}}),Jt=(t,...e)=>lt(o=>u.html.a(u.on.click(u.handleAnchorClick(()=>(Et(o,u.Signal.unwrap(t)),!0))),u.attr.href(t),...e)),at=u.makeProviderMark("Appearance"),Kt=t=>{const e=window.matchMedia!=null&&window.matchMedia("(prefers-color-scheme: dark)").matches,o=u.makeProp(e?"dark":"light"),n=r=>{o.set(r.matches?"dark":"light")},i=window.matchMedia!=null?window.matchMedia("(prefers-color-scheme: dark)"):void 0;return i==null||i.addEventListener("change",n),u.Fragment(u.WithProvider(at,o,t),u.OnUnmount(()=>i==null?void 0:i.removeEventListener("change",n)))},Gt=t=>u.UseProvider(at,t),kt=(t,e)=>{if(typeof e=="function")return kt(t,{success:e});const o=e.failure??(s=>u.Fragment(u.OnUnmount(s.on(console.error)),s.map(c=>`Error: ${c}`))),n=e.success,i=e.loading??(()=>u.Empty),r=e.notAsked??(()=>u.Empty);return u.OneOfType(u.Signal.wrap(t),{AsyncSuccess:s=>n(s.$.value),AsyncFailure:s=>o(s.$.error),Loading:s=>i(s.$.previousValue??u.makeSignal(void 0)),NotAsked:r})},Qt=(t=10)=>e=>{const o=setTimeout(()=>{var n;(n=e.element)==null||n.focus()},t);return n=>clearTimeout(o)},Zt=(t=10)=>e=>{const o=setTimeout(()=>{var n;(n=e.element)==null||n.select()},t);return n=>{clearTimeout(o)}},te=t=>{const e=t.element,o=e.style.getPropertyValue(":empty");return e.style.setProperty(":empty","display:none"),n=>{n&&e.style.setProperty(":empty",o)}},ee=t=>u.Portal("head > title",u.attr.innerText(t)),ne={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},J={partial:new Map,full:new Map},I={partial:null,full:null};function oe(t){return I[t]==null&&(I[t]=new IntersectionObserver(e=>{e.forEach(o=>{const n=J[t].get(o.target);n==null||n.set(o.isIntersecting)})},ne[t])),I[t]}const Pt=(t,e)=>{const o=u.makeProp(u.isSSR());return u.Fragment(u.OnMount(n=>{const i=typeof IntersectionObserver<"u"?oe(t):null;return J[t].set(n,o),i==null||i.observe(n),()=>{var r;i==null||i.unobserve(n),J[t].delete(n),J[t].size===0&&((r=I[t])==null||r.disconnect(),I[t]=null)}}),u.OnUnmount(o.dispose),u.renderableOfTNode(e(o)))},ie=(t,e,o)=>Pt(t,n=>u.When(n,e,o??u.Empty)),K=Math.min,M=Math.max,G=Math.round,Y=Math.floor,P=t=>({x:t,y:t}),re={left:"right",right:"left",bottom:"top",top:"bottom"},se={start:"end",end:"start"};function wt(t,e,o){return M(t,K(e,o))}function tt(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function et(t){return t.split("-")[1]}function Ct(t){return t==="x"?"y":"x"}function Ft(t){return t==="y"?"height":"width"}function z(t){return["top","bottom"].includes(W(t))?"y":"x"}function Mt(t){return Ct(z(t))}function ce(t,e,o){o===void 0&&(o=!1);const n=et(t),i=Mt(t),r=Ft(i);let s=i==="x"?n===(o?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=Q(s)),[s,Q(s)]}function le(t){const e=Q(t);return[st(t),e,st(e)]}function st(t){return t.replace(/start|end/g,e=>se[e])}function ae(t,e,o){const n=["left","right"],i=["right","left"],r=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return o?e?i:n:e?n:i;case"left":case"right":return e?r:s;default:return[]}}function ue(t,e,o,n){const i=et(t);let r=ae(W(t),o==="start",n);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(st)))),r}function Q(t){return t.replace(/left|right|bottom|top/g,e=>re[e])}function fe(t){return{top:0,right:0,bottom:0,left:0,...t}}function de(t){return typeof t!="number"?fe(t):{top:t,right:t,bottom:t,left:t}}function Z(t){const{x:e,y:o,width:n,height:i}=t;return{width:n,height:i,top:o,left:e,right:e+n,bottom:o+i,x:e,y:o}}function yt(t,e,o){let{reference:n,floating:i}=t;const r=z(e),s=Mt(e),c=Ft(s),a=W(e),l=r==="y",d=n.x+n.width/2-i.width/2,f=n.y+n.height/2-i.height/2,p=n[c]/2-i[c]/2;let h;switch(a){case"top":h={x:d,y:n.y-i.height};break;case"bottom":h={x:d,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:f};break;case"left":h={x:n.x-i.width,y:f};break;default:h={x:n.x,y:n.y}}switch(et(e)){case"start":h[s]-=p*(o&&l?-1:1);break;case"end":h[s]+=p*(o&&l?-1:1);break}return h}const he=async(t,e,o)=>{const{placement:n="bottom",strategy:i="absolute",middleware:r=[],platform:s}=o,c=r.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(e));let l=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:d,y:f}=yt(l,n,a),p=n,h={},g=0;for(let w=0;w<c.length;w++){const{name:y,fn:m}=c[w],{x:v,y:x,data:O,reset:b}=await m({x:d,y:f,initialPlacement:n,placement:p,strategy:i,middlewareData:h,rects:l,platform:s,elements:{reference:t,floating:e}});d=v??d,f=x??f,h={...h,[y]:{...h[y],...O}},b&&g<=50&&(g++,typeof b=="object"&&(b.placement&&(p=b.placement),b.rects&&(l=b.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:i}):b.rects),{x:d,y:f}=yt(l,p,a)),w=-1)}return{x:d,y:f,placement:p,strategy:i,middlewareData:h}};async function Wt(t,e){var o;e===void 0&&(e={});const{x:n,y:i,platform:r,rects:s,elements:c,strategy:a}=t,{boundary:l="clippingAncestors",rootBoundary:d="viewport",elementContext:f="floating",altBoundary:p=!1,padding:h=0}=tt(e,t),g=de(h),y=c[p?f==="floating"?"reference":"floating":f],m=Z(await r.getClippingRect({element:(o=await(r.isElement==null?void 0:r.isElement(y)))==null||o?y:y.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:l,rootBoundary:d,strategy:a})),v=f==="floating"?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,x=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),O=await(r.isElement==null?void 0:r.isElement(x))?await(r.getScale==null?void 0:r.getScale(x))||{x:1,y:1}:{x:1,y:1},b=Z(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:x,strategy:a}):v);return{top:(m.top-b.top+g.top)/O.y,bottom:(b.bottom-m.bottom+g.bottom)/O.y,left:(m.left-b.left+g.left)/O.x,right:(b.right-m.right+g.right)/O.x}}const me=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var o,n;const{placement:i,middlewareData:r,rects:s,initialPlacement:c,platform:a,elements:l}=e,{mainAxis:d=!0,crossAxis:f=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:w=!0,...y}=tt(t,e);if((o=r.arrow)!=null&&o.alignmentOffset)return{};const m=W(i),v=z(c),x=W(c)===c,O=await(a.isRTL==null?void 0:a.isRTL(l.floating)),b=p||(x||!w?[Q(c)]:le(c)),N=g!=="none";!p&&N&&b.push(...ue(c,w,g,O));const qt=[c,...b],it=await Wt(e,y),X=[];let _=((n=r.flip)==null?void 0:n.overflows)||[];if(d&&X.push(it[m]),f){const F=ce(i,s,O);X.push(it[F[0]],it[F[1]])}if(_=[..._,{placement:i,overflows:X}],!X.every(F=>F<=0)){var ht,mt;const F=(((ht=r.flip)==null?void 0:ht.index)||0)+1,gt=qt[F];if(gt)return{data:{index:F,overflows:_},reset:{placement:gt}};let B=(mt=_.filter(V=>V.overflows[0]<=0).sort((V,T)=>V.overflows[1]-T.overflows[1])[0])==null?void 0:mt.placement;if(!B)switch(h){case"bestFit":{var pt;const V=(pt=_.filter(T=>{if(N){const k=z(T.placement);return k===v||k==="y"}return!0}).map(T=>[T.placement,T.overflows.filter(k=>k>0).reduce((k,Xt)=>k+Xt,0)]).sort((T,k)=>T[1]-k[1])[0])==null?void 0:pt[0];V&&(B=V);break}case"initialPlacement":B=c;break}if(i!==B)return{reset:{placement:B}}}return{}}}};async function pe(t,e){const{placement:o,platform:n,elements:i}=t,r=await(n.isRTL==null?void 0:n.isRTL(i.floating)),s=W(o),c=et(o),a=z(o)==="y",l=["left","top"].includes(s)?-1:1,d=r&&a?-1:1,f=tt(e,t);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...f};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),a?{x:h*d,y:p*l}:{x:p*l,y:h*d}}const ge=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var o,n;const{x:i,y:r,placement:s,middlewareData:c}=e,a=await pe(e,t);return s===((o=c.offset)==null?void 0:o.placement)&&(n=c.arrow)!=null&&n.alignmentOffset?{}:{x:i+a.x,y:r+a.y,data:{...a,placement:s}}}}},we=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:o,y:n,placement:i}=e,{mainAxis:r=!0,crossAxis:s=!1,limiter:c={fn:y=>{let{x:m,y:v}=y;return{x:m,y:v}}},...a}=tt(t,e),l={x:o,y:n},d=await Wt(e,a),f=z(W(i)),p=Ct(f);let h=l[p],g=l[f];if(r){const y=p==="y"?"top":"left",m=p==="y"?"bottom":"right",v=h+d[y],x=h-d[m];h=wt(v,h,x)}if(s){const y=f==="y"?"top":"left",m=f==="y"?"bottom":"right",v=g+d[y],x=g-d[m];g=wt(v,g,x)}const w=c.fn({...e,[p]:h,[f]:g});return{...w,data:{x:w.x-o,y:w.y-n}}}}};function H(t){return Dt(t)?(t.nodeName||"").toLowerCase():"#document"}function A(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function S(t){var e;return(e=(Dt(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Dt(t){return t instanceof Node||t instanceof A(t).Node}function L(t){return t instanceof Element||t instanceof A(t).Element}function E(t){return t instanceof HTMLElement||t instanceof A(t).HTMLElement}function vt(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof A(t).ShadowRoot}function q(t){const{overflow:e,overflowX:o,overflowY:n,display:i}=R(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+o)&&!["inline","contents"].includes(i)}function ye(t){return["table","td","th"].includes(H(t))}function nt(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function ut(t){const e=ft(),o=R(t);return o.transform!=="none"||o.perspective!=="none"||(o.containerType?o.containerType!=="normal":!1)||!e&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!e&&(o.filter?o.filter!=="none":!1)||["transform","perspective","filter"].some(n=>(o.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(o.contain||"").includes(n))}function ve(t){let e=C(t);for(;E(e)&&!U(e);){if(nt(e))return null;if(ut(e))return e;e=C(e)}return null}function ft(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function U(t){return["html","body","#document"].includes(H(t))}function R(t){return A(t).getComputedStyle(t)}function ot(t){return L(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function C(t){if(H(t)==="html")return t;const e=t.assignedSlot||t.parentNode||vt(t)&&t.host||S(t);return vt(e)?e.host:e}function Nt(t){const e=C(t);return U(e)?t.ownerDocument?t.ownerDocument.body:t.body:E(e)&&q(e)?e:Nt(e)}function j(t,e,o){var n;e===void 0&&(e=[]),o===void 0&&(o=!0);const i=Nt(t),r=i===((n=t.ownerDocument)==null?void 0:n.body),s=A(i);return r?e.concat(s,s.visualViewport||[],q(i)?i:[],s.frameElement&&o?j(s.frameElement):[]):e.concat(i,j(i,[],o))}function Vt(t){const e=R(t);let o=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const i=E(t),r=i?t.offsetWidth:o,s=i?t.offsetHeight:n,c=G(o)!==r||G(n)!==s;return c&&(o=r,n=s),{width:o,height:n,$:c}}function dt(t){return L(t)?t:t.contextElement}function $(t){const e=dt(t);if(!E(e))return P(1);const o=e.getBoundingClientRect(),{width:n,height:i,$:r}=Vt(e);let s=(r?G(o.width):o.width)/n,c=(r?G(o.height):o.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const xe=P(0);function $t(t){const e=A(t);return!ft()||!e.visualViewport?xe:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function be(t,e,o){return e===void 0&&(e=!1),!o||e&&o!==A(t)?!1:e}function D(t,e,o,n){e===void 0&&(e=!1),o===void 0&&(o=!1);const i=t.getBoundingClientRect(),r=dt(t);let s=P(1);e&&(n?L(n)&&(s=$(n)):s=$(t));const c=be(r,o,n)?$t(r):P(0);let a=(i.left+c.x)/s.x,l=(i.top+c.y)/s.y,d=i.width/s.x,f=i.height/s.y;if(r){const p=A(r),h=n&&L(n)?A(n):n;let g=p,w=g.frameElement;for(;w&&n&&h!==g;){const y=$(w),m=w.getBoundingClientRect(),v=R(w),x=m.left+(w.clientLeft+parseFloat(v.paddingLeft))*y.x,O=m.top+(w.clientTop+parseFloat(v.paddingTop))*y.y;a*=y.x,l*=y.y,d*=y.x,f*=y.y,a+=x,l+=O,g=A(w),w=g.frameElement}}return Z({width:d,height:f,x:a,y:l})}function Oe(t){let{elements:e,rect:o,offsetParent:n,strategy:i}=t;const r=i==="fixed",s=S(n),c=e?nt(e.floating):!1;if(n===s||c&&r)return o;let a={scrollLeft:0,scrollTop:0},l=P(1);const d=P(0),f=E(n);if((f||!f&&!r)&&((H(n)!=="body"||q(s))&&(a=ot(n)),E(n))){const p=D(n);l=$(n),d.x=p.x+n.clientLeft,d.y=p.y+n.clientTop}return{width:o.width*l.x,height:o.height*l.y,x:o.x*l.x-a.scrollLeft*l.x+d.x,y:o.y*l.y-a.scrollTop*l.y+d.y}}function Ae(t){return Array.from(t.getClientRects())}function zt(t){return D(S(t)).left+ot(t).scrollLeft}function Re(t){const e=S(t),o=ot(t),n=t.ownerDocument.body,i=M(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=M(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-o.scrollLeft+zt(t);const c=-o.scrollTop;return R(n).direction==="rtl"&&(s+=M(e.clientWidth,n.clientWidth)-i),{width:i,height:r,x:s,y:c}}function Le(t,e){const o=A(t),n=S(t),i=o.visualViewport;let r=n.clientWidth,s=n.clientHeight,c=0,a=0;if(i){r=i.width,s=i.height;const l=ft();(!l||l&&e==="fixed")&&(c=i.offsetLeft,a=i.offsetTop)}return{width:r,height:s,x:c,y:a}}function Ee(t,e){const o=D(t,!0,e==="fixed"),n=o.top+t.clientTop,i=o.left+t.clientLeft,r=E(t)?$(t):P(1),s=t.clientWidth*r.x,c=t.clientHeight*r.y,a=i*r.x,l=n*r.y;return{width:s,height:c,x:a,y:l}}function xt(t,e,o){let n;if(e==="viewport")n=Le(t,o);else if(e==="document")n=Re(S(t));else if(L(e))n=Ee(e,o);else{const i=$t(t);n={...e,x:e.x-i.x,y:e.y-i.y}}return Z(n)}function Ut(t,e){const o=C(t);return o===e||!L(o)||U(o)?!1:R(o).position==="fixed"||Ut(o,e)}function Se(t,e){const o=e.get(t);if(o)return o;let n=j(t,[],!1).filter(c=>L(c)&&H(c)!=="body"),i=null;const r=R(t).position==="fixed";let s=r?C(t):t;for(;L(s)&&!U(s);){const c=R(s),a=ut(s);!a&&c.position==="fixed"&&(i=null),(r?!a&&!i:!a&&c.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||q(s)&&!a&&Ut(t,s))?n=n.filter(d=>d!==s):i=c,s=C(s)}return e.set(t,n),n}function Te(t){let{element:e,boundary:o,rootBoundary:n,strategy:i}=t;const s=[...o==="clippingAncestors"?nt(e)?[]:Se(e,this._c):[].concat(o),n],c=s[0],a=s.reduce((l,d)=>{const f=xt(e,d,i);return l.top=M(f.top,l.top),l.right=K(f.right,l.right),l.bottom=K(f.bottom,l.bottom),l.left=M(f.left,l.left),l},xt(e,c,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function ke(t){const{width:e,height:o}=Vt(t);return{width:e,height:o}}function Pe(t,e,o){const n=E(e),i=S(e),r=o==="fixed",s=D(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const a=P(0);if(n||!n&&!r)if((H(e)!=="body"||q(i))&&(c=ot(e)),n){const f=D(e,!0,r,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else i&&(a.x=zt(i));const l=s.left+c.scrollLeft-a.x,d=s.top+c.scrollTop-a.y;return{x:l,y:d,width:s.width,height:s.height}}function rt(t){return R(t).position==="static"}function bt(t,e){return!E(t)||R(t).position==="fixed"?null:e?e(t):t.offsetParent}function Ht(t,e){const o=A(t);if(nt(t))return o;if(!E(t)){let i=C(t);for(;i&&!U(i);){if(L(i)&&!rt(i))return i;i=C(i)}return o}let n=bt(t,e);for(;n&&ye(n)&&rt(n);)n=bt(n,e);return n&&U(n)&&rt(n)&&!ut(n)?o:n||ve(t)||o}const Ce=async function(t){const e=this.getOffsetParent||Ht,o=this.getDimensions,n=await o(t.floating);return{reference:Pe(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Fe(t){return R(t).direction==="rtl"}const Me={convertOffsetParentRelativeRectToViewportRelativeRect:Oe,getDocumentElement:S,getClippingRect:Te,getOffsetParent:Ht,getElementRects:Ce,getClientRects:Ae,getDimensions:ke,getScale:$,isElement:L,isRTL:Fe};function We(t,e){let o=null,n;const i=S(t);function r(){var c;clearTimeout(n),(c=o)==null||c.disconnect(),o=null}function s(c,a){c===void 0&&(c=!1),a===void 0&&(a=1),r();const{left:l,top:d,width:f,height:p}=t.getBoundingClientRect();if(c||e(),!f||!p)return;const h=Y(d),g=Y(i.clientWidth-(l+f)),w=Y(i.clientHeight-(d+p)),y=Y(l),v={rootMargin:-h+"px "+-g+"px "+-w+"px "+-y+"px",threshold:M(0,K(1,a))||1};let x=!0;function O(b){const N=b[0].intersectionRatio;if(N!==a){if(!x)return s();N?s(!1,N):n=setTimeout(()=>{s(!1,1e-7)},1e3)}x=!1}try{o=new IntersectionObserver(O,{...v,root:i.ownerDocument})}catch{o=new IntersectionObserver(O,v)}o.observe(t)}return s(!0),r}function De(t,e,o,n){n===void 0&&(n={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:a=!1}=n,l=dt(t),d=i||r?[...l?j(l):[],...j(e)]:[];d.forEach(m=>{i&&m.addEventListener("scroll",o,{passive:!0}),r&&m.addEventListener("resize",o)});const f=l&&c?We(l,o):null;let p=-1,h=null;s&&(h=new ResizeObserver(m=>{let[v]=m;v&&v.target===l&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(e)})),o()}),l&&!a&&h.observe(l),h.observe(e));let g,w=a?D(t):null;a&&y();function y(){const m=D(t);w&&(m.x!==w.x||m.y!==w.y||m.width!==w.width||m.height!==w.height)&&o(),w=m,g=requestAnimationFrame(y)}return o(),()=>{var m;d.forEach(v=>{i&&v.removeEventListener("scroll",o),r&&v.removeEventListener("resize",o)}),f==null||f(),(m=h)==null||m.disconnect(),h=null,a&&cancelAnimationFrame(g)}}const Ne=ge,Ve=we,Ot=me,$e=(t,e,o)=>{const n=new Map,i={platform:Me,...o},r={...i.platform,_c:n};return he(t,e,{...i,platform:r})},ze=({content:t,open:e,placement:o,offset:{mainAxis:n,crossAxis:i}={mainAxis:0,crossAxis:0}})=>r=>{const s=r.element,c=u.Signal.wrap(e);return u.When(c,u.Portal("body",u.html.div(u.OnMount(a=>{const l=a;return l.style.position="absolute",De(s,l,()=>{$e(s,l,{placement:o,strategy:"absolute",middleware:[Ot(),Ne({mainAxis:n,crossAxis:i}),Ve(),Ot()]}).then(({x:d,y:f})=>{l.style.top=`${f}px`,l.style.left=`${d}px`})})}),t())))(r)},_t=(t,e)=>{if(typeof e=="function")return _t(t,{success:e});const o=e.failure??(i=>u.Fragment(u.OnUnmount(i.on(console.error)),i.map(r=>`Error: ${r}`))),n=e.success;return u.OneOfType(u.Signal.wrap(t),{Success:i=>n(i.$.value),Failure:i=>o(i.$.error)})},Ue=()=>u.on.focus(t=>{var e;return(e=t.target)==null?void 0:e.select()}),He=t=>e=>{const o=e.element,n=u.makeProp({width:o.clientWidth,height:o.clientHeight}),i=u.renderableOfTNode(t(n))(e),r=()=>{n.set({width:o.clientWidth,height:o.clientHeight})};let s;return typeof ResizeObserver=="function"&&(s=new ResizeObserver(r),s.observe(o)),c=>{s==null||s.disconnect(),i(c)}},_e=t=>e=>{const o=u.makeProp({width:(window==null?void 0:window.innerWidth)??0,height:(window==null?void 0:window.innerHeight)??0}),n=u.renderableOfTNode(t(o))(e),i=()=>{o.set({width:(window==null?void 0:window.innerWidth)??0,height:(window==null?void 0:window.innerHeight)??0})};return window==null||window.addEventListener("resize",i),r=>{window==null||window.removeEventListener("resize",i),n(r)}},Bt=(t,e)=>{const o=e.split("/").filter(i=>i!==""),n={};for(let i=0;i<t.length;i++){const r=t[i],s=o[i];if(!s&&r.type!=="catch-all")return null;if(r.type==="literal"){if(r.value!==s)return null}else if(r.type==="param")n[r.name]=s;else if(r.type==="catch-all")return{params:n,path:e}}return o.length!==t.length?null:{params:n,path:e}},It=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!==""),jt=t=>{const e=t.map(o=>{const n=It(o);return{route:o,segments:n}});return function(n){for(const{segments:i,route:r}of e){const s=Bt(i,n);if(s)return{...s,route:r}}return null}},Be=t=>{const e=jt(Object.keys(t));return lt(o=>{const n=o.map(i=>{const r=e(i.pathname);if(r==null)throw console.error("No route found for",i),new Error("No route found");return{params:r.params,route:r.route,path:r.path,search:i.search,hash:i.hash}});return u.OneOfTuple(n.map(i=>[i.route,i]),t)})};exports.Anchor=Jt;exports.AsyncResultView=kt;exports.AutoFocus=Qt;exports.AutoSelect=Zt;exports.ElementSize=He;exports.HTMLTitle=ee;exports.HiddenWhenEmpty=te;exports.InViewport=Pt;exports.LocationProviderMarker=ct;exports.PopOver=ze;exports.ProvideAppearance=Kt;exports.ProvideLocation=Yt;exports.ResultView=_t;exports.Router=Be;exports.SelectOnFocus=Ue;exports.UseAppearance=Gt;exports.UseLocation=lt;exports.WhenInViewport=ie;exports.WindowSize=_e;exports._makeLocation=At;exports._makeLocationProp=Tt;exports._makeRouteMatcher=jt;exports._parseRouteSegments=It;exports.appearanceMarker=at;exports.areLocationsEqual=Rt;exports.locationFromURL=Lt;exports.matchesRoute=Bt;exports.setLocationFromUrl=Et;exports.urlFromLocation=St;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@tempots/dom"),Et=t=>{const e=t.split("/").pop();if(e==null||e.startsWith("."))return;const o=e.split(".")||[];return o.length>1?"."+o.pop():void 0},Rt=(t,e)=>{const o=Et(e);return o!=null&&(t.length===0||!t.some(n=>o==n))},Qt=(t,e,o,n)=>{let i=t.target;for(;i!=null&&!(i instanceof HTMLAnchorElement);)i=i.parentElement;if(i==null)return!0;const r=i;if(t.button!==0||t.ctrlKey||t.metaKey||r.target!=="_self"&&r.target!==""||r.getAttribute("download")!=null)return!0;const{pathname:s,search:c,hash:a}=r;if(n){const l=s+c+a,f=r.getAttribute("href");if(!(f!=null&&f.startsWith("#"))&&f!==l)return!0}return e?!1:Rt(o,s)},Ot=(t,e={ignoreUrlWithExtension:!0,allowedExtensions:[],ignoreExternalUrl:!0})=>{const o=e.ignoreUrlWithExtension===!0&&Array.isArray(e.allowedExtensions)?e.allowedExtensions.map(n=>n.startsWith(".")?n:"."+n):[];return n=>{Qt(n,e.ignoreUrlWithExtension??!0,o,e.ignoreExternalUrl??!0)||t()&&n.preventDefault()}},ct=u.makeProviderMark("LocationProvider"),Lt=()=>{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}},St=(t,e)=>t.pathname===e.pathname&&JSON.stringify(t.search)===JSON.stringify(e.search)&&t.hash===e.hash,kt=t=>{const e=new URL(t,(window==null?void 0:window.location.toString())??""),o=Object.fromEntries(e.searchParams.entries());let n=e.hash;return n.startsWith("#")&&(n=n.substring(1)),{pathname:e.pathname,search:o,hash:n===""?void 0:n}},Tt=(t,e)=>{const o=kt(e);return t.set(o),t},Pt=t=>{const o=new URLSearchParams(t.search).toString(),n=t.hash;return`${t.pathname}${o?`?${o}`:""}${n?`#${n}`:""}`},Ct=()=>{const t=u.makeProp(Lt(),St),e=()=>{let o=(window==null?void 0:window.location.hash)??"";o.startsWith("#")&&(o=o.substring(1));const n={pathname:(window==null?void 0:window.location.pathname)??"",search:Object.fromEntries(new URLSearchParams((window==null?void 0:window.location.search)??"").entries()),hash:o===""?void 0:o};t.set(n)};return window==null||window.addEventListener("popstate",e),t.onDispose(()=>{window==null||window.removeEventListener("popstate",e)}),t.on(o=>{window==null||window.history.pushState({},"",Pt(o))}),t},Zt=t=>{const e=Ct();return u.Fragment(u.OnUnmount(e.dispose),u.WithProvider(ct,e,t))},lt=t=>u.UseProvider(ct,e=>o=>{const n=u.makeProp(e.value,e.equals);e.feedProp(n),n.on(e.set);const i=u.renderableOfTNode(t(n))(o);return r=>{n.dispose(),i(r)}}),Ft=(t,...e)=>{if(typeof t=="string"||u.Signal.is(t))return Ft({href:t},...e);const{href:o,...n}=t;return lt(i=>u.html.a(u.on.click(Ot(()=>(Tt(i,u.Signal.unwrap(o)),!0),n)),u.attr.href(o),...e))},at=u.makeProviderMark("Appearance"),te=t=>{const e=window.matchMedia!=null&&window.matchMedia("(prefers-color-scheme: dark)").matches,o=u.makeProp(e?"dark":"light"),n=r=>{o.set(r.matches?"dark":"light")},i=window.matchMedia!=null?window.matchMedia("(prefers-color-scheme: dark)"):void 0;return i==null||i.addEventListener("change",n),u.Fragment(u.WithProvider(at,o,t),u.OnUnmount(()=>i==null?void 0:i.removeEventListener("change",n)))},ee=t=>u.UseProvider(at,t),Mt=(t,e)=>{if(typeof e=="function")return Mt(t,{success:e});const o=e.failure??(s=>u.Fragment(u.OnUnmount(s.on(console.error)),s.map(c=>`Error: ${c}`))),n=e.success,i=e.loading??(()=>u.Empty),r=e.notAsked??(()=>u.Empty);return u.OneOfType(u.Signal.wrap(t),{AsyncSuccess:s=>n(s.$.value),AsyncFailure:s=>o(s.$.error),Loading:s=>i(s.$.previousValue??u.makeSignal(void 0)),NotAsked:r})},ne=(t=10)=>e=>{const o=setTimeout(()=>{var n;(n=e.element)==null||n.focus()},t);return n=>clearTimeout(o)},oe=(t=10)=>e=>{const o=setTimeout(()=>{var n;(n=e.element)==null||n.select()},t);return n=>{clearTimeout(o)}},ie=t=>{const e=t.element,o=e.style.getPropertyValue(":empty");return e.style.setProperty(":empty","display:none"),n=>{n&&e.style.setProperty(":empty",o)}},re=t=>u.Portal("head > title",u.attr.innerText(t)),se={partial:{root:null,rootMargin:"0px",threshold:0},full:{root:null,rootMargin:"0px",threshold:1}},K={partial:new Map,full:new Map},I={partial:null,full:null};function ce(t){return I[t]==null&&(I[t]=new IntersectionObserver(e=>{e.forEach(o=>{const n=K[t].get(o.target);n==null||n.set(o.isIntersecting)})},se[t])),I[t]}const Wt=(t,e)=>{const o=u.makeProp(u.isSSR());return u.Fragment(u.OnMount(n=>{const i=typeof IntersectionObserver<"u"?ce(t):null;return K[t].set(n,o),i==null||i.observe(n),()=>{var r;i==null||i.unobserve(n),K[t].delete(n),K[t].size===0&&((r=I[t])==null||r.disconnect(),I[t]=null)}}),u.OnUnmount(o.dispose),u.renderableOfTNode(e(o)))},le=(t,e,o)=>Wt(t,n=>u.When(n,e,o??u.Empty)),J=Math.min,M=Math.max,G=Math.round,Y=Math.floor,P=t=>({x:t,y:t}),ae={left:"right",right:"left",bottom:"top",top:"bottom"},ue={start:"end",end:"start"};function wt(t,e,o){return M(t,J(e,o))}function tt(t,e){return typeof t=="function"?t(e):t}function W(t){return t.split("-")[0]}function et(t){return t.split("-")[1]}function Dt(t){return t==="x"?"y":"x"}function Nt(t){return t==="y"?"height":"width"}function _(t){return["top","bottom"].includes(W(t))?"y":"x"}function Vt(t){return Dt(_(t))}function fe(t,e,o){o===void 0&&(o=!1);const n=et(t),i=Vt(t),r=Nt(i);let s=i==="x"?n===(o?"end":"start")?"right":"left":n==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=Q(s)),[s,Q(s)]}function de(t){const e=Q(t);return[st(t),e,st(e)]}function st(t){return t.replace(/start|end/g,e=>ue[e])}function he(t,e,o){const n=["left","right"],i=["right","left"],r=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return o?e?i:n:e?n:i;case"left":case"right":return e?r:s;default:return[]}}function me(t,e,o,n){const i=et(t);let r=he(W(t),o==="start",n);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(st)))),r}function Q(t){return t.replace(/left|right|bottom|top/g,e=>ae[e])}function pe(t){return{top:0,right:0,bottom:0,left:0,...t}}function ge(t){return typeof t!="number"?pe(t):{top:t,right:t,bottom:t,left:t}}function Z(t){const{x:e,y:o,width:n,height:i}=t;return{width:n,height:i,top:o,left:e,right:e+n,bottom:o+i,x:e,y:o}}function yt(t,e,o){let{reference:n,floating:i}=t;const r=_(e),s=Vt(e),c=Nt(s),a=W(e),l=r==="y",f=n.x+n.width/2-i.width/2,d=n.y+n.height/2-i.height/2,p=n[c]/2-i[c]/2;let h;switch(a){case"top":h={x:f,y:n.y-i.height};break;case"bottom":h={x:f,y:n.y+n.height};break;case"right":h={x:n.x+n.width,y:d};break;case"left":h={x:n.x-i.width,y:d};break;default:h={x:n.x,y:n.y}}switch(et(e)){case"start":h[s]-=p*(o&&l?-1:1);break;case"end":h[s]+=p*(o&&l?-1:1);break}return h}const we=async(t,e,o)=>{const{placement:n="bottom",strategy:i="absolute",middleware:r=[],platform:s}=o,c=r.filter(Boolean),a=await(s.isRTL==null?void 0:s.isRTL(e));let l=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:d}=yt(l,n,a),p=n,h={},g=0;for(let w=0;w<c.length;w++){const{name:y,fn:m}=c[w],{x:v,y:x,data:A,reset:b}=await m({x:f,y:d,initialPlacement:n,placement:p,strategy:i,middlewareData:h,rects:l,platform:s,elements:{reference:t,floating:e}});f=v??f,d=x??d,h={...h,[y]:{...h[y],...A}},b&&g<=50&&(g++,typeof b=="object"&&(b.placement&&(p=b.placement),b.rects&&(l=b.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:i}):b.rects),{x:f,y:d}=yt(l,p,a)),w=-1)}return{x:f,y:d,placement:p,strategy:i,middlewareData:h}};async function Ut(t,e){var o;e===void 0&&(e={});const{x:n,y:i,platform:r,rects:s,elements:c,strategy:a}=t,{boundary:l="clippingAncestors",rootBoundary:f="viewport",elementContext:d="floating",altBoundary:p=!1,padding:h=0}=tt(e,t),g=ge(h),y=c[p?d==="floating"?"reference":"floating":d],m=Z(await r.getClippingRect({element:(o=await(r.isElement==null?void 0:r.isElement(y)))==null||o?y:y.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:l,rootBoundary:f,strategy:a})),v=d==="floating"?{x:n,y:i,width:s.floating.width,height:s.floating.height}:s.reference,x=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),A=await(r.isElement==null?void 0:r.isElement(x))?await(r.getScale==null?void 0:r.getScale(x))||{x:1,y:1}:{x:1,y:1},b=Z(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:v,offsetParent:x,strategy:a}):v);return{top:(m.top-b.top+g.top)/A.y,bottom:(b.bottom-m.bottom+g.bottom)/A.y,left:(m.left-b.left+g.left)/A.x,right:(b.right-m.right+g.right)/A.x}}const ye=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var o,n;const{placement:i,middlewareData:r,rects:s,initialPlacement:c,platform:a,elements:l}=e,{mainAxis:f=!0,crossAxis:d=!0,fallbackPlacements:p,fallbackStrategy:h="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:w=!0,...y}=tt(t,e);if((o=r.arrow)!=null&&o.alignmentOffset)return{};const m=W(i),v=_(c),x=W(c)===c,A=await(a.isRTL==null?void 0:a.isRTL(l.floating)),b=p||(x||!w?[Q(c)]:de(c)),N=g!=="none";!p&&N&&b.push(...me(c,w,g,A));const Jt=[c,...b],it=await Ut(e,y),X=[];let H=((n=r.flip)==null?void 0:n.overflows)||[];if(f&&X.push(it[m]),d){const F=fe(i,s,A);X.push(it[F[0]],it[F[1]])}if(H=[...H,{placement:i,overflows:X}],!X.every(F=>F<=0)){var ht,mt;const F=(((ht=r.flip)==null?void 0:ht.index)||0)+1,gt=Jt[F];if(gt)return{data:{index:F,overflows:H},reset:{placement:gt}};let B=(mt=H.filter(V=>V.overflows[0]<=0).sort((V,k)=>V.overflows[1]-k.overflows[1])[0])==null?void 0:mt.placement;if(!B)switch(h){case"bestFit":{var pt;const V=(pt=H.filter(k=>{if(N){const T=_(k.placement);return T===v||T==="y"}return!0}).map(k=>[k.placement,k.overflows.filter(T=>T>0).reduce((T,Gt)=>T+Gt,0)]).sort((k,T)=>k[1]-T[1])[0])==null?void 0:pt[0];V&&(B=V);break}case"initialPlacement":B=c;break}if(i!==B)return{reset:{placement:B}}}return{}}}};async function ve(t,e){const{placement:o,platform:n,elements:i}=t,r=await(n.isRTL==null?void 0:n.isRTL(i.floating)),s=W(o),c=et(o),a=_(o)==="y",l=["left","top"].includes(s)?-1:1,f=r&&a?-1:1,d=tt(e,t);let{mainAxis:p,crossAxis:h,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:0,crossAxis:0,alignmentAxis:null,...d};return c&&typeof g=="number"&&(h=c==="end"?g*-1:g),a?{x:h*f,y:p*l}:{x:p*l,y:h*f}}const xe=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var o,n;const{x:i,y:r,placement:s,middlewareData:c}=e,a=await ve(e,t);return s===((o=c.offset)==null?void 0:o.placement)&&(n=c.arrow)!=null&&n.alignmentOffset?{}:{x:i+a.x,y:r+a.y,data:{...a,placement:s}}}}},be=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:o,y:n,placement:i}=e,{mainAxis:r=!0,crossAxis:s=!1,limiter:c={fn:y=>{let{x:m,y:v}=y;return{x:m,y:v}}},...a}=tt(t,e),l={x:o,y:n},f=await Ut(e,a),d=_(W(i)),p=Dt(d);let h=l[p],g=l[d];if(r){const y=p==="y"?"top":"left",m=p==="y"?"bottom":"right",v=h+f[y],x=h-f[m];h=wt(v,h,x)}if(s){const y=d==="y"?"top":"left",m=d==="y"?"bottom":"right",v=g+f[y],x=g-f[m];g=wt(v,g,x)}const w=c.fn({...e,[p]:h,[d]:g});return{...w,data:{x:w.x-o,y:w.y-n}}}}};function z(t){return _t(t)?(t.nodeName||"").toLowerCase():"#document"}function E(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function S(t){var e;return(e=(_t(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function _t(t){return t instanceof Node||t instanceof E(t).Node}function O(t){return t instanceof Element||t instanceof E(t).Element}function L(t){return t instanceof HTMLElement||t instanceof E(t).HTMLElement}function vt(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof E(t).ShadowRoot}function q(t){const{overflow:e,overflowX:o,overflowY:n,display:i}=R(t);return/auto|scroll|overlay|hidden|clip/.test(e+n+o)&&!["inline","contents"].includes(i)}function Ae(t){return["table","td","th"].includes(z(t))}function nt(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function ut(t){const e=ft(),o=R(t);return o.transform!=="none"||o.perspective!=="none"||(o.containerType?o.containerType!=="normal":!1)||!e&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!e&&(o.filter?o.filter!=="none":!1)||["transform","perspective","filter"].some(n=>(o.willChange||"").includes(n))||["paint","layout","strict","content"].some(n=>(o.contain||"").includes(n))}function Ee(t){let e=C(t);for(;L(e)&&!$(e);){if(nt(e))return null;if(ut(e))return e;e=C(e)}return null}function ft(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function $(t){return["html","body","#document"].includes(z(t))}function R(t){return E(t).getComputedStyle(t)}function ot(t){return O(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function C(t){if(z(t)==="html")return t;const e=t.assignedSlot||t.parentNode||vt(t)&&t.host||S(t);return vt(e)?e.host:e}function $t(t){const e=C(t);return $(e)?t.ownerDocument?t.ownerDocument.body:t.body:L(e)&&q(e)?e:$t(e)}function j(t,e,o){var n;e===void 0&&(e=[]),o===void 0&&(o=!0);const i=$t(t),r=i===((n=t.ownerDocument)==null?void 0:n.body),s=E(i);return r?e.concat(s,s.visualViewport||[],q(i)?i:[],s.frameElement&&o?j(s.frameElement):[]):e.concat(i,j(i,[],o))}function zt(t){const e=R(t);let o=parseFloat(e.width)||0,n=parseFloat(e.height)||0;const i=L(t),r=i?t.offsetWidth:o,s=i?t.offsetHeight:n,c=G(o)!==r||G(n)!==s;return c&&(o=r,n=s),{width:o,height:n,$:c}}function dt(t){return O(t)?t:t.contextElement}function U(t){const e=dt(t);if(!L(e))return P(1);const o=e.getBoundingClientRect(),{width:n,height:i,$:r}=zt(e);let s=(r?G(o.width):o.width)/n,c=(r?G(o.height):o.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const Re=P(0);function Ht(t){const e=E(t);return!ft()||!e.visualViewport?Re:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Oe(t,e,o){return e===void 0&&(e=!1),!o||e&&o!==E(t)?!1:e}function D(t,e,o,n){e===void 0&&(e=!1),o===void 0&&(o=!1);const i=t.getBoundingClientRect(),r=dt(t);let s=P(1);e&&(n?O(n)&&(s=U(n)):s=U(t));const c=Oe(r,o,n)?Ht(r):P(0);let a=(i.left+c.x)/s.x,l=(i.top+c.y)/s.y,f=i.width/s.x,d=i.height/s.y;if(r){const p=E(r),h=n&&O(n)?E(n):n;let g=p,w=g.frameElement;for(;w&&n&&h!==g;){const y=U(w),m=w.getBoundingClientRect(),v=R(w),x=m.left+(w.clientLeft+parseFloat(v.paddingLeft))*y.x,A=m.top+(w.clientTop+parseFloat(v.paddingTop))*y.y;a*=y.x,l*=y.y,f*=y.x,d*=y.y,a+=x,l+=A,g=E(w),w=g.frameElement}}return Z({width:f,height:d,x:a,y:l})}function Le(t){let{elements:e,rect:o,offsetParent:n,strategy:i}=t;const r=i==="fixed",s=S(n),c=e?nt(e.floating):!1;if(n===s||c&&r)return o;let a={scrollLeft:0,scrollTop:0},l=P(1);const f=P(0),d=L(n);if((d||!d&&!r)&&((z(n)!=="body"||q(s))&&(a=ot(n)),L(n))){const p=D(n);l=U(n),f.x=p.x+n.clientLeft,f.y=p.y+n.clientTop}return{width:o.width*l.x,height:o.height*l.y,x:o.x*l.x-a.scrollLeft*l.x+f.x,y:o.y*l.y-a.scrollTop*l.y+f.y}}function Se(t){return Array.from(t.getClientRects())}function Bt(t){return D(S(t)).left+ot(t).scrollLeft}function ke(t){const e=S(t),o=ot(t),n=t.ownerDocument.body,i=M(e.scrollWidth,e.clientWidth,n.scrollWidth,n.clientWidth),r=M(e.scrollHeight,e.clientHeight,n.scrollHeight,n.clientHeight);let s=-o.scrollLeft+Bt(t);const c=-o.scrollTop;return R(n).direction==="rtl"&&(s+=M(e.clientWidth,n.clientWidth)-i),{width:i,height:r,x:s,y:c}}function Te(t,e){const o=E(t),n=S(t),i=o.visualViewport;let r=n.clientWidth,s=n.clientHeight,c=0,a=0;if(i){r=i.width,s=i.height;const l=ft();(!l||l&&e==="fixed")&&(c=i.offsetLeft,a=i.offsetTop)}return{width:r,height:s,x:c,y:a}}function Pe(t,e){const o=D(t,!0,e==="fixed"),n=o.top+t.clientTop,i=o.left+t.clientLeft,r=L(t)?U(t):P(1),s=t.clientWidth*r.x,c=t.clientHeight*r.y,a=i*r.x,l=n*r.y;return{width:s,height:c,x:a,y:l}}function xt(t,e,o){let n;if(e==="viewport")n=Te(t,o);else if(e==="document")n=ke(S(t));else if(O(e))n=Pe(e,o);else{const i=Ht(t);n={...e,x:e.x-i.x,y:e.y-i.y}}return Z(n)}function It(t,e){const o=C(t);return o===e||!O(o)||$(o)?!1:R(o).position==="fixed"||It(o,e)}function Ce(t,e){const o=e.get(t);if(o)return o;let n=j(t,[],!1).filter(c=>O(c)&&z(c)!=="body"),i=null;const r=R(t).position==="fixed";let s=r?C(t):t;for(;O(s)&&!$(s);){const c=R(s),a=ut(s);!a&&c.position==="fixed"&&(i=null),(r?!a&&!i:!a&&c.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||q(s)&&!a&&It(t,s))?n=n.filter(f=>f!==s):i=c,s=C(s)}return e.set(t,n),n}function Fe(t){let{element:e,boundary:o,rootBoundary:n,strategy:i}=t;const s=[...o==="clippingAncestors"?nt(e)?[]:Ce(e,this._c):[].concat(o),n],c=s[0],a=s.reduce((l,f)=>{const d=xt(e,f,i);return l.top=M(d.top,l.top),l.right=J(d.right,l.right),l.bottom=J(d.bottom,l.bottom),l.left=M(d.left,l.left),l},xt(e,c,i));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function Me(t){const{width:e,height:o}=zt(t);return{width:e,height:o}}function We(t,e,o){const n=L(e),i=S(e),r=o==="fixed",s=D(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const a=P(0);if(n||!n&&!r)if((z(e)!=="body"||q(i))&&(c=ot(e)),n){const d=D(e,!0,r,e);a.x=d.x+e.clientLeft,a.y=d.y+e.clientTop}else i&&(a.x=Bt(i));const l=s.left+c.scrollLeft-a.x,f=s.top+c.scrollTop-a.y;return{x:l,y:f,width:s.width,height:s.height}}function rt(t){return R(t).position==="static"}function bt(t,e){return!L(t)||R(t).position==="fixed"?null:e?e(t):t.offsetParent}function jt(t,e){const o=E(t);if(nt(t))return o;if(!L(t)){let i=C(t);for(;i&&!$(i);){if(O(i)&&!rt(i))return i;i=C(i)}return o}let n=bt(t,e);for(;n&&Ae(n)&&rt(n);)n=bt(n,e);return n&&$(n)&&rt(n)&&!ut(n)?o:n||Ee(t)||o}const De=async function(t){const e=this.getOffsetParent||jt,o=this.getDimensions,n=await o(t.floating);return{reference:We(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function Ne(t){return R(t).direction==="rtl"}const Ve={convertOffsetParentRelativeRectToViewportRelativeRect:Le,getDocumentElement:S,getClippingRect:Fe,getOffsetParent:jt,getElementRects:De,getClientRects:Se,getDimensions:Me,getScale:U,isElement:O,isRTL:Ne};function Ue(t,e){let o=null,n;const i=S(t);function r(){var c;clearTimeout(n),(c=o)==null||c.disconnect(),o=null}function s(c,a){c===void 0&&(c=!1),a===void 0&&(a=1),r();const{left:l,top:f,width:d,height:p}=t.getBoundingClientRect();if(c||e(),!d||!p)return;const h=Y(f),g=Y(i.clientWidth-(l+d)),w=Y(i.clientHeight-(f+p)),y=Y(l),v={rootMargin:-h+"px "+-g+"px "+-w+"px "+-y+"px",threshold:M(0,J(1,a))||1};let x=!0;function A(b){const N=b[0].intersectionRatio;if(N!==a){if(!x)return s();N?s(!1,N):n=setTimeout(()=>{s(!1,1e-7)},1e3)}x=!1}try{o=new IntersectionObserver(A,{...v,root:i.ownerDocument})}catch{o=new IntersectionObserver(A,v)}o.observe(t)}return s(!0),r}function _e(t,e,o,n){n===void 0&&(n={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:s=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:a=!1}=n,l=dt(t),f=i||r?[...l?j(l):[],...j(e)]:[];f.forEach(m=>{i&&m.addEventListener("scroll",o,{passive:!0}),r&&m.addEventListener("resize",o)});const d=l&&c?Ue(l,o):null;let p=-1,h=null;s&&(h=new ResizeObserver(m=>{let[v]=m;v&&v.target===l&&h&&(h.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var x;(x=h)==null||x.observe(e)})),o()}),l&&!a&&h.observe(l),h.observe(e));let g,w=a?D(t):null;a&&y();function y(){const m=D(t);w&&(m.x!==w.x||m.y!==w.y||m.width!==w.width||m.height!==w.height)&&o(),w=m,g=requestAnimationFrame(y)}return o(),()=>{var m;f.forEach(v=>{i&&v.removeEventListener("scroll",o),r&&v.removeEventListener("resize",o)}),d==null||d(),(m=h)==null||m.disconnect(),h=null,a&&cancelAnimationFrame(g)}}const $e=xe,ze=be,At=ye,He=(t,e,o)=>{const n=new Map,i={platform:Ve,...o},r={...i.platform,_c:n};return we(t,e,{...i,platform:r})},Be=({content:t,open:e,placement:o,offset:{mainAxis:n,crossAxis:i}={mainAxis:0,crossAxis:0}})=>r=>{const s=r.element,c=u.Signal.wrap(e);return u.When(c,u.Portal("body",u.html.div(u.OnMount(a=>{const l=a;return l.style.position="absolute",_e(s,l,()=>{He(s,l,{placement:o,strategy:"absolute",middleware:[At(),$e({mainAxis:n,crossAxis:i}),ze(),At()]}).then(({x:f,y:d})=>{l.style.top=`${d}px`,l.style.left=`${f}px`})})}),t())))(r)},qt=(t,e)=>{if(typeof e=="function")return qt(t,{success:e});const o=e.failure??(i=>u.Fragment(u.OnUnmount(i.on(console.error)),i.map(r=>`Error: ${r}`))),n=e.success;return u.OneOfType(u.Signal.wrap(t),{Success:i=>n(i.$.value),Failure:i=>o(i.$.error)})},Ie=()=>u.on.focus(t=>{var e;return(e=t.target)==null?void 0:e.select()}),je=t=>e=>{const o=e.element,n=u.makeProp({width:o.clientWidth,height:o.clientHeight}),i=u.renderableOfTNode(t(n))(e),r=()=>{n.set({width:o.clientWidth,height:o.clientHeight})};let s;return typeof ResizeObserver=="function"&&(s=new ResizeObserver(r),s.observe(o)),c=>{s==null||s.disconnect(),i(c)}},qe=t=>e=>{const o=u.makeProp({width:(window==null?void 0:window.innerWidth)??0,height:(window==null?void 0:window.innerHeight)??0}),n=u.renderableOfTNode(t(o))(e),i=()=>{o.set({width:(window==null?void 0:window.innerWidth)??0,height:(window==null?void 0:window.innerHeight)??0})};return window==null||window.addEventListener("resize",i),r=>{window==null||window.removeEventListener("resize",i),n(r)}},Xt=(t,e)=>{const o=e.split("/").filter(i=>i!==""),n={};for(let i=0;i<t.length;i++){const r=t[i],s=o[i];if(!s&&r.type!=="catch-all")return null;if(r.type==="literal"){if(r.value!==s)return null}else if(r.type==="param")n[r.name]=s;else if(r.type==="catch-all")return{params:n,path:e}}return o.length!==t.length?null:{params:n,path:e}},Yt=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!==""),Kt=t=>{const e=t.map(o=>{const n=Yt(o);return{route:o,segments:n}});return function(n){for(const{segments:i,route:r}of e){const s=Xt(i,n);if(s)return{...s,route:r}}return null}},Xe=t=>{const e=Kt(Object.keys(t));return lt(o=>{const n=o.map(i=>{const r=e(i.pathname);if(r==null)throw console.error("No route found for",i),new Error("No route found");return{params:r.params,route:r.route,path:r.path,search:i.search,hash:i.hash}});return u.OneOfTuple(n.map(i=>[i.route,i]),t)})};exports.Anchor=Ft;exports.AsyncResultView=Mt;exports.AutoFocus=ne;exports.AutoSelect=oe;exports.ElementSize=je;exports.HTMLTitle=re;exports.HiddenWhenEmpty=ie;exports.InViewport=Wt;exports.LocationProviderMarker=ct;exports.PopOver=Be;exports.ProvideAppearance=te;exports.ProvideLocation=Zt;exports.ResultView=qt;exports.Router=Xe;exports.SelectOnFocus=Ie;exports.UseAppearance=ee;exports.UseLocation=lt;exports.WhenInViewport=le;exports.WindowSize=qe;exports._checkExtensionCondition=Rt;exports._getExtension=Et;exports._makeLocation=Lt;exports._makeLocationProp=Ct;exports._makeRouteMatcher=Kt;exports._parseRouteSegments=Yt;exports.appearanceMarker=at;exports.areLocationsEqual=St;exports.handleAnchorClick=Ot;exports.locationFromURL=kt;exports.matchesRoute=Xt;exports.setLocationFromUrl=Tt;exports.urlFromLocation=Pt;
|
package/index.d.ts
CHANGED