@farris/ui-vue 1.8.5-beta.18 → 1.8.5-beta.19

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.
@@ -1 +1 @@
1
- (function(b,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(b=typeof globalThis<"u"?globalThis:b||self,e(b.tooltip={},b.Vue))})(this,function(b,e){"use strict";const R={content:{type:Object,default:""},contentTemplate:{type:Object},width:{type:String},customClass:{type:String},placement:{type:String,default:"top"},trigger:{type:String,default:"hover"},reference:{type:Object,require:!0},horizontalRelative:{type:String,default:""},verticalRelative:{type:String,default:""},clickToHide:{type:Boolean,default:!0},enable:{type:Boolean,default:!0},overflowShown:{type:Boolean,default:!1}};function Y(){const t=e.ref(!1);return e.onMounted(()=>{t.value=!0}),t}function K(t,o){const i=new Map([["top","bottom"],["bottom","top"],["left","right"],["right","left"]]),r=new Map([["top","height"],["bottom","height"],["left","width"],["right","width"]]);function p(n,l){const d=i.get(l)||l;return n.replace(l,d)}function a(n,l,d,c,u){let m=n;const f=n.split("-")[0],h=r.get(f),v=c[h]+u[h];return Math.abs(d[f]-l[f])<v&&(m=p(n,f)),m}return{adjustPlacement:a}}function Q(t,o){function r(a,n,l){let d=!1,c=l;return(n==="left"||n==="top")&&l<=a[n]&&(d=!0,c=a[n]+6),(n==="right"||n==="bottom")&&l>=a[n]&&(d=!0,c=a[n]-6),{overBound:d,fixedValue:c}}function p(a,n,l,d,c,u,m){let f=n.tooltip.left,h=n.tooltip.top,v=n.arrow.left,y=n.arrow.top;const w=a.split("-")[0];if(["top","bottom"].includes(w)){const L=r(l,"left",n.tooltip.left),P=r(l,"right",n.tooltip.left+c.width);f=L.overBound?L.fixedValue:P.overBound?P.fixedValue-c.width:n.tooltip.left,v=L.overBound?c.width-(f+c.width-d.right)-m.width:P.overBound?d.left-f:n.arrow.left}const T=r(l,"top",n.tooltip.top),k=r(l,"bottom",n.tooltip.top+c.height);return h=T.overBound?T.fixedValue:k.overBound?k.fixedValue-c.height:n.tooltip.top,y=T.overBound?n.arrow.top:k.overBound?c.height-(h+c.height-d.top):n.arrow.top,{arrow:{left:v,top:y},tooltip:{left:f,top:h}}}return{adjustPosition:p}}function Z(t,o){function r(n,l,d,c,u){const m=n.split("-"),f=m[0],h=m[1]||"middle",v=["top","bottom"].includes(f)?h==="middle"?(c.width-u.width)/2:h==="right"?c.width-u.width-6:6:0,y=["left","right"].includes(f)?h==="middle"?(c.height-u.height)/2:h==="bottom"?c.height-u.height-6:6:0,E=f==="left"?c.width+u.width:0,w=f==="top"?c.height+u.height:0;return{left:E+v,top:w+y,right:0}}function p(n,l,d,c,u){const m=n.split("-"),f=m[0],h=m[1]||"middle",v=(d.width-c.width)/2,y=(d.height-c.height)/2,E=f==="right"?l.right:l.left,w=f==="bottom"?l.bottom:l.top,T=f==="top"?0-y-c.height-u.height:f==="bottom"?0-y+u.height:0,k=["left","right"].includes(f)?h==="middle"?(l.height-c.height)/2:h==="bottom"?l.height-c.height:0:0,V=f==="left"?0-v-c.width-u.width:f==="right"?0-v+u.width:0,j=["top","bottom"].includes(f)?h==="middle"?(l.width-c.width)/2:h==="right"?l.width-c.width:0:0,L=w+T+k;return{left:E+V+j,top:L}}function a(n,l,d,c,u){const m=p(n,l,d,c,u);return{arrow:r(n,l,d,c,u),tooltip:m}}return{calculate:a}}function W(t){const o=e.isRef(t)?t.value:t;return typeof o=="string"?o==="body"||typeof document>"u"?"body":document.querySelector(o)||"body":!!o&&typeof o.getBoundingClientRect=="function"&&typeof o.insertBefore=="function"?o:"body"}function tt(t){return typeof document>"u"?null:t==="body"?document.body:t}function z(t,o){const i=tt(t);if(!i){const u=typeof window<"u"?window.innerHeight:0;return{left:0,top:0,width:0,height:u,bottom:u,scrollLeft:0,scrollTop:0}}const r=i.getBoundingClientRect(),p=t==="body"||i===document.body,a=typeof window<"u"?window.innerHeight:r.height;let{width:n}=r;const{top:l}=r;let{bottom:d,height:c}=r;if(p){const u=Math.max(r.top,0),m=Math.min(r.bottom,a);d=m,c=Math.max(m-u,0)||a,d<=u&&(d=a)}return{left:r.left,top:l,width:n,height:c,bottom:d,scrollLeft:i.scrollLeft||0,scrollTop:i.scrollTop||0}}function et(t){const o=z(t);return{left:o.left-o.scrollLeft,top:o.top-o.scrollTop}}function ot(t,o){const i=e.ref(t.horizontalRelative),r=e.ref(t.verticalRelative);function p(l){return typeof l=="string"?document.querySelector(l):l}function a(){return z(W("body"))}function n(){const l=a(),d=document.documentElement.clientWidth,c=document.documentElement.clientHeight;let u=Math.max(l.left,0),m=Math.max(l.top,0),f=Math.min(l.left+l.width,d),h=Math.min(l.bottom,c),v=u,y=m,E=f-u,w=h-m;return i.value&&({left:u,right:f,x:v,width:E}=p(i.value).getBoundingClientRect()),r.value&&({bottom:h,top:m,y,height:w}=p(r.value).getBoundingClientRect()),{top:m,left:u,right:f,bottom:h,height:w,width:E,x:v,y}}return{getRelativeElementBound:n}}function nt(t,o,i,r,p,a){const n=e.ref(t.placement),{getRelativeElementBound:l}=ot(t),{calculate:d}=Z(),{adjustPlacement:c}=K(),{adjustPosition:u}=Q(),m=e.computed(()=>n.value.split("-")[0]),f=e.computed(()=>{const h=l();n.value=c(n.value,h,i,r,a);const v=d(n.value,i,r,p,a);return u(n.value,v,h,i,r,p,a)});return{tooltipPlacement:m,tooltipPosition:f}}function it(t){const o=e.ref(),i=e.ref(!1),r=e.computed(()=>({display:i.value?"block":"none"})),p=e.computed(()=>{var n;const a=(n=t.customClass)==null?void 0:n.split(" ");return a==null?void 0:a.reduce((l,d)=>(l[d]=!0,l),{})});return{showTooltip:i,tooltipDisplayStyle:r,tooltipCustomClass:p,tooltipContainerRef:o}}const O=e.defineComponent({name:"FTooltip",props:R,emits:["click"],setup(t,o){const i=e.ref(),r=e.ref(),p=e.ref(),a=e.ref(),n=e.ref(),l=e.ref(t.placement.split("-")[0]),d=it(t),{showTooltip:c,tooltipCustomClass:u}=d,m=e.ref(!1),f=Y(),h=e.computed(()=>{let s={"fv-tooltip":!0,tooltip:!0,show:!0};const g=`bs-tooltip-${l.value}`;return s[g]=!0,o.slots.default&&(s={...s,...u.value}),s}),v=s=>{s.target!==n.value&&(s.stopPropagation(),document.body.removeEventListener("click",v),c.value=!1)},y=e.computed(()=>t.content&&!t.contentTemplate),E=e.computed(()=>t.content),w=e.ref("0px"),T=e.ref("0px"),k=e.computed(()=>{const s={left:w.value,top:T.value};return o.slots.default,s}),V=e.ref(""),j=e.ref(""),L=e.computed(()=>({left:V.value,top:j.value})),P=e.computed(()=>({"tooltip-inner":!0,"tooltip-inner-lg":a.value&&a.value&&a.value.scrollHeight>a.value.clientHeight})),_=e.computed(()=>{const s={};return t.width&&Object.assign(s,{width:t.width,"max-width":"none"}),s}),G=s=>{r.value&&p.value&&a.value&&(P.value,e.nextTick(()=>{const{tooltipPlacement:g,tooltipPosition:S}=nt(t,o,s.getBoundingClientRect(),p.value.getBoundingClientRect(),a.value.getBoundingClientRect(),r.value.getBoundingClientRect()),C=et(W("body"));w.value=`${S.value.tooltip.left-C.left}px`,T.value=`${S.value.tooltip.top-C.top}px`,V.value=`${S.value.arrow.left}px`,j.value=`${S.value.arrow.top}px`,l.value=g.value}))},H=s=>{var S;const g=(S=i.value)==null?void 0:S.nextElementSibling;g&&(t.overflowShown&&g.scrollWidth===g.clientWidth||(s.stopPropagation(),c.value=!0,e.nextTick(()=>{G(g)}),t.trigger==="click"&&document.body.addEventListener("click",v)))},J=(s,g=!0)=>{s.removeEventListener("mouseenter",H),s.removeEventListener("mouseleave",v),g&&(s.addEventListener("mouseenter",H),s.addEventListener("mouseleave",v))};function U(s,g=!0){s.removeEventListener("mouseenter",H),s.removeEventListener("mouseleave",v),g&&s.addEventListener("click",H)}function A(){var g;if(!t.enable)return;const s=(g=i.value)==null?void 0:g.nextElementSibling;s&&(t.trigger==="click"&&U(s),t.trigger==="hover"&&J(s))}function st(){var g;const s=(g=i.value)==null?void 0:g.nextElementSibling;s&&(t.trigger==="click"&&U(s,!1),t.trigger==="hover"&&J(s,!1))}e.watch(()=>t.enable,s=>{s?A():st()});function at(){i.value&&i.value.nodeName==="#text"&&!i.value.nextElementSibling&&(m.value=!0,e.nextTick(()=>{A()}))}e.onMounted(()=>{at(),A(),!y.value&&t.contentTemplate&&n.value&&n.value.appendChild(t.contentTemplate),t.reference&&G(t.reference)});function X(s){o.emit("click",s)}const ut=()=>e.createVNode("div",{ref:p,class:h.value,style:k.value,onClick:X},[e.createVNode("div",{ref:r,class:"arrow",style:L.value},null),e.createVNode("div",{ref:a,class:P.value,style:_.value},[e.createVNode("div",{class:"tooltip-tmpl"},[y.value&&e.createVNode("div",{class:"tooltip-text",innerHTML:E.value},null),!y.value&&e.createVNode("div",{class:"tooltip-text",ref:n},null)])])]);function ft(){const s={class:"tooltip-text",ref:n};if(o.slots.contentTemplate)return e.createVNode("div",s,[o.slots.contentTemplate()]);if(t.content){let g=t.content;return typeof t.content=="function"&&(g=t.content()),e.createVNode("div",e.mergeProps(s,{innerHTML:g}),null)}return e.createVNode("div",s,null)}const dt=()=>e.createVNode("div",{ref:p,class:h.value,style:k.value,onClick:X},[e.createVNode("div",{ref:r,class:"arrow",style:L.value},null),e.createVNode("div",{ref:a,class:P.value,style:_.value},[e.createVNode("div",{class:"tooltip-tmpl"},[ft()])])]);function pt(){var s,g,S,C;return m.value?e.createVNode("span",null,[(g=(s=o.slots).default)==null?void 0:g.call(s)]):(C=(S=o.slots).default)==null?void 0:C.call(S)}return()=>o.slots.default?e.createVNode(e.Fragment,{ref:i},[pt(),f.value&&e.createVNode(e.Teleport,{to:"body"},{default:()=>[c.value&&dt()]})]):ut()}});function lt(t,o){const i=document.createElement("div");t.customClass&&(i.className=t.customClass);const r=e.createApp({setup(){function p(){t.clickToHide&&r.unmount()}return e.onUnmounted(()=>{document.body.removeChild(i)}),()=>e.createVNode(O,e.mergeProps(t,{onClick:p}),null)}});return document.body.appendChild(i),r.mount(i),r}function D(t){const o=e.reactive({...t});return lt(o)}const x=new WeakMap;function F(t){if(!t)return;const o=x.get(t);o&&(o.unmount(),x.delete(t))}function rt(t,o){let i;t.addEventListener("mouseenter",r=>{if(o.value.enable!==!1&&!(o.value.overflowShown&&t.scrollWidth===t.clientWidth)&&(r.stopPropagation(),!i)){const p=t.dataset.tooltip&&JSON.parse(t.dataset.tooltip)||{},a=Object.assign({reference:t,contentTemplate:o.value.contentTemplate},p);i=D(a),x.set(t,i)}}),t.addEventListener("mouseleave",r=>{r.stopPropagation(),i&&(x.delete(t),i.unmount(),i=null)})}let B=null;const M="_farris-tooltip-directive_";function N(){document.querySelectorAll(`.${M}`).forEach(t=>{F(t)})}function ct(t,o){t.addEventListener("click",i=>{if(o.value.enable===!1||o.value.overflowShown===!0&&t.scrollWidth===t.clientWidth)return;i.stopPropagation();let r=x.get(t);if(r)r.unmount(),x.delete(t);else{N();const p=t.dataset.tooltip&&JSON.parse(t.dataset.tooltip)||{},a=Object.assign({trigger:"hover",reference:t},p);r=D(a),x.set(t,r)}})}function I(t,o){if(!o.value)t.dataset.tooltip="";else{const{contentTemplate:i,...r}=o.value;t.dataset.tooltip=JSON.stringify(r)}}function $(t,o){o.value.trigger==="click"||F(t)}const q={mounted:(t,o,i)=>{switch(t.classList.add(M),I(t,o),o.value.trigger){case"click":{ct(t,o);break}default:rt(t,o)}},beforeUnmount:(t,o,i)=>{$(t,o)},unmounted:(t,o,i)=>{$(t,o)},beforeUpdate:(t,o)=>{I(t,o)}};typeof window<"u"&&(window.clearAllTooltips=N),typeof document<"u"&&document.body&&(document.body.removeEventListener("click",B,!0),document.body.addEventListener("click",B=t=>{const o=t.target,i=o.closest(`.${M}`);i&&x.has(i)||o.closest(".tooltip")||N()},!0)),O.install=t=>{t.component(O.name,O),t.directive("tooltip",q)},b.FTooltip=O,b.FTooltipDirective=q,b.default=O,b.tooltipProps=R,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
1
+ (function(b,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(b=typeof globalThis<"u"?globalThis:b||self,e(b.tooltip={},b.Vue))})(this,function(b,e){"use strict";const R={content:{type:Object,default:""},contentTemplate:{type:Object},width:{type:String},customClass:{type:String},placement:{type:String,default:"top"},trigger:{type:String,default:"hover"},reference:{type:Object,require:!0},horizontalRelative:{type:String,default:""},verticalRelative:{type:String,default:""},clickToHide:{type:Boolean,default:!0},enable:{type:Boolean,default:!0},overflowShown:{type:Boolean,default:!1}};function G(){const t=e.ref(!1);return e.onMounted(()=>{t.value=!0}),t}function J(t,o){const n=new Map([["top","bottom"],["bottom","top"],["left","right"],["right","left"]]),l=new Map([["top","height"],["bottom","height"],["left","width"],["right","width"]]);function u(i,r){const f=n.get(r)||r;return i.replace(r,f)}function s(i,r,f,c,d){let h=i;const p=i.split("-")[0],m=l.get(p),v=c[m]+d[m];return Math.abs(f[p]-r[p])<v&&(h=u(i,p)),h}return{adjustPlacement:s}}function U(t,o){function l(s,i,r){let f=!1,c=r;return(i==="left"||i==="top")&&r<=s[i]&&(f=!0,c=s[i]+6),(i==="right"||i==="bottom")&&r>=s[i]&&(f=!0,c=s[i]-6),{overBound:f,fixedValue:c}}function u(s,i,r,f,c,d,h){let p=i.tooltip.left,m=i.tooltip.top,v=i.arrow.left,y=i.arrow.top;const w=s.split("-")[0];if(["top","bottom"].includes(w)){const x=l(r,"left",i.tooltip.left),P=l(r,"right",i.tooltip.left+c.width);p=x.overBound?x.fixedValue:P.overBound?P.fixedValue-c.width:i.tooltip.left,v=x.overBound?c.width-(p+c.width-f.right)-h.width:P.overBound?f.left-p:i.arrow.left}const T=l(r,"top",i.tooltip.top),L=l(r,"bottom",i.tooltip.top+c.height);return m=T.overBound?T.fixedValue:L.overBound?L.fixedValue-c.height:i.tooltip.top,y=T.overBound?i.arrow.top:L.overBound?c.height-(m+c.height-f.top):i.arrow.top,{arrow:{left:v,top:y},tooltip:{left:p,top:m}}}return{adjustPosition:u}}function K(t,o){function l(i,r,f,c,d){const h=i.split("-"),p=h[0],m=h[1]||"middle",v=["top","bottom"].includes(p)?m==="middle"?(c.width-d.width)/2:m==="right"?c.width-d.width-6:6:0,y=["left","right"].includes(p)?m==="middle"?(c.height-d.height)/2:m==="bottom"?c.height-d.height-6:6:0,k=p==="left"?c.width+d.width:0,w=p==="top"?c.height+d.height:0;return{left:k+v,top:w+y,right:0}}function u(i,r,f,c,d){const h=i.split("-"),p=h[0],m=h[1]||"middle",v=(f.width-c.width)/2,y=(f.height-c.height)/2,k=p==="right"?r.right:r.left,w=p==="bottom"?r.bottom:r.top,T=p==="top"?0-y-c.height-d.height:p==="bottom"?0-y+d.height:0,L=["left","right"].includes(p)?m==="middle"?(r.height-c.height)/2:m==="bottom"?r.height-c.height:0:0,V=p==="left"?0-v-c.width-d.width:p==="right"?0-v+d.width:0,j=["top","bottom"].includes(p)?m==="middle"?(r.width-c.width)/2:m==="right"?r.width-c.width:0:0,x=w+T+L;return{left:k+V+j,top:x}}function s(i,r,f,c,d){const h=u(i,r,f,c,d);return{arrow:l(i,r,f,c,d),tooltip:h}}return{calculate:s}}function Q(t){const o=e.isRef(t)?t.value:t;return typeof o=="string"?o==="body"||typeof document>"u"?"body":document.querySelector(o)||"body":!!o&&typeof o.getBoundingClientRect=="function"&&typeof o.insertBefore=="function"?o:"body"}function Z(t){return typeof document>"u"?null:t==="body"?document.body:t}function tt(t,o){const n=Z(t);if(!n){const d=typeof window<"u"?window.innerHeight:0;return{left:0,top:0,width:0,height:d,bottom:d,scrollLeft:0,scrollTop:0}}const l=n.getBoundingClientRect(),u=t==="body"||n===document.body,s=typeof window<"u"?window.innerHeight:l.height;let{width:i}=l;const{top:r}=l;let{bottom:f,height:c}=l;if(u){const d=Math.max(l.top,0),h=Math.min(l.bottom,s);f=h,c=Math.max(h-d,0)||s,f<=d&&(f=s)}return{left:l.left,top:r,width:i,height:c,bottom:f,scrollLeft:n.scrollLeft||0,scrollTop:n.scrollTop||0}}function et(t){const o=t.ownerDocument,n=t.offsetParent;if(!n)return null;if(n===o.body||n===o.documentElement){const u=(o.defaultView||window).getComputedStyle(n),s=r=>!!r&&r!=="none";if(!(u.position!=="static"||s(u.transform)||s(u.filter)||s(u.perspective)))return null}return n}function ot(t,o,n){const l=et(t);if(!l){const s=t.ownerDocument,i=s.defaultView||window,r=s.documentElement,f=(i.scrollX??r.scrollLeft)||0,c=(i.scrollY??r.scrollTop)||0;return{left:o+f,top:n+c}}const u=l.getBoundingClientRect();return{left:o-u.left-(l.clientLeft||0)+(l.scrollLeft||0),top:n-u.top-(l.clientTop||0)+(l.scrollTop||0)}}function nt(t,o){const n=e.ref(t.horizontalRelative),l=e.ref(t.verticalRelative);function u(r){return typeof r=="string"?document.querySelector(r):r}function s(){return tt(Q("body"))}function i(){const r=s(),f=document.documentElement.clientWidth,c=document.documentElement.clientHeight;let d=Math.max(r.left,0),h=Math.max(r.top,0),p=Math.min(r.left+r.width,f),m=Math.min(r.bottom,c),v=d,y=h,k=p-d,w=m-h;return n.value&&({left:d,right:p,x:v,width:k}=u(n.value).getBoundingClientRect()),l.value&&({bottom:m,top:h,y,height:w}=u(l.value).getBoundingClientRect()),{top:h,left:d,right:p,bottom:m,height:w,width:k,x:v,y}}return{getRelativeElementBound:i}}function it(t,o,n,l,u,s){const i=e.ref(t.placement),{getRelativeElementBound:r}=nt(t),{calculate:f}=K(),{adjustPlacement:c}=J(),{adjustPosition:d}=U(),h=e.computed(()=>i.value.split("-")[0]),p=e.computed(()=>{const m=r();i.value=c(i.value,m,n,l,s);const v=f(i.value,n,l,u,s);return d(i.value,v,m,n,l,u,s)});return{tooltipPlacement:h,tooltipPosition:p}}function lt(t){const o=e.ref(),n=e.ref(!1),l=e.computed(()=>({display:n.value?"block":"none"})),u=e.computed(()=>{var i;const s=(i=t.customClass)==null?void 0:i.split(" ");return s==null?void 0:s.reduce((r,f)=>(r[f]=!0,r),{})});return{showTooltip:n,tooltipDisplayStyle:l,tooltipCustomClass:u,tooltipContainerRef:o}}const C=e.defineComponent({name:"FTooltip",props:R,emits:["click"],setup(t,o){const n=e.ref(),l=e.ref(),u=e.ref(),s=e.ref(),i=e.ref(),r=e.ref(t.placement.split("-")[0]),f=lt(t),{showTooltip:c,tooltipCustomClass:d}=f,h=e.ref(!1),p=G(),m=e.computed(()=>{let a={"fv-tooltip":!0,tooltip:!0,show:!0};const g=`bs-tooltip-${r.value}`;return a[g]=!0,o.slots.default&&(a={...a,...d.value}),a}),v=a=>{a.target!==i.value&&(a.stopPropagation(),document.body.removeEventListener("click",v),c.value=!1)},y=e.computed(()=>t.content&&!t.contentTemplate),k=e.computed(()=>t.content),w=e.ref("0px"),T=e.ref("0px"),L=e.computed(()=>{const a={left:w.value,top:T.value};return o.slots.default,a}),V=e.ref(""),j=e.ref(""),x=e.computed(()=>({left:V.value,top:j.value})),P=e.computed(()=>({"tooltip-inner":!0,"tooltip-inner-lg":s.value&&s.value&&s.value.scrollHeight>s.value.clientHeight})),$=e.computed(()=>{const a={};return t.width&&Object.assign(a,{width:t.width,"max-width":"none"}),a}),q=a=>{l.value&&u.value&&s.value&&(P.value,e.nextTick(()=>{const{tooltipPlacement:g,tooltipPosition:E}=it(t,o,a.getBoundingClientRect(),u.value.getBoundingClientRect(),s.value.getBoundingClientRect(),l.value.getBoundingClientRect()),M=ot(u.value,E.value.tooltip.left,E.value.tooltip.top);w.value=`${M.left}px`,T.value=`${M.top}px`,V.value=`${E.value.arrow.left}px`,j.value=`${E.value.arrow.top}px`,r.value=g.value}))},H=a=>{var E;const g=(E=n.value)==null?void 0:E.nextElementSibling;g&&(t.overflowShown&&g.scrollWidth===g.clientWidth||(a.stopPropagation(),c.value=!0,e.nextTick(()=>{q(g)}),t.trigger==="click"&&document.body.addEventListener("click",v)))},X=(a,g=!0)=>{a.removeEventListener("mouseenter",H),a.removeEventListener("mouseleave",v),g&&(a.addEventListener("mouseenter",H),a.addEventListener("mouseleave",v))};function Y(a,g=!0){a.removeEventListener("mouseenter",H),a.removeEventListener("mouseleave",v),g&&a.addEventListener("click",H)}function A(){var g;if(!t.enable)return;const a=(g=n.value)==null?void 0:g.nextElementSibling;a&&(t.trigger==="click"&&Y(a),t.trigger==="hover"&&X(a))}function at(){var g;const a=(g=n.value)==null?void 0:g.nextElementSibling;a&&(t.trigger==="click"&&Y(a,!1),t.trigger==="hover"&&X(a,!1))}e.watch(()=>t.enable,a=>{a?A():at()});function ut(){n.value&&n.value.nodeName==="#text"&&!n.value.nextElementSibling&&(h.value=!0,e.nextTick(()=>{A()}))}e.onMounted(()=>{ut(),A(),!y.value&&t.contentTemplate&&i.value&&i.value.appendChild(t.contentTemplate),t.reference&&q(t.reference)});function _(a){o.emit("click",a)}const ft=()=>e.createVNode("div",{ref:u,class:m.value,style:L.value,onClick:_},[e.createVNode("div",{ref:l,class:"arrow",style:x.value},null),e.createVNode("div",{ref:s,class:P.value,style:$.value},[e.createVNode("div",{class:"tooltip-tmpl"},[y.value&&e.createVNode("div",{class:"tooltip-text",innerHTML:k.value},null),!y.value&&e.createVNode("div",{class:"tooltip-text",ref:i},null)])])]);function dt(){const a={class:"tooltip-text",ref:i};if(o.slots.contentTemplate)return e.createVNode("div",a,[o.slots.contentTemplate()]);if(t.content){let g=t.content;return typeof t.content=="function"&&(g=t.content()),e.createVNode("div",e.mergeProps(a,{innerHTML:g}),null)}return e.createVNode("div",a,null)}const pt=()=>e.createVNode("div",{ref:u,class:m.value,style:L.value,onClick:_},[e.createVNode("div",{ref:l,class:"arrow",style:x.value},null),e.createVNode("div",{ref:s,class:P.value,style:$.value},[e.createVNode("div",{class:"tooltip-tmpl"},[dt()])])]);function mt(){var a,g,E,M;return h.value?e.createVNode("span",null,[(g=(a=o.slots).default)==null?void 0:g.call(a)]):(M=(E=o.slots).default)==null?void 0:M.call(E)}return()=>o.slots.default?e.createVNode(e.Fragment,{ref:n},[mt(),p.value&&e.createVNode(e.Teleport,{to:"body"},{default:()=>[c.value&&pt()]})]):ft()}});function rt(t,o){const n=document.createElement("div");t.customClass&&(n.className=t.customClass);const l=e.createApp({setup(){function u(){t.clickToHide&&l.unmount()}return e.onUnmounted(()=>{document.body.removeChild(n)}),()=>e.createVNode(C,e.mergeProps(t,{onClick:u}),null)}});return document.body.appendChild(n),l.mount(n),l}function B(t){const o=e.reactive({...t});return rt(o)}const S=new WeakMap;function W(t){if(!t)return;const o=S.get(t);o&&(o.unmount(),S.delete(t))}function ct(t,o){let n;t.addEventListener("mouseenter",l=>{if(o.value.enable!==!1&&!(o.value.overflowShown&&t.scrollWidth===t.clientWidth)&&(l.stopPropagation(),!n)){const u=t.dataset.tooltip&&JSON.parse(t.dataset.tooltip)||{},s=Object.assign({reference:t,contentTemplate:o.value.contentTemplate},u);n=B(s),S.set(t,n)}}),t.addEventListener("mouseleave",l=>{l.stopPropagation(),n&&(S.delete(t),n.unmount(),n=null)})}let D=null;const N="_farris-tooltip-directive_";function O(){document.querySelectorAll(`.${N}`).forEach(t=>{W(t)})}function st(t,o){t.addEventListener("click",n=>{if(o.value.enable===!1||o.value.overflowShown===!0&&t.scrollWidth===t.clientWidth)return;n.stopPropagation();let l=S.get(t);if(l)l.unmount(),S.delete(t);else{O();const u=t.dataset.tooltip&&JSON.parse(t.dataset.tooltip)||{},s=Object.assign({trigger:"hover",reference:t},u);l=B(s),S.set(t,l)}})}function z(t,o){if(!o.value)t.dataset.tooltip="";else{const{contentTemplate:n,...l}=o.value;t.dataset.tooltip=JSON.stringify(l)}}function F(t,o){o.value.trigger==="click"||W(t)}const I={mounted:(t,o,n)=>{switch(t.classList.add(N),z(t,o),o.value.trigger){case"click":{st(t,o);break}default:ct(t,o)}},beforeUnmount:(t,o,n)=>{F(t,o)},unmounted:(t,o,n)=>{F(t,o)},beforeUpdate:(t,o)=>{z(t,o)}};typeof window<"u"&&(window.clearAllTooltips=O),typeof document<"u"&&document.body&&(document.body.removeEventListener("click",D,!0),document.body.addEventListener("click",D=t=>{const o=t.target,n=o.closest(`.${N}`);n&&S.has(n)||o.closest(".tooltip")||O()},!0)),C.install=t=>{t.component(C.name,C),t.directive("tooltip",I)},b.FTooltip=C,b.FTooltipDirective=I,b.default=C,b.tooltipProps=R,Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});