12 |
- "use strict";const t=require("./base-component-njT02uAw.js"),vt=require("./index-CK2pD4GQ.js"),Tt=require("./dataBsToggle-Dj-Ng54N.js"),tt=require("./showClass-D_Ms1FgG.js"),N=require("./popupContainer-DTYSNPih.js"),it=require("./fadeClass-Co6nOzNJ.js"),Z="popover",rt="Popover",T="tooltip",ct=s=>{const e=s===T,o=e?`${s}-inner`:`${s}-body`,i=e?"":`<h3 class="${s}-header"></h3>`,l=`<div class="${s}-arrow"></div>`,a=`<div class="${o}"></div>`;return`<div class="${s}" role="${T}">${i+l+a}</div>`},ht={top:"top",bottom:"bottom",left:"start",right:"end"},et=s=>{requestAnimationFrame(()=>{const e=/\b(top|bottom|start|end)+/,{element:o,tooltip:i,container:l,offsetParent:a,options:d,arrow:c}=s;if(!i)return;const f=t.Ho(o),{x:w,y:h}=t.No(a);t.Eo(i,{top:"",left:"",right:"",bottom:""});const{offsetWidth:u,offsetHeight:m}=i,{clientWidth:g,clientHeight:P,offsetWidth:A}=t.w(o);let{placement:n}=d;const{clientWidth:b,offsetWidth:k}=l,p=t.f(l,"position")==="fixed",D=Math.abs(p?b-k:g-A),x=f&&p?D:0,$=g-(f?0:D)-1,V=s._observer.getEntry(o),{width:r,height:v,left:F,right:gt,top:z}=V?.boundingClientRect||t.y(o,!0),{x:I,y:_}=t.Co(o,a,{x:w,y:h});t.Eo(c,{top:"",left:"",right:"",bottom:""});let H=0,O="",y=0,Y="",L="",K="",J="";const S=c.offsetWidth||0,C=c.offsetHeight||0,U=S/2;let q=z-m-C<0,G=z+m+v+C>=P,R=F-u-S<x,M=F+u+r+S>=$;const j=["left","right"],X=["top","bottom"];q=j.includes(n)?z+v/2-m/2-C<0:q,G=j.includes(n)?z+m/2+v/2+C>=P:G,R=X.includes(n)?F+r/2-u/2<x:R,M=X.includes(n)?F+u/2+r/2>=$:M,n=j.includes(n)&&R&&M?"top":n,n=n==="top"&&q?"bottom":n,n=n==="bottom"&&G?"top":n,n=n==="left"&&R?"right":n,n=n==="right"&&M?"left":n,i.className.includes(n)||(i.className=i.className.replace(e,ht[n])),j.includes(n)?(n==="left"?y=I-u-S:y=I+r+S,q&&G?(H=0,O=0,L=_+v/2-C/2):q?(H=_,O="",L=v/2-S):G?(H=_-m+v,O="",L=m-v/2-S):(H=_-m/2+v/2,L=m/2-C/2)):X.includes(n)&&(n==="top"?H=_-m-C:H=_+v+C,R?(y=0,K=I+r/2-U):M?(y="auto",Y=0,J=r/2+$-gt-U):(y=I-u/2+r/2,K=u/2-U)),t.Eo(i,{top:`${H}px`,bottom:O===""?"":`${O}px`,left:y==="auto"?y:`${y}px`,right:Y!==""?`${Y}px`:""}),t.b(c)&&(L!==""&&(c.style.top=`${L}px`),K!==""?c.style.left=`${K}px`:J!==""&&(c.style.right=`${J}px`));const bt=t.mo(`updated.bs.${t.yo(s.name)}`);t.Z(o,bt)})},ot={template:ct(T),title:"",customClass:"",trigger:"hover focus",placement:"top",sanitizeFn:void 0,animation:!0,delay:200,container:document.body,content:"",dismissible:!1,btnClose:""},dt="data-original-title",W="Tooltip",E=(s,e,o)=>{if(t.N(e)&&e.length){let i=e.trim();t.xo(o)&&(i=o(i));const a=new DOMParser().parseFromString(i,"text/html");s.append(...a.body.childNodes)}else t.b(e)?s.append(e):(t.Vo(e)||t.Se(e)&&e.every(t.u))&&s.append(...e)},wt=s=>{const e=s.name===W,{id:o,element:i,options:l}=s,{title:a,placement:d,template:c,animation:f,customClass:w,sanitizeFn:h,dismissible:u,content:m,btnClose:g}=l,P=e?T:Z,A={...ht};let n=[],b=[];t.Ho(i)&&(A.left="end",A.right="start");const k=`bs-${P}-${A[d]}`;let B;if(t.b(c))B=c;else{const r=t.se("div");E(r,c,h),B=r.firstChild}if(!t.b(B))return;s.tooltip=B.cloneNode(!0);const{tooltip:p}=s;t.Qn(p,"id",o),t.Qn(p,"role",T);const D=e?`${T}-inner`:`${Z}-body`,x=e?null:t.Wo(`.${Z}-header`,p),$=t.Wo(`.${D}`,p);s.arrow=t.Wo(`.${P}-arrow`,p);const{arrow:V}=s;if(t.b(a))n=[a.cloneNode(!0)];else{const r=t.se("div");E(r,a,h),n=[...r.childNodes]}if(t.b(m))b=[m.cloneNode(!0)];else{const r=t.se("div");E(r,m,h),b=[...r.childNodes]}if(u)if(a)if(t.b(g))n=[...n,g.cloneNode(!0)];else{const r=t.se("div");E(r,g,h),n=[...n,r.firstChild]}else if(x&&x.remove(),t.b(g))b=[...b,g.cloneNode(!0)];else{const r=t.se("div");E(r,g,h),b=[...b,r.firstChild]}e?a&&$&&E($,a,h):(a&&x&&E(x,n,h),m&&$&&E($,b,h),s.btn=t.Wo(".btn-close",p)||void 0),t.Gn(p,"position-absolute"),t.Gn(V,"position-absolute"),t._n(p,P)||t.Gn(p,P),f&&!t._n(p,it.fadeClass)&&t.Gn(p,it.fadeClass),w&&!t._n(p,w)&&t.Gn(p,w),t._n(p,k)||t.Gn(p,k)},$t=s=>{const e=["HTML","BODY"],o=[];let{parentNode:i}=s;for(;i&&!e.includes(i.nodeName);)i=t.k(i),t.me(i)||t.be(i)||o.push(i);return o.find((l,a)=>(t.f(l,"position")!=="relative"||t.f(l,"position")==="relative"&&l.offsetHeight!==l.scrollHeight)&&o.slice(a+1).every(d=>t.f(d,"position")==="static")?l:null)||t.d(s).body},yt=`[${Tt.dataBsToggle}="${T}"],[data-tip="${T}"]`,pt="title";let st=s=>t.to(s,W);const Ct=s=>new ut(s),Et=s=>{const{element:e,tooltip:o,container:i}=s;t.Kn(e,t.Le),N.removePopup(o,i)},Q=s=>{const{tooltip:e,container:o}=s;return e&&N.hasPopup(e,o)},Pt=(s,e)=>{const{element:o}=s;s._toggleEventListeners(),t.oe(o,dt)&&s.name===W&&mt(s),e&&e()},ft=(s,e)=>{const o=e?t.E:t.r,{element:i}=s;o(t.d(i),t.Qt,s.handleTouch,t.vo)},nt=s=>{const{element:e}=s,o=t.mo(`shown.bs.${t.yo(s.name)}`);ft(s,!0),t.Z(e,o),t.ho.clear(e,"in")},lt=s=>{const{element:e}=s,o=t.mo(`hidden.bs.${t.yo(s.name)}`);ft(s),Et(s),t.Z(e,o),t.ho.clear(e,"out")},at=(s,e)=>{const o=e?t.E:t.r,{element:i,tooltip:l}=s,a=t.Ne(i,`.${N.modalString}`),d=t.Ne(i,`.${N.offcanvasString}`);e?[i,l].forEach(c=>s._observer.observe(c)):s._observer.disconnect(),a&&o(a,`hide.bs.${N.modalString}`,s.handleHide),d&&o(d,`hide.bs.${N.offcanvasString}`,s.handleHide)},mt=(s,e)=>{const o=[dt,pt],{element:i}=s;t.Qn(i,o[e?0:1],e||t.K(i,o[0])||""),t.Kn(i,o[e?1:0])};class ut extends t.BaseComponent{static selector=yt;static init=Ct;static getInstance=st;static styleTip=et;constructor(e,o){super(e,o);const{element:i}=this,l=this.name===W,a=l?T:Z,d=l?W:rt;st=h=>t.to(h,d),this.enabled=!0,this.id=`${a}-${t.Ae(i,a)}`;const{options:c}=this;if(!c.title&&l||!l&&!c.content)return;t.T(ot,{titleAttr:""}),t.oe(i,pt)&&l&&typeof c.title=="string"&&mt(this,c.title);const f=$t(i),w=["sticky","fixed","relative"].some(h=>t.f(f,"position")===h)?f:t.ve(i);this.container=f,this.offsetParent=w,wt(this),this.tooltip&&(this._observer=new vt.y(()=>this.update()),this._toggleEventListeners(!0))}get name(){return W}get defaults(){return ot}handleFocus=()=>t.ao(this.element);handleShow=()=>this.show();show(){const{options:e,tooltip:o,element:i,container:l,id:a}=this,{animation:d}=e,c=t.ho.get(i,"out");t.ho.clear(i,"out"),o&&!c&&!Q(this)&&t.ho.set(i,()=>{const f=t.mo(`show.bs.${t.yo(this.name)}`);t.Z(i,f),f.defaultPrevented||(N.appendPopup(o,l),t.Qn(i,t.Le,`#${a}`),this.update(),at(this,!0),t._n(o,tt.showClass)||t.Gn(o,tt.showClass),d?t.so(o,()=>nt(this)):nt(this))},17,"in")}handleHide=()=>this.hide();hide(){const{options:e,tooltip:o,element:i}=this,{animation:l,delay:a}=e;t.ho.clear(i,"in"),o&&Q(this)&&t.ho.set(i,()=>{const d=t.mo(`hide.bs.${t.yo(this.name)}`);t.Z(i,d),d.defaultPrevented||(this.update(),t.Zn(o,tt.showClass),at(this),l?t.so(o,()=>lt(this)):lt(this))},a+17,"out")}update=()=>{et(this)};toggle=()=>{const{tooltip:e}=this;e&&!Q(this)?this.show():this.hide()};enable(){const{enabled:e}=this;e||(this._toggleEventListeners(!0),this.enabled=!e)}disable(){const{tooltip:e,enabled:o}=this;o&&(e&&Q(this)&&this.hide(),this._toggleEventListeners(),this.enabled=!o)}toggleEnabled(){this.enabled?this.disable():this.enable()}handleTouch=({target:e})=>{const{tooltip:o,element:i}=this;o&&o.contains(e)||e===i||e&&i.contains(e)||this.hide()};_toggleEventListeners=e=>{const o=e?t.E:t.r,{element:i,options:l,btn:a}=this,{trigger:d}=l,f=!!(this.name!==W&&l.dismissible);d.includes("manual")||(this.enabled=!!e,d.split(" ").forEach(h=>{h===t.yt?(o(i,t.Et,this.handleShow),o(i,t.wt,this.handleShow),f||(o(i,t.At,this.handleHide),o(t.d(i),t.Qt,this.handleTouch,t.vo))):h===t.vt?o(i,h,f?this.handleShow:this.toggle):h===t.ct&&(o(i,t.at,this.handleShow),f||o(i,t.it,this.handleHide),t.zn()&&o(i,t.vt,this.handleFocus)),f&&a&&o(a,t.vt,this.handleHide)}))};dispose(){const{tooltip:e,options:o}=this,i={...this,name:this.name},l=()=>setTimeout(()=>Pt(i,()=>super.dispose()),17);o.animation&&Q(i)?(this.options.delay=0,this.hide(),t.so(e,l)):l()}}exports.Tooltip=ut;exports.getTipTemplate=ct;exports.popoverComponent=rt;exports.popoverString=Z;exports.styleTip=et;exports.tooltipDefaults=ot;
- //# sourceMappingURL=tooltip-BLrcblIT.js.map
|