{"version":3,"file":"tooltip.module.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":[],"mappings":";;AAAA,MAAM,MAAM,GAAG;AACf,EAAE,MAAM,EAAE,IAAI;AACd,EAAE,SAAS,EAAE,MAAM;AACnB,EAAE,YAAY,EAAE,SAAS;AACzB,EAAE,OAAO,EAAE,QAAQ;AACnB,CAAC;;ACJD,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;;ACC7B,MAAM,eAAe,GAAG;AAC/B,EAAE,OAAO,EAAE,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;AAC/C,EAAE,KAAK,EAAE,GAAG,CAA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