1 line
No EOL
14 KiB
Text
1 line
No EOL
14 KiB
Text
{"version":3,"file":"navigation.module.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":[],"mappings":";;AAAA,MAAM,MAAM,GAAG;AACf,EAAE,MAAM,EAAE,IAAI;AACd,EAAE,SAAS,EAAE,MAAM;AACnB,EAAE,YAAY,EAAE,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