{"version":3,"file":"tooltip.module.min.js","sources":["../../../.config/config.js","../../../src/core/api.js","../../../src/component/tooltip/script/tooltip/tooltip-selector.js","../../../src/component/tooltip/script/tooltip/tooltip-referent.js","../../../src/core/script/api/utilities/namespace.js","../../../src/component/tooltip/script/tooltip/tooltip-event.js","../../../src/component/tooltip/script/tooltip/tooltip.js","../../../src/component/tooltip/index.js","../../../src/component/tooltip/main.js"],"sourcesContent":["const config = {\r\n prefix: 'fr',\r\n namespace: 'dsfr',\r\n organisation: '@gouvfr',\r\n version: '1.11.2'\r\n};\r\n\r\nexport default config;\r\n","import config from './config.js';\nconst api = window[config.namespace];\nexport default api;\n","import api from '../../api.js';\n\nexport const TooltipSelector = {\n TOOLTIP: api.internals.ns.selector('tooltip'),\n SHOWN: api.internals.ns.selector('tooltip--shown'),\n BUTTON: api.internals.ns.selector('btn--tooltip')\n};\n","import api from '../../api.js';\nimport { TooltipSelector } from './tooltip-selector';\n\nconst TooltipReferentState = {\n FOCUS: 1 << 0,\n HOVER: 1 << 1\n};\n\nclass TooltipReferent extends api.core.PlacementReferent {\n constructor () {\n super();\n this._state = 0;\n }\n\n static get instanceClassName () {\n return 'TooltipReferent';\n }\n\n init () {\n super.init();\n this.listen('focusin', this.focusIn.bind(this));\n this.listen('focusout', this.focusOut.bind(this));\n if (!this.matches(TooltipSelector.BUTTON)) {\n const mouseover = this.mouseover.bind(this);\n this.listen('mouseover', mouseover);\n this.placement.listen('mouseover', mouseover);\n const mouseout = this.mouseout.bind(this);\n this.listen('mouseout', mouseout);\n this.placement.listen('mouseout', mouseout);\n }\n this.addEmission(api.core.RootEmission.KEYDOWN, this._keydown.bind(this));\n this.listen('click', this._click.bind(this));\n this.addEmission(api.core.RootEmission.CLICK, this._clickOut.bind(this));\n }\n\n _click () {\n this.focus();\n }\n\n _clickOut (target) {\n if (!this.node.contains(target)) this.blur();\n }\n\n _keydown (keyCode) {\n switch (keyCode) {\n case api.core.KeyCodes.ESCAPE:\n this.blur();\n this.close();\n break;\n }\n }\n\n close () {\n this.state = 0;\n }\n\n get state () {\n return this._state;\n }\n\n set state (value) {\n if (this._state === value) return;\n this.isShown = value > 0;\n this._state = value;\n }\n\n focusIn () {\n this.state |= TooltipReferentState.FOCUS;\n }\n\n focusOut () {\n this.state &= ~TooltipReferentState.FOCUS;\n }\n\n mouseover () {\n this.state |= TooltipReferentState.HOVER;\n }\n\n mouseout () {\n this.state &= ~TooltipReferentState.HOVER;\n }\n}\n\nexport { TooltipReferent };\n","import config from '../../../config.js';\n\nconst ns = name => `${config.prefix}-${name}`;\n\nns.selector = (name, notation) => {\n if (notation === undefined) notation = '.';\n return `${notation}${ns(name)}`;\n};\n\nns.attr = (name) => `data-${ns(name)}`;\n\nns.attr.selector = (name, value) => {\n let result = ns.attr(name);\n if (value !== undefined) result += `=\"${value}\"`;\n return `[${result}]`;\n};\n\nns.event = (type) => `${config.namespace}.${type}`;\n\nns.emission = (domain, type) => `emission:${domain}.${type}`;\n\nexport default ns;\n","import ns from '../../../../core/script/api/utilities/namespace.js';\n\nconst TooltipEvent = {\n SHOW: ns.event('show'),\n HIDE: ns.event('hide')\n};\n\nexport { TooltipEvent };\n","import api from '../../api.js';\nimport { TooltipReferent } from './tooltip-referent';\nimport { TooltipSelector } from './tooltip-selector';\nimport { TooltipEvent } from './tooltip-event.js';\n\nconst TooltipState = {\n HIDDEN: 'hidden',\n SHOWN: 'shown',\n HIDING: 'hiding'\n};\n\nclass Tooltip extends api.core.Placement {\n constructor () {\n super(api.core.PlacementMode.AUTO, [api.core.PlacementPosition.TOP, api.core.PlacementPosition.BOTTOM], [api.core.PlacementAlign.CENTER, api.core.PlacementAlign.START, api.core.PlacementAlign.END]);\n this.modifier = '';\n this._state = TooltipState.HIDDEN;\n }\n\n static get instanceClassName () {\n return 'Tooltip';\n }\n\n init () {\n super.init();\n this.register(`[aria-describedby=\"${this.id}\"]`, TooltipReferent);\n this.listen('transitionend', this.transitionEnd.bind(this));\n }\n\n transitionEnd () {\n if (this._state === TooltipState.HIDING) {\n this._state = TooltipState.HIDDEN;\n this.isShown = false;\n }\n }\n\n get isShown () {\n return super.isShown;\n }\n\n set isShown (value) {\n if (!this.isEnabled) return;\n switch (true) {\n case value:\n this._state = TooltipState.SHOWN;\n this.addClass(TooltipSelector.SHOWN);\n this.dispatch(TooltipEvent.SHOW);\n super.isShown = true;\n break;\n\n case this.isShown && !value && this._state === TooltipState.SHOWN:\n this._state = TooltipState.HIDING;\n this.removeClass(TooltipSelector.SHOWN);\n break;\n\n case this.isShown && !value && this._state === TooltipState.HIDDEN:\n this.dispatch(TooltipEvent.HIDE);\n super.isShown = false;\n break;\n }\n }\n\n render () {\n super.render();\n let x = this.referentRect.center - this.rect.center;\n const limit = this.rect.width * 0.5 - 8;\n if (x < -limit) x = -limit;\n if (x > limit) x = limit;\n this.setProperty('--arrow-x', `${x.toFixed(2)}px`);\n }\n}\n\nexport { Tooltip };\n","import api from './api.js';\nimport { Tooltip } from './script/tooltip/tooltip.js';\nimport { TooltipSelector } from './script/tooltip/tooltip-selector.js';\nimport { TooltipEvent } from './script/tooltip/tooltip-event';\n\napi.tooltip = {\n Tooltip: Tooltip,\n TooltipSelector: TooltipSelector,\n TooltipEvent: TooltipEvent\n};\n\nexport default api;\n","import api from './index.js';\n\napi.internals.register(api.tooltip.TooltipSelector.TOOLTIP, api.tooltip.Tooltip);\n\nexport default api;\n"],"names":["config","api","window","TooltipSelector","TOOLTIP","internals","ns","selector","SHOWN","BUTTON","TooltipReferentState","TooltipReferent","core","PlacementReferent","constructor","super","this","_state","instanceClassName","init","listen","focusIn","bind","focusOut","matches","mouseover","placement","mouseout","addEmission","RootEmission","KEYDOWN","_keydown","_click","CLICK","_clickOut","focus","target","node","contains","blur","keyCode","KeyCodes","ESCAPE","close","state","value","isShown","name","notation","undefined","attr","result","event","type","emission","domain","TooltipEvent","SHOW","HIDE","TooltipState","Tooltip","Placement","PlacementMode","AUTO","PlacementPosition","TOP","BOTTOM","PlacementAlign","CENTER","START","END","modifier","register","id","transitionEnd","isEnabled","addClass","dispatch","removeClass","render","x","referentRect","center","rect","limit","width","setProperty","toFixed","tooltip"],"mappings":";AAAA,MAAMA,EACI,KADJA,EAEO,OCDPC,EAAMC,OAAOF,GCCNG,EAAkB,CAC7BC,QAASH,EAAII,UAAUC,GAAGC,SAAS,WACnCC,MAAOP,EAAII,UAAUC,GAAGC,SAAS,kBACjCE,OAAQR,EAAII,UAAUC,GAAGC,SAAS,iBCF9BG,EACG,EADHA,EAEG,EAGT,MAAMC,UAAwBV,EAAIW,KAAKC,kBACrCC,cACEC,QACAC,KAAKC,OAAS,EAGLC,+BACT,MAAO,kBAGTC,OAIE,GAHAJ,MAAMI,OACNH,KAAKI,OAAO,UAAWJ,KAAKK,QAAQC,KAAKN,OACzCA,KAAKI,OAAO,WAAYJ,KAAKO,SAASD,KAAKN,QACtCA,KAAKQ,QAAQrB,EAAgBM,QAAS,CACzC,MAAMgB,EAAYT,KAAKS,UAAUH,KAAKN,MACtCA,KAAKI,OAAO,YAAaK,GACzBT,KAAKU,UAAUN,OAAO,YAAaK,GACnC,MAAME,EAAWX,KAAKW,SAASL,KAAKN,MACpCA,KAAKI,OAAO,WAAYO,GACxBX,KAAKU,UAAUN,OAAO,WAAYO,GAEpCX,KAAKY,YAAY3B,EAAIW,KAAKiB,aAAaC,QAASd,KAAKe,SAAST,KAAKN,OACnEA,KAAKI,OAAO,QAASJ,KAAKgB,OAAOV,KAAKN,OACtCA,KAAKY,YAAY3B,EAAIW,KAAKiB,aAAaI,MAAOjB,KAAKkB,UAAUZ,KAAKN,OAGpEgB,SACEhB,KAAKmB,QAGPD,UAAWE,GACJpB,KAAKqB,KAAKC,SAASF,IAASpB,KAAKuB,OAGxCR,SAAUS,GACR,GAAQA,IACDvC,EAAIW,KAAK6B,SAASC,OACrB1B,KAAKuB,OACLvB,KAAK2B,QAKXA,QACE3B,KAAK4B,MAAQ,EAGXA,YACF,OAAO5B,KAAKC,OAGV2B,UAAOC,GACL7B,KAAK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