1 line
No EOL
11 KiB
Text
1 line
No EOL
11 KiB
Text
{"version":3,"file":"navigation.nomodule.min.js","sources":["../../../.config/config.js","../../../src/core/api.js","../../../src/component/navigation/script/navigation/navigation-selector.js","../../../src/component/navigation/script/navigation/navigation-item.js","../../../src/component/navigation/script/navigation/navigation-mouse-position.js","../../../src/component/navigation/script/navigation/navigation.js","../../../src/component/navigation/index.js","../../../src/component/navigation/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\nconst ITEM = api.internals.ns.selector('nav__item');\nconst COLLAPSE = api.internals.ns.selector('collapse');\n\nexport const NavigationSelector = {\n NAVIGATION: api.internals.ns.selector('nav'),\n COLLAPSE: `${ITEM} > ${COLLAPSE}, ${ITEM} > *:not(${ITEM}):not(${COLLAPSE}) > ${COLLAPSE}, ${ITEM} > *:not(${ITEM}):not(${COLLAPSE}) > *:not(${ITEM}):not(${COLLAPSE}) > ${COLLAPSE}`,\n COLLAPSE_LEGACY: `${ITEM} ${COLLAPSE}`,\n ITEM: ITEM,\n ITEM_RIGHT: `${ITEM}--align-right`,\n MENU: api.internals.ns.selector('menu'),\n BUTTON: api.internals.ns.selector('nav__btn'),\n TRANSLATE_BUTTON: api.internals.ns.selector('translate__btn')\n};\n","import api from '../../api.js';\nimport { NavigationSelector } from './navigation-selector.js';\n\nclass NavigationItem extends api.core.Instance {\n constructor () {\n super();\n this._isRightAligned = false;\n }\n\n static get instanceClassName () {\n return 'NavigationItem';\n }\n\n init () {\n this.addAscent(api.core.DisclosureEmission.ADDED, this.calculate.bind(this));\n this.addAscent(api.core.DisclosureEmission.REMOVED, this.calculate.bind(this));\n this.isResizing = true;\n this.calculate();\n }\n\n resize () {\n this.calculate();\n }\n\n calculate () {\n const collapse = this.element.getDescendantInstances(api.core.Collapse.instanceClassName, null, true)[0];\n if (collapse && this.isBreakpoint(api.core.Breakpoints.LG) && collapse.element.node.matches(NavigationSelector.MENU)) {\n const right = this.element.node.parentElement.getBoundingClientRect().right; // todo: ne fonctionne que si la nav fait 100% du container\n const width = collapse.element.node.getBoundingClientRect().width;\n const left = this.element.node.getBoundingClientRect().left;\n this.isRightAligned = left + width > right;\n } else this.isRightAligned = false;\n }\n\n get isRightAligned () {\n return this._isRightAligned;\n }\n\n set isRightAligned (value) {\n if (this._isRightAligned === value) return;\n this._isRightAligned = value;\n if (value) api.internals.dom.addClass(this.element.node, NavigationSelector.ITEM_RIGHT);\n else api.internals.dom.removeClass(this.element.node, NavigationSelector.ITEM_RIGHT);\n }\n\n get collapsePrimary () {\n const buttons = this.element.children.map(child => child.getInstance('CollapseButton')).filter(button => button !== null && (button.hasClass(NavigationSelector.BUTTON) || button.hasClass(NavigationSelector.TRANSLATE_BUTTON)));\n return buttons[0];\n }\n}\n\nexport { NavigationItem };\n","export const NavigationMousePosition = {\n NONE: -1,\n INSIDE: 0,\n OUTSIDE: 1\n};\n","import api from '../../api.js';\nimport { NavigationSelector } from './navigation-selector.js';\nimport { NavigationMousePosition } from './navigation-mouse-position.js';\n\nclass Navigation extends api.core.CollapsesGroup {\n static get instanceClassName () {\n return 'Navigation';\n }\n\n init () {\n super.init();\n this.clicked = false;\n this.out = false;\n this.addEmission(api.core.RootEmission.CLICK, this._handleRootClick.bind(this));\n this.listen('mousedown', this.handleMouseDown.bind(this));\n this.listenClick({ capture: true });\n this.isResizing = true;\n }\n\n validate (member) {\n return super.validate(member) && member.element.node.matches(api.internals.legacy.isLegacy ? NavigationSelector.COLLAPSE_LEGACY : NavigationSelector.COLLAPSE);\n }\n\n handleMouseDown (e) {\n if (!this.isBreakpoint(api.core.Breakpoints.LG) || this.index === -1 || !this.current) return;\n this.position = this.current.node.contains(e.target) ? NavigationMousePosition.INSIDE : NavigationMousePosition.OUTSIDE;\n this.requestPosition();\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 this.index = -1;\n }\n }\n\n _handleRootClick (target) {\n if (!this.isBreakpoint(api.core.Breakpoints.LG)) return;\n if (!this.node.contains(target)) {\n this.out = true;\n this.requestPosition();\n }\n }\n\n requestPosition () {\n if (this.isRequesting) return;\n this.isRequesting = true;\n this.request(this.getPosition.bind(this));\n }\n\n getPosition () {\n if (this.out) {\n switch (this.position) {\n case NavigationMousePosition.OUTSIDE:\n this.index = -1;\n break;\n\n case NavigationMousePosition.INSIDE:\n if (this.current && !this.current.node.contains(document.activeElement)) this.current.focus();\n break;\n\n default:\n if (this.index > -1 && !this.current.hasFocus) this.index = -1;\n }\n }\n\n this.request(this.requested.bind(this));\n }\n\n requested () {\n this.position = NavigationMousePosition.NONE;\n this.out = false;\n this.isRequesting = false;\n }\n\n get index () { return super.index; }\n\n set index (value) {\n if (value === -1 && this.current && this.current.hasFocus) this.current.focus();\n super.index = value;\n }\n\n get canUngroup () {\n return !this.isBreakpoint(api.core.Breakpoints.LG);\n }\n\n resize () {\n this.update();\n }\n}\n\nexport { Navigation };\n","import api from './api.js';\nimport { NavigationItem } from './script/navigation/navigation-item.js';\nimport { Navigation } from './script/navigation/navigation.js';\nimport { NavigationSelector } from './script/navigation/navigation-selector.js';\nimport { NavigationMousePosition } from './script/navigation/navigation-mouse-position.js';\n\napi.navigation = {\n Navigation: Navigation,\n NavigationItem: NavigationItem,\n NavigationMousePosition: NavigationMousePosition,\n NavigationSelector: NavigationSelector\n};\n\nexport default api;\n","import api from './index.js';\n\napi.internals.register(api.navigation.NavigationSelector.NAVIGATION, api.navigation.Navigation);\napi.internals.register(api.navigation.NavigationSelector.ITEM, api.navigation.NavigationItem);\n\nexport default api;\n"],"names":["const","api","window","ITEM","internals","ns","selector","COLLAPSE","NavigationSelector","NAVIGATION","COLLAPSE_LEGACY","ITEM_RIGHT","MENU","BUTTON","TRANSLATE_BUTTON","NavigationItem","super","this","_isRightAligned","staticAccessors","instanceClassName","init","addAscent","core","DisclosureEmission","ADDED","calculate","bind","REMOVED","isResizing","resize","collapse","element","getDescendantInstances","Collapse","isBreakpoint","Breakpoints","LG","node","matches","right","parentElement","getBoundingClientRect","width","left","isRightAligned","prototypeAccessors","value","dom","addClass","removeClass","collapsePrimary","children","map","child","getInstance","filter","button","hasClass","Instance","NavigationMousePosition","NONE","INSIDE","OUTSIDE","Navigation","clicked","out","addEmission","RootEmission","CLICK","_handleRootClick","listen","handleMouseDown","listenClick","capture","validate","member","legacy","isLegacy","e","index","current","position","contains","target","requestPosition","handleClick","DisclosureSelector","PREVENT_CONCEAL","isRequesting","request","getPosition","document","activeElement","focus","hasFocus","requested","canUngroup","update","CollapsesGroup","navigation","register"],"mappings":";yBAAAA,ICCMC,EAAMC,OAAuB,KCC7BC,EAAOF,EAAIG,UAAUC,GAAGC,SAAS,aACjCC,EAAWN,EAAIG,UAAUC,GAAGC,SAAS,YAE9BE,EAAqB,CAChCC,WAAYR,EAAIG,UAAUC,GAAGC,SAAS,OACtCC,SAAaJ,QAAUI,OAAaJ,cAAgBA,WAAaI,SAAeA,OAAaJ,cAAgBA,WAAaI,eAAqBJ,WAAaI,SAAeA,EAC3KG,gBAAoBP,MAAQI,EAC5BJ,KAAMA,EACNQ,WAAeR,kBACfS,KAAMX,EAAIG,UAAUC,GAAGC,SAAS,QAChCO,OAAQZ,EAAIG,UAAUC,GAAGC,SAAS,YAClCQ,iBAAkBb,EAAIG,UAAUC,GAAGC,SAAS,mBCVxCS,cACJ,aACEC,aACAC,KAAKC,iBAAkB,mNAGzBC,EAAWC,iCACT,MAAO,8BAGTC,gBACEJ,KAAKK,UAAUrB,EAAIsB,KAAKC,mBAAmBC,MAAOR,KAAKS,UAAUC,KAAKV,OACtEA,KAAKK,UAAUrB,EAAIsB,KAAKC,mBAAmBI,QAASX,KAAKS,UAAUC,KAAKV,OACxEA,KAAKY,YAAa,EAClBZ,KAAKS,yBA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