1 line
No EOL
7.7 KiB
Text
1 line
No EOL
7.7 KiB
Text
{"version":3,"file":"header.module.min.js","sources":["../../../.config/config.js","../../../src/core/api.js","../../../src/component/header/script/header/header-selector.js","../../../src/component/header/script/header/header-links.js","../../../src/component/header/script/header/header-modal.js","../../../src/component/header/index.js","../../../src/component/header/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 HeaderSelector = {\n HEADER: api.internals.ns.selector('header'),\n TOOLS_LINKS: api.internals.ns.selector('header__tools-links'),\n MENU_LINKS: api.internals.ns.selector('header__menu-links'),\n BUTTONS: `${api.internals.ns.selector('header__tools-links')} ${api.internals.ns.selector('btns-group')}, ${api.internals.ns.selector('header__tools-links')} ${api.internals.ns.selector('links-group')}`,\n MODALS: `${api.internals.ns.selector('header__search')}${api.internals.ns.selector('modal')}, ${api.internals.ns.selector('header__menu')}${api.internals.ns.selector('modal')}`\n};\n","import api from '../../api.js';\nimport { HeaderSelector } from './header-selector.js';\n\nclass HeaderLinks extends api.core.Instance {\n static get instanceClassName () {\n return 'HeaderLinks';\n }\n\n init () {\n const header = this.queryParentSelector(HeaderSelector.HEADER);\n this.toolsLinks = header.querySelector(HeaderSelector.TOOLS_LINKS);\n this.menuLinks = header.querySelector(HeaderSelector.MENU_LINKS);\n const copySuffix = '-mobile';\n\n const toolsHtml = this.toolsLinks.innerHTML.replace(/ +/g, ' ');\n const menuHtml = this.menuLinks.innerHTML.replace(/ +/g, ' ');\n // Pour éviter de dupliquer des id, on ajoute un suffixe aux id et aria-controls duppliqués.\n let toolsHtmlIdList = toolsHtml.match(/id=\"(.*?)\"/gm) || [];\n\n // on a besoin d'échapper les backslash dans la chaine de caractère\n // eslint-disable-next-line no-useless-escape\n toolsHtmlIdList = toolsHtmlIdList.map(element => element.replace('id=\\\"', '').replace('\\\"', ''));\n\n const toolsHtmlAriaControlList = toolsHtml.match(/aria-controls=\"(.*?)\"/gm);\n let toolsHtmlDuplicateId = toolsHtml.replace(/id=\"(.*?)\"/gm, 'id=\"$1' + copySuffix + '\"');\n if (toolsHtmlAriaControlList) {\n for (const element of toolsHtmlAriaControlList) {\n const ariaControlsValue = element.replace('aria-controls=\"', '').replace('\"', '');\n if (toolsHtmlIdList.includes(ariaControlsValue)) {\n toolsHtmlDuplicateId = toolsHtmlDuplicateId.replace(`aria-controls=\"${ariaControlsValue}\"`, `aria-controls=\"${ariaControlsValue + copySuffix}\"`);\n };\n }\n }\n\n if (toolsHtmlDuplicateId === menuHtml) return;\n\n switch (api.mode) {\n case api.Modes.ANGULAR:\n case api.Modes.REACT:\n case api.Modes.VUE:\n this.warn(`header__tools-links content is different from header__menu-links content.\nAs you're using a dynamic framework, you should handle duplication of this content yourself, please refer to documentation:\n${api.header.doc}`);\n break;\n\n default:\n this.menuLinks.innerHTML = toolsHtmlDuplicateId;\n }\n }\n}\n\nexport { HeaderLinks };\n","import api from '../../api.js';\n\nclass HeaderModal extends api.core.Instance {\n static get instanceClassName () {\n return 'HeaderModal';\n }\n\n init () {\n this.isResizing = true;\n }\n\n resize () {\n if (this.isBreakpoint(api.core.Breakpoints.LG)) this.deactivateModal();\n else this.activateModal();\n }\n\n activateModal () {\n const modal = this.element.getInstance('Modal');\n if (!modal) return;\n modal.isEnabled = true;\n this.listenClick({ capture: true });\n }\n\n deactivateModal () {\n const modal = this.element.getInstance('Modal');\n if (!modal) return;\n modal.conceal();\n modal.isEnabled = false;\n this.unlistenClick({ capture: true });\n }\n\n handleClick (e) {\n if (e.target.matches('a, button') && !e.target.matches('[aria-controls]') && !e.target.matches(api.core.DisclosureSelector.PREVENT_CONCEAL)) {\n const modal = this.element.getInstance('Modal');\n modal.conceal();\n }\n }\n}\n\nexport { HeaderModal };\n","import api from './api.js';\nimport { HeaderLinks } from './script/header/header-links.js';\nimport { HeaderModal } from './script/header/header-modal.js';\nimport { HeaderSelector } from './script/header/header-selector.js';\n\napi.header = {\n HeaderLinks: HeaderLinks,\n HeaderModal: HeaderModal,\n HeaderSelector: HeaderSelector,\n doc: 'https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/en-tete'\n};\n\nexport default api;\n","import api from './index.js';\n\napi.internals.register(api.header.HeaderSelector.TOOLS_LINKS, api.header.HeaderLinks);\napi.internals.register(api.header.HeaderSelector.MODALS, api.header.HeaderModal);\n\nexport default api;\n"],"names":["api","window","HeaderSelector","HEADER","internals","ns","selector","TOOLS_LINKS","MENU_LINKS","BUTTONS","MODALS","HeaderLinks","core","Instance","instanceClassName","init","header","this","queryParentSelector","toolsLinks","querySelector","menuLinks","copySuffix","toolsHtml","innerHTML","replace","menuHtml","toolsHtmlIdList","match","map","element","toolsHtmlAriaControlList","toolsHtmlDuplicateId","ariaControlsValue","includes","mode","Modes","ANGULAR","REACT","VUE","warn","doc","HeaderModal","isResizing","resize","isBreakpoint","Breakpoints","LG","deactivateModal","activateModal","modal","getInstance","isEnabled","listenClick","capture","conceal","unlistenClick","handleClick","e","target","matches","DisclosureSelector","PREVENT_CONCEAL","register"],"mappings":";AAAA,MCCMA,EAAMC,OAAuB,KCCtBC,EAAiB,CAC5BC,OAAQH,EAAII,UAAUC,GAAGC,SAAS,UAClCC,YAAaP,EAAII,UAAUC,GAAGC,SAAS,uBACvCE,WAAYR,EAAII,UAAUC,GAAGC,SAAS,sBACtCG,QAAS,GAAGT,EAAII,UAAUC,GAAGC,SAAS,0BAA0BN,EAAII,UAAUC,GAAGC,SAAS,kBAAkBN,EAAII,UAAUC,GAAGC,SAAS,0BAA0BN,EAAII,UAAUC,GAAGC,SAAS,iBAC1LI,OAAQ,GAAGV,EAAII,UAAUC,GAAGC,SAAS,oBAAoBN,EAAII,UAAUC,GAAGC,SAAS,aAAaN,EAAII,UAAUC,GAAGC,SAAS,kBAAkBN,EAAII,UAAUC,GAAGC,SAAS,YCJxK,MAA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