1 line
No EOL
9.7 KiB
Text
1 line
No EOL
9.7 KiB
Text
{"version":3,"file":"tooltip.nomodule.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":["const","config","api","window","TooltipSelector","TOOLTIP","internals","ns","selector","SHOWN","BUTTON","TooltipReferentState","TooltipReferent","super","this","_state","staticAccessors","instanceClassName","init","listen","focusIn","bind","focusOut","matches","mouseover","placement","mouseout","addEmission","core","RootEmission","KEYDOWN","_keydown","_click","CLICK","_clickOut","focus","target","node","contains","blur","keyCode","KeyCodes","ESCAPE","close","state","prototypeAccessors","value","isShown","PlacementReferent","name","notation","undefined","attr","let","result","event","type","emission","domain","TooltipEvent","SHOW","HIDE","TooltipState","Tooltip","PlacementMode","AUTO","PlacementPosition","TOP","BOTTOM","PlacementAlign","CENTER","START","END","modifier","register","transitionEnd","isEnabled","addClass","dispatch","removeClass","render","x","referentRect","center","rect","limit","width","setProperty","toFixed","Placement","tooltip"],"mappings":";yBAAAA,IAAMC,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,EAGHC,cACJ,aACEC,aACAC,KAAKC,OAAS,wKAGhBC,EAAWC,iCACT,MAAO,+BAGTC,gBAIE,GAHAL,YAAMK,gBACNJ,KAAKK,OAAO,UAAWL,KAAKM,QAAQC,KAAKP,OACzCA,KAAKK,OAAO,WAAYL,KAAKQ,SAASD,KAAKP,QACtCA,KAAKS,QAAQnB,EAAgBM,QAAS,CACzCV,IAAMwB,EAAYV,KAAKU,UAAUH,KAAKP,MACtCA,KAAKK,OAAO,YAAaK,GACzBV,KAAKW,UAAUN,OAAO,YAAaK,GACnCxB,IAAM0B,EAAWZ,KAAKY,SAASL,KAAKP,MACpCA,KAAKK,OAAO,WAAYO,GACxBZ,KAAKW,UAAUN,OAAO,WAAYO,GAEpCZ,KAAKa,YAAYzB,EAAI0B,KAAKC,aAAaC,QAAShB,KAAKiB,SAASV,KAAKP,OACnEA,KAAKK,OAAO,QAASL,KAAKkB,OAAOX,KAAKP,OACtCA,KAAKa,YAAYzB,EAAI0B,KAAKC,aAAaI,MAAOnB,KAAKoB,UAAUb,KAAKP,oBAGpEkB,kBACElB,KAAKqB,qBAGPD,mBAAWE,GACJtB,KAAKuB,KAAKC,SAASF,IAAStB,KAAKyB,oBAGxCR,kBAAUS,GACR,GAAQA,IACDtC,EAAI0B,KAAKa,SAASC,OACrB5B,KAAKyB,OACLzB,KAAK6B,qBAKXA,iBACE7B,KAA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