UNPKG

@thebase/ui

Version:

CDN-installable Owl and Bootstrap 5 UI component library.

2 lines (1 loc) • 2.94 kB
import{a as I,b as K,c as L,d as N,e as j}from"./chunk-MAWHENWJ.js";import{c as A}from"./chunk-K2ROPYIW.js";import{n as R,t as q}from"./chunk-R43NMSZO.js";import{P as B,T as F,U as H,ea as M}from"./chunk-XNCXGIZE.js";import{f as e,g as i,h as s}from"./chunk-23NN352E.js";var g,y,x,m,d,p,l,k,P,u,a,f,$,w,z,X=(z=class{constructor(n){i(this,g);i(this,y);i(this,x);i(this,m);i(this,d);i(this,p);i(this,l);i(this,k);i(this,P);i(this,u);i(this,a);i(this,f);i(this,$);i(this,w);s(this,p,!1),this.onShow=()=>{},this.onHide=()=>{},s(this,a,t=>{j(t,this.element,{placement:e(this,m).placement??"top",middleware:[N(),K(e(this,k)),L(e(this,P)),...e(this,x)],...e(this,m)}).then(({x:o,y:h})=>{Object.assign(this.element.style,{left:`${o}px`,top:`${h}px`})}).catch(console.error)}),s(this,f,t=>e(this,d)!==t.dom.parentElement),s(this,$,(t,o)=>{var _;let{state:h,composing:c}=t,{selection:r,doc:O}=h,{ranges:T}=r,E=Math.min(...T.map(C=>C.$from.pos)),S=Math.max(...T.map(C=>C.$to.pos)),U=o&&o.doc.eq(O)&&o.selection.eq(r);if(e(this,p)||((e(this,d)??t.dom.parentElement??document.body).appendChild(this.element),s(this,p,!0)),c||U)return;if((_=e(this,l))==null||_.call(this),s(this,l,void 0),!e(this,y).call(this,t,o)){this.hide();return}let b={getBoundingClientRect:()=>M(t,E,S),contextElement:t.dom};e(this,f).call(this,t)?s(this,l,I(b,this.element,()=>e(this,a).call(this,b))):e(this,a).call(this,b),this.show()}),this.update=(t,o)=>{e(this,u).call(this,t,o)},s(this,w,t=>{let{doc:o,selection:h}=t.state,{empty:c,from:r,to:O}=h,T=!o.textBetween(r,O).length&&t.state.selection instanceof B,E=this.element.contains(document.activeElement),S=!t.hasFocus()&&!E,U=!t.editable;return!(S||c||T||U)}),this.destroy=()=>{var t;(t=e(this,l))==null||t.call(this),e(this,u).cancel()},this.show=(t,o)=>{var h;if(this.element.dataset.show="true",t){(h=e(this,l))==null||h.call(this),s(this,l,void 0);let c={...t,contextElement:o?.dom};o&&e(this,f).call(this,o)?s(this,l,I(c,this.element,()=>e(this,a).call(this,c))):e(this,a).call(this,c)}this.onShow()},this.hide=()=>{this.element.dataset.show!=="false"&&(this.element.dataset.show="false",this.onHide())},this.element=n.content,s(this,g,n.debounce??200),s(this,y,n.shouldShow??e(this,w)),s(this,k,n.offset),s(this,P,n.shift),s(this,x,n.middleware??[]),s(this,m,n.floatingUIOptions??{}),s(this,d,n.root),this.element.dataset.show="false",s(this,u,A(e(this,$),e(this,g)))}},g=new WeakMap,y=new WeakMap,x=new WeakMap,m=new WeakMap,d=new WeakMap,p=new WeakMap,l=new WeakMap,k=new WeakMap,P=new WeakMap,u=new WeakMap,a=new WeakMap,f=new WeakMap,$=new WeakMap,w=new WeakMap,z);function Y(n){let t=q({},`${n}_TOOLTIP_SPEC`),o=R(c=>{let r=c.get(t.key);return new F({key:new H(`${n}_TOOLTIP`),...r})}),h=[t,o];return h.key=t.key,h.pluginKey=o.key,t.meta={package:"@milkdown/plugin-tooltip",displayName:`Ctx<tooltipSpec>|${n}`},o.meta={package:"@milkdown/plugin-tooltip",displayName:`Prose<tooltip>|${n}`},h}export{X as a,Y as b};