diff --git a/assets/data/cdn/jsdelivr.yml b/assets/data/cdn/jsdelivr.yml index d4747fee..a50a884f 100644 --- a/assets/data/cdn/jsdelivr.yml +++ b/assets/data/cdn/jsdelivr.yml @@ -18,8 +18,8 @@ libFiles: artalkJS: artalk@latest/dist/Artalk.js # @algolia/autocomplete-js@1.19.9 https://github.com/algolia/autocomplete autocompleteJS: '@algolia/autocomplete-js@1.19.9/dist/umd/index.production.js' - # cell-tooltip@0.3.1 https://github.com/Lruihao/cell-tooltip - cellTooltipJS: cell-tooltip@0.3.1/dist/cell-tooltip.umd.js + # cell-tooltip@0.4.0 https://github.com/Lruihao/cell-tooltip + cellTooltipJS: cell-tooltip@0.4.0/dist/cell-tooltip.umd.js # cell-watermark@1.0.4 https://github.com/Lruihao/watermark cellWatermarkJS: cell-watermark@1.0.4/src/watermark.js # cookieconsent@3.1.1 https://github.com/osano/cookieconsent diff --git a/assets/data/cdn/unpkg.yml b/assets/data/cdn/unpkg.yml index 48f1c6af..a83973b2 100644 --- a/assets/data/cdn/unpkg.yml +++ b/assets/data/cdn/unpkg.yml @@ -18,8 +18,8 @@ libFiles: artalkJS: artalk@latest/dist/Artalk.js # @algolia/autocomplete-js@1.19.9 https://github.com/algolia/autocomplete autocompleteJS: '@algolia/autocomplete-js@1.19.9/dist/umd/index.production.js' - # cell-tooltip@0.3.1 https://github.com/Lruihao/cell-tooltip - cellTooltipJS: cell-tooltip@0.3.1/dist/cell-tooltip.umd.js + # cell-tooltip@0.4.0 https://github.com/Lruihao/cell-tooltip + cellTooltipJS: cell-tooltip@0.4.0/dist/cell-tooltip.umd.js # cell-watermark@1.0.4 https://github.com/Lruihao/watermark cellWatermarkJS: cell-watermark@1.0.4/src/watermark.js # cookieconsent@3.1.1 https://github.com/osano/cookieconsent diff --git a/assets/lib/cell-tooltip/cell-tooltip.umd.js b/assets/lib/cell-tooltip/cell-tooltip.umd.js index d05ccab0..0d428a4f 100644 --- a/assets/lib/cell-tooltip/cell-tooltip.umd.js +++ b/assets/lib/cell-tooltip/cell-tooltip.umd.js @@ -1 +1 @@ -(function(p,l){typeof exports=="object"&&typeof module<"u"?module.exports=l():typeof define=="function"&&define.amd?define(l):(p=typeof globalThis<"u"?globalThis:p||self,p.CellTooltip=l())})(this,(function(){"use strict";const p=".cell-tooltip{position:absolute;z-index:999;pointer-events:none;opacity:0;transform:scale(.97);transition:opacity .12s ease,transform .12s ease;filter:drop-shadow(0 0 4px var(--tooltip-shadow-color, rgba(255, 255, 255, .18)));--tooltip-bg: #111827;--tooltip-color: #f8fafc;--tooltip-arrow-size: 8px}.cell-tooltip[data-theme=auto],.cell-tooltip[data-theme=light]{--tooltip-bg: #ffffff;--tooltip-color: #0f172a;--tooltip-shadow-color: rgba(0, 0, 0, .18)}@media(prefers-color-scheme:dark){.cell-tooltip[data-theme=auto]{--tooltip-bg: #111827;--tooltip-color: #f8fafc;--tooltip-shadow-color: rgba(255, 255, 255, .18)}}.cell-tooltip.show{opacity:1;transform:scale(1)}.cell-tooltip-inner{max-width:240px;padding:6px 10px;border-radius:8px;font-size:12px;line-height:1.35;color:var(--tooltip-color);background:var(--tooltip-bg);text-align:center;word-wrap:break-word}.cell-tooltip-arrow{position:absolute;width:0;height:0;transform:translate(-50%,-50%)}.cell-tooltip[data-placement=top] .cell-tooltip-arrow{bottom:calc(-1 * var(--tooltip-arrow-size));border-left:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid transparent;border-top:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=bottom] .cell-tooltip-arrow{top:0;border-left:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=left] .cell-tooltip-arrow{right:calc(-1 * var(--tooltip-arrow-size));border-top:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid transparent;border-left:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=right] .cell-tooltip-arrow{left:0;border-top:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid var(--tooltip-bg)}",l={placement:"top",trigger:"hover focus",theme:"dark",offset:8,html:!1},w={show:120,hide:80},v=["top","bottom","right","left"],m=new WeakMap;let b=0;function x(o){return b+=1,`${o}-${b}`}function T(o){return o instanceof HTMLElement}function L(o){return typeof o=="number"?{show:o,hide:o}:{show:o?.show??w.show,hide:o?.hide??w.hide}}function z(o){const t=o.trim().split(/\s+/).filter(Boolean);if(t.length===0)return["hover","focus"];const e=[];for(const i of t)(i==="hover"||i==="focus"||i==="click"||i==="manual")&&e.push(i);return e.length>0?e:["hover","focus"]}function g(o,t,e){return Math.min(Math.max(o,t),e)}function C(o){return o==="light"||o==="dark"||o==="auto"?o:l.theme}class u{element;config;tip=null;arrow=null;isEnabled=!0;timeoutId=null;hoverState=null;activeTrigger={click:!1,hover:!1,focus:!1};listeners=[];constructor(t,e={}){this.element=t;const i=h=>h.dataset.ctTitle??h.dataset.ctOriginalTitle??h.getAttribute("title")??"",a=t.getAttribute("data-ct-placement")??void 0,r=t.getAttribute("data-ct-trigger")??void 0,s=t.getAttribute("data-ct-theme")??void 0;this.config={title:e.title??i,placement:e.placement??a??l.placement,trigger:e.trigger??r??l.trigger,theme:C(e.theme??s??l.theme),container:e.container??document.body,offset:e.offset??l.offset,html:e.html??l.html,delay:L(e.delay)},t.title&&(t.setAttribute("data-ct-original-title",t.title),t.removeAttribute("title")),this.addListeners(),m.set(t,this)}static getOrCreateInstance(t,e){return m.get(t)??new u(t,e)}static initAll(t="[data-ct-title]",e){return Array.from(document.querySelectorAll(t)).map(i=>u.getOrCreateInstance(i,e))}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}toggleEnabled(){this.isEnabled=!this.isEnabled}toggle(){if(this.tip&&this.tip.classList.contains("show")){this.leave();return}this.enter()}show(){if(!this.isEnabled||!this.hasContent())return;const t=this.getTipElement();t.dataset.theme=this.config.theme;const e=t.classList.contains("show");t.isConnected||this.config.container.appendChild(t),this.setContent(t),e||(this.updatePosition(),t.classList.add("show"),this.element.setAttribute("aria-describedby",t.id))}hide(){const t=this.tip;t&&(t.classList.remove("show"),this.activeTrigger.click=!1,this.activeTrigger.focus=!1,this.activeTrigger.hover=!1,this.hoverState=null,this.element.removeAttribute("aria-describedby"),window.setTimeout(()=>{t.classList.contains("show")||t.remove()},150))}update(){this.tip&&this.tip.classList.contains("show")&&this.updatePosition()}refresh(){!this.tip||!this.tip.classList.contains("show")||(this.setContent(this.tip),this.updatePosition())}setTitle(t){this.config.title=t,this.refresh()}dispose(){this.clearTimer(),this.listeners.forEach(t=>t()),this.listeners=[],this.hide(),m.delete(this.element)}addListeners(){const t=z(this.config.trigger);for(const e of t)e!=="manual"&&(e==="hover"&&(this.bind(this.element,"mouseenter",()=>{this.activeTrigger.hover=!0,this.enter()}),this.bind(this.element,"mouseleave",()=>{this.activeTrigger.hover=!1,this.leave()})),e==="focus"&&(this.bind(this.element,"focusin",()=>{this.activeTrigger.focus=!0,this.enter()}),this.bind(this.element,"focusout",()=>{this.activeTrigger.focus=!1,this.leave()})),e==="click"&&this.bind(this.element,"click",i=>{i.preventDefault(),this.activeTrigger.click=!this.activeTrigger.click,this.toggle()}));this.bind(window,"resize",()=>this.update()),this.bind(window,"scroll",()=>{if(this.activeTrigger.hover||this.activeTrigger.focus){this.hide();return}this.update()})}bind(t,e,i){t.addEventListener(e,i),this.listeners.push(()=>t.removeEventListener(e,i))}clearTimer(){this.timeoutId!==null&&(window.clearTimeout(this.timeoutId),this.timeoutId=null)}enter(){this.isEnabled&&(this.clearTimer(),this.hoverState="show",this.timeoutId=window.setTimeout(()=>{this.hoverState==="show"&&this.show()},this.config.delay.show))}leave(){this.hasActiveTrigger()||(this.clearTimer(),this.hoverState="out",this.timeoutId=window.setTimeout(()=>{this.hoverState==="out"&&this.hide()},this.config.delay.hide))}hasActiveTrigger(){return this.activeTrigger.click||this.activeTrigger.focus||this.activeTrigger.hover}hasContent(){return this.getTitle().trim().length>0}getTitle(){const{title:t}=this.config;return typeof t=="function"?t(this.element):t}getTipElement(){if(this.tip)return this.tip;const t=document.createElement("div");t.className="cell-tooltip",t.id=x("cell-tooltip"),t.setAttribute("role","tooltip"),t.dataset.theme=this.config.theme,t.innerHTML='
';const e=t.querySelector(".cell-tooltip-arrow");if(!T(e))throw new Error("Tooltip arrow element is missing");return this.tip=t,this.arrow=e,t}setContent(t){const e=t.querySelector(".cell-tooltip-inner");if(!T(e))throw new Error("Tooltip inner element is missing");const i=this.getTitle();if(this.config.html){e.innerHTML=i;return}e.textContent=i}updatePosition(){const t=this.getTipElement();t.style.top="0",t.style.left="0";const e=this.element.getBoundingClientRect(),i=t.getBoundingClientRect(),a=this.resolvePlacement(e,i);t.dataset.placement=a;const r=window.scrollX,s=window.scrollY,h=window.innerWidth,f=window.innerHeight,c=this.config.offset;let n=0,d=0;switch(a){case"top":n=e.top+s-i.height-c,d=e.left+r+(e.width-i.width)/2;break;case"bottom":n=e.bottom+s+c,d=e.left+r+(e.width-i.width)/2;break;case"left":n=e.top+s+(e.height-i.height)/2,d=e.left+r-i.width-1.5*c;break;case"right":n=e.top+s+(e.height-i.height)/2,d=e.right+r+c;break}const E=g(n,s+4,s+f-i.height-4),A=g(d,r+4,r+h-i.width-4);t.style.top=`${Math.round(E)}px`,t.style.left=`${Math.round(A)}px`,this.updateArrowPosition(a,e,{top:E,left:A,width:i.width,height:i.height})}resolvePlacement(t,e){if(this.config.placement!=="auto")return this.config.placement;const i=this.config.offset,a=t.top,r=window.innerHeight-t.bottom,s=t.left,h=window.innerWidth-t.right,f={top:a>=e.height+i,bottom:r>=e.height+i,left:s>=e.width+i,right:h>=e.width+i};for(const n of v)if(f[n])return n;const c={top:a,bottom:r,left:s,right:h};return v.reduce((n,d)=>c[d]>c[n]?d:n,"top")}updateArrowPosition(t,e,i){if(!this.arrow)return;const a=e.left+window.scrollX+e.width/2,r=e.top+window.scrollY+e.height/2;if(t==="top"||t==="bottom"){const f=a-i.left,c=g(f,10,i.width-10);this.arrow.style.left=`${c}px`,this.arrow.style.top="";return}const s=r-i.top,h=g(s,10,i.height-10);this.arrow.style.top=`${h}px`,this.arrow.style.left=""}}const y="cell-tooltip-runtime-style";function k(){if(typeof document>"u"||document.getElementById(y))return;const o=document.createElement("style");o.id=y,o.textContent=p,document.head.appendChild(o)}return k(),u})); +(function(v,b){typeof exports=="object"&&typeof module<"u"?module.exports=b():typeof define=="function"&&define.amd?define(b):(v=typeof globalThis<"u"?globalThis:v||self,v.CellTooltip=b())})(this,(function(){"use strict";const v=".cell-tooltip{position:absolute;z-index:999;pointer-events:none;opacity:0;will-change:opacity,transform;contain:layout style;transition:opacity var(--tooltip-duration) ease,transform var(--tooltip-duration) ease;filter:drop-shadow(0 0 4px var(--tooltip-shadow-color, rgba(255, 255, 255, .18)));--tooltip-bg: #111827;--tooltip-color: #f8fafc;--tooltip-arrow-size: 8px;--tooltip-duration: .12s}.cell-tooltip[data-theme=auto],.cell-tooltip[data-theme=light]{--tooltip-bg: #ffffff;--tooltip-color: #0f172a;--tooltip-shadow-color: rgba(0, 0, 0, .18)}@media(prefers-color-scheme:dark){.cell-tooltip[data-theme=auto]{--tooltip-bg: #111827;--tooltip-color: #f8fafc;--tooltip-shadow-color: rgba(255, 255, 255, .18)}}.cell-tooltip[data-animation=scale]{transform:scale(.97)}.cell-tooltip[data-animation=scale].show{opacity:1;transform:scale(1)}.cell-tooltip[data-animation=fade].show{opacity:1}.cell-tooltip[data-animation=shift-away]{transform:translateY(4px)}.cell-tooltip[data-animation=shift-away].show{opacity:1;transform:translateY(0)}.cell-tooltip[data-animation=none].show{opacity:1}.cell-tooltip-inner{max-width:240px;padding:6px 10px;border-radius:8px;font-size:12px;line-height:1.35;color:var(--tooltip-color);background:var(--tooltip-bg);text-align:center;overflow-wrap:break-word}.cell-tooltip-arrow{position:absolute;width:0;height:0;transform:translate(-50%,-50%)}.cell-tooltip[data-placement=top] .cell-tooltip-arrow{bottom:calc(-1 * var(--tooltip-arrow-size));border-left:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid transparent;border-top:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=bottom] .cell-tooltip-arrow{top:0;border-left:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=left] .cell-tooltip-arrow{right:calc(-1 * var(--tooltip-arrow-size));border-top:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid transparent;border-left:var(--tooltip-arrow-size) solid var(--tooltip-bg)}.cell-tooltip[data-placement=right] .cell-tooltip-arrow{left:0;border-top:var(--tooltip-arrow-size) solid transparent;border-bottom:var(--tooltip-arrow-size) solid transparent;border-right:var(--tooltip-arrow-size) solid var(--tooltip-bg)}@media print{.cell-tooltip{display:none!important}}",l={placement:"top",trigger:"hover focus",theme:"dark",offset:8,html:!1,customClass:"",animation:"scale",template:'
',showOnCreate:!1,interactive:!1,autoDispose:!0},A={show:120,hide:80},E=["top","bottom","right","left"],T=new WeakMap;let C=0;function S(r){return C+=1,`${r}-${C}`}function k(r){return typeof r=="number"?{show:r,hide:r}:{show:r?.show??A.show,hide:r?.hide??A.hide}}const z=new Set(["hover","focus","click","manual"]);function D(r){const t=r.trim().split(/\s+/).filter(e=>z.has(e));return t.length>0?t:["hover","focus"]}function y(r,t,e){return Math.min(Math.max(r,t),e)}const M=new Set(["light","dark","auto"]);function O(r){return r&&M.has(r)?r:l.theme}class m{element;config;tip=null;arrow=null;isEnabled=!0;timeoutId=null;hoverState=null;activeTrigger={click:!1,hover:!1,focus:!1};listeners=[];rafId=null;observer=null;constructor(t,e={}){this.element=t;const i=d=>d.dataset.ctTitle??d.dataset.ctOriginalTitle??d.getAttribute("title")??"",o=t.getAttribute("data-ct-placement")??void 0,s=t.getAttribute("data-ct-trigger")??void 0,n=t.getAttribute("data-ct-theme")??void 0,a=t.getAttribute("data-ct-html")==="true"?!0:void 0,c=t.dataset.ctOffset?Number(t.dataset.ctOffset):void 0,f=t.dataset.ctDelay?Number(t.dataset.ctDelay):void 0,p=t.getAttribute("data-ct-custom-class")??void 0,h=t.hasAttribute("data-ct-show-on-create")?!0:void 0,u=t.hasAttribute("data-ct-interactive")?!0:void 0,g=t.getAttribute("data-ct-animation");this.config={title:e.title??i,placement:e.placement??o??l.placement,trigger:e.trigger??s??l.trigger,theme:O(e.theme??n??l.theme),container:e.container??document.body,boundary:e.boundary??"viewport",offset:e.offset??c??l.offset,html:e.html??a??l.html,delay:k(e.delay??f),maxWidth:e.maxWidth,customClass:e.customClass??p??l.customClass,animation:e.animation??g??l.animation,template:e.template??l.template,showOnCreate:e.showOnCreate??h??l.showOnCreate,interactive:e.interactive??u??l.interactive,autoDispose:e.autoDispose??l.autoDispose,onShow:e.onShow,onHide:e.onHide},t.title&&(t.setAttribute("data-ct-original-title",t.title),t.removeAttribute("title")),this.addListeners(),T.set(t,this),this.config.autoDispose&&(this.observer=new MutationObserver(()=>{t.isConnected||this.dispose()}),this.observer.observe(t.parentNode||document.body,{childList:!0})),this.config.showOnCreate&&this.show()}static getInstance(t){return T.get(t)??null}static getOrCreateInstance(t,e){return T.get(t)??new m(t,e)}static initAll(t="[data-ct-title]",e){return Array.from(document.querySelectorAll(t)).map(i=>m.getOrCreateInstance(i,e))}static observe(t="[data-ct-title]",e){const i=new MutationObserver(o=>{for(const s of o)for(const n of s.addedNodes)n instanceof HTMLElement&&(n.matches(t)&&m.getOrCreateInstance(n,e),n.querySelectorAll(t).forEach(a=>{m.getOrCreateInstance(a,e)}))});return i.observe(document.body,{childList:!0,subtree:!0}),m.initAll(t,e),i}enable(){this.isEnabled=!0}disable(){this.isEnabled=!1}toggleEnabled(){this.isEnabled=!this.isEnabled}toggle(){if(this.tip&&this.tip.classList.contains("show")){this.leave();return}this.enter()}show(){if(!this.isEnabled||!this.hasContent()||this.isDisabledElement())return;const t=this.getTipElement();t.dataset.theme=this.config.theme,t.dataset.animation=this.config.animation;const e=t.classList.contains("show");t.isConnected||this.config.container.appendChild(t),this.setContent(t),e||(this.updatePosition(),t.classList.add("show"),this.element.setAttribute("aria-describedby",t.id),this.config.onShow?.(this))}hide(){const t=this.tip;t&&(t.classList.remove("show"),this.activeTrigger.click=!1,this.activeTrigger.focus=!1,this.activeTrigger.hover=!1,this.hoverState=null,this.element.removeAttribute("aria-describedby"),this.config.onHide?.(this),window.setTimeout(()=>{t.classList.contains("show")||t.remove()},150))}update(){this.tip&&this.tip.classList.contains("show")&&this.updatePosition()}refresh(){!this.tip||!this.tip.classList.contains("show")||(this.setContent(this.tip),this.updatePosition())}setTitle(t){this.config.title=t,this.refresh()}getContent(){return this.getTitle()}getConfig(){return this.config}dispose(){this.clearTimer(),this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null),this.observer&&(this.observer.disconnect(),this.observer=null),this.listeners.forEach(t=>t()),this.listeners=[],this.tip&&(this.tip.remove(),this.tip=null,this.arrow=null),this.element.removeAttribute("aria-describedby"),this.hoverState=null,this.activeTrigger.click=!1,this.activeTrigger.focus=!1,this.activeTrigger.hover=!1,T.delete(this.element)}addListeners(){const t=D(this.config.trigger);for(const i of t)i!=="manual"&&(i==="hover"&&(this.bind(this.element,"mouseenter",()=>{this.activeTrigger.hover=!0,this.enter()}),this.bind(this.element,"mouseleave",()=>{this.activeTrigger.hover=!1,this.leave()}),this.bind(this.element,"touchstart",()=>{this.activeTrigger.hover=!0,this.enter()},{passive:!0}),this.bind(document,"touchstart",(o=>{const s=o.target;this.activeTrigger.hover&&this.tip?.classList.contains("show")&&!this.element.contains(s)&&!this.tip.contains(s)&&(this.activeTrigger.hover=!1,this.leave())}),{passive:!0})),i==="focus"&&(this.bind(this.element,"focusin",()=>{this.activeTrigger.focus=!0,this.enter()}),this.bind(this.element,"focusout",()=>{this.activeTrigger.focus=!1,this.leave()})),i==="click"&&(this.bind(this.element,"click",o=>{o.preventDefault(),this.activeTrigger.click=!this.activeTrigger.click,this.toggle()}),this.bind(document,"click",(o=>{const s=o.target;this.activeTrigger.click&&this.tip?.classList.contains("show")&&!this.element.contains(s)&&!this.tip.contains(s)&&(this.activeTrigger.click=!1,this.hide())}))));const e=()=>{this.rafId===null&&(this.rafId=requestAnimationFrame(()=>{if(this.rafId=null,this.tip&&this.tip.classList.contains("show")){const i=this.element.getBoundingClientRect(),o=this.getBoundaryRect();i.bottom>o.top&&i.topo.left&&i.left{i.key==="Escape"&&this.tip?.classList.contains("show")&&this.hide()}))}bind(t,e,i,o){t.addEventListener(e,i,o),this.listeners.push(()=>t.removeEventListener(e,i,o))}clearTimer(){this.timeoutId!==null&&(window.clearTimeout(this.timeoutId),this.timeoutId=null)}enter(){this.isEnabled&&(this.clearTimer(),this.hoverState="show",this.timeoutId=window.setTimeout(()=>{this.hoverState==="show"&&this.show()},this.config.delay.show))}leave(){this.hasActiveTrigger()||(this.clearTimer(),this.hoverState="out",this.timeoutId=window.setTimeout(()=>{this.hoverState==="out"&&this.hide()},this.config.delay.hide))}hasActiveTrigger(){return this.activeTrigger.click||this.activeTrigger.focus||this.activeTrigger.hover}hasContent(){return this.getTitle().trim().length>0}isDisabledElement(){return this.element.hasAttribute("disabled")||this.element.getAttribute("aria-disabled")==="true"}getTitle(){const{title:t}=this.config;return typeof t=="function"?t(this.element):t}getTipElement(){if(this.tip)return this.tip;const t=document.createElement("div");t.className=this.config.customClass?`cell-tooltip ${this.config.customClass}`:"cell-tooltip",t.id=S("cell-tooltip"),t.setAttribute("role","tooltip"),t.setAttribute("aria-live","polite"),t.dataset.theme=this.config.theme,t.innerHTML=this.config.template,this.config.interactive&&(t.style.pointerEvents="auto",t.addEventListener("mouseenter",()=>{this.clearTimer(),this.activeTrigger.hover=!0}),t.addEventListener("mouseleave",()=>{this.activeTrigger.hover=!1,this.leave()}));const e=t.querySelector(".cell-tooltip-arrow"),i=t.querySelector(".cell-tooltip-inner");if(!(e instanceof HTMLElement)||!(i instanceof HTMLElement))throw new Error("Tooltip template must contain .cell-tooltip-arrow and .cell-tooltip-inner elements");return this.tip=t,this.arrow=e,t}setContent(t){const e=t.querySelector(".cell-tooltip-inner");if(!(e instanceof HTMLElement))throw new Error("Tooltip template is missing .cell-tooltip-inner element");this.config.maxWidth!=null&&(e.style.maxWidth=typeof this.config.maxWidth=="number"?`${this.config.maxWidth}px`:this.config.maxWidth);const i=this.getTitle();if(this.config.html){e.innerHTML=i;return}e.textContent=i}getBoundaryRect(){return this.config.boundary==="viewport"?new DOMRect(0,0,window.innerWidth,window.innerHeight):this.config.boundary.getBoundingClientRect()}updatePosition(){const t=this.getTipElement();t.style.top="0",t.style.left="0";const e=this.element.getBoundingClientRect(),i=t.getBoundingClientRect(),o=this.config.container.getBoundingClientRect(),s=this.config.container===document.body,n=s?window.scrollY:this.config.container.scrollTop,a=s?window.scrollX:this.config.container.scrollLeft,c=s?0:o.top,f=s?0:o.left,p=s?window.innerHeight:this.config.container.clientHeight,h=s?window.innerWidth:this.config.container.clientWidth,u=this.resolvePlacement(e,i);t.dataset.placement=u;const g=this.config.offset;let d=0,w=0;switch(u){case"top":d=e.top-c+n-i.height-g,w=e.left-f+a+(e.width-i.width)/2;break;case"bottom":d=e.bottom-c+n+g,w=e.left-f+a+(e.width-i.width)/2;break;case"left":d=e.top-c+n+(e.height-i.height)/2,w=e.left-f+a-i.width-g;break;case"right":d=e.top-c+n+(e.height-i.height)/2,w=e.right-f+a+g;break}const x=y(d,n+4,n+p-i.height-4),I=y(w,a+4,a+h-i.width-4);t.style.top=`${Math.round(x)}px`,t.style.left=`${Math.round(I)}px`,this.updateArrowPosition(u,e,{top:x,left:I,width:i.width,height:i.height})}resolvePlacement(t,e){if(this.config.placement!=="auto")return this.config.placement;const i=this.config.offset,o=this.getBoundaryRect(),s=t.top-o.top,n=o.bottom-t.bottom,a=t.left-o.left,c=o.right-t.right,f={top:s>=e.height+i,bottom:n>=e.height+i,left:a>=e.width+i,right:c>=e.width+i};for(const h of E)if(f[h])return h;const p={top:s,bottom:n,left:a,right:c};return E.reduce((h,u)=>p[u]>p[h]?u:h,"top")}updateArrowPosition(t,e,i){if(!this.arrow)return;const o=this.config.container.getBoundingClientRect(),s=this.config.container===document.body,n=s?window.scrollY:this.config.container.scrollTop,a=s?window.scrollX:this.config.container.scrollLeft,c=s?0:o.top,f=s?0:o.left,p=e.left-f+a+e.width/2,h=e.top-c+n+e.height/2;if(t==="top"||t==="bottom"){const d=p-i.left,w=y(d,10,i.width-10);this.arrow.style.left=`${w}px`,this.arrow.style.top="";return}const u=h-i.top,g=y(u,10,i.height-10);this.arrow.style.top=`${g}px`,this.arrow.style.left=""}}const L="cell-tooltip-runtime-style";function F(){if(typeof document>"u"||document.getElementById(L))return;const r=document.createElement("style");r.id=L,r.textContent=v,document.head.appendChild(r)}return F(),m})); diff --git a/librarybot.yml b/librarybot.yml index 1218a98d..a3a0122f 100644 --- a/librarybot.yml +++ b/librarybot.yml @@ -28,7 +28,7 @@ libraries: - from: dist/APlayer.min.js to: aplayer/APlayer.min.js - npm: cell-tooltip - version: 0.3.1 + version: 0.4.0 local: items: - from: dist/cell-tooltip.umd.js