tailtip 1.0.3
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/LICENSE.md +21 -0
- package/README.md +47 -0
- package/dist/tailtip.cjs +1 -0
- package/dist/tailtip.js +1 -0
- package/dist/tailtip.mjs +884 -0
- package/package.json +47 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Tailtip (Versoly Limited) <volkan@versoly.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<div align="">
|
|
2
|
+
<a href="https://versoly.com/versoly-ui/plugins/tailtip" align=""><h1>Tailtip - A tiny Tailwind friendly tooltip library</h1></a>
|
|
3
|
+
<p>Tailtip extends floating UI + combines it with Tailwind to easily create tooltips.</p>
|
|
4
|
+
|
|
5
|
+
<p>
|
|
6
|
+
<a href="https://discord.versoly.com"><img src="https://flat.badgen.net/badge/icon/discord?icon=discord&label" alt="Discord"></a>
|
|
7
|
+
<a href="https://github.com/versoly/tailtip/blob/main/LICENSE.md"><img src="https://img.shields.io/badge/license-MIT-blue" alt="Licenese"></a>
|
|
8
|
+
<a href="https://unpkg.com/tailtip@1.0.3/dist/tailtip.js">
|
|
9
|
+
<img src="https://flat.badgen.net/badgesize/brotli/https://unpkg.com/tailtip@1.0.3/dist/tailtip.js?icon=jsdelivr&label&color=blue&cache=10800" alt="brotli bundle size">
|
|
10
|
+
</a>
|
|
11
|
+
</p>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
------
|
|
15
|
+
|
|
16
|
+
## Demo
|
|
17
|
+
|
|
18
|
+
To view examples of Tailtip in action go to [Tailtip docs](https://versoly.com/versoly-ui/plugins/tailtip).
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Getting started
|
|
22
|
+
|
|
23
|
+
Tailtip can be included as a plugin into an existing Tailwind CSS project and will allow you to add responsive Tailwind CSS utility classes for animation on scroll.
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
### Add JavaScript scripts
|
|
28
|
+
|
|
29
|
+
Add the CDN script or download and paste right before the closing `</body>` tag
|
|
30
|
+
```html
|
|
31
|
+
<script src="https://unpkg.com/tailtip@1.0.3/dist/tailtip.js"></script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Roadmap
|
|
35
|
+
|
|
36
|
+
- Middleware offset + padding options
|
|
37
|
+
- init attr on script tag
|
|
38
|
+
|
|
39
|
+
## Community
|
|
40
|
+
|
|
41
|
+
If you need help or just want to discuss about the library join the community on Github:
|
|
42
|
+
|
|
43
|
+
[Discuss about Tailtip on GitHub](https://github.com/versoly/tailtip/discussions)
|
|
44
|
+
|
|
45
|
+
For casual chatting with others using the library:
|
|
46
|
+
|
|
47
|
+
[Join the Versoly Discord Server](https://discord.versoly.com)
|
package/dist/tailtip.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Nt=Object.defineProperty,Vt=Object.defineProperties;var Bt=Object.getOwnPropertyDescriptors;var Z=Object.getOwnPropertySymbols;var gt=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var pt=(t,e,n)=>e in t?Nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,b=(t,e)=>{for(var n in e||(e={}))gt.call(e,n)&&pt(t,n,e[n]);if(Z)for(var n of Z(e))ht.call(e,n)&&pt(t,n,e[n]);return t},P=(t,e)=>Vt(t,Bt(e));var rt=(t,e)=>{var n={};for(var o in t)gt.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&Z)for(var o of Z(t))e.indexOf(o)<0&&ht.call(t,o)&&(n[o]=t[o]);return n};const K=Math.min,j=Math.max,tt=Math.round,V=t=>({x:t,y:t}),Ft={left:"right",right:"left",bottom:"top",top:"bottom"},Wt={start:"end",end:"start"};function ct(t,e,n){return j(t,K(e,n))}function J(t,e){return typeof t=="function"?t(e):t}function $(t){return t.split("-")[0]}function Q(t){return t.split("-")[1]}function vt(t){return t==="x"?"y":"x"}function at(t){return t==="y"?"height":"width"}function ot(t){return["top","bottom"].includes($(t))?"y":"x"}function ut(t){return vt(ot(t))}function Mt(t,e,n){n===void 0&&(n=!1);const o=Q(t),i=ut(t),r=at(i);let s=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=et(s)),[s,et(s)]}function Ht(t){const e=et(t);return[lt(t),e,lt(e)]}function lt(t){return t.replace(/start|end/g,e=>Wt[e])}function $t(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:s;default:return[]}}function jt(t,e,n,o){const i=Q(t);let r=$t($(t),n==="start",o);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(lt)))),r}function et(t){return t.replace(/left|right|bottom|top/g,e=>Ft[e])}function _t(t){return b({top:0,right:0,bottom:0,left:0},t)}function At(t){return typeof t!="number"?_t(t):{top:t,right:t,bottom:t,left:t}}function nt(t){return P(b({},t),{top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height})}function wt(t,e,n){let{reference:o,floating:i}=t;const r=ot(e),s=ut(e),c=at(s),l=$(e),f=r==="y",p=o.x+o.width/2-i.width/2,d=o.y+o.height/2-i.height/2,m=o[c]/2-i[c]/2;let a;switch(l){case"top":a={x:p,y:o.y-i.height};break;case"bottom":a={x:p,y:o.y+o.height};break;case"right":a={x:o.x+o.width,y:d};break;case"left":a={x:o.x-i.width,y:d};break;default:a={x:o.x,y:o.y}}switch(Q(e)){case"start":a[s]-=m*(n&&f?-1:1);break;case"end":a[s]+=m*(n&&f?-1:1);break}return a}const Xt=async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:s}=n,c=r.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(e));let f=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:p,y:d}=wt(f,o,l),m=o,a={},u=0;for(let g=0;g<c.length;g++){const{name:w,fn:h}=c[g],{x:y,y:x,data:A,reset:v}=await h({x:p,y:d,initialPlacement:o,placement:m,strategy:i,middlewareData:a,rects:f,platform:s,elements:{reference:t,floating:e}});if(p=y!=null?y:p,d=x!=null?x:d,a=P(b({},a),{[w]:b(b({},a[w]),A)}),v&&u<=50){u++,typeof v=="object"&&(v.placement&&(m=v.placement),v.rects&&(f=v.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:i}):v.rects),{x:p,y:d}=wt(f,m,l)),g=-1;continue}}return{x:p,y:d,placement:m,strategy:i,middlewareData:a}};async function Et(t,e){var n;e===void 0&&(e={});const{x:o,y:i,platform:r,rects:s,elements:c,strategy:l}=t,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:d="floating",altBoundary:m=!1,padding:a=0}=J(e,t),u=At(a),w=c[m?d==="floating"?"reference":"floating":d],h=nt(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(w)))==null||n?w:w.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:f,rootBoundary:p,strategy:l})),y=d==="floating"?P(b({},s.floating),{x:o,y:i}):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},v=nt(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:y,offsetParent:x,strategy:l}):y);return{top:(h.top-v.top+u.top)/A.y,bottom:(v.bottom-h.bottom+u.bottom)/A.y,left:(h.left-v.left+u.left)/A.x,right:(v.right-h.right+u.right)/A.x}}const Yt=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:i,rects:r,platform:s,elements:c,middlewareData:l}=e,{element:f,padding:p=0}=J(t,e)||{};if(f==null)return{};const d=At(p),m={x:n,y:o},a=ut(i),u=at(a),g=await s.getDimensions(f),w=a==="y",h=w?"top":"left",y=w?"bottom":"right",x=w?"clientHeight":"clientWidth",A=r.reference[u]+r.reference[a]-m[a]-r.floating[u],v=m[a]-r.reference[a],W=await(s.getOffsetParent==null?void 0:s.getOffsetParent(f));let O=W?W[x]:0;(!O||!await(s.isElement==null?void 0:s.isElement(W)))&&(O=c.floating[x]||r.floating[u]);const M=A/2-v/2,Y=O/2-g[u]/2-1,q=K(d[h],Y),I=K(d[y],Y),H=q,T=O-g[u]-I,R=O/2-g[u]/2+M,D=ct(H,R,T),L=!l.arrow&&Q(i)!=null&&R!=D&&r.reference[u]/2-(R<H?q:I)-g[u]/2<0,S=L?R<H?R-H:R-T:0;return{[a]:m[a]+S,data:b({[a]:D,centerOffset:R-D-S},L&&{alignmentOffset:S}),reset:L}}}),qt=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:s,initialPlacement:c,platform:l,elements:f}=e,H=J(t,e),{mainAxis:p=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:a="bestFit",fallbackAxisSideDirection:u="none",flipAlignment:g=!0}=H,w=rt(H,["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"]);if((n=r.arrow)!=null&&n.alignmentOffset)return{};const h=$(i),y=$(c)===c,x=await(l.isRTL==null?void 0:l.isRTL(f.floating)),A=m||(y||!g?[et(c)]:Ht(c));!m&&u!=="none"&&A.push(...jt(c,g,u,x));const v=[c,...A],W=await Et(e,w),O=[];let M=((o=r.flip)==null?void 0:o.overflows)||[];if(p&&O.push(W[h]),d){const T=Mt(i,s,x);O.push(W[T[0]],W[T[1]])}if(M=[...M,{placement:i,overflows:O}],!O.every(T=>T<=0)){var Y,q;const T=(((Y=r.flip)==null?void 0:Y.index)||0)+1,R=v[T];if(R)return{data:{index:T,overflows:M},reset:{placement:R}};let D=(q=M.filter(L=>L.overflows[0]<=0).sort((L,S)=>L.overflows[1]-S.overflows[1])[0])==null?void 0:q.placement;if(!D)switch(a){case"bestFit":{var I;const L=(I=M.map(S=>[S.placement,S.overflows.filter(z=>z>0).reduce((z,Dt)=>z+Dt,0)]).sort((S,z)=>S[1]-z[1])[0])==null?void 0:I[0];L&&(D=L);break}case"initialPlacement":D=c;break}if(i!==D)return{reset:{placement:D}}}return{}}}};async function It(t,e){const{placement:n,platform:o,elements:i}=t,r=await(o.isRTL==null?void 0:o.isRTL(i.floating)),s=$(n),c=Q(n),l=ot(n)==="y",f=["left","top"].includes(s)?-1:1,p=r&&l?-1:1,d=J(e,t);let{mainAxis:m,crossAxis:a,alignmentAxis:u}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:b({mainAxis:0,crossAxis:0,alignmentAxis:null},d);return c&&typeof u=="number"&&(a=c==="end"?u*-1:u),l?{x:a*p,y:m*f}:{x:m*f,y:a*p}}const zt=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:r,placement:s,middlewareData:c}=e,l=await It(e,t);return s===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:P(b({},l),{placement:s})}}}},Kt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,w=J(t,e),{mainAxis:r=!0,crossAxis:s=!1,limiter:c={fn:h=>{let{x:y,y:x}=h;return{x:y,y:x}}}}=w,l=rt(w,["mainAxis","crossAxis","limiter"]),f={x:n,y:o},p=await Et(e,l),d=ot($(i)),m=vt(d);let a=f[m],u=f[d];if(r){const h=m==="y"?"top":"left",y=m==="y"?"bottom":"right",x=a+p[h],A=a-p[y];a=ct(x,a,A)}if(s){const h=d==="y"?"top":"left",y=d==="y"?"bottom":"right",x=u+p[h],A=u-p[y];u=ct(x,u,A)}const g=c.fn(P(b({},e),{[m]:a,[d]:u}));return P(b({},g),{data:{x:g.x-n,y:g.y-o}})}}};function B(t){return Ct(t)?(t.nodeName||"").toLowerCase():"#document"}function E(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function F(t){var e;return(e=(Ct(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Ct(t){return t instanceof Node||t instanceof E(t).Node}function N(t){return t instanceof Element||t instanceof E(t).Element}function k(t){return t instanceof HTMLElement||t instanceof E(t).HTMLElement}function xt(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof E(t).ShadowRoot}function U(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=C(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function Gt(t){return["table","td","th"].includes(B(t))}function dt(t){const e=mt(),n=C(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 Jt(t){let e=X(t);for(;k(e)&&!it(e);){if(dt(e))return e;e=X(e)}return null}function mt(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function it(t){return["html","body","#document"].includes(B(t))}function C(t){return E(t).getComputedStyle(t)}function st(t){return N(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function X(t){if(B(t)==="html")return t;const e=t.assignedSlot||t.parentNode||xt(t)&&t.host||F(t);return xt(e)?e.host:e}function Ot(t){const e=X(t);return it(e)?t.ownerDocument?t.ownerDocument.body:t.body:k(e)&&U(e)?e:Ot(e)}function ft(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=Ot(t),r=i===((o=t.ownerDocument)==null?void 0:o.body),s=E(i);return r?e.concat(s,s.visualViewport||[],U(i)?i:[],s.frameElement&&n?ft(s.frameElement):[]):e.concat(i,ft(i,[],n))}function Tt(t){const e=C(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=k(t),r=i?t.offsetWidth:n,s=i?t.offsetHeight:o,c=tt(n)!==r||tt(o)!==s;return c&&(n=r,o=s),{width:n,height:o,$:c}}function Rt(t){return N(t)?t:t.contextElement}function _(t){const e=Rt(t);if(!k(e))return V(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=Tt(e);let s=(r?tt(n.width):n.width)/o,c=(r?tt(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const Qt=V(0);function Lt(t){const e=E(t);return!mt()||!e.visualViewport?Qt:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Ut(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==E(t)?!1:e}function G(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),r=Rt(t);let s=V(1);e&&(o?N(o)&&(s=_(o)):s=_(t));const c=Ut(r,n,o)?Lt(r):V(0);let l=(i.left+c.x)/s.x,f=(i.top+c.y)/s.y,p=i.width/s.x,d=i.height/s.y;if(r){const m=E(r),a=o&&N(o)?E(o):o;let u=m.frameElement;for(;u&&o&&a!==m;){const g=_(u),w=u.getBoundingClientRect(),h=C(u),y=w.left+(u.clientLeft+parseFloat(h.paddingLeft))*g.x,x=w.top+(u.clientTop+parseFloat(h.paddingTop))*g.y;l*=g.x,f*=g.y,p*=g.x,d*=g.y,l+=y,f+=x,u=E(u).frameElement}}return nt({width:p,height:d,x:l,y:f})}function Zt(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=k(n),r=F(n);if(n===r)return e;let s={scrollLeft:0,scrollTop:0},c=V(1);const l=V(0);if((i||!i&&o!=="fixed")&&((B(n)!=="body"||U(r))&&(s=st(n)),k(n))){const f=G(n);c=_(n),l.x=f.x+n.clientLeft,l.y=f.y+n.clientTop}return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-s.scrollLeft*c.x+l.x,y:e.y*c.y-s.scrollTop*c.y+l.y}}function te(t){return Array.from(t.getClientRects())}function St(t){return G(F(t)).left+st(t).scrollLeft}function ee(t){const e=F(t),n=st(t),o=t.ownerDocument.body,i=j(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=j(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let s=-n.scrollLeft+St(t);const c=-n.scrollTop;return C(o).direction==="rtl"&&(s+=j(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:s,y:c}}function ne(t,e){const n=E(t),o=F(t),i=n.visualViewport;let r=o.clientWidth,s=o.clientHeight,c=0,l=0;if(i){r=i.width,s=i.height;const f=mt();(!f||f&&e==="fixed")&&(c=i.offsetLeft,l=i.offsetTop)}return{width:r,height:s,x:c,y:l}}function oe(t,e){const n=G(t,!0,e==="fixed"),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=k(t)?_(t):V(1),s=t.clientWidth*r.x,c=t.clientHeight*r.y,l=i*r.x,f=o*r.y;return{width:s,height:c,x:l,y:f}}function yt(t,e,n){let o;if(e==="viewport")o=ne(t,n);else if(e==="document")o=ee(F(t));else if(N(e))o=oe(e,n);else{const i=Lt(t);o=P(b({},e),{x:e.x-i.x,y:e.y-i.y})}return nt(o)}function Pt(t,e){const n=X(t);return n===e||!N(n)||it(n)?!1:C(n).position==="fixed"||Pt(n,e)}function ie(t,e){const n=e.get(t);if(n)return n;let o=ft(t,[],!1).filter(c=>N(c)&&B(c)!=="body"),i=null;const r=C(t).position==="fixed";let s=r?X(t):t;for(;N(s)&&!it(s);){const c=C(s),l=dt(s);!l&&c.position==="fixed"&&(i=null),(r?!l&&!i:!l&&c.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||U(s)&&!l&&Pt(t,s))?o=o.filter(p=>p!==s):i=c,s=X(s)}return e.set(t,o),o}function se(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const s=[...n==="clippingAncestors"?ie(e,this._c):[].concat(n),o],c=s[0],l=s.reduce((f,p)=>{const d=yt(e,p,i);return f.top=j(d.top,f.top),f.right=K(d.right,f.right),f.bottom=K(d.bottom,f.bottom),f.left=j(d.left,f.left),f},yt(e,c,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function re(t){return Tt(t)}function ce(t,e,n){const o=k(e),i=F(e),r=n==="fixed",s=G(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const l=V(0);if(o||!o&&!r)if((B(e)!=="body"||U(i))&&(c=st(e)),o){const f=G(e,!0,r,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else i&&(l.x=St(i));return{x:s.left+c.scrollLeft-l.x,y:s.top+c.scrollTop-l.y,width:s.width,height:s.height}}function bt(t,e){return!k(t)||C(t).position==="fixed"?null:e?e(t):t.offsetParent}function kt(t,e){const n=E(t);if(!k(t))return n;let o=bt(t,e);for(;o&&Gt(o)&&C(o).position==="static";)o=bt(o,e);return o&&(B(o)==="html"||B(o)==="body"&&C(o).position==="static"&&!dt(o))?n:o||Jt(t)||n}const le=async function(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||kt,r=this.getDimensions;return{reference:ce(e,await i(n),o),floating:b({x:0,y:0},await r(n))}};function fe(t){return C(t).direction==="rtl"}const ae={convertOffsetParentRelativeRectToViewportRelativeRect:Zt,getDocumentElement:F,getClippingRect:se,getOffsetParent:kt,getElementRects:le,getClientRects:te,getDimensions:re,getScale:_,isElement:N,isRTL:fe},ue=(t,e,n)=>{const o=new Map,i=b({platform:ae},n),r=P(b({},i.platform),{_c:o});return Xt(t,e,P(b({},i),{platform:r}))},de=function(t,e={}){const n=t.nextElementSibling,o=n.querySelector(".tooltip-arrow"),i=[zt(6),qt(),Kt({padding:5})];o&&i.push(Yt({element:o}));function r(){ue(t,n,{placement:e.placement||"top",middleware:i}).then(({x:m,y:a,placement:u,middlewareData:g})=>{if(Object.assign(n.style,{left:"".concat(m,"px"),top:"".concat(a,"px")}),g.arrow){const{x:w,y:h}=g.arrow,y={top:"bottom",right:"left",bottom:"top",left:"right"}[u.split("-")[0]];Object.assign(o.style,{left:w!=null?"".concat(w,"px"):"",top:h!=null?"".concat(h,"px"):"",right:"",bottom:"",[y]:"-4px"})}})}const s=()=>{n.style.display="block",requestAnimationFrame(()=>{n.classList.add("opacity-100","visible")}),r()},c=()=>{n.style.display="",n.classList.remove("opacity-100","visible")},l=()=>{if(n.style.display==="block"){c();return}s()};let f=["mouseenter","focus"],p=["mouseleave","blur"],d=[];e.trigger==="click"&&(f=[],p=["blur"],d=["click"]),f.forEach(m=>{t.addEventListener(m,s)}),p.forEach(m=>{t.addEventListener(m,c)}),d.forEach(m=>{t.addEventListener(m,l)})};module.exports=de;
|
package/dist/tailtip.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Tailtip=function(){"use strict";var fe=Object.defineProperty,ae=Object.defineProperties;var ue=Object.getOwnPropertyDescriptors;var st=Object.getOwnPropertySymbols;var Pt=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable;var St=(h,w,v)=>w in h?fe(h,w,{enumerable:!0,configurable:!0,writable:!0,value:v}):h[w]=v,C=(h,w)=>{for(var v in w||(w={}))Pt.call(w,v)&&St(h,v,w[v]);if(st)for(var v of st(w))kt.call(w,v)&&St(h,v,w[v]);return h},B=(h,w)=>ae(h,ue(w));var mt=(h,w)=>{var v={};for(var E in h)Pt.call(h,E)&&w.indexOf(E)<0&&(v[E]=h[E]);if(h!=null&&st)for(var E of st(h))w.indexOf(E)<0&&kt.call(h,E)&&(v[E]=h[E]);return v};const h=Math.min,w=Math.max,v=Math.round,E=t=>({x:t,y:t}),Dt={left:"right",right:"left",bottom:"top",top:"bottom"},Nt={start:"end",end:"start"};function rt(t,e,n){return w(t,h(e,n))}function I(t,e){return typeof t=="function"?t(e):t}function $(t){return t.split("-")[0]}function z(t){return t.split("-")[1]}function pt(t){return t==="x"?"y":"x"}function ct(t){return t==="y"?"height":"width"}function tt(t){return["top","bottom"].includes($(t))?"y":"x"}function lt(t){return pt(tt(t))}function Vt(t,e,n){n===void 0&&(n=!1);const o=z(t),i=lt(t),r=ct(i);let s=i==="x"?o===(n?"end":"start")?"right":"left":o==="start"?"bottom":"top";return e.reference[r]>e.floating[r]&&(s=et(s)),[s,et(s)]}function Bt(t){const e=et(t);return[ft(t),e,ft(e)]}function ft(t){return t.replace(/start|end/g,e=>Nt[e])}function Ft(t,e,n){const o=["left","right"],i=["right","left"],r=["top","bottom"],s=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:o:e?o:i;case"left":case"right":return e?r:s;default:return[]}}function Wt(t,e,n,o){const i=z(t);let r=Ft($(t),n==="start",o);return i&&(r=r.map(s=>s+"-"+i),e&&(r=r.concat(r.map(ft)))),r}function et(t){return t.replace(/left|right|bottom|top/g,e=>Dt[e])}function Mt(t){return C({top:0,right:0,bottom:0,left:0},t)}function gt(t){return typeof t!="number"?Mt(t):{top:t,right:t,bottom:t,left:t}}function nt(t){return B(C({},t),{top:t.y,left:t.x,right:t.x+t.width,bottom:t.y+t.height})}function ht(t,e,n){let{reference:o,floating:i}=t;const r=tt(e),s=lt(e),c=ct(s),l=$(e),f=r==="y",p=o.x+o.width/2-i.width/2,d=o.y+o.height/2-i.height/2,m=o[c]/2-i[c]/2;let a;switch(l){case"top":a={x:p,y:o.y-i.height};break;case"bottom":a={x:p,y:o.y+o.height};break;case"right":a={x:o.x+o.width,y:d};break;case"left":a={x:o.x-i.width,y:d};break;default:a={x:o.x,y:o.y}}switch(z(e)){case"start":a[s]-=m*(n&&f?-1:1);break;case"end":a[s]+=m*(n&&f?-1:1);break}return a}const Ht=async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:s}=n,c=r.filter(Boolean),l=await(s.isRTL==null?void 0:s.isRTL(e));let f=await s.getElementRects({reference:t,floating:e,strategy:i}),{x:p,y:d}=ht(f,o,l),m=o,a={},u=0;for(let g=0;g<c.length;g++){const{name:y,fn:x}=c[g],{x:A,y:b,data:T,reset:O}=await x({x:p,y:d,initialPlacement:o,placement:m,strategy:i,middlewareData:a,rects:f,platform:s,elements:{reference:t,floating:e}});if(p=A!=null?A:p,d=b!=null?b:d,a=B(C({},a),{[y]:C(C({},a[y]),T)}),O&&u<=50){u++,typeof O=="object"&&(O.placement&&(m=O.placement),O.rects&&(f=O.rects===!0?await s.getElementRects({reference:t,floating:e,strategy:i}):O.rects),{x:p,y:d}=ht(f,m,l)),g=-1;continue}}return{x:p,y:d,placement:m,strategy:i,middlewareData:a}};async function wt(t,e){var n;e===void 0&&(e={});const{x:o,y:i,platform:r,rects:s,elements:c,strategy:l}=t,{boundary:f="clippingAncestors",rootBoundary:p="viewport",elementContext:d="floating",altBoundary:m=!1,padding:a=0}=I(e,t),u=gt(a),y=c[m?d==="floating"?"reference":"floating":d],x=nt(await r.getClippingRect({element:(n=await(r.isElement==null?void 0:r.isElement(y)))==null||n?y:y.contextElement||await(r.getDocumentElement==null?void 0:r.getDocumentElement(c.floating)),boundary:f,rootBoundary:p,strategy:l})),A=d==="floating"?B(C({},s.floating),{x:o,y:i}):s.reference,b=await(r.getOffsetParent==null?void 0:r.getOffsetParent(c.floating)),T=await(r.isElement==null?void 0:r.isElement(b))?await(r.getScale==null?void 0:r.getScale(b))||{x:1,y:1}:{x:1,y:1},O=nt(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({rect:A,offsetParent:b,strategy:l}):A);return{top:(x.top-O.top+u.top)/T.y,bottom:(O.bottom-x.bottom+u.bottom)/T.y,left:(x.left-O.left+u.left)/T.x,right:(O.right-x.right+u.right)/T.x}}const $t=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:o,placement:i,rects:r,platform:s,elements:c,middlewareData:l}=e,{element:f,padding:p=0}=I(t,e)||{};if(f==null)return{};const d=gt(p),m={x:n,y:o},a=lt(i),u=ct(a),g=await s.getDimensions(f),y=a==="y",x=y?"top":"left",A=y?"bottom":"right",b=y?"clientHeight":"clientWidth",T=r.reference[u]+r.reference[a]-m[a]-r.floating[u],O=m[a]-r.reference[a],j=await(s.getOffsetParent==null?void 0:s.getOffsetParent(f));let P=j?j[b]:0;(!P||!await(s.isElement==null?void 0:s.isElement(j)))&&(P=c.floating[b]||r.floating[u]);const _=T/2-O/2,J=P/2-g[u]/2-1,Q=h(d[x],J),U=h(d[A],J),X=Q,k=P-g[u]-U,D=P/2-g[u]/2+_,W=rt(X,D,k),N=!l.arrow&&z(i)!=null&&D!=W&&r.reference[u]/2-(D<X?Q:U)-g[u]/2<0,V=N?D<X?D-X:D-k:0;return{[a]:m[a]+V,data:C({[a]:W,centerOffset:D-W-V},N&&{alignmentOffset:V}),reset:N}}}),jt=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:s,initialPlacement:c,platform:l,elements:f}=e,X=I(t,e),{mainAxis:p=!0,crossAxis:d=!0,fallbackPlacements:m,fallbackStrategy:a="bestFit",fallbackAxisSideDirection:u="none",flipAlignment:g=!0}=X,y=mt(X,["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"]);if((n=r.arrow)!=null&&n.alignmentOffset)return{};const x=$(i),A=$(c)===c,b=await(l.isRTL==null?void 0:l.isRTL(f.floating)),T=m||(A||!g?[et(c)]:Bt(c));!m&&u!=="none"&&T.push(...Wt(c,g,u,b));const O=[c,...T],j=await wt(e,y),P=[];let _=((o=r.flip)==null?void 0:o.overflows)||[];if(p&&P.push(j[x]),d){const k=Vt(i,s,b);P.push(j[k[0]],j[k[1]])}if(_=[..._,{placement:i,overflows:P}],!P.every(k=>k<=0)){var J,Q;const k=(((J=r.flip)==null?void 0:J.index)||0)+1,D=O[k];if(D)return{data:{index:k,overflows:_},reset:{placement:D}};let W=(Q=_.filter(N=>N.overflows[0]<=0).sort((N,V)=>N.overflows[1]-V.overflows[1])[0])==null?void 0:Q.placement;if(!W)switch(a){case"bestFit":{var U;const N=(U=_.map(V=>[V.placement,V.overflows.filter(Z=>Z>0).reduce((Z,le)=>Z+le,0)]).sort((V,Z)=>V[1]-Z[1])[0])==null?void 0:U[0];N&&(W=N);break}case"initialPlacement":W=c;break}if(i!==W)return{reset:{placement:W}}}return{}}}};async function _t(t,e){const{placement:n,platform:o,elements:i}=t,r=await(o.isRTL==null?void 0:o.isRTL(i.floating)),s=$(n),c=z(n),l=tt(n)==="y",f=["left","top"].includes(s)?-1:1,p=r&&l?-1:1,d=I(e,t);let{mainAxis:m,crossAxis:a,alignmentAxis:u}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:C({mainAxis:0,crossAxis:0,alignmentAxis:null},d);return c&&typeof u=="number"&&(a=c==="end"?u*-1:u),l?{x:a*p,y:m*f}:{x:m*f,y:a*p}}const Xt=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:r,placement:s,middlewareData:c}=e,l=await _t(e,t);return s===((n=c.offset)==null?void 0:n.placement)&&(o=c.arrow)!=null&&o.alignmentOffset?{}:{x:i+l.x,y:r+l.y,data:B(C({},l),{placement:s})}}}},Yt=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i}=e,y=I(t,e),{mainAxis:r=!0,crossAxis:s=!1,limiter:c={fn:x=>{let{x:A,y:b}=x;return{x:A,y:b}}}}=y,l=mt(y,["mainAxis","crossAxis","limiter"]),f={x:n,y:o},p=await wt(e,l),d=tt($(i)),m=pt(d);let a=f[m],u=f[d];if(r){const x=m==="y"?"top":"left",A=m==="y"?"bottom":"right",b=a+p[x],T=a-p[A];a=rt(b,a,T)}if(s){const x=d==="y"?"top":"left",A=d==="y"?"bottom":"right",b=u+p[x],T=u-p[A];u=rt(b,u,T)}const g=c.fn(B(C({},e),{[m]:a,[d]:u}));return B(C({},g),{data:{x:g.x-n,y:g.y-o}})}}};function M(t){return xt(t)?(t.nodeName||"").toLowerCase():"#document"}function R(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function H(t){var e;return(e=(xt(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function xt(t){return t instanceof Node||t instanceof R(t).Node}function F(t){return t instanceof Element||t instanceof R(t).Element}function S(t){return t instanceof HTMLElement||t instanceof R(t).HTMLElement}function yt(t){return typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof R(t).ShadowRoot}function K(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=L(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!["inline","contents"].includes(i)}function qt(t){return["table","td","th"].includes(M(t))}function at(t){const e=ut(),n=L(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 It(t){let e=Y(t);for(;S(e)&&!ot(e);){if(at(e))return e;e=Y(e)}return null}function ut(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function ot(t){return["html","body","#document"].includes(M(t))}function L(t){return R(t).getComputedStyle(t)}function it(t){return F(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Y(t){if(M(t)==="html")return t;const e=t.assignedSlot||t.parentNode||yt(t)&&t.host||H(t);return yt(e)?e.host:e}function bt(t){const e=Y(t);return ot(e)?t.ownerDocument?t.ownerDocument.body:t.body:S(e)&&K(e)?e:bt(e)}function dt(t,e,n){var o;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=bt(t),r=i===((o=t.ownerDocument)==null?void 0:o.body),s=R(i);return r?e.concat(s,s.visualViewport||[],K(i)?i:[],s.frameElement&&n?dt(s.frameElement):[]):e.concat(i,dt(i,[],n))}function vt(t){const e=L(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=S(t),r=i?t.offsetWidth:n,s=i?t.offsetHeight:o,c=v(n)!==r||v(o)!==s;return c&&(n=r,o=s),{width:n,height:o,$:c}}function At(t){return F(t)?t:t.contextElement}function q(t){const e=At(t);if(!S(e))return E(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=vt(e);let s=(r?v(n.width):n.width)/o,c=(r?v(n.height):n.height)/i;return(!s||!Number.isFinite(s))&&(s=1),(!c||!Number.isFinite(c))&&(c=1),{x:s,y:c}}const zt=E(0);function Et(t){const e=R(t);return!ut()||!e.visualViewport?zt:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Kt(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==R(t)?!1:e}function G(t,e,n,o){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),r=At(t);let s=E(1);e&&(o?F(o)&&(s=q(o)):s=q(t));const c=Kt(r,n,o)?Et(r):E(0);let l=(i.left+c.x)/s.x,f=(i.top+c.y)/s.y,p=i.width/s.x,d=i.height/s.y;if(r){const m=R(r),a=o&&F(o)?R(o):o;let u=m.frameElement;for(;u&&o&&a!==m;){const g=q(u),y=u.getBoundingClientRect(),x=L(u),A=y.left+(u.clientLeft+parseFloat(x.paddingLeft))*g.x,b=y.top+(u.clientTop+parseFloat(x.paddingTop))*g.y;l*=g.x,f*=g.y,p*=g.x,d*=g.y,l+=A,f+=b,u=R(u).frameElement}}return nt({width:p,height:d,x:l,y:f})}function Gt(t){let{rect:e,offsetParent:n,strategy:o}=t;const i=S(n),r=H(n);if(n===r)return e;let s={scrollLeft:0,scrollTop:0},c=E(1);const l=E(0);if((i||!i&&o!=="fixed")&&((M(n)!=="body"||K(r))&&(s=it(n)),S(n))){const f=G(n);c=q(n),l.x=f.x+n.clientLeft,l.y=f.y+n.clientTop}return{width:e.width*c.x,height:e.height*c.y,x:e.x*c.x-s.scrollLeft*c.x+l.x,y:e.y*c.y-s.scrollTop*c.y+l.y}}function Jt(t){return Array.from(t.getClientRects())}function Ct(t){return G(H(t)).left+it(t).scrollLeft}function Qt(t){const e=H(t),n=it(t),o=t.ownerDocument.body,i=w(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=w(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let s=-n.scrollLeft+Ct(t);const c=-n.scrollTop;return L(o).direction==="rtl"&&(s+=w(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:s,y:c}}function Ut(t,e){const n=R(t),o=H(t),i=n.visualViewport;let r=o.clientWidth,s=o.clientHeight,c=0,l=0;if(i){r=i.width,s=i.height;const f=ut();(!f||f&&e==="fixed")&&(c=i.offsetLeft,l=i.offsetTop)}return{width:r,height:s,x:c,y:l}}function Zt(t,e){const n=G(t,!0,e==="fixed"),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=S(t)?q(t):E(1),s=t.clientWidth*r.x,c=t.clientHeight*r.y,l=i*r.x,f=o*r.y;return{width:s,height:c,x:l,y:f}}function Ot(t,e,n){let o;if(e==="viewport")o=Ut(t,n);else if(e==="document")o=Qt(H(t));else if(F(e))o=Zt(e,n);else{const i=Et(t);o=B(C({},e),{x:e.x-i.x,y:e.y-i.y})}return nt(o)}function Tt(t,e){const n=Y(t);return n===e||!F(n)||ot(n)?!1:L(n).position==="fixed"||Tt(n,e)}function te(t,e){const n=e.get(t);if(n)return n;let o=dt(t,[],!1).filter(c=>F(c)&&M(c)!=="body"),i=null;const r=L(t).position==="fixed";let s=r?Y(t):t;for(;F(s)&&!ot(s);){const c=L(s),l=at(s);!l&&c.position==="fixed"&&(i=null),(r?!l&&!i:!l&&c.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||K(s)&&!l&&Tt(t,s))?o=o.filter(p=>p!==s):i=c,s=Y(s)}return e.set(t,o),o}function ee(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const s=[...n==="clippingAncestors"?te(e,this._c):[].concat(n),o],c=s[0],l=s.reduce((f,p)=>{const d=Ot(e,p,i);return f.top=w(d.top,f.top),f.right=h(d.right,f.right),f.bottom=h(d.bottom,f.bottom),f.left=w(d.left,f.left),f},Ot(e,c,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function ne(t){return vt(t)}function oe(t,e,n){const o=S(e),i=H(e),r=n==="fixed",s=G(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const l=E(0);if(o||!o&&!r)if((M(e)!=="body"||K(i))&&(c=it(e)),o){const f=G(e,!0,r,e);l.x=f.x+e.clientLeft,l.y=f.y+e.clientTop}else i&&(l.x=Ct(i));return{x:s.left+c.scrollLeft-l.x,y:s.top+c.scrollTop-l.y,width:s.width,height:s.height}}function Rt(t,e){return!S(t)||L(t).position==="fixed"?null:e?e(t):t.offsetParent}function Lt(t,e){const n=R(t);if(!S(t))return n;let o=Rt(t,e);for(;o&&qt(o)&&L(o).position==="static";)o=Rt(o,e);return o&&(M(o)==="html"||M(o)==="body"&&L(o).position==="static"&&!at(o))?n:o||It(t)||n}const ie=async function(t){let{reference:e,floating:n,strategy:o}=t;const i=this.getOffsetParent||Lt,r=this.getDimensions;return{reference:oe(e,await i(n),o),floating:C({x:0,y:0},await r(n))}};function se(t){return L(t).direction==="rtl"}const re={convertOffsetParentRelativeRectToViewportRelativeRect:Gt,getDocumentElement:H,getClippingRect:ee,getOffsetParent:Lt,getElementRects:ie,getClientRects:Jt,getDimensions:ne,getScale:q,isElement:F,isRTL:se},ce=(t,e,n)=>{const o=new Map,i=C({platform:re},n),r=B(C({},i.platform),{_c:o});return Ht(t,e,B(C({},i),{platform:r}))};return function(t,e={}){const n=t.nextElementSibling,o=n.querySelector(".tooltip-arrow"),i=[Xt(6),jt(),Yt({padding:5})];o&&i.push($t({element:o}));function r(){ce(t,n,{placement:e.placement||"top",middleware:i}).then(({x:m,y:a,placement:u,middlewareData:g})=>{if(Object.assign(n.style,{left:"".concat(m,"px"),top:"".concat(a,"px")}),g.arrow){const{x:y,y:x}=g.arrow,A={top:"bottom",right:"left",bottom:"top",left:"right"}[u.split("-")[0]];Object.assign(o.style,{left:y!=null?"".concat(y,"px"):"",top:x!=null?"".concat(x,"px"):"",right:"",bottom:"",[A]:"-4px"})}})}const s=()=>{n.style.display="block",requestAnimationFrame(()=>{n.classList.add("opacity-100","visible")}),r()},c=()=>{n.style.display="",n.classList.remove("opacity-100","visible")},l=()=>{if(n.style.display==="block"){c();return}s()};let f=["mouseenter","focus"],p=["mouseleave","blur"],d=[];e.trigger==="click"&&(f=[],p=["blur"],d=["click"]),f.forEach(m=>{t.addEventListener(m,s)}),p.forEach(m=>{t.addEventListener(m,c)}),d.forEach(m=>{t.addEventListener(m,l)})}}();
|
package/dist/tailtip.mjs
ADDED
|
@@ -0,0 +1,884 @@
|
|
|
1
|
+
var Nt = Object.defineProperty, Vt = Object.defineProperties;
|
|
2
|
+
var Bt = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var Z = Object.getOwnPropertySymbols;
|
|
4
|
+
var gt = Object.prototype.hasOwnProperty, ht = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var pt = (t, e, n) => e in t ? Nt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, b = (t, e) => {
|
|
6
|
+
for (var n in e || (e = {}))
|
|
7
|
+
gt.call(e, n) && pt(t, n, e[n]);
|
|
8
|
+
if (Z)
|
|
9
|
+
for (var n of Z(e))
|
|
10
|
+
ht.call(e, n) && pt(t, n, e[n]);
|
|
11
|
+
return t;
|
|
12
|
+
}, P = (t, e) => Vt(t, Bt(e));
|
|
13
|
+
var rt = (t, e) => {
|
|
14
|
+
var n = {};
|
|
15
|
+
for (var o in t)
|
|
16
|
+
gt.call(t, o) && e.indexOf(o) < 0 && (n[o] = t[o]);
|
|
17
|
+
if (t != null && Z)
|
|
18
|
+
for (var o of Z(t))
|
|
19
|
+
e.indexOf(o) < 0 && ht.call(t, o) && (n[o] = t[o]);
|
|
20
|
+
return n;
|
|
21
|
+
};
|
|
22
|
+
const K = Math.min, j = Math.max, tt = Math.round, V = (t) => ({
|
|
23
|
+
x: t,
|
|
24
|
+
y: t
|
|
25
|
+
}), Ft = {
|
|
26
|
+
left: "right",
|
|
27
|
+
right: "left",
|
|
28
|
+
bottom: "top",
|
|
29
|
+
top: "bottom"
|
|
30
|
+
}, Wt = {
|
|
31
|
+
start: "end",
|
|
32
|
+
end: "start"
|
|
33
|
+
};
|
|
34
|
+
function ct(t, e, n) {
|
|
35
|
+
return j(t, K(e, n));
|
|
36
|
+
}
|
|
37
|
+
function J(t, e) {
|
|
38
|
+
return typeof t == "function" ? t(e) : t;
|
|
39
|
+
}
|
|
40
|
+
function $(t) {
|
|
41
|
+
return t.split("-")[0];
|
|
42
|
+
}
|
|
43
|
+
function Q(t) {
|
|
44
|
+
return t.split("-")[1];
|
|
45
|
+
}
|
|
46
|
+
function vt(t) {
|
|
47
|
+
return t === "x" ? "y" : "x";
|
|
48
|
+
}
|
|
49
|
+
function at(t) {
|
|
50
|
+
return t === "y" ? "height" : "width";
|
|
51
|
+
}
|
|
52
|
+
function ot(t) {
|
|
53
|
+
return ["top", "bottom"].includes($(t)) ? "y" : "x";
|
|
54
|
+
}
|
|
55
|
+
function ut(t) {
|
|
56
|
+
return vt(ot(t));
|
|
57
|
+
}
|
|
58
|
+
function Mt(t, e, n) {
|
|
59
|
+
n === void 0 && (n = !1);
|
|
60
|
+
const o = Q(t), i = ut(t), r = at(i);
|
|
61
|
+
let s = i === "x" ? o === (n ? "end" : "start") ? "right" : "left" : o === "start" ? "bottom" : "top";
|
|
62
|
+
return e.reference[r] > e.floating[r] && (s = et(s)), [s, et(s)];
|
|
63
|
+
}
|
|
64
|
+
function Ht(t) {
|
|
65
|
+
const e = et(t);
|
|
66
|
+
return [lt(t), e, lt(e)];
|
|
67
|
+
}
|
|
68
|
+
function lt(t) {
|
|
69
|
+
return t.replace(/start|end/g, (e) => Wt[e]);
|
|
70
|
+
}
|
|
71
|
+
function $t(t, e, n) {
|
|
72
|
+
const o = ["left", "right"], i = ["right", "left"], r = ["top", "bottom"], s = ["bottom", "top"];
|
|
73
|
+
switch (t) {
|
|
74
|
+
case "top":
|
|
75
|
+
case "bottom":
|
|
76
|
+
return n ? e ? i : o : e ? o : i;
|
|
77
|
+
case "left":
|
|
78
|
+
case "right":
|
|
79
|
+
return e ? r : s;
|
|
80
|
+
default:
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function jt(t, e, n, o) {
|
|
85
|
+
const i = Q(t);
|
|
86
|
+
let r = $t($(t), n === "start", o);
|
|
87
|
+
return i && (r = r.map((s) => s + "-" + i), e && (r = r.concat(r.map(lt)))), r;
|
|
88
|
+
}
|
|
89
|
+
function et(t) {
|
|
90
|
+
return t.replace(/left|right|bottom|top/g, (e) => Ft[e]);
|
|
91
|
+
}
|
|
92
|
+
function _t(t) {
|
|
93
|
+
return b({
|
|
94
|
+
top: 0,
|
|
95
|
+
right: 0,
|
|
96
|
+
bottom: 0,
|
|
97
|
+
left: 0
|
|
98
|
+
}, t);
|
|
99
|
+
}
|
|
100
|
+
function At(t) {
|
|
101
|
+
return typeof t != "number" ? _t(t) : {
|
|
102
|
+
top: t,
|
|
103
|
+
right: t,
|
|
104
|
+
bottom: t,
|
|
105
|
+
left: t
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function nt(t) {
|
|
109
|
+
return P(b({}, t), {
|
|
110
|
+
top: t.y,
|
|
111
|
+
left: t.x,
|
|
112
|
+
right: t.x + t.width,
|
|
113
|
+
bottom: t.y + t.height
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function wt(t, e, n) {
|
|
117
|
+
let {
|
|
118
|
+
reference: o,
|
|
119
|
+
floating: i
|
|
120
|
+
} = t;
|
|
121
|
+
const r = ot(e), s = ut(e), c = at(s), l = $(e), f = r === "y", p = o.x + o.width / 2 - i.width / 2, d = o.y + o.height / 2 - i.height / 2, m = o[c] / 2 - i[c] / 2;
|
|
122
|
+
let a;
|
|
123
|
+
switch (l) {
|
|
124
|
+
case "top":
|
|
125
|
+
a = {
|
|
126
|
+
x: p,
|
|
127
|
+
y: o.y - i.height
|
|
128
|
+
};
|
|
129
|
+
break;
|
|
130
|
+
case "bottom":
|
|
131
|
+
a = {
|
|
132
|
+
x: p,
|
|
133
|
+
y: o.y + o.height
|
|
134
|
+
};
|
|
135
|
+
break;
|
|
136
|
+
case "right":
|
|
137
|
+
a = {
|
|
138
|
+
x: o.x + o.width,
|
|
139
|
+
y: d
|
|
140
|
+
};
|
|
141
|
+
break;
|
|
142
|
+
case "left":
|
|
143
|
+
a = {
|
|
144
|
+
x: o.x - i.width,
|
|
145
|
+
y: d
|
|
146
|
+
};
|
|
147
|
+
break;
|
|
148
|
+
default:
|
|
149
|
+
a = {
|
|
150
|
+
x: o.x,
|
|
151
|
+
y: o.y
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
switch (Q(e)) {
|
|
155
|
+
case "start":
|
|
156
|
+
a[s] -= m * (n && f ? -1 : 1);
|
|
157
|
+
break;
|
|
158
|
+
case "end":
|
|
159
|
+
a[s] += m * (n && f ? -1 : 1);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
return a;
|
|
163
|
+
}
|
|
164
|
+
const Xt = async (t, e, n) => {
|
|
165
|
+
const {
|
|
166
|
+
placement: o = "bottom",
|
|
167
|
+
strategy: i = "absolute",
|
|
168
|
+
middleware: r = [],
|
|
169
|
+
platform: s
|
|
170
|
+
} = n, c = r.filter(Boolean), l = await (s.isRTL == null ? void 0 : s.isRTL(e));
|
|
171
|
+
let f = await s.getElementRects({
|
|
172
|
+
reference: t,
|
|
173
|
+
floating: e,
|
|
174
|
+
strategy: i
|
|
175
|
+
}), {
|
|
176
|
+
x: p,
|
|
177
|
+
y: d
|
|
178
|
+
} = wt(f, o, l), m = o, a = {}, u = 0;
|
|
179
|
+
for (let g = 0; g < c.length; g++) {
|
|
180
|
+
const {
|
|
181
|
+
name: w,
|
|
182
|
+
fn: h
|
|
183
|
+
} = c[g], {
|
|
184
|
+
x: y,
|
|
185
|
+
y: x,
|
|
186
|
+
data: A,
|
|
187
|
+
reset: v
|
|
188
|
+
} = await h({
|
|
189
|
+
x: p,
|
|
190
|
+
y: d,
|
|
191
|
+
initialPlacement: o,
|
|
192
|
+
placement: m,
|
|
193
|
+
strategy: i,
|
|
194
|
+
middlewareData: a,
|
|
195
|
+
rects: f,
|
|
196
|
+
platform: s,
|
|
197
|
+
elements: {
|
|
198
|
+
reference: t,
|
|
199
|
+
floating: e
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
if (p = y != null ? y : p, d = x != null ? x : d, a = P(b({}, a), {
|
|
203
|
+
[w]: b(b({}, a[w]), A)
|
|
204
|
+
}), v && u <= 50) {
|
|
205
|
+
u++, typeof v == "object" && (v.placement && (m = v.placement), v.rects && (f = v.rects === !0 ? await s.getElementRects({
|
|
206
|
+
reference: t,
|
|
207
|
+
floating: e,
|
|
208
|
+
strategy: i
|
|
209
|
+
}) : v.rects), {
|
|
210
|
+
x: p,
|
|
211
|
+
y: d
|
|
212
|
+
} = wt(f, m, l)), g = -1;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
x: p,
|
|
218
|
+
y: d,
|
|
219
|
+
placement: m,
|
|
220
|
+
strategy: i,
|
|
221
|
+
middlewareData: a
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
async function Et(t, e) {
|
|
225
|
+
var n;
|
|
226
|
+
e === void 0 && (e = {});
|
|
227
|
+
const {
|
|
228
|
+
x: o,
|
|
229
|
+
y: i,
|
|
230
|
+
platform: r,
|
|
231
|
+
rects: s,
|
|
232
|
+
elements: c,
|
|
233
|
+
strategy: l
|
|
234
|
+
} = t, {
|
|
235
|
+
boundary: f = "clippingAncestors",
|
|
236
|
+
rootBoundary: p = "viewport",
|
|
237
|
+
elementContext: d = "floating",
|
|
238
|
+
altBoundary: m = !1,
|
|
239
|
+
padding: a = 0
|
|
240
|
+
} = J(e, t), u = At(a), w = c[m ? d === "floating" ? "reference" : "floating" : d], h = nt(await r.getClippingRect({
|
|
241
|
+
element: (n = await (r.isElement == null ? void 0 : r.isElement(w))) == null || n ? w : w.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(c.floating)),
|
|
242
|
+
boundary: f,
|
|
243
|
+
rootBoundary: p,
|
|
244
|
+
strategy: l
|
|
245
|
+
})), y = d === "floating" ? P(b({}, s.floating), {
|
|
246
|
+
x: o,
|
|
247
|
+
y: i
|
|
248
|
+
}) : 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)) || {
|
|
249
|
+
x: 1,
|
|
250
|
+
y: 1
|
|
251
|
+
} : {
|
|
252
|
+
x: 1,
|
|
253
|
+
y: 1
|
|
254
|
+
}, v = nt(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
255
|
+
rect: y,
|
|
256
|
+
offsetParent: x,
|
|
257
|
+
strategy: l
|
|
258
|
+
}) : y);
|
|
259
|
+
return {
|
|
260
|
+
top: (h.top - v.top + u.top) / A.y,
|
|
261
|
+
bottom: (v.bottom - h.bottom + u.bottom) / A.y,
|
|
262
|
+
left: (h.left - v.left + u.left) / A.x,
|
|
263
|
+
right: (v.right - h.right + u.right) / A.x
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
const Yt = (t) => ({
|
|
267
|
+
name: "arrow",
|
|
268
|
+
options: t,
|
|
269
|
+
async fn(e) {
|
|
270
|
+
const {
|
|
271
|
+
x: n,
|
|
272
|
+
y: o,
|
|
273
|
+
placement: i,
|
|
274
|
+
rects: r,
|
|
275
|
+
platform: s,
|
|
276
|
+
elements: c,
|
|
277
|
+
middlewareData: l
|
|
278
|
+
} = e, {
|
|
279
|
+
element: f,
|
|
280
|
+
padding: p = 0
|
|
281
|
+
} = J(t, e) || {};
|
|
282
|
+
if (f == null)
|
|
283
|
+
return {};
|
|
284
|
+
const d = At(p), m = {
|
|
285
|
+
x: n,
|
|
286
|
+
y: o
|
|
287
|
+
}, a = ut(i), u = at(a), g = await s.getDimensions(f), w = a === "y", h = w ? "top" : "left", y = w ? "bottom" : "right", x = w ? "clientHeight" : "clientWidth", A = r.reference[u] + r.reference[a] - m[a] - r.floating[u], v = m[a] - r.reference[a], W = await (s.getOffsetParent == null ? void 0 : s.getOffsetParent(f));
|
|
288
|
+
let O = W ? W[x] : 0;
|
|
289
|
+
(!O || !await (s.isElement == null ? void 0 : s.isElement(W))) && (O = c.floating[x] || r.floating[u]);
|
|
290
|
+
const M = A / 2 - v / 2, Y = O / 2 - g[u] / 2 - 1, q = K(d[h], Y), I = K(d[y], Y), H = q, T = O - g[u] - I, R = O / 2 - g[u] / 2 + M, D = ct(H, R, T), L = !l.arrow && Q(i) != null && R != D && r.reference[u] / 2 - (R < H ? q : I) - g[u] / 2 < 0, S = L ? R < H ? R - H : R - T : 0;
|
|
291
|
+
return {
|
|
292
|
+
[a]: m[a] + S,
|
|
293
|
+
data: b({
|
|
294
|
+
[a]: D,
|
|
295
|
+
centerOffset: R - D - S
|
|
296
|
+
}, L && {
|
|
297
|
+
alignmentOffset: S
|
|
298
|
+
}),
|
|
299
|
+
reset: L
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}), qt = function(t) {
|
|
303
|
+
return t === void 0 && (t = {}), {
|
|
304
|
+
name: "flip",
|
|
305
|
+
options: t,
|
|
306
|
+
async fn(e) {
|
|
307
|
+
var n, o;
|
|
308
|
+
const {
|
|
309
|
+
placement: i,
|
|
310
|
+
middlewareData: r,
|
|
311
|
+
rects: s,
|
|
312
|
+
initialPlacement: c,
|
|
313
|
+
platform: l,
|
|
314
|
+
elements: f
|
|
315
|
+
} = e, H = J(t, e), {
|
|
316
|
+
mainAxis: p = !0,
|
|
317
|
+
crossAxis: d = !0,
|
|
318
|
+
fallbackPlacements: m,
|
|
319
|
+
fallbackStrategy: a = "bestFit",
|
|
320
|
+
fallbackAxisSideDirection: u = "none",
|
|
321
|
+
flipAlignment: g = !0
|
|
322
|
+
} = H, w = rt(H, [
|
|
323
|
+
"mainAxis",
|
|
324
|
+
"crossAxis",
|
|
325
|
+
"fallbackPlacements",
|
|
326
|
+
"fallbackStrategy",
|
|
327
|
+
"fallbackAxisSideDirection",
|
|
328
|
+
"flipAlignment"
|
|
329
|
+
]);
|
|
330
|
+
if ((n = r.arrow) != null && n.alignmentOffset)
|
|
331
|
+
return {};
|
|
332
|
+
const h = $(i), y = $(c) === c, x = await (l.isRTL == null ? void 0 : l.isRTL(f.floating)), A = m || (y || !g ? [et(c)] : Ht(c));
|
|
333
|
+
!m && u !== "none" && A.push(...jt(c, g, u, x));
|
|
334
|
+
const v = [c, ...A], W = await Et(e, w), O = [];
|
|
335
|
+
let M = ((o = r.flip) == null ? void 0 : o.overflows) || [];
|
|
336
|
+
if (p && O.push(W[h]), d) {
|
|
337
|
+
const T = Mt(i, s, x);
|
|
338
|
+
O.push(W[T[0]], W[T[1]]);
|
|
339
|
+
}
|
|
340
|
+
if (M = [...M, {
|
|
341
|
+
placement: i,
|
|
342
|
+
overflows: O
|
|
343
|
+
}], !O.every((T) => T <= 0)) {
|
|
344
|
+
var Y, q;
|
|
345
|
+
const T = (((Y = r.flip) == null ? void 0 : Y.index) || 0) + 1, R = v[T];
|
|
346
|
+
if (R)
|
|
347
|
+
return {
|
|
348
|
+
data: {
|
|
349
|
+
index: T,
|
|
350
|
+
overflows: M
|
|
351
|
+
},
|
|
352
|
+
reset: {
|
|
353
|
+
placement: R
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
let D = (q = M.filter((L) => L.overflows[0] <= 0).sort((L, S) => L.overflows[1] - S.overflows[1])[0]) == null ? void 0 : q.placement;
|
|
357
|
+
if (!D)
|
|
358
|
+
switch (a) {
|
|
359
|
+
case "bestFit": {
|
|
360
|
+
var I;
|
|
361
|
+
const L = (I = M.map((S) => [S.placement, S.overflows.filter((z) => z > 0).reduce((z, Dt) => z + Dt, 0)]).sort((S, z) => S[1] - z[1])[0]) == null ? void 0 : I[0];
|
|
362
|
+
L && (D = L);
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
case "initialPlacement":
|
|
366
|
+
D = c;
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
if (i !== D)
|
|
370
|
+
return {
|
|
371
|
+
reset: {
|
|
372
|
+
placement: D
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
return {};
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
async function It(t, e) {
|
|
381
|
+
const {
|
|
382
|
+
placement: n,
|
|
383
|
+
platform: o,
|
|
384
|
+
elements: i
|
|
385
|
+
} = t, r = await (o.isRTL == null ? void 0 : o.isRTL(i.floating)), s = $(n), c = Q(n), l = ot(n) === "y", f = ["left", "top"].includes(s) ? -1 : 1, p = r && l ? -1 : 1, d = J(e, t);
|
|
386
|
+
let {
|
|
387
|
+
mainAxis: m,
|
|
388
|
+
crossAxis: a,
|
|
389
|
+
alignmentAxis: u
|
|
390
|
+
} = typeof d == "number" ? {
|
|
391
|
+
mainAxis: d,
|
|
392
|
+
crossAxis: 0,
|
|
393
|
+
alignmentAxis: null
|
|
394
|
+
} : b({
|
|
395
|
+
mainAxis: 0,
|
|
396
|
+
crossAxis: 0,
|
|
397
|
+
alignmentAxis: null
|
|
398
|
+
}, d);
|
|
399
|
+
return c && typeof u == "number" && (a = c === "end" ? u * -1 : u), l ? {
|
|
400
|
+
x: a * p,
|
|
401
|
+
y: m * f
|
|
402
|
+
} : {
|
|
403
|
+
x: m * f,
|
|
404
|
+
y: a * p
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
const zt = function(t) {
|
|
408
|
+
return t === void 0 && (t = 0), {
|
|
409
|
+
name: "offset",
|
|
410
|
+
options: t,
|
|
411
|
+
async fn(e) {
|
|
412
|
+
var n, o;
|
|
413
|
+
const {
|
|
414
|
+
x: i,
|
|
415
|
+
y: r,
|
|
416
|
+
placement: s,
|
|
417
|
+
middlewareData: c
|
|
418
|
+
} = e, l = await It(e, t);
|
|
419
|
+
return s === ((n = c.offset) == null ? void 0 : n.placement) && (o = c.arrow) != null && o.alignmentOffset ? {} : {
|
|
420
|
+
x: i + l.x,
|
|
421
|
+
y: r + l.y,
|
|
422
|
+
data: P(b({}, l), {
|
|
423
|
+
placement: s
|
|
424
|
+
})
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
};
|
|
428
|
+
}, Kt = function(t) {
|
|
429
|
+
return t === void 0 && (t = {}), {
|
|
430
|
+
name: "shift",
|
|
431
|
+
options: t,
|
|
432
|
+
async fn(e) {
|
|
433
|
+
const {
|
|
434
|
+
x: n,
|
|
435
|
+
y: o,
|
|
436
|
+
placement: i
|
|
437
|
+
} = e, w = J(t, e), {
|
|
438
|
+
mainAxis: r = !0,
|
|
439
|
+
crossAxis: s = !1,
|
|
440
|
+
limiter: c = {
|
|
441
|
+
fn: (h) => {
|
|
442
|
+
let {
|
|
443
|
+
x: y,
|
|
444
|
+
y: x
|
|
445
|
+
} = h;
|
|
446
|
+
return {
|
|
447
|
+
x: y,
|
|
448
|
+
y: x
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
} = w, l = rt(w, [
|
|
453
|
+
"mainAxis",
|
|
454
|
+
"crossAxis",
|
|
455
|
+
"limiter"
|
|
456
|
+
]), f = {
|
|
457
|
+
x: n,
|
|
458
|
+
y: o
|
|
459
|
+
}, p = await Et(e, l), d = ot($(i)), m = vt(d);
|
|
460
|
+
let a = f[m], u = f[d];
|
|
461
|
+
if (r) {
|
|
462
|
+
const h = m === "y" ? "top" : "left", y = m === "y" ? "bottom" : "right", x = a + p[h], A = a - p[y];
|
|
463
|
+
a = ct(x, a, A);
|
|
464
|
+
}
|
|
465
|
+
if (s) {
|
|
466
|
+
const h = d === "y" ? "top" : "left", y = d === "y" ? "bottom" : "right", x = u + p[h], A = u - p[y];
|
|
467
|
+
u = ct(x, u, A);
|
|
468
|
+
}
|
|
469
|
+
const g = c.fn(P(b({}, e), {
|
|
470
|
+
[m]: a,
|
|
471
|
+
[d]: u
|
|
472
|
+
}));
|
|
473
|
+
return P(b({}, g), {
|
|
474
|
+
data: {
|
|
475
|
+
x: g.x - n,
|
|
476
|
+
y: g.y - o
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
};
|
|
481
|
+
};
|
|
482
|
+
function B(t) {
|
|
483
|
+
return Ct(t) ? (t.nodeName || "").toLowerCase() : "#document";
|
|
484
|
+
}
|
|
485
|
+
function E(t) {
|
|
486
|
+
var e;
|
|
487
|
+
return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
|
|
488
|
+
}
|
|
489
|
+
function F(t) {
|
|
490
|
+
var e;
|
|
491
|
+
return (e = (Ct(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
|
|
492
|
+
}
|
|
493
|
+
function Ct(t) {
|
|
494
|
+
return t instanceof Node || t instanceof E(t).Node;
|
|
495
|
+
}
|
|
496
|
+
function N(t) {
|
|
497
|
+
return t instanceof Element || t instanceof E(t).Element;
|
|
498
|
+
}
|
|
499
|
+
function k(t) {
|
|
500
|
+
return t instanceof HTMLElement || t instanceof E(t).HTMLElement;
|
|
501
|
+
}
|
|
502
|
+
function xt(t) {
|
|
503
|
+
return typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof E(t).ShadowRoot;
|
|
504
|
+
}
|
|
505
|
+
function U(t) {
|
|
506
|
+
const {
|
|
507
|
+
overflow: e,
|
|
508
|
+
overflowX: n,
|
|
509
|
+
overflowY: o,
|
|
510
|
+
display: i
|
|
511
|
+
} = C(t);
|
|
512
|
+
return /auto|scroll|overlay|hidden|clip/.test(e + o + n) && !["inline", "contents"].includes(i);
|
|
513
|
+
}
|
|
514
|
+
function Gt(t) {
|
|
515
|
+
return ["table", "td", "th"].includes(B(t));
|
|
516
|
+
}
|
|
517
|
+
function dt(t) {
|
|
518
|
+
const e = mt(), n = C(t);
|
|
519
|
+
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));
|
|
520
|
+
}
|
|
521
|
+
function Jt(t) {
|
|
522
|
+
let e = X(t);
|
|
523
|
+
for (; k(e) && !it(e); ) {
|
|
524
|
+
if (dt(e))
|
|
525
|
+
return e;
|
|
526
|
+
e = X(e);
|
|
527
|
+
}
|
|
528
|
+
return null;
|
|
529
|
+
}
|
|
530
|
+
function mt() {
|
|
531
|
+
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
|
|
532
|
+
}
|
|
533
|
+
function it(t) {
|
|
534
|
+
return ["html", "body", "#document"].includes(B(t));
|
|
535
|
+
}
|
|
536
|
+
function C(t) {
|
|
537
|
+
return E(t).getComputedStyle(t);
|
|
538
|
+
}
|
|
539
|
+
function st(t) {
|
|
540
|
+
return N(t) ? {
|
|
541
|
+
scrollLeft: t.scrollLeft,
|
|
542
|
+
scrollTop: t.scrollTop
|
|
543
|
+
} : {
|
|
544
|
+
scrollLeft: t.pageXOffset,
|
|
545
|
+
scrollTop: t.pageYOffset
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function X(t) {
|
|
549
|
+
if (B(t) === "html")
|
|
550
|
+
return t;
|
|
551
|
+
const e = (
|
|
552
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
553
|
+
t.assignedSlot || // DOM Element detected.
|
|
554
|
+
t.parentNode || // ShadowRoot detected.
|
|
555
|
+
xt(t) && t.host || // Fallback.
|
|
556
|
+
F(t)
|
|
557
|
+
);
|
|
558
|
+
return xt(e) ? e.host : e;
|
|
559
|
+
}
|
|
560
|
+
function Ot(t) {
|
|
561
|
+
const e = X(t);
|
|
562
|
+
return it(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : k(e) && U(e) ? e : Ot(e);
|
|
563
|
+
}
|
|
564
|
+
function ft(t, e, n) {
|
|
565
|
+
var o;
|
|
566
|
+
e === void 0 && (e = []), n === void 0 && (n = !0);
|
|
567
|
+
const i = Ot(t), r = i === ((o = t.ownerDocument) == null ? void 0 : o.body), s = E(i);
|
|
568
|
+
return r ? e.concat(s, s.visualViewport || [], U(i) ? i : [], s.frameElement && n ? ft(s.frameElement) : []) : e.concat(i, ft(i, [], n));
|
|
569
|
+
}
|
|
570
|
+
function Tt(t) {
|
|
571
|
+
const e = C(t);
|
|
572
|
+
let n = parseFloat(e.width) || 0, o = parseFloat(e.height) || 0;
|
|
573
|
+
const i = k(t), r = i ? t.offsetWidth : n, s = i ? t.offsetHeight : o, c = tt(n) !== r || tt(o) !== s;
|
|
574
|
+
return c && (n = r, o = s), {
|
|
575
|
+
width: n,
|
|
576
|
+
height: o,
|
|
577
|
+
$: c
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
function Rt(t) {
|
|
581
|
+
return N(t) ? t : t.contextElement;
|
|
582
|
+
}
|
|
583
|
+
function _(t) {
|
|
584
|
+
const e = Rt(t);
|
|
585
|
+
if (!k(e))
|
|
586
|
+
return V(1);
|
|
587
|
+
const n = e.getBoundingClientRect(), {
|
|
588
|
+
width: o,
|
|
589
|
+
height: i,
|
|
590
|
+
$: r
|
|
591
|
+
} = Tt(e);
|
|
592
|
+
let s = (r ? tt(n.width) : n.width) / o, c = (r ? tt(n.height) : n.height) / i;
|
|
593
|
+
return (!s || !Number.isFinite(s)) && (s = 1), (!c || !Number.isFinite(c)) && (c = 1), {
|
|
594
|
+
x: s,
|
|
595
|
+
y: c
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
const Qt = /* @__PURE__ */ V(0);
|
|
599
|
+
function Lt(t) {
|
|
600
|
+
const e = E(t);
|
|
601
|
+
return !mt() || !e.visualViewport ? Qt : {
|
|
602
|
+
x: e.visualViewport.offsetLeft,
|
|
603
|
+
y: e.visualViewport.offsetTop
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
function Ut(t, e, n) {
|
|
607
|
+
return e === void 0 && (e = !1), !n || e && n !== E(t) ? !1 : e;
|
|
608
|
+
}
|
|
609
|
+
function G(t, e, n, o) {
|
|
610
|
+
e === void 0 && (e = !1), n === void 0 && (n = !1);
|
|
611
|
+
const i = t.getBoundingClientRect(), r = Rt(t);
|
|
612
|
+
let s = V(1);
|
|
613
|
+
e && (o ? N(o) && (s = _(o)) : s = _(t));
|
|
614
|
+
const c = Ut(r, n, o) ? Lt(r) : V(0);
|
|
615
|
+
let l = (i.left + c.x) / s.x, f = (i.top + c.y) / s.y, p = i.width / s.x, d = i.height / s.y;
|
|
616
|
+
if (r) {
|
|
617
|
+
const m = E(r), a = o && N(o) ? E(o) : o;
|
|
618
|
+
let u = m.frameElement;
|
|
619
|
+
for (; u && o && a !== m; ) {
|
|
620
|
+
const g = _(u), w = u.getBoundingClientRect(), h = C(u), y = w.left + (u.clientLeft + parseFloat(h.paddingLeft)) * g.x, x = w.top + (u.clientTop + parseFloat(h.paddingTop)) * g.y;
|
|
621
|
+
l *= g.x, f *= g.y, p *= g.x, d *= g.y, l += y, f += x, u = E(u).frameElement;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return nt({
|
|
625
|
+
width: p,
|
|
626
|
+
height: d,
|
|
627
|
+
x: l,
|
|
628
|
+
y: f
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
function Zt(t) {
|
|
632
|
+
let {
|
|
633
|
+
rect: e,
|
|
634
|
+
offsetParent: n,
|
|
635
|
+
strategy: o
|
|
636
|
+
} = t;
|
|
637
|
+
const i = k(n), r = F(n);
|
|
638
|
+
if (n === r)
|
|
639
|
+
return e;
|
|
640
|
+
let s = {
|
|
641
|
+
scrollLeft: 0,
|
|
642
|
+
scrollTop: 0
|
|
643
|
+
}, c = V(1);
|
|
644
|
+
const l = V(0);
|
|
645
|
+
if ((i || !i && o !== "fixed") && ((B(n) !== "body" || U(r)) && (s = st(n)), k(n))) {
|
|
646
|
+
const f = G(n);
|
|
647
|
+
c = _(n), l.x = f.x + n.clientLeft, l.y = f.y + n.clientTop;
|
|
648
|
+
}
|
|
649
|
+
return {
|
|
650
|
+
width: e.width * c.x,
|
|
651
|
+
height: e.height * c.y,
|
|
652
|
+
x: e.x * c.x - s.scrollLeft * c.x + l.x,
|
|
653
|
+
y: e.y * c.y - s.scrollTop * c.y + l.y
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
function te(t) {
|
|
657
|
+
return Array.from(t.getClientRects());
|
|
658
|
+
}
|
|
659
|
+
function St(t) {
|
|
660
|
+
return G(F(t)).left + st(t).scrollLeft;
|
|
661
|
+
}
|
|
662
|
+
function ee(t) {
|
|
663
|
+
const e = F(t), n = st(t), o = t.ownerDocument.body, i = j(e.scrollWidth, e.clientWidth, o.scrollWidth, o.clientWidth), r = j(e.scrollHeight, e.clientHeight, o.scrollHeight, o.clientHeight);
|
|
664
|
+
let s = -n.scrollLeft + St(t);
|
|
665
|
+
const c = -n.scrollTop;
|
|
666
|
+
return C(o).direction === "rtl" && (s += j(e.clientWidth, o.clientWidth) - i), {
|
|
667
|
+
width: i,
|
|
668
|
+
height: r,
|
|
669
|
+
x: s,
|
|
670
|
+
y: c
|
|
671
|
+
};
|
|
672
|
+
}
|
|
673
|
+
function ne(t, e) {
|
|
674
|
+
const n = E(t), o = F(t), i = n.visualViewport;
|
|
675
|
+
let r = o.clientWidth, s = o.clientHeight, c = 0, l = 0;
|
|
676
|
+
if (i) {
|
|
677
|
+
r = i.width, s = i.height;
|
|
678
|
+
const f = mt();
|
|
679
|
+
(!f || f && e === "fixed") && (c = i.offsetLeft, l = i.offsetTop);
|
|
680
|
+
}
|
|
681
|
+
return {
|
|
682
|
+
width: r,
|
|
683
|
+
height: s,
|
|
684
|
+
x: c,
|
|
685
|
+
y: l
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
function oe(t, e) {
|
|
689
|
+
const n = G(t, !0, e === "fixed"), o = n.top + t.clientTop, i = n.left + t.clientLeft, r = k(t) ? _(t) : V(1), s = t.clientWidth * r.x, c = t.clientHeight * r.y, l = i * r.x, f = o * r.y;
|
|
690
|
+
return {
|
|
691
|
+
width: s,
|
|
692
|
+
height: c,
|
|
693
|
+
x: l,
|
|
694
|
+
y: f
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
function yt(t, e, n) {
|
|
698
|
+
let o;
|
|
699
|
+
if (e === "viewport")
|
|
700
|
+
o = ne(t, n);
|
|
701
|
+
else if (e === "document")
|
|
702
|
+
o = ee(F(t));
|
|
703
|
+
else if (N(e))
|
|
704
|
+
o = oe(e, n);
|
|
705
|
+
else {
|
|
706
|
+
const i = Lt(t);
|
|
707
|
+
o = P(b({}, e), {
|
|
708
|
+
x: e.x - i.x,
|
|
709
|
+
y: e.y - i.y
|
|
710
|
+
});
|
|
711
|
+
}
|
|
712
|
+
return nt(o);
|
|
713
|
+
}
|
|
714
|
+
function Pt(t, e) {
|
|
715
|
+
const n = X(t);
|
|
716
|
+
return n === e || !N(n) || it(n) ? !1 : C(n).position === "fixed" || Pt(n, e);
|
|
717
|
+
}
|
|
718
|
+
function ie(t, e) {
|
|
719
|
+
const n = e.get(t);
|
|
720
|
+
if (n)
|
|
721
|
+
return n;
|
|
722
|
+
let o = ft(t, [], !1).filter((c) => N(c) && B(c) !== "body"), i = null;
|
|
723
|
+
const r = C(t).position === "fixed";
|
|
724
|
+
let s = r ? X(t) : t;
|
|
725
|
+
for (; N(s) && !it(s); ) {
|
|
726
|
+
const c = C(s), l = dt(s);
|
|
727
|
+
!l && c.position === "fixed" && (i = null), (r ? !l && !i : !l && c.position === "static" && !!i && ["absolute", "fixed"].includes(i.position) || U(s) && !l && Pt(t, s)) ? o = o.filter((p) => p !== s) : i = c, s = X(s);
|
|
728
|
+
}
|
|
729
|
+
return e.set(t, o), o;
|
|
730
|
+
}
|
|
731
|
+
function se(t) {
|
|
732
|
+
let {
|
|
733
|
+
element: e,
|
|
734
|
+
boundary: n,
|
|
735
|
+
rootBoundary: o,
|
|
736
|
+
strategy: i
|
|
737
|
+
} = t;
|
|
738
|
+
const s = [...n === "clippingAncestors" ? ie(e, this._c) : [].concat(n), o], c = s[0], l = s.reduce((f, p) => {
|
|
739
|
+
const d = yt(e, p, i);
|
|
740
|
+
return f.top = j(d.top, f.top), f.right = K(d.right, f.right), f.bottom = K(d.bottom, f.bottom), f.left = j(d.left, f.left), f;
|
|
741
|
+
}, yt(e, c, i));
|
|
742
|
+
return {
|
|
743
|
+
width: l.right - l.left,
|
|
744
|
+
height: l.bottom - l.top,
|
|
745
|
+
x: l.left,
|
|
746
|
+
y: l.top
|
|
747
|
+
};
|
|
748
|
+
}
|
|
749
|
+
function re(t) {
|
|
750
|
+
return Tt(t);
|
|
751
|
+
}
|
|
752
|
+
function ce(t, e, n) {
|
|
753
|
+
const o = k(e), i = F(e), r = n === "fixed", s = G(t, !0, r, e);
|
|
754
|
+
let c = {
|
|
755
|
+
scrollLeft: 0,
|
|
756
|
+
scrollTop: 0
|
|
757
|
+
};
|
|
758
|
+
const l = V(0);
|
|
759
|
+
if (o || !o && !r)
|
|
760
|
+
if ((B(e) !== "body" || U(i)) && (c = st(e)), o) {
|
|
761
|
+
const f = G(e, !0, r, e);
|
|
762
|
+
l.x = f.x + e.clientLeft, l.y = f.y + e.clientTop;
|
|
763
|
+
} else
|
|
764
|
+
i && (l.x = St(i));
|
|
765
|
+
return {
|
|
766
|
+
x: s.left + c.scrollLeft - l.x,
|
|
767
|
+
y: s.top + c.scrollTop - l.y,
|
|
768
|
+
width: s.width,
|
|
769
|
+
height: s.height
|
|
770
|
+
};
|
|
771
|
+
}
|
|
772
|
+
function bt(t, e) {
|
|
773
|
+
return !k(t) || C(t).position === "fixed" ? null : e ? e(t) : t.offsetParent;
|
|
774
|
+
}
|
|
775
|
+
function kt(t, e) {
|
|
776
|
+
const n = E(t);
|
|
777
|
+
if (!k(t))
|
|
778
|
+
return n;
|
|
779
|
+
let o = bt(t, e);
|
|
780
|
+
for (; o && Gt(o) && C(o).position === "static"; )
|
|
781
|
+
o = bt(o, e);
|
|
782
|
+
return o && (B(o) === "html" || B(o) === "body" && C(o).position === "static" && !dt(o)) ? n : o || Jt(t) || n;
|
|
783
|
+
}
|
|
784
|
+
const le = async function(t) {
|
|
785
|
+
let {
|
|
786
|
+
reference: e,
|
|
787
|
+
floating: n,
|
|
788
|
+
strategy: o
|
|
789
|
+
} = t;
|
|
790
|
+
const i = this.getOffsetParent || kt, r = this.getDimensions;
|
|
791
|
+
return {
|
|
792
|
+
reference: ce(e, await i(n), o),
|
|
793
|
+
floating: b({
|
|
794
|
+
x: 0,
|
|
795
|
+
y: 0
|
|
796
|
+
}, await r(n))
|
|
797
|
+
};
|
|
798
|
+
};
|
|
799
|
+
function fe(t) {
|
|
800
|
+
return C(t).direction === "rtl";
|
|
801
|
+
}
|
|
802
|
+
const ae = {
|
|
803
|
+
convertOffsetParentRelativeRectToViewportRelativeRect: Zt,
|
|
804
|
+
getDocumentElement: F,
|
|
805
|
+
getClippingRect: se,
|
|
806
|
+
getOffsetParent: kt,
|
|
807
|
+
getElementRects: le,
|
|
808
|
+
getClientRects: te,
|
|
809
|
+
getDimensions: re,
|
|
810
|
+
getScale: _,
|
|
811
|
+
isElement: N,
|
|
812
|
+
isRTL: fe
|
|
813
|
+
}, ue = (t, e, n) => {
|
|
814
|
+
const o = /* @__PURE__ */ new Map(), i = b({
|
|
815
|
+
platform: ae
|
|
816
|
+
}, n), r = P(b({}, i.platform), {
|
|
817
|
+
_c: o
|
|
818
|
+
});
|
|
819
|
+
return Xt(t, e, P(b({}, i), {
|
|
820
|
+
platform: r
|
|
821
|
+
}));
|
|
822
|
+
}, me = function(t, e = {}) {
|
|
823
|
+
const n = t.nextElementSibling, o = n.querySelector(".tooltip-arrow"), i = [
|
|
824
|
+
zt(6),
|
|
825
|
+
qt(),
|
|
826
|
+
Kt({
|
|
827
|
+
padding: 5
|
|
828
|
+
})
|
|
829
|
+
];
|
|
830
|
+
o && i.push(
|
|
831
|
+
Yt({
|
|
832
|
+
element: o
|
|
833
|
+
})
|
|
834
|
+
);
|
|
835
|
+
function r() {
|
|
836
|
+
ue(t, n, {
|
|
837
|
+
placement: e.placement || "top",
|
|
838
|
+
middleware: i
|
|
839
|
+
}).then(({ x: m, y: a, placement: u, middlewareData: g }) => {
|
|
840
|
+
if (Object.assign(n.style, {
|
|
841
|
+
left: "".concat(m, "px"),
|
|
842
|
+
top: "".concat(a, "px")
|
|
843
|
+
}), g.arrow) {
|
|
844
|
+
const { x: w, y: h } = g.arrow, y = {
|
|
845
|
+
top: "bottom",
|
|
846
|
+
right: "left",
|
|
847
|
+
bottom: "top",
|
|
848
|
+
left: "right"
|
|
849
|
+
}[u.split("-")[0]];
|
|
850
|
+
Object.assign(o.style, {
|
|
851
|
+
left: w != null ? "".concat(w, "px") : "",
|
|
852
|
+
top: h != null ? "".concat(h, "px") : "",
|
|
853
|
+
right: "",
|
|
854
|
+
bottom: "",
|
|
855
|
+
[y]: "-4px"
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
}
|
|
860
|
+
const s = () => {
|
|
861
|
+
n.style.display = "block", requestAnimationFrame(() => {
|
|
862
|
+
n.classList.add("opacity-100", "visible");
|
|
863
|
+
}), r();
|
|
864
|
+
}, c = () => {
|
|
865
|
+
n.style.display = "", n.classList.remove("opacity-100", "visible");
|
|
866
|
+
}, l = () => {
|
|
867
|
+
if (n.style.display === "block") {
|
|
868
|
+
c();
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
871
|
+
s();
|
|
872
|
+
};
|
|
873
|
+
let f = ["mouseenter", "focus"], p = ["mouseleave", "blur"], d = [];
|
|
874
|
+
e.trigger === "click" && (f = [], p = ["blur"], d = ["click"]), f.forEach((m) => {
|
|
875
|
+
t.addEventListener(m, s);
|
|
876
|
+
}), p.forEach((m) => {
|
|
877
|
+
t.addEventListener(m, c);
|
|
878
|
+
}), d.forEach((m) => {
|
|
879
|
+
t.addEventListener(m, l);
|
|
880
|
+
});
|
|
881
|
+
};
|
|
882
|
+
export {
|
|
883
|
+
me as default
|
|
884
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "tailtip",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "Tailtip - A tiny Tailwind friendly tooltip library",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"tailtip",
|
|
11
|
+
"tooltips",
|
|
12
|
+
"tailwind tooltips"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"main": "dist/tailtip.umd.cjs",
|
|
16
|
+
"unpkg": "dist/tailtip.iife.js",
|
|
17
|
+
"jsdelivr": "dist/tailtip.iife.js",
|
|
18
|
+
"module": "./dist/tailtip.js",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./dist/tailtip.js",
|
|
22
|
+
"require": "./dist/tailtip.umd.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/versoly/tailtip.git"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/versoly/tailtip/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://versoly.com/tailtip",
|
|
33
|
+
"contributors": [
|
|
34
|
+
"Volkan Kaya <volkan@versoly.com>"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"dev": "vite",
|
|
38
|
+
"build": "vite build"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@floating-ui/dom": "1.5.3"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"vite": "^5.0.6"
|
|
45
|
+
},
|
|
46
|
+
"author": "Versoly"
|
|
47
|
+
}
|