markstream-vue 0.0.3-beta.5 → 0.0.3-beta.7
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/README.md +4 -0
- package/README.zh-CN.md +4 -0
- package/dist/Tooltip.js +1 -0
- package/dist/exports.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +132 -91
- package/dist/index.js +1 -87
- package/dist/index.tailwind.css +1 -1
- package/dist/tailwind.ts +0 -0
- package/dist/workers/katexRenderer.worker.js +1 -45
- package/dist/workers/mermaidParser.worker.js +1 -92
- package/package.json +4 -4
- package/dist/exports-1obt4rfJ.cjs +0 -246
- package/dist/exports-DhNgUzYL.js +0 -5344
- package/dist/index-BDPiDbZr.js +0 -113
- package/dist/index-BS4IAchB.cjs +0 -22
- package/dist/index-Cy9ounEH.js +0 -122
- package/dist/index-DD2YWdWI.cjs +0 -1
- package/dist/index-KPngPBen.cjs +0 -1
- package/dist/index-gpZy9BH3.js +0 -976
- package/dist/index.cjs +0 -1
package/README.md
CHANGED
|
@@ -89,6 +89,10 @@ createApp({
|
|
|
89
89
|
|
|
90
90
|
Import `markstream-vue/index.css` after your reset (e.g., Tailwind `@layer components`) so renderer styles win over utility classes. Install optional peers such as `stream-monaco`, `shiki`, `mermaid`, and `katex` only when you need Monaco code blocks, Shiki highlighting, diagrams, or math.
|
|
91
91
|
|
|
92
|
+
Renderer CSS is scoped under an internal `.markstream-vue` container to minimize global style conflicts. If you render exported node components outside of `MarkdownRender`, wrap them in an element with class `markstream-vue`.
|
|
93
|
+
|
|
94
|
+
For dark theme variables, either add a `.dark` class on an ancestor, or pass `:is-dark="true"` to `MarkdownRender` to scope dark mode to the renderer.
|
|
95
|
+
|
|
92
96
|
Enable heavy peers only when needed:
|
|
93
97
|
|
|
94
98
|
```ts
|
package/README.zh-CN.md
CHANGED
|
@@ -88,6 +88,10 @@ createApp({
|
|
|
88
88
|
|
|
89
89
|
确保在 CSS reset(如 `@tailwind base` 或 `@unocss/reset`)之后导入 `markstream-vue/index.css`,最好放在 `@layer components` 中以避免 Tailwind/UnoCSS 覆盖组件样式。根据需求再按需安装可选 peer 依赖:`stream-monaco`(Monaco 代码块)、`shiki`(Shiki 高亮)、`mermaid`(Mermaid 图表)、`katex`(数学公式)。
|
|
90
90
|
|
|
91
|
+
渲染器的 CSS 会作用于内部 `.markstream-vue` 容器下,以尽量降低对全局的影响;如果你脱离 `MarkdownRender` 单独使用导出的节点组件,请在外层包一层带 `markstream-vue` 类名的容器。
|
|
92
|
+
|
|
93
|
+
暗色变量可以通过给祖先节点加 `.dark`,或直接给 `MarkdownRender` 传入 `:is-dark="true"`(仅对渲染器生效)。
|
|
94
|
+
|
|
91
95
|
按需启用重型依赖:
|
|
92
96
|
|
|
93
97
|
```ts
|
package/dist/Tooltip.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var t=Object.defineProperty,e=Object.defineProperties,n=Object.getOwnPropertyDescriptors,o=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable,l=(e,n,o)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,c=(t,e)=>{for(var n in e||(e={}))i.call(e,n)&&l(t,n,e[n]);if(o)for(var n of o(e))r.call(e,n)&&l(t,n,e[n]);return t},s=(t,o)=>e(t,n(o)),a=(t,e)=>{var n={};for(var l in t)i.call(t,l)&&e.indexOf(l)<0&&(n[l]=t[l]);if(null!=t&&o)for(var l of o(t))e.indexOf(l)<0&&r.call(t,l)&&(n[l]=t[l]);return n},f=(t,e,n)=>new Promise((o,i)=>{var r=t=>{try{c(n.next(t))}catch(e){i(e)}},l=t=>{try{c(n.throw(t))}catch(e){i(e)}},c=t=>t.done?o(t.value):Promise.resolve(t.value).then(r,l);c((n=n.apply(t,e)).next())});import{defineComponent as u,computed as d,ref as p,watch as h,nextTick as m,onBeforeUnmount as y,createBlock as g,openBlock as x,Teleport as v,createVNode as w,Transition as b,withCtx as R,withDirectives as E,createElementVNode as L,normalizeClass as T,normalizeStyle as A,toDisplayString as S,vShow as O}from"vue";import{_ as k}from"./exports.js";const D=Math.min,P=Math.max,C=Math.round,M=Math.floor,F=t=>({x:t,y:t}),B={left:"right",right:"left",bottom:"top",top:"bottom"},W={start:"end",end:"start"};function H(t,e,n){return P(t,D(e,n))}function j(t,e){return"function"==typeof t?t(e):t}function V(t){return t.split("-")[0]}function _(t){return t.split("-")[1]}function N(t){return"x"===t?"y":"x"}function z(t){return"y"===t?"height":"width"}const X=/* @__PURE__ */new Set(["top","bottom"]);function Y(t){return X.has(V(t))?"y":"x"}function $(t){return N(Y(t))}function I(t){return t.replace(/start|end/g,t=>W[t])}const q=["left","right"],G=["right","left"],J=["top","bottom"],K=["bottom","top"];function Q(t){return t.replace(/left|right|bottom|top/g,t=>B[t])}function U(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function Z(t,e,n){let{reference:o,floating:i}=t;const r=Y(e),l=$(e),c=z(l),s=V(e),a="y"===r,f=o.x+o.width/2-i.width/2,u=o.y+o.height/2-i.height/2,d=o[c]/2-i[c]/2;let p;switch(s){case"top":p={x:f,y:o.y-i.height};break;case"bottom":p={x:f,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:u};break;case"left":p={x:o.x-i.width,y:u};break;default:p={x:o.x,y:o.y}}switch(_(e)){case"start":p[l]-=d*(n&&a?-1:1);break;case"end":p[l]+=d*(n&&a?-1:1)}return p}function tt(t,e){return f(this,null,function*(){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:l,elements:s,strategy:a}=t,{boundary:f="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:p=!1,padding:h=0}=j(e,t),m=function(t){return"number"!=typeof t?function(t){return c({top:0,right:0,bottom:0,left:0},t)}(t):{top:t,right:t,bottom:t,left:t}}(h),y=s[p?"floating"===d?"reference":"floating":d],g=U(yield r.getClippingRect({element:null==(n=yield null==r.isElement?void 0:r.isElement(y))||n?y:y.contextElement||(yield null==r.getDocumentElement?void 0:r.getDocumentElement(s.floating)),boundary:f,rootBoundary:u,strategy:a})),x="floating"===d?{x:o,y:i,width:l.floating.width,height:l.floating.height}:l.reference,v=yield null==r.getOffsetParent?void 0:r.getOffsetParent(s.floating),w=(yield null==r.isElement?void 0:r.isElement(v))&&(yield null==r.getScale?void 0:r.getScale(v))||{x:1,y:1},b=U(r.convertOffsetParentRelativeRectToViewportRelativeRect?yield r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:v,strategy:a}):x);return{top:(g.top-b.top+m.top)/w.y,bottom:(b.bottom-g.bottom+m.bottom)/w.y,left:(g.left-b.left+m.left)/w.x,right:(b.right-g.right+m.right)/w.x}})}const et=/* @__PURE__ */new Set(["left","top"]);function nt(){return"undefined"!=typeof window}function ot(t){return lt(t)?(t.nodeName||"").toLowerCase():"#document"}function it(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function rt(t){var e;return null==(e=(lt(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function lt(t){return!!nt()&&(t instanceof Node||t instanceof it(t).Node)}function ct(t){return!!nt()&&(t instanceof Element||t instanceof it(t).Element)}function st(t){return!!nt()&&(t instanceof HTMLElement||t instanceof it(t).HTMLElement)}function at(t){return!(!nt()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof it(t).ShadowRoot)}const ft=/* @__PURE__ */new Set(["inline","contents"]);function ut(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=Et(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&!ft.has(i)}const dt=/* @__PURE__ */new Set(["table","td","th"]);function pt(t){return dt.has(ot(t))}const ht=[":popover-open",":modal"];function mt(t){return ht.some(e=>{try{return t.matches(e)}catch(n){return!1}})}const yt=["transform","translate","scale","rotate","perspective"],gt=["transform","translate","scale","rotate","perspective","filter"],xt=["paint","layout","strict","content"];function vt(t){const e=wt(),n=ct(t)?Et(t):t;return yt.some(t=>!!n[t]&&"none"!==n[t])||!!n.containerType&&"normal"!==n.containerType||!e&&!!n.backdropFilter&&"none"!==n.backdropFilter||!e&&!!n.filter&&"none"!==n.filter||gt.some(t=>(n.willChange||"").includes(t))||xt.some(t=>(n.contain||"").includes(t))}function wt(){return!("undefined"==typeof CSS||!CSS.supports)&&CSS.supports("-webkit-backdrop-filter","none")}const bt=/* @__PURE__ */new Set(["html","body","#document"]);function Rt(t){return bt.has(ot(t))}function Et(t){return it(t).getComputedStyle(t)}function Lt(t){return ct(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Tt(t){if("html"===ot(t))return t;const e=t.assignedSlot||t.parentNode||at(t)&&t.host||rt(t);return at(e)?e.host:e}function At(t){const e=Tt(t);return Rt(e)?t.ownerDocument?t.ownerDocument.body:t.body:st(e)&&ut(e)?e:At(e)}function St(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=At(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=it(i);if(r){const t=Ot(l);return e.concat(l,l.visualViewport||[],ut(i)?i:[],t&&n?St(t):[])}return e.concat(i,St(i,[],n))}function Ot(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function kt(t){const e=Et(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=st(t),r=i?t.offsetWidth:n,l=i?t.offsetHeight:o,c=C(n)!==r||C(o)!==l;return c&&(n=r,o=l),{width:n,height:o,$:c}}function Dt(t){return ct(t)?t:t.contextElement}function Pt(t){const e=Dt(t);if(!st(e))return F(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:r}=kt(e);let l=(r?C(n.width):n.width)/o,c=(r?C(n.height):n.height)/i;return l&&Number.isFinite(l)||(l=1),c&&Number.isFinite(c)||(c=1),{x:l,y:c}}const Ct=/* @__PURE__ */F(0);function Mt(t){const e=it(t);return wt()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:Ct}function Ft(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),r=Dt(t);let l=F(1);e&&(o?ct(o)&&(l=Pt(o)):l=Pt(t));const c=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==it(t))&&e}(r,n,o)?Mt(r):F(0);let s=(i.left+c.x)/l.x,a=(i.top+c.y)/l.y,f=i.width/l.x,u=i.height/l.y;if(r){const t=it(r),e=o&&ct(o)?it(o):o;let n=t,i=Ot(n);for(;i&&o&&e!==n;){const t=Pt(i),e=i.getBoundingClientRect(),o=Et(i),r=e.left+(i.clientLeft+parseFloat(o.paddingLeft))*t.x,l=e.top+(i.clientTop+parseFloat(o.paddingTop))*t.y;s*=t.x,a*=t.y,f*=t.x,u*=t.y,s+=r,a+=l,n=it(i),i=Ot(n)}}return U({width:f,height:u,x:s,y:a})}function Bt(t,e){const n=Lt(t).scrollLeft;return e?e.left+n:Ft(rt(t)).left+n}function Wt(t,e){const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-Bt(t,n),y:n.top+e.scrollTop}}const Ht=/* @__PURE__ */new Set(["absolute","fixed"]);function jt(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=it(t),o=rt(t),i=n.visualViewport;let r=o.clientWidth,l=o.clientHeight,c=0,s=0;if(i){r=i.width,l=i.height;const t=wt();(!t||t&&"fixed"===e)&&(c=i.offsetLeft,s=i.offsetTop)}const a=Bt(o);if(a<=0){const t=o.ownerDocument,e=t.body,n=getComputedStyle(e),i="CSS1Compat"===t.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,l=Math.abs(o.clientWidth-e.clientWidth-i);l<=25&&(r-=l)}else a<=25&&(r+=a);return{width:r,height:l,x:c,y:s}}(t,n);else if("document"===e)o=function(t){const e=rt(t),n=Lt(t),o=t.ownerDocument.body,i=P(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),r=P(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let l=-n.scrollLeft+Bt(t);const c=-n.scrollTop;return"rtl"===Et(o).direction&&(l+=P(e.clientWidth,o.clientWidth)-i),{width:i,height:r,x:l,y:c}}(rt(t));else if(ct(e))o=function(t,e){const n=Ft(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=st(t)?Pt(t):F(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(e,n);else{const n=Mt(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return U(o)}function Vt(t,e){const n=Tt(t);return!(n===e||!ct(n)||Rt(n))&&("fixed"===Et(n).position||Vt(n,e))}function _t(t,e,n){const o=st(e),i=rt(e),r="fixed"===n,l=Ft(t,!0,r,e);let c={scrollLeft:0,scrollTop:0};const s=F(0);function a(){s.x=Bt(i)}if(o||!o&&!r)if(("body"!==ot(e)||ut(i))&&(c=Lt(e)),o){const t=Ft(e,!0,r,e);s.x=t.x+e.clientLeft,s.y=t.y+e.clientTop}else i&&a();r&&!o&&i&&a();const f=!i||o||r?F(0):Wt(i,c);return{x:l.left+c.scrollLeft-s.x-f.x,y:l.top+c.scrollTop-s.y-f.y,width:l.width,height:l.height}}function Nt(t){return"static"===Et(t).position}function zt(t,e){if(!st(t)||"fixed"===Et(t).position)return null;if(e)return e(t);let n=t.offsetParent;return rt(t)===n&&(n=n.ownerDocument.body),n}function Xt(t,e){const n=it(t);if(mt(t))return n;if(!st(t)){let e=Tt(t);for(;e&&!Rt(e);){if(ct(e)&&!Nt(e))return e;e=Tt(e)}return n}let o=zt(t,e);for(;o&&pt(o)&&Nt(o);)o=zt(o,e);return o&&Rt(o)&&Nt(o)&&!vt(o)?n:o||function(t){let e=Tt(t);for(;st(e)&&!Rt(e);){if(vt(e))return e;if(mt(e))return null;e=Tt(e)}return null}(t)||n}const Yt={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const r="fixed"===i,l=rt(o),c=!!e&&mt(e.floating);if(o===l||c&&r)return n;let s={scrollLeft:0,scrollTop:0},a=F(1);const f=F(0),u=st(o);if((u||!u&&!r)&&(("body"!==ot(o)||ut(l))&&(s=Lt(o)),st(o))){const t=Ft(o);a=Pt(o),f.x=t.x+o.clientLeft,f.y=t.y+o.clientTop}const d=!l||u||r?F(0):Wt(l,s);return{width:n.width*a.x,height:n.height*a.y,x:n.x*a.x-s.scrollLeft*a.x+f.x+d.x,y:n.y*a.y-s.scrollTop*a.y+f.y+d.y}},getDocumentElement:rt,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:o,strategy:i}=t;const r=[..."clippingAncestors"===n?mt(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=St(t,[],!1).filter(t=>ct(t)&&"body"!==ot(t)),i=null;const r="fixed"===Et(t).position;let l=r?Tt(t):t;for(;ct(l)&&!Rt(l);){const e=Et(l),n=vt(l);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&Ht.has(i.position)||ut(l)&&!n&&Vt(t,l))?o=o.filter(t=>t!==l):i=e,l=Tt(l)}return e.set(t,o),o}(e,this._c):[].concat(n),o],l=r[0],c=r.reduce((t,n)=>{const o=jt(e,n,i);return t.top=P(o.top,t.top),t.right=D(o.right,t.right),t.bottom=D(o.bottom,t.bottom),t.left=P(o.left,t.left),t},jt(e,l,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}},getOffsetParent:Xt,getElementRects:function(t){return f(this,null,function*(){const e=this.getOffsetParent||Xt,n=this.getDimensions,o=yield n(t.floating);return{reference:_t(t.reference,yield e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}})},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=kt(t);return{width:e,height:n}},getScale:Pt,isElement:ct,isRTL:function(t){return"rtl"===Et(t).direction}};function $t(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function It(t,e,n,o){void 0===o&&(o={});const{ancestorScroll:i=!0,ancestorResize:r=!0,elementResize:l="function"==typeof ResizeObserver,layoutShift:a="function"==typeof IntersectionObserver,animationFrame:f=!1}=o,u=Dt(t),d=i||r?[...u?St(u):[],...St(e)]:[];d.forEach(t=>{i&&t.addEventListener("scroll",n,{passive:!0}),r&&t.addEventListener("resize",n)});const p=u&&a?function(t,e){let n,o=null;const i=rt(t);function r(){var t;clearTimeout(n),null==(t=o)||t.disconnect(),o=null}return function l(a,f){void 0===a&&(a=!1),void 0===f&&(f=1),r();const u=t.getBoundingClientRect(),{left:d,top:p,width:h,height:m}=u;if(a||e(),!h||!m)return;const y={rootMargin:-M(p)+"px "+-M(i.clientWidth-(d+h))+"px "+-M(i.clientHeight-(p+m))+"px "+-M(d)+"px",threshold:P(0,D(1,f))||1};let g=!0;function x(e){const o=e[0].intersectionRatio;if(o!==f){if(!g)return l();o?l(!1,o):n=setTimeout(()=>{l(!1,1e-7)},1e3)}1!==o||$t(u,t.getBoundingClientRect())||l(),g=!1}try{o=new IntersectionObserver(x,s(c({},y),{root:i.ownerDocument}))}catch(v){o=new IntersectionObserver(x,y)}o.observe(t)}(!0),r}(u,n):null;let h,m=-1,y=null;l&&(y=new ResizeObserver(t=>{let[o]=t;o&&o.target===u&&y&&(y.unobserve(e),cancelAnimationFrame(m),m=requestAnimationFrame(()=>{var t;null==(t=y)||t.observe(e)})),n()}),u&&!f&&y.observe(u),y.observe(e));let g=f?Ft(t):null;return f&&function e(){const o=Ft(t);g&&!$t(g,o)&&n(),g=o,h=requestAnimationFrame(e)}(),n(),()=>{var t;d.forEach(t=>{i&&t.removeEventListener("scroll",n),r&&t.removeEventListener("resize",n)}),null==p||p(),null==(t=y)||t.disconnect(),y=null,f&&cancelAnimationFrame(h)}}const qt=function(t){return void 0===t&&(t={}),{name:"shift",options:t,fn(e){return f(this,null,function*(){const{x:n,y:o,placement:i}=e,r=j(t,e),{mainAxis:l=!0,crossAxis:f=!1,limiter:u={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}}}=r,d=a(r,["mainAxis","crossAxis","limiter"]),p={x:n,y:o},h=yield tt(e,d),m=Y(V(i)),y=N(m);let g=p[y],x=p[m];if(l){const t="y"===y?"bottom":"right";g=H(g+h["y"===y?"top":"left"],g,g-h[t])}if(f){const t="y"===m?"bottom":"right";x=H(x+h["y"===m?"top":"left"],x,x-h[t])}const v=u.fn(s(c({},e),{[y]:g,[m]:x}));return s(c({},v),{data:{x:v.x-n,y:v.y-o,enabled:{[y]:l,[m]:f}}})})}}},Gt=function(t){return void 0===t&&(t={}),{name:"flip",options:t,fn(e){return f(this,null,function*(){var n,o;const{placement:i,middlewareData:r,rects:l,initialPlacement:c,platform:s,elements:f}=e,u=j(t,e),{mainAxis:d=!0,crossAxis:p=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:g=!0}=u,x=a(u,["mainAxis","crossAxis","fallbackPlacements","fallbackStrategy","fallbackAxisSideDirection","flipAlignment"]);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const v=V(i),w=Y(c),b=V(c)===c,R=yield null==s.isRTL?void 0:s.isRTL(f.floating),E=h||(b||!g?[Q(c)]:function(t){const e=Q(t);return[I(t),e,I(e)]}(c)),L="none"!==y;!h&&L&&E.push(...function(t,e,n,o){const i=_(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?G:q:e?q:G;case"left":case"right":return e?J:K;default:return[]}}(V(t),"start"===n,o);return i&&(r=r.map(t=>t+"-"+i),e&&(r=r.concat(r.map(I)))),r}(c,g,y,R));const T=[c,...E],A=yield tt(e,x),S=[];let O=(null==(o=r.flip)?void 0:o.overflows)||[];if(d&&S.push(A[v]),p){const t=function(t,e,n){void 0===n&&(n=!1);const o=_(t),i=$(t),r=z(i);let l="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(l=Q(l)),[l,Q(l)]}(i,l,R);S.push(A[t[0]],A[t[1]])}if(O=[...O,{placement:i,overflows:S}],!S.every(t=>t<=0)){var k,D;const t=((null==(k=r.flip)?void 0:k.index)||0)+1,e=T[t];if(e&&("alignment"!==p||w===Y(e)||O.every(t=>Y(t.placement)!==w||t.overflows[0]>0)))return{data:{index:t,overflows:O},reset:{placement:e}};let n=null==(D=O.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:D.placement;if(!n)switch(m){case"bestFit":{var P;const t=null==(P=O.filter(t=>{if(L){const e=Y(t.placement);return e===w||"y"===e}return!0}).map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:P[0];t&&(n=t);break}case"initialPlacement":n=c}if(i!==n)return{reset:{placement:n}}}return{}})}}},Jt=["id"],Kt=/* @__PURE__ */k(/* @__PURE__ */u({__name:"Tooltip",props:{visible:{type:Boolean},anchorEl:{},content:{},placement:{},offset:{},originX:{},originY:{},id:{},isDark:{type:[Boolean,null]}},setup(t){const e=t,n=d(()=>{if(void 0!==e.isDark&&null!==e.isDark)return Boolean(e.isDark);if("undefined"!=typeof document)try{if(document.documentElement.classList.contains("dark"))return!0;if((null==window?void 0:window.matchMedia)&&window.matchMedia("(prefers-color-scheme: dark)").matches)return!0}catch(t){}return!1}),o=p(null),i=p({transform:"translate3d(0px, 0px, 0px)",left:"0px",top:"0px"}),r=p(!1);let l=null;function a(){return f(this,null,function*(){var t,n;if(!e.anchorEl||!o.value)return;const r=[(u=null!=(t=e.offset)?t:8,void 0===u&&(u=0),{name:"offset",options:u,fn(t){return f(this,null,function*(){var e,n;const{x:o,y:i,placement:r,middlewareData:l}=t,a=yield function(t,e){return f(this,null,function*(){const{placement:n,platform:o,elements:i}=t,r=yield null==o.isRTL?void 0:o.isRTL(i.floating),l=V(n),c=_(n),s="y"===Y(n),a=et.has(l)?-1:1,f=r&&s?-1:1,u=j(e,t);let{mainAxis:d,crossAxis:p,alignmentAxis:h}="number"==typeof u?{mainAxis:u,crossAxis:0,alignmentAxis:null}:{mainAxis:u.mainAxis||0,crossAxis:u.crossAxis||0,alignmentAxis:u.alignmentAxis};return c&&"number"==typeof h&&(p="end"===c?-1*h:h),s?{x:p*f,y:d*a}:{x:d*a,y:p*f}})}(t,u);return r===(null==(e=l.offset)?void 0:e.placement)&&null!=(n=l.arrow)&&n.alignmentOffset?{}:{x:o+a.x,y:i+a.y,data:s(c({},a),{placement:r})}})}}),Gt(),qt({padding:8})],{x:l,y:a}=yield((t,e,n)=>{const o=/* @__PURE__ */new Map,i=c({platform:Yt},n),r=s(c({},i.platform),{_c:o});return((t,e,n)=>f(null,null,function*(){const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:l}=n,a=r.filter(Boolean),f=yield null==l.isRTL?void 0:l.isRTL(e);let u=yield l.getElementRects({reference:t,floating:e,strategy:i}),{x:d,y:p}=Z(u,o,f),h=o,m={},y=0;for(let n=0;n<a.length;n++){const{name:r,fn:g}=a[n],{x,y:v,data:w,reset:b}=yield g({x:d,y:p,initialPlacement:o,placement:h,strategy:i,middlewareData:m,rects:u,platform:l,elements:{reference:t,floating:e}});d=null!=x?x:d,p=null!=v?v:p,m=s(c({},m),{[r]:c(c({},m[r]),w)}),b&&y<=50&&(y++,"object"==typeof b&&(b.placement&&(h=b.placement),b.rects&&(u=!0===b.rects?yield l.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:d,y:p}=Z(u,h,f))),n=-1)}return{x:d,y:p,placement:h,strategy:i,middlewareData:m}}))(t,e,s(c({},i),{platform:r}))})(e.anchorEl,o.value,{placement:null!=(n=e.placement)?n:"top",middleware:r,strategy:"fixed"});var u;i.value.transform=`translate3d(${Math.round(l)}px, ${Math.round(a)}px, 0)`,i.value.left="0px",i.value.top="0px"})}return h(()=>e.visible,t=>f(null,null,function*(){if(t)if(r.value=!1,yield m(),e.anchorEl&&o.value)try{const t=e.anchorEl.getBoundingClientRect();yield a();const n=i.value.transform;if(null!=e.originX&&null!=e.originY){const o=Math.abs(Number(e.originX)-t.left),l=Math.abs(Number(e.originY)-t.top);Math.hypot(o,l)>120?(i.value.transform=`translate3d(${Math.round(e.originX)}px, ${Math.round(e.originY)}px, 0)`,yield m(),r.value=!0,yield m(),i.value.transform=n):r.value=!0}else r.value=!0;l=It(e.anchorEl,o.value,a)}catch(n){yield a(),r.value=!0,l=It(e.anchorEl,o.value,a)}else r.value=!0;else r.value=!1,l&&(l(),l=null)})),h([()=>e.anchorEl,()=>e.placement,()=>e.content],()=>f(null,null,function*(){e.visible&&e.anchorEl&&o.value&&(yield m(),yield a())})),y(()=>{l&&l()}),(l,c)=>(x(),g(v,{to:"body"},[w(b,{name:"tooltip",appear:""},{default:R(()=>[E(L("div",{id:e.id,ref_key:"tooltip",ref:o,style:A({position:"fixed",left:i.value.left,top:i.value.top,transform:i.value.transform}),class:T(["z-[9999] inline-block text-base py-2 px-3 rounded-md shadow-md whitespace-nowrap pointer-events-none tooltip-element border",[n.value?"bg-gray-900 text-white border-gray-700 border is-dark":"bg-white text-gray-900 border-gray-200 border"]]),role:"tooltip"},S(t.content),15,Jt),[[O,t.visible&&r.value]])]),_:1})]))}}),[["__scopeId","data-v-993f63aa"]]);export{Kt as default};
|