UNPKG

@anoki/fse-ui

Version:

FSE UI components library

3 lines (2 loc) • 9.03 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("./index.cjs665.js"),a=require("./index.cjs666.js"),i=require("./index.cjs667.js");function A(t){const e=i.getComputedStyle(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const s=i.isHTMLElement(t),l=s?t.offsetWidth:n,r=s?t.offsetHeight:o,c=a.round(n)!==l||a.round(o)!==r;return c&&(n=l,o=r),{width:n,height:o,$:c}}function W(t){return i.isElement(t)?t:t.contextElement}function L(t){const e=W(t);if(!i.isHTMLElement(e))return a.createCoords(1);const n=e.getBoundingClientRect(),{width:o,height:s,$:l}=A(e);let r=(l?a.round(n.width):n.width)/o,c=(l?a.round(n.height):n.height)/s;return(!r||!Number.isFinite(r))&&(r=1),(!c||!Number.isFinite(c))&&(c=1),{x:r,y:c}}const q=a.createCoords(0);function B(t){const e=i.getWindow(t);return!i.isWebKit()||!e.visualViewport?q:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function U(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==i.getWindow(t)?!1:e}function b(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),l=W(t);let r=a.createCoords(1);e&&(o?i.isElement(o)&&(r=L(o)):r=L(t));const c=U(l,n,o)?B(l):a.createCoords(0);let u=(s.left+c.x)/r.x,f=(s.top+c.y)/r.y,d=s.width/r.x,g=s.height/r.y;if(l){const m=i.getWindow(l),h=o&&i.isElement(o)?i.getWindow(o):o;let y=m,w=i.getFrameElement(y);for(;w&&o&&h!==y;){const v=L(w),p=w.getBoundingClientRect(),x=i.getComputedStyle(w),E=p.left+(w.clientLeft+parseFloat(x.paddingLeft))*v.x,T=p.top+(w.clientTop+parseFloat(x.paddingTop))*v.y;u*=v.x,f*=v.y,d*=v.x,g*=v.y,u+=E,f+=T,y=i.getWindow(w),w=i.getFrameElement(y)}}return a.rectToClientRect({width:d,height:g,x:u,y:f})}function R(t,e){const n=i.getNodeScroll(t).scrollLeft;return e?e.left+n:b(i.getDocumentElement(t)).left+n}function z(t,e){const n=t.getBoundingClientRect(),o=n.left+e.scrollLeft-R(t,n),s=n.top+e.scrollTop;return{x:o,y:s}}function k(t){let{elements:e,rect:n,offsetParent:o,strategy:s}=t;const l=s==="fixed",r=i.getDocumentElement(o),c=e?i.isTopLayer(e.floating):!1;if(o===r||c&&l)return n;let u={scrollLeft:0,scrollTop:0},f=a.createCoords(1);const d=a.createCoords(0),g=i.isHTMLElement(o);if((g||!g&&!l)&&((i.getNodeName(o)!=="body"||i.isOverflowElement(r))&&(u=i.getNodeScroll(o)),i.isHTMLElement(o))){const h=b(o);f=L(o),d.x=h.x+o.clientLeft,d.y=h.y+o.clientTop}const m=r&&!g&&!l?z(r,u):a.createCoords(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-u.scrollLeft*f.x+d.x+m.x,y:n.y*f.y-u.scrollTop*f.y+d.y+m.y}}function X(t){return Array.from(t.getClientRects())}function K(t){const e=i.getDocumentElement(t),n=i.getNodeScroll(t),o=t.ownerDocument.body,s=a.max(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),l=a.max(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let r=-n.scrollLeft+R(t);const c=-n.scrollTop;return i.getComputedStyle(o).direction==="rtl"&&(r+=a.max(e.clientWidth,o.clientWidth)-s),{width:s,height:l,x:r,y:c}}const D=25;function $(t,e){const n=i.getWindow(t),o=i.getDocumentElement(t),s=n.visualViewport;let l=o.clientWidth,r=o.clientHeight,c=0,u=0;if(s){l=s.width,r=s.height;const d=i.isWebKit();(!d||d&&e==="fixed")&&(c=s.offsetLeft,u=s.offsetTop)}const f=R(o);if(f<=0){const d=o.ownerDocument,g=d.body,m=getComputedStyle(g),h=d.compatMode==="CSS1Compat"&&parseFloat(m.marginLeft)+parseFloat(m.marginRight)||0,y=Math.abs(o.clientWidth-g.clientWidth-h);y<=D&&(l-=y)}else f<=D&&(l+=f);return{width:l,height:r,x:c,y:u}}const j=new Set(["absolute","fixed"]);function G(t,e){const n=b(t,!0,e==="fixed"),o=n.top+t.clientTop,s=n.left+t.clientLeft,l=i.isHTMLElement(t)?L(t):a.createCoords(1),r=t.clientWidth*l.x,c=t.clientHeight*l.y,u=s*l.x,f=o*l.y;return{width:r,height:c,x:u,y:f}}function M(t,e,n){let o;if(e==="viewport")o=$(t,n);else if(e==="document")o=K(i.getDocumentElement(t));else if(i.isElement(e))o=G(e,n);else{const s=B(t);o={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return a.rectToClientRect(o)}function I(t,e){const n=i.getParentNode(t);return n===e||!i.isElement(n)||i.isLastTraversableNode(n)?!1:i.getComputedStyle(n).position==="fixed"||I(n,e)}function J(t,e){const n=e.get(t);if(n)return n;let o=i.getOverflowAncestors(t,[],!1).filter(c=>i.isElement(c)&&i.getNodeName(c)!=="body"),s=null;const l=i.getComputedStyle(t).position==="fixed";let r=l?i.getParentNode(t):t;for(;i.isElement(r)&&!i.isLastTraversableNode(r);){const c=i.getComputedStyle(r),u=i.isContainingBlock(r);!u&&c.position==="fixed"&&(s=null),(l?!u&&!s:!u&&c.position==="static"&&!!s&&j.has(s.position)||i.isOverflowElement(r)&&!u&&I(t,r))?o=o.filter(d=>d!==r):s=c,r=i.getParentNode(r)}return e.set(t,o),o}function Q(t){let{element:e,boundary:n,rootBoundary:o,strategy:s}=t;const r=[...n==="clippingAncestors"?i.isTopLayer(e)?[]:J(e,this._c):[].concat(n),o],c=r[0],u=r.reduce((f,d)=>{const g=M(e,d,s);return f.top=a.max(g.top,f.top),f.right=a.min(g.right,f.right),f.bottom=a.min(g.bottom,f.bottom),f.left=a.max(g.left,f.left),f},M(e,c,s));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function Y(t){const{width:e,height:n}=A(t);return{width:e,height:n}}function Z(t,e,n){const o=i.isHTMLElement(e),s=i.getDocumentElement(e),l=n==="fixed",r=b(t,!0,l,e);let c={scrollLeft:0,scrollTop:0};const u=a.createCoords(0);function f(){u.x=R(s)}if(o||!o&&!l)if((i.getNodeName(e)!=="body"||i.isOverflowElement(s))&&(c=i.getNodeScroll(e)),o){const h=b(e,!0,l,e);u.x=h.x+e.clientLeft,u.y=h.y+e.clientTop}else s&&f();l&&!o&&s&&f();const d=s&&!o&&!l?z(s,c):a.createCoords(0),g=r.left+c.scrollLeft-u.x-d.x,m=r.top+c.scrollTop-u.y-d.y;return{x:g,y:m,width:r.width,height:r.height}}function S(t){return i.getComputedStyle(t).position==="static"}function H(t,e){if(!i.isHTMLElement(t)||i.getComputedStyle(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return i.getDocumentElement(t)===n&&(n=n.ownerDocument.body),n}function _(t,e){const n=i.getWindow(t);if(i.isTopLayer(t))return n;if(!i.isHTMLElement(t)){let s=i.getParentNode(t);for(;s&&!i.isLastTraversableNode(s);){if(i.isElement(s)&&!S(s))return s;s=i.getParentNode(s)}return n}let o=H(t,e);for(;o&&i.isTableElement(o)&&S(o);)o=H(o,e);return o&&i.isLastTraversableNode(o)&&S(o)&&!i.isContainingBlock(o)?n:o||i.getContainingBlock(t)||n}const tt=async function(t){const e=this.getOffsetParent||_,n=this.getDimensions,o=await n(t.floating);return{reference:Z(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function et(t){return i.getComputedStyle(t).direction==="rtl"}const V={convertOffsetParentRelativeRectToViewportRelativeRect:k,getDocumentElement:i.getDocumentElement,getClippingRect:Q,getOffsetParent:_,getElementRects:tt,getClientRects:X,getDimensions:Y,getScale:L,isElement:i.isElement,isRTL:et};function P(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function ot(t,e){let n=null,o;const s=i.getDocumentElement(t);function l(){var c;clearTimeout(o),(c=n)==null||c.disconnect(),n=null}function r(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),l();const f=t.getBoundingClientRect(),{left:d,top:g,width:m,height:h}=f;if(c||e(),!m||!h)return;const y=a.floor(g),w=a.floor(s.clientWidth-(d+m)),v=a.floor(s.clientHeight-(g+h)),p=a.floor(d),E={rootMargin:-y+"px "+-w+"px "+-v+"px "+-p+"px",threshold:a.max(0,a.min(1,u))||1};let T=!0;function N(F){const O=F[0].intersectionRatio;if(O!==u){if(!T)return r();O?r(!1,O):o=setTimeout(()=>{r(!1,1e-7)},1e3)}O===1&&!P(f,t.getBoundingClientRect())&&r(),T=!1}try{n=new IntersectionObserver(N,{...E,root:s.ownerDocument})}catch{n=new IntersectionObserver(N,E)}n.observe(t)}return r(!0),l}function nt(t,e,n,o){o===void 0&&(o={});const{ancestorScroll:s=!0,ancestorResize:l=!0,elementResize:r=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=o,f=W(t),d=s||l?[...f?i.getOverflowAncestors(f):[],...i.getOverflowAncestors(e)]:[];d.forEach(p=>{s&&p.addEventListener("scroll",n,{passive:!0}),l&&p.addEventListener("resize",n)});const g=f&&c?ot(f,n):null;let m=-1,h=null;r&&(h=new ResizeObserver(p=>{let[x]=p;x&&x.target===f&&h&&(h.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var E;(E=h)==null||E.observe(e)})),n()}),f&&!u&&h.observe(f),h.observe(e));let y,w=u?b(t):null;u&&v();function v(){const p=b(t);w&&!P(w,p)&&n(),w=p,y=requestAnimationFrame(v)}return n(),()=>{var p;d.forEach(x=>{s&&x.removeEventListener("scroll",n),l&&x.removeEventListener("resize",n)}),g==null||g(),(p=h)==null||p.disconnect(),h=null,u&&cancelAnimationFrame(y)}}const it=C.offset,st=C.shift,rt=C.flip,lt=C.size,ct=C.hide,ft=C.arrow,ut=C.limitShift,at=(t,e,n)=>{const o=new Map,s={platform:V,...n},l={...s.platform,_c:o};return C.computePosition(t,e,{...s,platform:l})};exports.getOverflowAncestors=i.getOverflowAncestors;exports.arrow=ft;exports.autoUpdate=nt;exports.computePosition=at;exports.flip=rt;exports.hide=ct;exports.limitShift=ut;exports.offset=it;exports.platform=V;exports.shift=st;exports.size=lt; //# sourceMappingURL=index.cjs615.js.map