1 line
No EOL
13 KiB
Text
1 line
No EOL
13 KiB
Text
{"version":3,"file":"navigation.nomodule.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","super"],"mappings":";;;;;EAAAA,IAAM,MAAM,GAAG;EACf,EAAE,MAAM,EAAE,IAAI;EACd,EAAE,SAAS,EAAE,MAAM;EACnB,EAAE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