TP_JO2024/home/dist/component/tooltip/tooltip.nomodule.min.js

4 lines
3.7 KiB
JavaScript
Raw Permalink Normal View History

2024-03-27 17:19:37 +01:00
/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
!function(){"use strict";var t="fr",e="dsfr",i=window[e],o={TOOLTIP:i.internals.ns.selector("tooltip"),SHOWN:i.internals.ns.selector("tooltip--shown"),BUTTON:i.internals.ns.selector("btn--tooltip")},s=1,n=2,r=function(t){function e(){t.call(this),this._state=0}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var r={state:{configurable:!0}},c={instanceClassName:{configurable:!0}};return c.instanceClassName.get=function(){return"TooltipReferent"},e.prototype.init=function(){if(t.prototype.init.call(this),this.listen("focusin",this.focusIn.bind(this)),this.listen("focusout",this.focusOut.bind(this)),!this.matches(o.BUTTON)){var e=this.mouseover.bind(this);this.listen("mouseover",e),this.placement.listen("mouseover",e);var s=this.mouseout.bind(this);this.listen("mouseout",s),this.placement.listen("mouseout",s)}this.addEmission(i.core.RootEmission.KEYDOWN,this._keydown.bind(this)),this.listen("click",this._click.bind(this)),this.addEmission(i.core.RootEmission.CLICK,this._clickOut.bind(this))},e.prototype._click=function(){this.focus()},e.prototype._clickOut=function(t){this.node.contains(t)||this.blur()},e.prototype._keydown=function(t){if(t===i.core.KeyCodes.ESCAPE)this.blur(),this.close()},e.prototype.close=function(){this.state=0},r.state.get=function(){return this._state},r.state.set=function(t){this._state!==t&&(this.isShown=t>0,this._state=t)},e.prototype.focusIn=function(){this.state|=s},e.prototype.focusOut=function(){this.state&=~s},e.prototype.mouseover=function(){this.state|=n},e.prototype.mouseout=function(){this.state&=~n},Object.defineProperties(e.prototype,r),Object.defineProperties(e,c),e}(i.core.PlacementReferent),c=function(e){return t+"-"+e};c.selector=function(t,e){return void 0===e&&(e="."),""+e+c(t)},(c.attr=function(t){return"data-"+c(t)}).selector=function(t,e){var i=c.attr(t);return void 0!==e&&(i+='="'+e+'"'),"["+i+"]"},c.event=function(t){return e+"."+t},c.emission=function(t,e){return"emission:"+t+"."+e};var h={SHOW:c.event("show"),HIDE:c.event("hide")},a="hidden",p="shown",l="hiding",u=function(t){function e(){t.call(this,i.core.PlacementMode.AUTO,[i.core.PlacementPosition.TOP,i.core.PlacementPosition.BOTTOM],[i.core.PlacementAlign.CENTER,i.core.PlacementAlign.START,i.core.PlacementAlign.END]),this.modifier="",this._state=a}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var s={isShown:{configurable:!0}},n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"Tooltip"},e.prototype.init=function(){t.prototype.init.call(this),this.register('[aria-describedby="'+this.id+'"]',r),this.listen("transitionend",this.transitionEnd.bind(this))},e.prototype.transitionEnd=function(){this._state===l&&(this._state=a,this.isShown=!1)},s.isShown.get=function(){return t.prototype.isShown},s.isShown.set=function(e){if(this.isEnabled)switch(!0){case e:this._state=p,this.addClass(o.SHOWN),this.dispatch(h.SHOW),t.prototype.isShown=!0;break;case this.isShown&&!e&&this._state===p:this._state=l,this.removeClass(o.SHOWN);break;case this.isShown&&!e&&this._state===a:this.dispatch(h.HIDE),t.prototype.isShown=!1}},e.prototype.render=function(){t.prototype.render.call(this);var e=this.referentRect.center-this.rect.center,i=.5*this.rect.width-8;e<-i&&(e=-i),e>i&&(e=i),this.setProperty("--arrow-x",e.toFixed(2)+"px")},Object.defineProperties(e.prototype,s),Object.defineProperties(e,n),e}(i.core.Placement);i.tooltip={Tooltip:u,TooltipSelector:o,TooltipEvent:h},i.internals.register(i.tooltip.TooltipSelector.TOOLTIP,i.tooltip.Tooltip)}();
//# sourceMappingURL=tooltip.nomodule.min.js.map