@ew-color-picker/tooltip 2.0.13 → 2.0.14
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/dist/tooltip.esm.js
CHANGED
|
@@ -254,7 +254,7 @@ var Tooltip = /** @class */ (function () {
|
|
|
254
254
|
if (isNull(content) || isUndefined(content))
|
|
255
255
|
return;
|
|
256
256
|
if (isString(content)) {
|
|
257
|
-
if (this.options.rawContent) {
|
|
257
|
+
if (this.options.html || this.options.rawContent) {
|
|
258
258
|
node.innerHTML = content;
|
|
259
259
|
}
|
|
260
260
|
else {
|
package/dist/tooltip.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@ew-color-picker/utils")):"function"==typeof define&&define.amd?define(["exports","@ew-color-picker/utils"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Tooltip={},t.Utils)})(this,function(t,d){var e=["hover","click","focus","contextmenu"],p={top:"bottom",bottom:"top",left:"right",right:"left"},i=0;function o(t){return-1<e.indexOf(t)}function r(t){var e;return d.isArray(t)?(e=t.filter(o)).length?e:["hover"]:o(t)?[t]:["hover"]}Object.defineProperty(s.prototype,"prefix",{get:function(){return this.options.prefix},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"strategy",{get:function(){return"absolute"===this.options.popperOptions.strategy?"absolute":"fixed"},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"triggerList",{get:function(){return this.options.trigger},enumerable:!1,configurable:!0}),s.prototype.hasContent=function(t){return void 0===t&&(t=this.currentContent),!d.isNull(t)&&!d.isUndefined(t)&&(!d.isString(t)||0<t.trim().length)},s.prototype.resolveElement=function(t){return t?d.isString(t)?d.$(t):t:null},s.prototype.getAnchorElement=function(){var t;return this.options.virtualTriggering?(t=this.options.virtualRef,d.isHTMLElement(t)?t:null):this.imperativeAnchor||this.resolveElement(this.options.target)},s.prototype.getAnchorRect=function(){var t;return this.options.virtualTriggering?(t=this.options.virtualRef)&&d.isFunction(t.getBoundingClientRect)?t.getBoundingClientRect():null:(t=this.getAnchorElement())?d.getRect(t):null},s.prototype.getParent=function(){var t;return!1===this.options.teleported?(null==(t=this.getAnchorElement())?void 0:t.parentElement)||document.body:(t=null!=(t=this.options.appendTo)?t:this.options.container,d.isString(t)?d.$(t)||document.body:t||document.body)},s.prototype.applyCustomClasses=function(t){var e=[this.options.popperClass,this.options.className].filter(Boolean).join(" ");e&&d.addClass(t,e),this.options.transition&&d.addClass(t,this.options.transition)},s.prototype.applyPopperStyle=function(t){var e=this.options.popperStyle;e&&(t.style.cssText+=d.isString(e)?e:d.toStyleStr(e))},s.prototype.ensureNode=function(){var t,e;return this.node?(this.attachNode(),this.node):(t=this.prefix,(e=d.create("div")).id="".concat(t,"tooltip-").concat(++i),d.addClass(e,"".concat(t,"tooltip")),d.addClass(e,"".concat(t,"tooltip--").concat(this.options.effect)),this.options.enterable&&d.addClass(e,"".concat(t,"tooltip--enterable")),d.setAttr(e,{role:"tooltip"}),this.options.ariaLabel&&d.setAttr(e,{"aria-label":this.options.ariaLabel}),this.applyCustomClasses(e),e.style.position=this.strategy,this.contentNode=d.create("div"),d.addClass(this.contentNode,"".concat(t,"tooltip__content")),d.insertNode(e,this.contentNode),this.arrowNode=d.create("div"),d.addClass(this.arrowNode,"".concat(t,"tooltip__arrow")),this.options.showArrow||(this.arrowNode.style.display="none"),d.insertNode(e,this.arrowNode),this.applyPopperStyle(e),this.node=e,this.attachNode(),this.bindPopperEvents(),e)},s.prototype.attachNode=function(){var t;this.node&&(t=this.getParent())&&this.node.parentNode!==t&&t.appendChild(this.node)},s.prototype.applyContent=function(){var t,e=this.contentNode;e&&(t=this.currentContent,e.textContent="",d.isNull(t)||d.isUndefined(t)||(d.isString(t)?this.options.rawContent?e.innerHTML=t:e.textContent=t:d.isHTMLElement(t)?e.appendChild(t):e.textContent=String(t)))},s.prototype.destroyNode=function(){this.unbindPopperEvents(),this.node&&(d.removeElement(this.node),this.node=null),this.contentNode=null,this.arrowNode=null},s.prototype.getNodeSize=function(){var t;return this.node?{width:(t=d.getElementSize(this.node)).offsetWidth||0,height:t.offsetHeight||0}:{width:0,height:0}},s.prototype.computeCoords=function(t,e,i){function o(){return"start"===r?e.left:"end"===r?e.right-i.width:e.left+(e.width-i.width)/2}function n(){return"start"===r?e.top:"end"===r?e.bottom-i.height:e.top+(e.height-i.height)/2}var t=d.parsePlacement(t),s=t.side,r=t.align,h=this.options.offset,p=0,a=0;switch(s){case"top":a=e.top-h-i.height,p=o();break;case"bottom":a=e.bottom+h,p=o();break;case"left":p=e.left-h-i.width,a=n();break;case"right":p=e.right+h,a=n()}var t=window.innerWidth,l=window.innerHeight;return"top"===s||"bottom"===s?p=d.clamp(p,5,Math.max(5,t-i.width-5)):a=d.clamp(a,5,Math.max(5,l-i.height-5)),"absolute"===this.strategy&&(p+=window.scrollX||window.pageXOffset||0,a+=window.scrollY||window.pageYOffset||0),{left:p,top:a}},s.prototype.fitsViewport=function(t,e,i){var t=d.parsePlacement(t).side,o=this.options.offset,n=window.innerWidth,s=window.innerHeight;switch(t){case"top":return 5<=e.top-o-i.height;case"bottom":return e.bottom+o+i.height<=s-5;case"left":return 5<=e.left-o-i.width;case"right":return e.right+o+i.width<=n-5}},s.prototype.resolvePlacement=function(t,e){var i=this.options.placement;if(!this.fitsViewport(i,t,e))for(var o=d.parsePlacement(i),n=o.side,o=o.align,n=p[n],n="center"===o?n:"".concat(n,"-").concat(o),s=0,r=this.options.fallbackPlacements.length?this.options.fallbackPlacements:[n];s<r.length;s++){var h=r[s];if(d.isPlacement(h)&&this.fitsViewport(h,t,e))return h}return i},s.prototype.updateArrow=function(t,e,i,o){var n,s,r,h=this.arrowNode;h&&(this.options.showArrow?(h.style.display="",h.style.left="",h.style.right="",h.style.top="",h.style.bottom="",n=d.parsePlacement(t).side,s=this.options.arrowOffset,"top"===n||"bottom"===n?(r=e.left+e.width/2-i.left,o.width>2*s&&(r=d.clamp(r,s,o.width-s)),h.style.left="".concat(r-4,"px"),"top"===n?h.style.bottom="".concat(-4,"px"):h.style.top="".concat(-4,"px")):(r=e.top+e.height/2-i.top,o.height>2*s&&(r=d.clamp(r,s,o.height-s)),h.style.top="".concat(r-4,"px"),"left"===n?h.style.right="".concat(-4,"px"):h.style.left="".concat(-4,"px")),d.setAttr(h,{"data-placement":t})):h.style.display="none")},s.prototype.updatePosition=function(){var t,e,i,o,n=this.node;n&&(t=this.getAnchorRect())&&(e=this.getNodeSize(),i=this.resolvePlacement(t,e),o=this.computeCoords(i,t,e),n.style.left="".concat(Math.round(o.left),"px"),n.style.top="".concat(Math.round(o.top),"px"),d.setAttr(n,{"data-placement":i,"data-popper-placement":i}),this.updateArrow(i,t,o,e))},s.prototype.addTriggerListener=function(t,e,i){d.on(t,e,i),this.triggerListeners.push({el:t,type:e,handler:i})},s.prototype.bindTriggerEvents=function(){var t,e,i,o,n,s=this;this.unbindTriggerEvents(),this.options.virtualTriggering||(t=this.resolveElement(this.options.target))&&(e=-1<(n=this.triggerList).indexOf("hover"),i=-1<n.indexOf("click"),o=-1<n.indexOf("focus"),n=-1<n.indexOf("contextmenu"),e&&(this.addTriggerListener(t,"mouseenter",function(){return s.requestOpen()}),this.addTriggerListener(t,"mouseleave",function(t){return s.requestHide(t)}),this.addTriggerListener(t,"focus",function(){return s.requestOpen()}),this.addTriggerListener(t,"blur",function(t){return s.handleBlur(t)})),o&&!e&&(this.addTriggerListener(t,"focus",function(){return s.requestOpen()}),this.addTriggerListener(t,"blur",function(t){return s.handleBlur(t)})),i&&(this.addTriggerListener(t,"click",function(){s.isOpen?s.hide():s.requestOpen()}),this.addTriggerListener(t,"keydown",function(t){return s.handleTriggerKeydown(t)})),n)&&this.addTriggerListener(t,"contextmenu",function(t){t.preventDefault(),s.requestOpen(t)})},s.prototype.unbindTriggerEvents=function(){this.triggerListeners.forEach(function(t){var e=t.el;d.off(e,t.type,t.handler)}),this.triggerListeners=[]},s.prototype.bindPopperEvents=function(){var t,e,i=this;this.node&&!this.popperListeners.length&&(e=function(t){return i.requestHide(t)},d.on(this.node,"mouseenter",t=function(){return i.clearHideTimer()}),d.on(this.node,"mouseleave",e),this.popperListeners=[{type:"mouseenter",handler:t},{type:"mouseleave",handler:e}])},s.prototype.unbindPopperEvents=function(){var i=this;this.node&&this.popperListeners.forEach(function(t){var e=t.type;d.off(i.node,e,t.handler)}),this.popperListeners=[]},s.prototype.handleBlur=function(t){var e=t.relatedTarget;e&&this.node&&this.node.contains(e)&&this.options.enterable||this.requestHide(t)},s.prototype.handleTriggerKeydown=function(t){var e=this.options.triggerKeys;!(-1<e.indexOf(t.key)||-1<e.indexOf(t.code))||this.isOpen||this.options.disabled||(t.preventDefault(),this.requestOpen(t))},s.prototype.bindGlobalEvents=function(){this.globalBound||(d.on(window,"scroll",this.scheduleUpdate,{capture:!0}),d.on(window,"resize",this.scheduleUpdate),d.on(document,"keydown",this.handleDocumentKeydown),-1<this.triggerList.indexOf("click")&&d.on(document,"click",this.handleDocumentClick,{capture:!0}),this.globalBound=!0)},s.prototype.unbindGlobalEvents=function(){this.globalBound&&(d.off(window,"scroll",this.scheduleUpdate,{capture:!0}),d.off(window,"resize",this.scheduleUpdate),d.off(document,"keydown",this.handleDocumentKeydown),-1<this.triggerList.indexOf("click")&&d.off(document,"click",this.handleDocumentClick,{capture:!0}),this.globalBound=!1,null!==this.positionFrame)&&("function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this.positionFrame),this.positionFrame=null)},s.prototype.setAriaDescribedBy=function(t){var e=this.getAnchorElement();e&&this.node&&(t?(this.prevAriaDescribedBy=d.getAttr(e,"aria-describedby"),d.setAttr(e,{"aria-describedby":this.node.id})):d.getAttr(e,"aria-describedby")===this.node.id&&(this.prevAriaDescribedBy?d.setAttr(e,{"aria-describedby":this.prevAriaDescribedBy}):e.removeAttribute("aria-describedby")))},s.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var o=this.listeners[t],o=(o&&o.forEach(function(t){return t.apply(void 0,e)}),"on".concat(t.charAt(0).toUpperCase()).concat(t.slice(1))),t=this.options[o];d.isFunction(t)&&t.apply(void 0,e)},s.prototype.clearShowTimer=function(){this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null)},s.prototype.clearHideTimer=function(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null)},s.prototype.clearAutoCloseTimer=function(){this.autoCloseTimer&&(clearTimeout(this.autoCloseTimer),this.autoCloseTimer=null)},s.prototype.requestOpen=function(t){var e,i=this;this.options.disabled||(this.clearHideTimer(),this.isOpen)||(this.controlled?this.emit("visibleChange",!0):0<(e=this.options.showAfter)?(this.clearShowTimer(),this.showTimer=setTimeout(function(){return i.doOpen(t)},e)):this.doOpen(t))},s.prototype.requestHide=function(t){var e,i=this;this.clearShowTimer(),this.isOpen&&(this.controlled?this.emit("visibleChange",!1):0<(e=this.options.hideAfter)?(this.clearHideTimer(),this.hideTimer=setTimeout(function(){return i.doHide(t)},e)):this.doHide(t))},s.prototype.doOpen=function(t){var e,i=this;!this.options.disabled&&this.hasContent()&&(this.triggerListeners.length||this.options.virtualTriggering||this.bindTriggerEvents(),this.isOpen?(this.applyContent(),this.updatePosition()):(this.clearTimers(),this.emit("beforeShow",t),e=this.ensureNode(),this.applyContent(),d.addClass(e,"".concat(this.prefix,"tooltip--visible")),this.isOpen=!0,this.updatePosition(),this.bindGlobalEvents(),this.setAriaDescribedBy(!0),this.emit("show",t),this.emit("visibleChange",!0),0<this.options.autoClose&&(this.autoCloseTimer=setTimeout(function(){i.doHide()},this.options.autoClose))))},s.prototype.doHide=function(t){this.isOpen&&(this.emit("beforeHide",t),this.isOpen=!1,this.node&&d.removeClass(this.node,"".concat(this.prefix,"tooltip--visible")),this.setAriaDescribedBy(!1),this.unbindGlobalEvents(),this.clearTimers(),this.emit("hide",t),this.emit("visibleChange",!1),this.options.persistent||this.destroyNode(),this.options.focusOnTarget)&&null!=(t=this.getAnchorElement())&&t.focus()},s.prototype.clearTimers=function(){this.clearShowTimer(),this.clearHideTimer(),this.clearAutoCloseTimer()},s.prototype.show=function(t,e){e&&(this.imperativeAnchor=e),void 0!==t&&(this.currentContent=t),this.hasContent()?this.options.disabled||(this.controlled?this.emit("visibleChange",!0):this.doOpen()):this.hide()},s.prototype.hide=function(t){this.controlled?this.emit("visibleChange",!1):this.doHide(t)},s.prototype.onOpen=function(){this.requestOpen()},s.prototype.onClose=function(){this.hide()},s.prototype.isVisible=function(){return this.isOpen},s.prototype.getElement=function(){return this.node},s.prototype.getContentElement=function(){return this.contentNode},s.prototype.getTrigger=function(){return this.resolveElement(this.options.target)},s.prototype.isFocusInsideContent=function(){return Boolean(this.node&&this.node.contains(document.activeElement))},s.prototype.updatePopper=function(){this.updatePosition()},s.prototype.setContent=function(t){this.currentContent=t,this.isOpen&&(this.applyContent(),this.updatePosition())},s.prototype.setOptions=function(t){var e=this.options.target,i=this.options.trigger.join(","),o=this.options.appendTo,n=this.options.container,s=this.options.virtualTriggering;this.options=d.extend(this.options,t),void 0!==t.trigger&&(this.options.trigger=r(t.trigger)),t.triggerKeys&&(this.options.triggerKeys=t.triggerKeys),t.popperOptions&&(this.options.popperOptions=t.popperOptions),void 0!==t.content&&(this.currentContent=t.content),Object.prototype.hasOwnProperty.call(t,"visible")&&(this.controlled=d.isBoolean(t.visible)),void 0===t.target&&void 0===t.trigger&&void 0===t.virtualTriggering&&e===this.options.target&&i===this.options.trigger.join(",")&&s===this.options.virtualTriggering||this.bindTriggerEvents(),!this.node||void 0===t.appendTo&&void 0===t.container&&void 0===t.teleported&&o===this.options.appendTo&&n===this.options.container||this.attachNode(),this.node&&(e=this.prefix,this.node.style.position=this.strategy,d.removeClass(this.node,"".concat(e,"tooltip--dark")),d.removeClass(this.node,"".concat(e,"tooltip--light")),d.addClass(this.node,"".concat(e,"tooltip--").concat(this.options.effect)),this.options.enterable?d.addClass(this.node,"".concat(e,"tooltip--enterable")):d.removeClass(this.node,"".concat(e,"tooltip--enterable")),this.arrowNode&&(this.arrowNode.style.display=this.options.showArrow?"":"none"),this.options.ariaLabel&&d.setAttr(this.node,{"aria-label":this.options.ariaLabel}),this.options.popperClass&&d.addClass(this.node,this.options.popperClass),this.options.popperStyle&&this.applyPopperStyle(this.node),this.isOpen)&&(this.applyContent(),this.updatePosition()),this.options.disabled?this.doHide():this.controlled&&(this.options.visible?this.doOpen():this.doHide())},s.prototype.on=function(t,e){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e),this},s.prototype.off=function(t,e){var i=this.listeners[t];return i&&(this.listeners[t]=e?i.filter(function(t){return t!==e}):[]),this},s.prototype.destroy=function(){this.clearTimers(),this.unbindTriggerEvents(),this.unbindGlobalEvents(),this.unbindPopperEvents(),this.setAriaDescribedBy(!1),this.destroyNode(),this.currentContent=void 0,this.imperativeAnchor=null,this.isOpen=!1,this.listeners={},this.controlled=!1};var n=s;function s(t){void 0===t&&(t={});var i=this;this.node=null,this.contentNode=null,this.arrowNode=null,this.isOpen=!1,this.controlled=!1,this.currentContent=void 0,this.imperativeAnchor=null,this.prevAriaDescribedBy=null,this.showTimer=null,this.hideTimer=null,this.autoCloseTimer=null,this.positionFrame=null,this.globalBound=!1,this.triggerListeners=[],this.popperListeners=[],this.listeners={},this.scheduleUpdate=function(){var t;null===i.positionFrame&&(t="function"==typeof requestAnimationFrame?requestAnimationFrame:function(t){return setTimeout(function(){return t(Date.now())},16)},i.positionFrame=t(function(){i.positionFrame=null,i.updatePosition()}))},this.handleDocumentKeydown=function(t){"Escape"===t.key&&i.isOpen&&i.doHide(t)},this.handleDocumentClick=function(t){var e,t=t.target;!t||i.node&&i.node.contains(t)||(e=i.getAnchorElement())&&e.contains(t)||i.hide()},this.options=d.extend({prefix:d.DEFAULT_PREFIX,rawContent:!1,effect:"dark",placement:"bottom",fallbackPlacements:[],disabled:!1,offset:12,arrowOffset:5,showArrow:!0,showAfter:0,hideAfter:200,autoClose:0,popperClass:"",popperStyle:"",teleported:!0,enterable:!0,triggerKeys:["Enter","Space"],persistent:!0,transition:"",ariaLabel:"",focusOnTarget:!1,popperOptions:{},className:""},t),this.options.trigger=r(t.trigger),this.options.popperOptions=t.popperOptions||{},this.options.triggerKeys=t.triggerKeys||["Enter","Space"],this.controlled=Object.prototype.hasOwnProperty.call(t,"visible")&&d.isBoolean(t.visible),this.currentContent=t.content,this.bindTriggerEvents(),this.controlled&&this.options.visible&&this.doOpen()}Object.defineProperty(t,"isTextTruncated",{enumerable:!0,get:function(){return d.isTextTruncated}}),t.Tooltip=n,t.default=n,Object.defineProperty(t,"__esModule",{value:!0})});
|
|
1
|
+
((t,e)=>{"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@ew-color-picker/utils")):"function"==typeof define&&define.amd?define(["exports","@ew-color-picker/utils"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Tooltip={},t.Utils)})(this,function(t,d){var e=["hover","click","focus","contextmenu"],p={top:"bottom",bottom:"top",left:"right",right:"left"},i=0;function o(t){return-1<e.indexOf(t)}function r(t){var e;return d.isArray(t)?(e=t.filter(o)).length?e:["hover"]:o(t)?[t]:["hover"]}Object.defineProperty(s.prototype,"prefix",{get:function(){return this.options.prefix},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"strategy",{get:function(){return"absolute"===this.options.popperOptions.strategy?"absolute":"fixed"},enumerable:!1,configurable:!0}),Object.defineProperty(s.prototype,"triggerList",{get:function(){return this.options.trigger},enumerable:!1,configurable:!0}),s.prototype.hasContent=function(t){return void 0===t&&(t=this.currentContent),!d.isNull(t)&&!d.isUndefined(t)&&(!d.isString(t)||0<t.trim().length)},s.prototype.resolveElement=function(t){return t?d.isString(t)?d.$(t):t:null},s.prototype.getAnchorElement=function(){var t;return this.options.virtualTriggering?(t=this.options.virtualRef,d.isHTMLElement(t)?t:null):this.imperativeAnchor||this.resolveElement(this.options.target)},s.prototype.getAnchorRect=function(){var t;return this.options.virtualTriggering?(t=this.options.virtualRef)&&d.isFunction(t.getBoundingClientRect)?t.getBoundingClientRect():null:(t=this.getAnchorElement())?d.getRect(t):null},s.prototype.getParent=function(){var t;return!1===this.options.teleported?(null==(t=this.getAnchorElement())?void 0:t.parentElement)||document.body:(t=null!=(t=this.options.appendTo)?t:this.options.container,d.isString(t)?d.$(t)||document.body:t||document.body)},s.prototype.applyCustomClasses=function(t){var e=[this.options.popperClass,this.options.className].filter(Boolean).join(" ");e&&d.addClass(t,e),this.options.transition&&d.addClass(t,this.options.transition)},s.prototype.applyPopperStyle=function(t){var e=this.options.popperStyle;e&&(t.style.cssText+=d.isString(e)?e:d.toStyleStr(e))},s.prototype.ensureNode=function(){var t,e;return this.node?(this.attachNode(),this.node):(t=this.prefix,(e=d.create("div")).id="".concat(t,"tooltip-").concat(++i),d.addClass(e,"".concat(t,"tooltip")),d.addClass(e,"".concat(t,"tooltip--").concat(this.options.effect)),this.options.enterable&&d.addClass(e,"".concat(t,"tooltip--enterable")),d.setAttr(e,{role:"tooltip"}),this.options.ariaLabel&&d.setAttr(e,{"aria-label":this.options.ariaLabel}),this.applyCustomClasses(e),e.style.position=this.strategy,this.contentNode=d.create("div"),d.addClass(this.contentNode,"".concat(t,"tooltip__content")),d.insertNode(e,this.contentNode),this.arrowNode=d.create("div"),d.addClass(this.arrowNode,"".concat(t,"tooltip__arrow")),this.options.showArrow||(this.arrowNode.style.display="none"),d.insertNode(e,this.arrowNode),this.applyPopperStyle(e),this.node=e,this.attachNode(),this.bindPopperEvents(),e)},s.prototype.attachNode=function(){var t;this.node&&(t=this.getParent())&&this.node.parentNode!==t&&t.appendChild(this.node)},s.prototype.applyContent=function(){var t,e=this.contentNode;e&&(t=this.currentContent,e.textContent="",d.isNull(t)||d.isUndefined(t)||(d.isString(t)?this.options.html||this.options.rawContent?e.innerHTML=t:e.textContent=t:d.isHTMLElement(t)?e.appendChild(t):e.textContent=String(t)))},s.prototype.destroyNode=function(){this.unbindPopperEvents(),this.node&&(d.removeElement(this.node),this.node=null),this.contentNode=null,this.arrowNode=null},s.prototype.getNodeSize=function(){var t;return this.node?{width:(t=d.getElementSize(this.node)).offsetWidth||0,height:t.offsetHeight||0}:{width:0,height:0}},s.prototype.computeCoords=function(t,e,i){function o(){return"start"===r?e.left:"end"===r?e.right-i.width:e.left+(e.width-i.width)/2}function n(){return"start"===r?e.top:"end"===r?e.bottom-i.height:e.top+(e.height-i.height)/2}var t=d.parsePlacement(t),s=t.side,r=t.align,h=this.options.offset,p=0,a=0;switch(s){case"top":a=e.top-h-i.height,p=o();break;case"bottom":a=e.bottom+h,p=o();break;case"left":p=e.left-h-i.width,a=n();break;case"right":p=e.right+h,a=n()}var t=window.innerWidth,l=window.innerHeight;return"top"===s||"bottom"===s?p=d.clamp(p,5,Math.max(5,t-i.width-5)):a=d.clamp(a,5,Math.max(5,l-i.height-5)),"absolute"===this.strategy&&(p+=window.scrollX||window.pageXOffset||0,a+=window.scrollY||window.pageYOffset||0),{left:p,top:a}},s.prototype.fitsViewport=function(t,e,i){var t=d.parsePlacement(t).side,o=this.options.offset,n=window.innerWidth,s=window.innerHeight;switch(t){case"top":return 5<=e.top-o-i.height;case"bottom":return e.bottom+o+i.height<=s-5;case"left":return 5<=e.left-o-i.width;case"right":return e.right+o+i.width<=n-5}},s.prototype.resolvePlacement=function(t,e){var i=this.options.placement;if(!this.fitsViewport(i,t,e))for(var o=d.parsePlacement(i),n=o.side,o=o.align,n=p[n],n="center"===o?n:"".concat(n,"-").concat(o),s=0,r=this.options.fallbackPlacements.length?this.options.fallbackPlacements:[n];s<r.length;s++){var h=r[s];if(d.isPlacement(h)&&this.fitsViewport(h,t,e))return h}return i},s.prototype.updateArrow=function(t,e,i,o){var n,s,r,h=this.arrowNode;h&&(this.options.showArrow?(h.style.display="",h.style.left="",h.style.right="",h.style.top="",h.style.bottom="",n=d.parsePlacement(t).side,s=this.options.arrowOffset,"top"===n||"bottom"===n?(r=e.left+e.width/2-i.left,o.width>2*s&&(r=d.clamp(r,s,o.width-s)),h.style.left="".concat(r-4,"px"),"top"===n?h.style.bottom="".concat(-4,"px"):h.style.top="".concat(-4,"px")):(r=e.top+e.height/2-i.top,o.height>2*s&&(r=d.clamp(r,s,o.height-s)),h.style.top="".concat(r-4,"px"),"left"===n?h.style.right="".concat(-4,"px"):h.style.left="".concat(-4,"px")),d.setAttr(h,{"data-placement":t})):h.style.display="none")},s.prototype.updatePosition=function(){var t,e,i,o,n=this.node;n&&(t=this.getAnchorRect())&&(e=this.getNodeSize(),i=this.resolvePlacement(t,e),o=this.computeCoords(i,t,e),n.style.left="".concat(Math.round(o.left),"px"),n.style.top="".concat(Math.round(o.top),"px"),d.setAttr(n,{"data-placement":i,"data-popper-placement":i}),this.updateArrow(i,t,o,e))},s.prototype.addTriggerListener=function(t,e,i){d.on(t,e,i),this.triggerListeners.push({el:t,type:e,handler:i})},s.prototype.bindTriggerEvents=function(){var t,e,i,o,n,s=this;this.unbindTriggerEvents(),this.options.virtualTriggering||(t=this.resolveElement(this.options.target))&&(e=-1<(n=this.triggerList).indexOf("hover"),i=-1<n.indexOf("click"),o=-1<n.indexOf("focus"),n=-1<n.indexOf("contextmenu"),e&&(this.addTriggerListener(t,"mouseenter",function(){return s.requestOpen()}),this.addTriggerListener(t,"mouseleave",function(t){return s.requestHide(t)}),this.addTriggerListener(t,"focus",function(){return s.requestOpen()}),this.addTriggerListener(t,"blur",function(t){return s.handleBlur(t)})),o&&!e&&(this.addTriggerListener(t,"focus",function(){return s.requestOpen()}),this.addTriggerListener(t,"blur",function(t){return s.handleBlur(t)})),i&&(this.addTriggerListener(t,"click",function(){s.isOpen?s.hide():s.requestOpen()}),this.addTriggerListener(t,"keydown",function(t){return s.handleTriggerKeydown(t)})),n)&&this.addTriggerListener(t,"contextmenu",function(t){t.preventDefault(),s.requestOpen(t)})},s.prototype.unbindTriggerEvents=function(){this.triggerListeners.forEach(function(t){var e=t.el;d.off(e,t.type,t.handler)}),this.triggerListeners=[]},s.prototype.bindPopperEvents=function(){var t,e,i=this;this.node&&!this.popperListeners.length&&(e=function(t){return i.requestHide(t)},d.on(this.node,"mouseenter",t=function(){return i.clearHideTimer()}),d.on(this.node,"mouseleave",e),this.popperListeners=[{type:"mouseenter",handler:t},{type:"mouseleave",handler:e}])},s.prototype.unbindPopperEvents=function(){var i=this;this.node&&this.popperListeners.forEach(function(t){var e=t.type;d.off(i.node,e,t.handler)}),this.popperListeners=[]},s.prototype.handleBlur=function(t){var e=t.relatedTarget;e&&this.node&&this.node.contains(e)&&this.options.enterable||this.requestHide(t)},s.prototype.handleTriggerKeydown=function(t){var e=this.options.triggerKeys;!(-1<e.indexOf(t.key)||-1<e.indexOf(t.code))||this.isOpen||this.options.disabled||(t.preventDefault(),this.requestOpen(t))},s.prototype.bindGlobalEvents=function(){this.globalBound||(d.on(window,"scroll",this.scheduleUpdate,{capture:!0}),d.on(window,"resize",this.scheduleUpdate),d.on(document,"keydown",this.handleDocumentKeydown),-1<this.triggerList.indexOf("click")&&d.on(document,"click",this.handleDocumentClick,{capture:!0}),this.globalBound=!0)},s.prototype.unbindGlobalEvents=function(){this.globalBound&&(d.off(window,"scroll",this.scheduleUpdate,{capture:!0}),d.off(window,"resize",this.scheduleUpdate),d.off(document,"keydown",this.handleDocumentKeydown),-1<this.triggerList.indexOf("click")&&d.off(document,"click",this.handleDocumentClick,{capture:!0}),this.globalBound=!1,null!==this.positionFrame)&&("function"==typeof cancelAnimationFrame&&cancelAnimationFrame(this.positionFrame),this.positionFrame=null)},s.prototype.setAriaDescribedBy=function(t){var e=this.getAnchorElement();e&&this.node&&(t?(this.prevAriaDescribedBy=d.getAttr(e,"aria-describedby"),d.setAttr(e,{"aria-describedby":this.node.id})):d.getAttr(e,"aria-describedby")===this.node.id&&(this.prevAriaDescribedBy?d.setAttr(e,{"aria-describedby":this.prevAriaDescribedBy}):e.removeAttribute("aria-describedby")))},s.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var o=this.listeners[t],o=(o&&o.forEach(function(t){return t.apply(void 0,e)}),"on".concat(t.charAt(0).toUpperCase()).concat(t.slice(1))),t=this.options[o];d.isFunction(t)&&t.apply(void 0,e)},s.prototype.clearShowTimer=function(){this.showTimer&&(clearTimeout(this.showTimer),this.showTimer=null)},s.prototype.clearHideTimer=function(){this.hideTimer&&(clearTimeout(this.hideTimer),this.hideTimer=null)},s.prototype.clearAutoCloseTimer=function(){this.autoCloseTimer&&(clearTimeout(this.autoCloseTimer),this.autoCloseTimer=null)},s.prototype.requestOpen=function(t){var e,i=this;this.options.disabled||(this.clearHideTimer(),this.isOpen)||(this.controlled?this.emit("visibleChange",!0):0<(e=this.options.showAfter)?(this.clearShowTimer(),this.showTimer=setTimeout(function(){return i.doOpen(t)},e)):this.doOpen(t))},s.prototype.requestHide=function(t){var e,i=this;this.clearShowTimer(),this.isOpen&&(this.controlled?this.emit("visibleChange",!1):0<(e=this.options.hideAfter)?(this.clearHideTimer(),this.hideTimer=setTimeout(function(){return i.doHide(t)},e)):this.doHide(t))},s.prototype.doOpen=function(t){var e,i=this;!this.options.disabled&&this.hasContent()&&(this.triggerListeners.length||this.options.virtualTriggering||this.bindTriggerEvents(),this.isOpen?(this.applyContent(),this.updatePosition()):(this.clearTimers(),this.emit("beforeShow",t),e=this.ensureNode(),this.applyContent(),d.addClass(e,"".concat(this.prefix,"tooltip--visible")),this.isOpen=!0,this.updatePosition(),this.bindGlobalEvents(),this.setAriaDescribedBy(!0),this.emit("show",t),this.emit("visibleChange",!0),0<this.options.autoClose&&(this.autoCloseTimer=setTimeout(function(){i.doHide()},this.options.autoClose))))},s.prototype.doHide=function(t){this.isOpen&&(this.emit("beforeHide",t),this.isOpen=!1,this.node&&d.removeClass(this.node,"".concat(this.prefix,"tooltip--visible")),this.setAriaDescribedBy(!1),this.unbindGlobalEvents(),this.clearTimers(),this.emit("hide",t),this.emit("visibleChange",!1),this.options.persistent||this.destroyNode(),this.options.focusOnTarget)&&null!=(t=this.getAnchorElement())&&t.focus()},s.prototype.clearTimers=function(){this.clearShowTimer(),this.clearHideTimer(),this.clearAutoCloseTimer()},s.prototype.show=function(t,e){e&&(this.imperativeAnchor=e),void 0!==t&&(this.currentContent=t),this.hasContent()?this.options.disabled||(this.controlled?this.emit("visibleChange",!0):this.doOpen()):this.hide()},s.prototype.hide=function(t){this.controlled?this.emit("visibleChange",!1):this.doHide(t)},s.prototype.onOpen=function(){this.requestOpen()},s.prototype.onClose=function(){this.hide()},s.prototype.isVisible=function(){return this.isOpen},s.prototype.getElement=function(){return this.node},s.prototype.getContentElement=function(){return this.contentNode},s.prototype.getTrigger=function(){return this.resolveElement(this.options.target)},s.prototype.isFocusInsideContent=function(){return Boolean(this.node&&this.node.contains(document.activeElement))},s.prototype.updatePopper=function(){this.updatePosition()},s.prototype.setContent=function(t){this.currentContent=t,this.isOpen&&(this.applyContent(),this.updatePosition())},s.prototype.setOptions=function(t){var e=this.options.target,i=this.options.trigger.join(","),o=this.options.appendTo,n=this.options.container,s=this.options.virtualTriggering;this.options=d.extend(this.options,t),void 0!==t.trigger&&(this.options.trigger=r(t.trigger)),t.triggerKeys&&(this.options.triggerKeys=t.triggerKeys),t.popperOptions&&(this.options.popperOptions=t.popperOptions),void 0!==t.content&&(this.currentContent=t.content),Object.prototype.hasOwnProperty.call(t,"visible")&&(this.controlled=d.isBoolean(t.visible)),void 0===t.target&&void 0===t.trigger&&void 0===t.virtualTriggering&&e===this.options.target&&i===this.options.trigger.join(",")&&s===this.options.virtualTriggering||this.bindTriggerEvents(),!this.node||void 0===t.appendTo&&void 0===t.container&&void 0===t.teleported&&o===this.options.appendTo&&n===this.options.container||this.attachNode(),this.node&&(e=this.prefix,this.node.style.position=this.strategy,d.removeClass(this.node,"".concat(e,"tooltip--dark")),d.removeClass(this.node,"".concat(e,"tooltip--light")),d.addClass(this.node,"".concat(e,"tooltip--").concat(this.options.effect)),this.options.enterable?d.addClass(this.node,"".concat(e,"tooltip--enterable")):d.removeClass(this.node,"".concat(e,"tooltip--enterable")),this.arrowNode&&(this.arrowNode.style.display=this.options.showArrow?"":"none"),this.options.ariaLabel&&d.setAttr(this.node,{"aria-label":this.options.ariaLabel}),this.options.popperClass&&d.addClass(this.node,this.options.popperClass),this.options.popperStyle&&this.applyPopperStyle(this.node),this.isOpen)&&(this.applyContent(),this.updatePosition()),this.options.disabled?this.doHide():this.controlled&&(this.options.visible?this.doOpen():this.doHide())},s.prototype.on=function(t,e){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(e),this},s.prototype.off=function(t,e){var i=this.listeners[t];return i&&(this.listeners[t]=e?i.filter(function(t){return t!==e}):[]),this},s.prototype.destroy=function(){this.clearTimers(),this.unbindTriggerEvents(),this.unbindGlobalEvents(),this.unbindPopperEvents(),this.setAriaDescribedBy(!1),this.destroyNode(),this.currentContent=void 0,this.imperativeAnchor=null,this.isOpen=!1,this.listeners={},this.controlled=!1};var n=s;function s(t){void 0===t&&(t={});var i=this;this.node=null,this.contentNode=null,this.arrowNode=null,this.isOpen=!1,this.controlled=!1,this.currentContent=void 0,this.imperativeAnchor=null,this.prevAriaDescribedBy=null,this.showTimer=null,this.hideTimer=null,this.autoCloseTimer=null,this.positionFrame=null,this.globalBound=!1,this.triggerListeners=[],this.popperListeners=[],this.listeners={},this.scheduleUpdate=function(){var t;null===i.positionFrame&&(t="function"==typeof requestAnimationFrame?requestAnimationFrame:function(t){return setTimeout(function(){return t(Date.now())},16)},i.positionFrame=t(function(){i.positionFrame=null,i.updatePosition()}))},this.handleDocumentKeydown=function(t){"Escape"===t.key&&i.isOpen&&i.doHide(t)},this.handleDocumentClick=function(t){var e,t=t.target;!t||i.node&&i.node.contains(t)||(e=i.getAnchorElement())&&e.contains(t)||i.hide()},this.options=d.extend({prefix:d.DEFAULT_PREFIX,rawContent:!1,effect:"dark",placement:"bottom",fallbackPlacements:[],disabled:!1,offset:12,arrowOffset:5,showArrow:!0,showAfter:0,hideAfter:200,autoClose:0,popperClass:"",popperStyle:"",teleported:!0,enterable:!0,triggerKeys:["Enter","Space"],persistent:!0,transition:"",ariaLabel:"",focusOnTarget:!1,popperOptions:{},className:""},t),this.options.trigger=r(t.trigger),this.options.popperOptions=t.popperOptions||{},this.options.triggerKeys=t.triggerKeys||["Enter","Space"],this.controlled=Object.prototype.hasOwnProperty.call(t,"visible")&&d.isBoolean(t.visible),this.currentContent=t.content,this.bindTriggerEvents(),this.controlled&&this.options.visible&&this.doOpen()}Object.defineProperty(t,"isTextTruncated",{enumerable:!0,get:function(){return d.isTextTruncated}}),t.Tooltip=n,t.default=n,Object.defineProperty(t,"__esModule",{value:!0})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ew-color-picker/tooltip",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.14",
|
|
4
4
|
"description": "Standalone tooltip utility used by ew-color-picker plugins",
|
|
5
5
|
"main": "dist/tooltip.min.js",
|
|
6
6
|
"module": "dist/tooltip.esm.js",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"author": "eveningwater(854806732@qq.com)",
|
|
19
19
|
"license": "MIT",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@ew-color-picker/utils": "^2.0.
|
|
21
|
+
"@ew-color-picker/utils": "^2.0.14"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"rollup": "^3.0.0",
|
|
25
25
|
"rollup-plugin-typescript2": "^0.34.0",
|
|
26
26
|
"typescript": "^4.9.0",
|
|
27
27
|
"rimraf": "^3.0.2",
|
|
28
|
-
"@ew-color-picker/utils": "2.0.
|
|
28
|
+
"@ew-color-picker/utils": "2.0.14"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|