@freshworks/crayons
Version:
Crayons Web Components library
1 lines • 3.51 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(t,e,o,n){function r(t){return t instanceof o?t:new o((function(e){e(t)}))}return new(o||(o=Promise))((function(o,i){function s(t){try{l(n.next(t))}catch(e){i(e)}}function a(t){try{l(n["throw"](t))}catch(e){i(e)}}function l(t){t.done?o(t.value):r(t.value).then(s,a)}l((n=n.apply(t,e||[])).next())}))};var __generator=this&&this.__generator||function(t,e){var o={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,r,i,s;return s={next:a(0),throw:a(1),return:a(2)},typeof Symbol==="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(t){return function(e){return l([t,e])}}function l(s){if(n)throw new TypeError("Generator is already executing.");while(o)try{if(n=1,r&&(i=s[0]&2?r["return"]:s[0]?r["throw"]||((i=r["return"])&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;if(r=0,i)s=[s[0]&2,i.value];switch(s[0]){case 0:case 1:i=s;break;case 4:o.label++;return{value:s[1],done:false};case 5:o.label++;r=s[1];s=[0];continue;case 7:s=o.ops.pop();o.trys.pop();continue;default:if(!(i=o.trys,i=i.length>0&&i[i.length-1])&&(s[0]===6||s[0]===2)){o=0;continue}if(s[0]===3&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(s[0]===6&&o.label<i[1]){o.label=i[1];i=s;break}if(i&&o.label<i[2]){o.label=i[2];o.ops.push(s);break}if(i[2])o.ops.pop();o.trys.pop();continue}s=e.call(t,o)}catch(a){s=[6,a];r=0}finally{n=i=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:true}}};import{r as registerInstance,h,i as getElement}from"./index-25bc21e4.js";import{h as hasSlot}from"./index-04e9b0fa.js";var tooltipCss=':host{font-family:var(--fw-font-family, -apple-system, blinkmacsystemfont, "Segoe UI", roboto, oxygen, ubuntu, cantarell, "Open Sans", "Helvetica Neue", sans-serif);-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-box-sizing:border-box;box-sizing:border-box}:host{--fw-popover-border-radius:4px}.tooltip{color:#fff;background:#12344d;border-radius:4px;font-size:12px;font-weight:600;line-height:18px;padding:6px 8px;max-width:236px;overflow:visible;overflow-wrap:anywhere;word-break:break-word}';var Tooltip=function(){function t(t){registerInstance(this,t);this.placement="top";this.fallbackPlacements=["top"];this.content="";this.distance="10";this.trigger="hover";this.hoist=false;this.custom=null}t.prototype.componentWillLoad=function(){if(this.custom===null){this.custom=hasSlot(this.host,"tooltip-content")}};t.prototype.show=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.popoverRef.show();return[2,true]}))}))};t.prototype.hide=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){this.popoverRef.hide();return[2,true]}))}))};t.prototype.render=function(){var t=this;return h("fw-popover",{trigger:this.trigger,placement:this.placement,fallbackPlacements:this.fallbackPlacements,sameWidth:false,distance:this.distance,"disable-transition":"true","has-border":"false",hoist:this.hoist,ref:function(e){return t.popoverRef=e}},h("slot",{slot:"popover-trigger"}),this.custom?h("div",{class:"tooltip",slot:"popover-content",role:"tooltip"},h("slot",{name:"tooltip-content"})):this.content.trim().length&&h("div",{class:"tooltip",slot:"popover-content",role:"tooltip"},this.content.trim()))};Object.defineProperty(t.prototype,"host",{get:function(){return getElement(this)},enumerable:false,configurable:true});return t}();Tooltip.style=tooltipCss;export{Tooltip as fw_tooltip};