@codegouvfr/react-dsfr
Version:
French State Design System React integration library
4 lines (3 loc) • 38 kB
JavaScript
/*! DSFR v1.8.5 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
!function(){"use strict";var t=window.dsfr,e={GROUP:t.internals.ns.selector("accordions-group"),COLLAPSE:t.internals.ns.selector("accordion")+" > "+t.internals.ns.selector("collapse")},n=function(t){function n(){t.apply(this,arguments)}t&&(n.__proto__=t),n.prototype=Object.create(t&&t.prototype),n.prototype.constructor=n;var i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"AccordionsGroup"},n.prototype.validate=function(t){return t.node.matches(e.COLLAPSE)},Object.defineProperties(n,i),n}(t.core.CollapsesGroup);t.accordion={AccordionSelector:e,AccordionsGroup:n},t.internals.register(t.accordion.AccordionSelector.GROUP,t.accordion.AccordionsGroup);var i={EQUISIZED_BUTTON:t.internals.ns.selector("btns-group--equisized")+" "+t.internals.ns.selector("btn"),EQUISIZED_GROUP:t.internals.ns.selector("btns-group--equisized")};t.button={ButtonSelector:i},t.internals.register(t.button.ButtonSelector.EQUISIZED_BUTTON,t.core.Equisized),t.internals.register(t.button.ButtonSelector.EQUISIZED_GROUP,t.core.EquisizedsGroup);var s=function(e){function n(){e.call(this),this.count=0,this.focusing=this.focus.bind(this)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={proxy:{configurable:!0},links:{configurable:!0},collapse:{configurable:!0}},s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"Breadcrumb"},n.prototype.init=function(){this.getCollapse(),this.isResizing=!0},i.proxy.get=function(){var t=this;return Object.assign.call(this,e.prototype.proxy,{focus:t.focus.bind(t),disclose:t.collapse.disclose.bind(t.collapse)})},n.prototype.getCollapse=function(){var e=this.collapse;e?e.listen(t.core.DisclosureEvent.DISCLOSE,this.focusing):this.addAscent(t.core.DisclosureEmission.ADDED,this.getCollapse.bind(this))},n.prototype.resize=function(){var e=this.collapse,n=this.links;e&&n.length&&(this.isBreakpoint(t.core.Breakpoints.MD)?e.buttonHasFocus&&n[0].focus():n.indexOf(document.activeElement)>-1&&e.focus())},i.links.get=function(){return[].concat(this.querySelectorAll("a[href]"))},i.collapse.get=function(){return this.element.getDescendantInstances(t.core.Collapse.instanceClassName,null,!0)[0]},n.prototype.focus=function(){this.count=0,this._focus()},n.prototype._focus=function(){var t=this.links[0];t&&(t.focus(),this.request(this.verify.bind(this)))},n.prototype.verify=function(){if(this.count++,!(this.count>100)){var t=this.links[0];t&&document.activeElement!==t&&this._focus()}},Object.defineProperties(n.prototype,i),Object.defineProperties(n,s),n}(t.core.Instance),o={BREADCRUMB:t.internals.ns.selector("breadcrumb")};t.breadcrumb={BreadcrumbSelector:o,Breadcrumb:s},t.internals.register(t.breadcrumb.BreadcrumbSelector.BREADCRUMB,t.breadcrumb.Breadcrumb);var r=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={isChecked:{configurable:!0}},i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"ToggleInput"},n.isChecked.get=function(){return this.hasAttribute("checked")},Object.defineProperties(e.prototype,n),Object.defineProperties(e,i),e}(t.core.Instance),a=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={proxy:{configurable:!0},input:{configurable:!0}},i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"ToggleStatusLabel"},e.prototype.init=function(){this.register('input[id="'+this.getAttribute("for")+'"]',r),this.update(),this.isSwappingFont=!0},n.proxy.get=function(){return Object.assign.call(this,t.prototype.proxy,{update:this.update.bind(this)})},n.input.get=function(){return this.getRegisteredInstances("ToggleInput")[0]},e.prototype.update=function(){this.node.style.removeProperty("--toggle-status-width");var t=this.input.isChecked,e=getComputedStyle(this.node,":before"),n=parseFloat(e.width);this.input.node.checked=!t;var i=getComputedStyle(this.node,":before"),s=parseFloat(i.width);s>n&&(n=s),this.input.node.checked=t,this.node.style.setProperty("--toggle-status-width",n/16+"rem")},e.prototype.swapFont=function(t){this.update()},Object.defineProperties(e.prototype,n),Object.defineProperties(e,i),e}(t.core.Instance),c={STATUS_LABEL:""+t.internals.ns.selector("toggle__label")+t.internals.ns.attr.selector("checked-label")+t.internals.ns.attr.selector("unchecked-label")};t.toggle={ToggleStatusLabel:a,ToggleSelector:c},t.internals.register(t.toggle.ToggleSelector.STATUS_LABEL,t.toggle.ToggleStatusLabel);var l={LIST:t.internals.ns.selector("sidemenu__list"),COLLAPSE:t.internals.ns.selector("sidemenu__item")+" > "+t.internals.ns.selector("collapse")},p=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"SidemenuList"},e.prototype.validate=function(t){return t.node.matches(l.COLLAPSE)},Object.defineProperties(e,n),e}(t.core.CollapsesGroup);t.sidemenu={SidemenuList:p,SidemenuSelector:l},t.internals.register(t.sidemenu.SidemenuSelector.LIST,t.sidemenu.SidemenuList);var u={MODAL:t.internals.ns.selector("modal"),SCROLL_SHADOW:t.internals.ns.selector("scroll-shadow"),BODY:t.internals.ns.selector("modal__body")},h=function(e){function n(){e.call(this,t.core.DisclosureType.OPENED)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"ModalButton"},Object.defineProperties(n,i),n}(t.core.DisclosureButton),d={CONCEALING_BACKDROP:t.internals.ns.attr("concealing-backdrop")},f=function(e){function n(){e.call(this,t.core.DisclosureType.OPENED,u.MODAL,h,"ModalsGroup"),this.scrolling=this.resize.bind(this,!1),this.resizing=this.resize.bind(this,!0)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={body:{configurable:!0}},s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"Modal"},n.prototype.init=function(){e.prototype.init.call(this),this.listen("click",this.click.bind(this)),this.listenKey(t.core.KeyCodes.ESCAPE,this.conceal.bind(this,!1,!1),!0,!0)},i.body.get=function(){return this.element.getDescendantInstances("ModalBody","Modal")[0]},n.prototype.click=function(t){t.target===this.node&&"false"!==this.getAttribute(d.CONCEALING_BACKDROP)&&this.conceal()},n.prototype.disclose=function(t){return!!e.prototype.disclose.call(this,t)&&(this.body&&this.body.activate(),this.isScrollLocked=!0,this.setAttribute("aria-modal","true"),this.setAttribute("open","true"),!0)},n.prototype.conceal=function(t,n){return!!e.prototype.conceal.call(this,t,n)&&(this.isScrollLocked=!1,this.removeAttribute("aria-modal"),this.removeAttribute("open"),this.body&&this.body.deactivate(),!0)},Object.defineProperties(n.prototype,i),Object.defineProperties(n,s),n}(t.core.Disclosure),g=['[tabindex="0"]',"a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])","audio[controls]","video[controls]",'[contenteditable]:not([contenteditable="false"])',"details>summary:first-of-type","details","iframe"].join(),b=['[tabindex]:not([tabindex="-1"]):not([tabindex="0"])'].join(),y=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);if(!n)return!1;if("hidden"===n.visibility)return!1;for(void 0===e&&(e=t);e.contains(t);){if("none"===n.display)return!1;t=t.parentElement}return!0},m=function(t,e){this.element=null,this.activeElement=null,this.onTrap=t,this.onUntrap=e,this.waiting=this.wait.bind(this),this.handling=this.handle.bind(this),this.focusing=this.maintainFocus.bind(this),this.current=null},_={trapped:{configurable:!0},focusables:{configurable:!0}};_.trapped.get=function(){return null!==this.element},m.prototype.trap=function(t){this.trapped&&this.untrap(),this.element=t,this.isTrapping=!0,this.wait(),this.onTrap&&this.onTrap()},m.prototype.wait=function(){y(this.element)?this.trapping():window.requestAnimationFrame(this.waiting)},m.prototype.trapping=function(){if(this.isTrapping){this.isTrapping=!1;var t=this.focusables;t.length&&t[0].focus(),this.element.setAttribute("aria-modal",!0),window.addEventListener("keydown",this.handling),document.body.addEventListener("focus",this.focusing,!0)}},m.prototype.stun=function(t){for(var e=0,n=t.children;e<n.length;e+=1){var i=n[e];i!==this.element&&(i.contains(this.element)?this.stun(i):this.stunneds.push(new S(i)))}},m.prototype.maintainFocus=function(t){if(!this.element.contains(t.target)){var e=this.focusables;if(0===e.length)return;var n=e[0];t.preventDefault(),n.focus()}},m.prototype.handle=function(t){if(9===t.keyCode){var e=this.focusables;if(0!==e.length){var n=e[0],i=e[e.length-1],s=e.indexOf(document.activeElement);t.shiftKey?!this.element.contains(document.activeElement)||s<1?(t.preventDefault(),i.focus()):(document.activeElement.tabIndex>0||e[s-1].tabIndex>0)&&(t.preventDefault(),e[s-1].focus()):this.element.contains(document.activeElement)&&s!==e.length-1&&-1!==s?document.activeElement.tabIndex>0&&(t.preventDefault(),e[s+1].focus()):(t.preventDefault(),n.focus())}}},_.focusables.get=function(){var e=this,n=t.internals.dom.querySelectorAllArray(this.element,g),i=t.internals.dom.querySelectorAllArray(document.documentElement,'input[type="radio"]');if(i.length){for(var s={},o=0,r=i;o<r.length;o+=1){var a=r[o],c=a.getAttribute("name");void 0===s[c]&&(s[c]=new v(c)),s[c].push(a)}n=n.filter((function(t){if("input"!==t.tagName.toLowerCase()||"radio"!==t.getAttribute("type").toLowerCase())return!0;var e=t.getAttribute("name");return s[e].keep(t)}))}var l=t.internals.dom.querySelectorAllArray(this.element,b);l.sort((function(t,e){return t.tabIndex-e.tabIndex}));var p=n.filter((function(t){return-1===l.indexOf(t)}));return l.concat(p).filter((function(t){return"-1"!==t.tabIndex&&y(t,e.element)}))},m.prototype.untrap=function(){this.trapped&&(this.isTrapping=!1,this.element.removeAttribute("aria-modal"),window.removeEventListener("keydown",this.handling),document.body.removeEventListener("focus",this.focusing,!0),this.element=null,this.onUntrap&&this.onUntrap())},m.prototype.dispose=function(){this.untrap()},Object.defineProperties(m.prototype,_);var S=function(t){this.element=t,this.inert=t.getAttribute("inert"),this.element.setAttribute("inert","")};S.prototype.unstun=function(){null===this.inert?this.element.removeAttribute("inert"):this.element.setAttribute("inert",this.inert)};var v=function(t){this.name=t,this.buttons=[]};v.prototype.push=function(t){this.buttons.push(t),(t===document.activeElement||t.checked||void 0===this.selected)&&(this.selected=t)},v.prototype.keep=function(t){return this.selected===t};var T=function(t){function e(){t.call(this,"Modal",!1),this.focusTrap=new m}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"ModalsGroup"},e.prototype.apply=function(e,n){t.prototype.apply.call(this,e,n),null===this.current?this.focusTrap.untrap():this.focusTrap.trap(this.current.node)},Object.defineProperties(e,n),e}(t.core.DisclosuresGroup),O=function(e){function n(){e.apply(this,arguments)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"ModalBody"},n.prototype.init=function(){this.listen("scroll",this.shade.bind(this))},n.prototype.activate=function(){this.isResizing=!0,this.resize()},n.prototype.deactivate=function(){this.isResizing=!1},n.prototype.shade=function(){this.node.scrollHeight>this.node.clientHeight?this.node.offsetHeight+this.node.scrollTop>=this.node.scrollHeight?this.removeClass(u.SCROLL_SHADOW):this.addClass(u.SCROLL_SHADOW):this.removeClass(u.SCROLL_SHADOW)},n.prototype.resize=function(){this.adjust(),this.request(this.adjust.bind(this))},n.prototype.adjust=function(){var e=32*(this.isBreakpoint(t.core.Breakpoints.MD)?2:1);this.isLegacy?this.style.maxHeight=window.innerHeight-e+"px":this.style.setProperty("--modal-max-height",window.innerHeight-e+"px"),this.shade()},Object.defineProperties(n,i),n}(t.core.Instance);t.modal={Modal:f,ModalButton:h,ModalBody:O,ModalsGroup:T,ModalSelector:u},t.internals.register(t.modal.ModalSelector.MODAL,t.modal.Modal),t.internals.register(t.modal.ModalSelector.BODY,t.modal.ModalBody),t.internals.register(t.core.RootSelector.ROOT,t.modal.ModalsGroup);var A={TOGGLE:t.internals.ns.emission("password","toggle"),ADJUST:t.internals.ns.emission("password","adjust")},E=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={width:{configurable:!0},isChecked:{configurable:!0}},i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"PasswordToggle"},e.prototype.init=function(){this.listen("click",this.toggle.bind(this)),this.ascend(A.ADJUST,this.width),this.isSwappingFont=!0,this._isChecked=this.isChecked},n.width.get=function(){var t=getComputedStyle(this.node.parentNode);return parseInt(t.width)},n.isChecked.get=function(){return this.node.checked},n.isChecked.set=function(t){this._isChecked=t,this.ascend(A.TOGGLE,t)},e.prototype.toggle=function(){this.isChecked=!this._isChecked},e.prototype.swapFont=function(t){this.ascend(A.ADJUST,this.width)},Object.defineProperties(e.prototype,n),Object.defineProperties(e,i),e}(t.core.Instance),C=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"Password"},e.prototype.init=function(){this.addAscent(A.TOGGLE,this.toggle.bind(this)),this.addAscent(A.ADJUST,this.adjust.bind(this))},e.prototype.toggle=function(t){this.descend(A.TOGGLE,t)},e.prototype.adjust=function(t){this.descend(A.ADJUST,t)},Object.defineProperties(e,n),e}(t.core.Instance),L={PASSWORD:t.internals.ns.selector("password"),INPUT:t.internals.ns.selector("password__input"),LABEL:t.internals.ns.selector("password__label"),TOOGLE:t.internals.ns.selector("password__checkbox")+' input[type="checkbox"]'},N=function(e){function n(){e.apply(this,arguments)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={isRevealed:{configurable:!0}},s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"PasswordInput"},n.prototype.init=function(){this.addDescent(A.TOGGLE,this.toggle.bind(this)),this._isRevealed="password"===this.hasAttribute("type"),this.listen("keydown",this.capslock.bind(this)),this.listen("keyup",this.capslock.bind(this))},n.prototype.toggle=function(t){this.isRevealed=t,this.setAttribute("type",t?"text":"password")},i.isRevealed.get=function(){return this._isRevealed},n.prototype.capslock=function(e){e.getModifierState("CapsLock")?this.node.parentNode.setAttribute(t.internals.ns.attr("capslock"),""):this.node.parentNode.removeAttribute(t.internals.ns.attr("capslock"))},i.isRevealed.set=function(t){this._isRevealed=t,this.setAttribute("type",t?"text":"password")},Object.defineProperties(n.prototype,i),Object.defineProperties(n,s),n}(t.core.Instance),D=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"PasswordLabel"},e.prototype.init=function(){this.addDescent(A.ADJUST,this.adjust.bind(this))},e.prototype.adjust=function(t){var e=Math.ceil(t/16);this.node.style.paddingRight=e+"rem"},Object.defineProperties(e,n),e}(t.core.Instance);t.password={Password:C,PasswordToggle:E,PasswordSelector:L,PasswordInput:N,PasswordLabel:D},t.internals.register(t.password.PasswordSelector.INPUT,t.password.PasswordInput),t.internals.register(t.password.PasswordSelector.PASSWORD,t.password.Password),t.internals.register(t.password.PasswordSelector.TOOGLE,t.password.PasswordToggle),t.internals.register(t.password.PasswordSelector.LABEL,t.password.PasswordLabel);var P={NAVIGATION:t.internals.ns.selector("nav"),COLLAPSE:t.internals.ns.selector("nav__item")+" > "+t.internals.ns.selector("collapse"),ITEM:t.internals.ns.selector("nav__item"),ITEM_RIGHT:t.internals.ns("nav__item--align-right"),MENU:t.internals.ns.selector("menu")},I=function(e){function n(){e.call(this),this._isRightAligned=!1}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={isRightAligned:{configurable:!0}},s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"NavigationItem"},n.prototype.init=function(){this.addAscent(t.core.DisclosureEmission.ADDED,this.calculate.bind(this)),this.addAscent(t.core.DisclosureEmission.REMOVED,this.calculate.bind(this)),this.isResizing=!0,this.calculate()},n.prototype.resize=function(){this.calculate()},n.prototype.calculate=function(){var e=this.element.getDescendantInstances(t.core.Collapse.instanceClassName,null,!0)[0];if(e&&this.isBreakpoint(t.core.Breakpoints.LG)&&e.element.node.matches(P.MENU)){var n=this.element.node.parentElement.getBoundingClientRect().right,i=e.element.node.getBoundingClientRect().width,s=this.element.node.getBoundingClientRect().left;this.isRightAligned=s+i>n}else this.isRightAligned=!1},i.isRightAligned.get=function(){return this._isRightAligned},i.isRightAligned.set=function(e){this._isRightAligned!==e&&(this._isRightAligned=e,e?t.internals.dom.addClass(this.element.node,P.ITEM_RIGHT):t.internals.dom.removeClass(this.element.node,P.ITEM_RIGHT))},Object.defineProperties(n.prototype,i),Object.defineProperties(n,s),n}(t.core.Instance),w={NONE:-1,INSIDE:0,OUTSIDE:1},H=function(e){function n(){e.apply(this,arguments)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={index:{configurable:!0}},s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"Navigation"},n.prototype.init=function(){e.prototype.init.call(this),this.clicked=!1,this.out=!1,this.listen("focusout",this.focusOut.bind(this)),this.listen("mousedown",this.down.bind(this))},n.prototype.validate=function(t){return t.element.node.matches(P.COLLAPSE)},n.prototype.down=function(e){this.isBreakpoint(t.core.Breakpoints.LG)&&-1!==this.index&&this.current&&(this.position=this.current.node.contains(e.target)?w.INSIDE:w.OUTSIDE,this.requestPosition())},n.prototype.focusOut=function(e){this.isBreakpoint(t.core.Breakpoints.LG)&&(this.out=!0,this.requestPosition())},n.prototype.requestPosition=function(){this.isRequesting||(this.isRequesting=!0,this.request(this.getPosition.bind(this)))},n.prototype.getPosition=function(){if(this.out)switch(this.position){case w.OUTSIDE:this.index=-1;break;case w.INSIDE:this.current&&!this.current.node.contains(document.activeElement)&&this.current.focus();break;default:this.index>-1&&!this.current.hasFocus&&(this.index=-1)}this.request(this.requested.bind(this))},n.prototype.requested=function(){this.position=w.NONE,this.out=!1,this.isRequesting=!1},i.index.get=function(){return e.prototype.index},i.index.set=function(t){-1===t&&null!==this.current&&this.current.hasFocus&&this.current.focus(),e.prototype.index=t},Object.defineProperties(n.prototype,i),Object.defineProperties(n,s),n}(t.core.CollapsesGroup);t.navigation={Navigation:H,NavigationItem:I,NavigationMousePosition:w,NavigationSelector:P},t.internals.register(t.navigation.NavigationSelector.NAVIGATION,t.navigation.Navigation),t.internals.register(t.navigation.NavigationSelector.ITEM,t.navigation.NavigationItem);var k=function(e){function n(){e.call(this,t.core.DisclosureType.SELECT)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={list:{configurable:!0}},s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"TabButton"},n.prototype.apply=function(t){e.prototype.apply.call(this,t),this.isPrimary&&(this.setAttribute("tabindex",t?"0":"-1"),t&&this.list&&this.list.focalize(this))},i.list.get=function(){return this.element.getAscendantInstance("TabsList","TabsGroup")},Object.defineProperties(n.prototype,i),Object.defineProperties(n,s),n}(t.core.DisclosureButton),R={TAB:t.internals.ns.selector("tabs__tab"),GROUP:t.internals.ns.selector("tabs"),PANEL:t.internals.ns.selector("tabs__panel"),LIST:t.internals.ns.selector("tabs__list"),SHADOW:t.internals.ns.selector("tabs__shadow"),SHADOW_LEFT:t.internals.ns.selector("tabs__shadow--left"),SHADOW_RIGHT:t.internals.ns.selector("tabs__shadow--right"),PANEL_START:t.internals.ns.selector("tabs__panel--direction-start"),PANEL_END:t.internals.ns.selector("tabs__panel--direction-end")},j="direction-start",M="direction-end",G="none",B=function(e){function n(){e.call(this,t.core.DisclosureType.SELECT,R.PANEL,k,"TabsGroup"),this._direction=G,this._isPreventingTransition=!1}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={direction:{configurable:!0},isPreventingTransition:{configurable:!0}},s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"TabPanel"},i.direction.get=function(){return this._direction},i.direction.set=function(t){if(t!==this._direction){switch(this._direction){case j:this.removeClass(R.PANEL_START);break;case M:this.removeClass(R.PANEL_END);break;case G:break;default:return}switch(this._direction=t,this._direction){case j:this.addClass(R.PANEL_START);break;case M:this.addClass(R.PANEL_END)}}},i.isPreventingTransition.get=function(){return this._isPreventingTransition},i.isPreventingTransition.set=function(e){this._isPreventingTransition!==e&&(e?this.addClass(t.internals.motion.TransitionSelector.NONE):this.removeClass(t.internals.motion.TransitionSelector.NONE),this._isPreventingTransition=!0===e)},n.prototype.translate=function(t,e){this.isPreventingTransition=e,this.direction=t},n.prototype.reset=function(){this.group.index=0},Object.defineProperties(n.prototype,i),Object.defineProperties(n,s),n}(t.core.Disclosure),x=function(e){function n(){e.call(this,"TabPanel")}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={list:{configurable:!0},buttonHasFocus:{configurable:!0},isPreventingTransition:{configurable:!0}},s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"TabsGroup"},n.prototype.init=function(){e.prototype.init.call(this),this.listen("transitionend",this.transitionend.bind(this)),this.listenKey(t.core.KeyCodes.RIGHT,this.pressRight.bind(this),!0,!0),this.listenKey(t.core.KeyCodes.LEFT,this.pressLeft.bind(this),!0,!0),this.listenKey(t.core.KeyCodes.HOME,this.pressHome.bind(this),!0,!0),this.listenKey(t.core.KeyCodes.END,this.pressEnd.bind(this),!0,!0),this.isRendering=!0,this.list&&this.list.apply()},i.list.get=function(){return this.element.getDescendantInstances("TabsList","TabsGroup",!0)[0]},n.prototype.transitionend=function(t){this.isPreventingTransition=!0},i.buttonHasFocus.get=function(){return this.members.some((function(t){return t.buttonHasFocus}))},n.prototype.pressRight=function(){this.buttonHasFocus&&(this.index<this.length-1?this.index++:this.index=0,this.focus())},n.prototype.pressLeft=function(){this.buttonHasFocus&&(this.index>0?this.index--:this.index=this.length-1,this.focus())},n.prototype.pressHome=function(){this.buttonHasFocus&&(this.index=0,this.focus())},n.prototype.pressEnd=function(){this.buttonHasFocus&&(this.index=this.length-1,this.focus())},n.prototype.focus=function(){this.current&&this.current.focus()},n.prototype.apply=function(){for(var t=0;t<this._index;t++)this.members[t].translate(j);this.current.translate(G);for(var e=this._index+1;e<this.length;e++)this.members[e].translate(M);this.isPreventingTransition=!1},i.isPreventingTransition.get=function(){return this._isPreventingTransition},i.isPreventingTransition.set=function(e){this._isPreventingTransition!==e&&(e?this.addClass(t.internals.motion.TransitionSelector.NONE):this.removeClass(t.internals.motion.TransitionSelector.NONE),this._isPreventingTransition=!0===e)},n.prototype.render=function(){if(null!==this.current){var t=Math.round(this.current.node.offsetHeight);if(this.panelHeight!==t){this.panelHeight=t;var e=0;this.list&&(e=this.list.node.offsetHeight),this.style.setProperty("--tabs-height",this.panelHeight+e+"px")}}},Object.defineProperties(n.prototype,i),Object.defineProperties(n,s),n}(t.core.DisclosuresGroup),U=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={group:{configurable:!0},isScrolling:{configurable:!0}},i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"TabsList"},e.prototype.init=function(){this.listen("scroll",this.scroll.bind(this)),this.isResizing=!0},n.group.get=function(){return this.element.getAscendantInstance("TabsGroup","TabsList")},e.prototype.focalize=function(t){var e=t.getRect(),n=this.getRect(),i=this.node.scrollLeft;e.left<n.left?this.node.scrollTo(i-n.left+e.left-16,0):e.right>n.right&&this.node.scrollTo(i-n.right+e.right+16,0)},n.isScrolling.get=function(){return this._isScrolling},n.isScrolling.set=function(t){this._isScrolling!==t&&(this._isScrolling=t,this.apply())},e.prototype.apply=function(){this.group&&(this._isScrolling?(this.group.addClass(R.SHADOW),this.scroll()):(this.group.removeClass(R.SHADOW_RIGHT),this.group.removeClass(R.SHADOW_LEFT),this.group.removeClass(R.SHADOW)))},e.prototype.scroll=function(){if(this.group){var t=this.node.scrollLeft,e=t<=16,n=this.node.scrollWidth-this.node.clientWidth-16,i=Math.abs(t)>=n,s="rtl"===document.documentElement.getAttribute("dir"),o=s?R.SHADOW_RIGHT:R.SHADOW_LEFT,r=s?R.SHADOW_LEFT:R.SHADOW_RIGHT;e?this.group.removeClass(o):this.group.addClass(o),i?this.group.removeClass(r):this.group.addClass(r)}},e.prototype.resize=function(){this.isScrolling=this.node.scrollWidth>this.node.clientWidth+16,this.setProperty("--tab-list-height",this.getRect().height+"px")},e.prototype.dispose=function(){this.isScrolling=!1},Object.defineProperties(e.prototype,n),Object.defineProperties(e,i),e}(t.core.Instance);t.tab={TabPanel:B,TabButton:k,TabsGroup:x,TabsList:U,TabSelector:R},t.internals.register(t.tab.TabSelector.PANEL,t.tab.TabPanel),t.internals.register(t.tab.TabSelector.GROUP,t.tab.TabsGroup),t.internals.register(t.tab.TabSelector.LIST,t.tab.TabsList);var W={SCROLLABLE:t.internals.ns.emission("table","scrollable"),CHANGE:t.internals.ns.emission("table","change"),CAPTION_HEIGHT:t.internals.ns.emission("table","captionheight")},F=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"Table"},e.prototype.init=function(){this.addAscent(W.CAPTION_HEIGHT,this.setCaptionHeight.bind(this))},e.prototype.setCaptionHeight=function(t){this.setProperty("--table-offset","calc("+t+"px + 1rem)")},Object.defineProperties(e,n),e}(t.core.Instance),q={TABLE:t.internals.ns.selector("table"),SHADOW:t.internals.ns.selector("table__shadow"),SHADOW_LEFT:t.internals.ns.selector("table__shadow--left"),SHADOW_RIGHT:t.internals.ns.selector("table__shadow--right"),ELEMENT:t.internals.ns.selector("table")+":not("+t.internals.ns.selector("table--no-scroll")+") table",CAPTION:t.internals.ns.selector("table")+" table caption"},z=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={isScrolling:{configurable:!0}},i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"TableElement"},e.prototype.init=function(){this.listen("scroll",this.scroll.bind(this)),this.content=this.querySelector("tbody"),this.isResizing=!0},n.isScrolling.get=function(){return this._isScrolling},n.isScrolling.set=function(t){this._isScrolling!==t&&(this._isScrolling=t,t?(this.addClass(q.SHADOW),this.scroll()):(this.removeClass(q.SHADOW),this.removeClass(q.SHADOW_LEFT),this.removeClass(q.SHADOW_RIGHT)))},e.prototype.scroll=function(){var t=this.node.scrollLeft<=8,e=this.content.offsetWidth-this.node.offsetWidth-8,n=Math.abs(this.node.scrollLeft)>=e,i="rtl"===document.documentElement.getAttribute("dir"),s=i?q.SHADOW_RIGHT:q.SHADOW_LEFT,o=i?q.SHADOW_LEFT:q.SHADOW_RIGHT;t?this.removeClass(s):this.addClass(s),n?this.removeClass(o):this.addClass(o)},e.prototype.resize=function(){this.isScrolling=this.content.offsetWidth>this.node.offsetWidth},e.prototype.dispose=function(){this.isScrolling=!1},Object.defineProperties(e.prototype,n),Object.defineProperties(e,i),e}(t.core.Instance),K=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"TableCaption"},e.prototype.init=function(){this.height=0,this.isResizing=!0},e.prototype.resize=function(){var t=this.getRect().height;this.height!==t&&(this.height=t,this.ascend(W.CAPTION_HEIGHT,t))},Object.defineProperties(e,n),e}(t.core.Instance);t.table={Table:F,TableElement:z,TableCaption:K,TableSelector:q},t.internals.register(t.table.TableSelector.TABLE,t.table.Table),t.internals.register(t.table.TableSelector.ELEMENT,t.table.TableElement),t.internals.register(t.table.TableSelector.CAPTION,t.table.TableCaption);var V={DISMISS:t.internals.ns.event("dismiss")},$=function(e){function n(){e.apply(this,arguments)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"TagDismissible"},n.prototype.init=function(){this.listen("click",this.click.bind(this))},n.prototype.click=function(){switch(this.focusClosest(),t.mode){case t.Modes.ANGULAR:case t.Modes.REACT:case t.Modes.VUE:this.request(this.verify.bind(this));break;default:this.remove()}this.dispatch(V.DISMISS)},n.prototype.verify=function(){document.body.contains(this.node)&&t.inspector.warn("a TagDismissible has just been dismissed and should be removed from the dom. In "+t.mode+" mode, the api doesn't handle dom modification. An event "+V.DISMISS+" is dispatched by the element to trigger the removal")},Object.defineProperties(n,i),n}(t.core.Instance),J={PRESSABLE:t.internals.ns.selector("tag")+"[aria-pressed]",DISMISSIBLE:""+t.internals.ns.selector("tag--dismiss")};t.tag={TagDismissible:$,TagSelector:J,TagEvent:V},t.internals.register(t.tag.TagSelector.PRESSABLE,t.core.Toggle),t.internals.register(t.tag.TagSelector.DISMISSIBLE,t.tag.TagDismissible);var Y={DOWNLOAD_ASSESS_FILE:""+t.internals.ns.attr.selector("assess-file"),DOWNLOAD_DETAIL:""+t.internals.ns.selector("download__detail")},Q=function(e){function n(){e.apply(this,arguments)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"AssessFile"},n.prototype.init=function(){this.lang=this.getLang(this.node),this.href=this.getAttribute("href"),this.hreflang=this.getAttribute("hreflang"),this.file={},this.detail=this.querySelector(Y.DOWNLOAD_DETAIL),this.update()},n.prototype.getFileLength=function(){var t=this;void 0!==this.href?fetch(this.href,{method:"HEAD",mode:"cors"}).then((function(e){t.length=e.headers.get("content-length")||-1,-1===t.length&&console.warn("Impossible de détecter le poids du fichier "+t.href+'\nErreur de récupération de l\'en-tête HTTP : "content-length"'),t.update()})):this.length=-1},n.prototype.update=function(){if(this.isLegacy&&(this.length=-1),this.length){var t=[];if(this.detail){if(this.href){var e=this.parseExtension(this.href);e&&t.push(e.toUpperCase())}-1!==this.length&&t.push(this.bytesToSize(this.length)),this.hreflang&&t.push(this.getLangDisplayName(this.hreflang)),this.detail.innerHTML=t.join(" - ")}}else this.getFileLength()},n.prototype.getLang=function(t){return t.lang?t.lang:document.documentElement===t?window.navigator.language:this.getLang(t.parentElement)},n.prototype.parseExtension=function(t){return t.match(/\.(\w{1,9})(?:$|[?#])/)[0].replace(".","")},n.prototype.getLangDisplayName=function(t){if(this.isLegacy)return t;var e=new Intl.DisplayNames([this.lang],{type:"language"}).of(t);return e.charAt(0).toUpperCase()+e.slice(1)},n.prototype.bytesToSize=function(e){if(-1===e)return null;var n=["octets","ko","Mo","Go","To"];"bytes"===this.getAttribute(t.internals.ns.attr("assess-file"))&&(n=["bytes","KB","MB","GB","TB"]);var i=parseInt(Math.floor(Math.log(e)/Math.log(1e3)),10);if(0===i)return e+" "+n[i];var s=e/Math.pow(1e3,i),o=Math.round(100*(s+Number.EPSILON))/100;return String(o).replace(".",",")+" "+n[i]},Object.defineProperties(n,i),n}(t.core.Instance);t.download={DownloadSelector:Y,AssessFile:Q},t.internals.register(t.download.DownloadSelector.DOWNLOAD_ASSESS_FILE,t.download.AssessFile);var Z={HEADER:t.internals.ns.selector("header"),TOOLS_LINKS:t.internals.ns.selector("header__tools-links"),MENU_LINKS:t.internals.ns.selector("header__menu-links"),BUTTONS:t.internals.ns.selector("header__tools-links")+" "+t.internals.ns.selector("btns-group")+", "+t.internals.ns.selector("header__tools-links")+" "+t.internals.ns.selector("links-group"),MODALS:""+t.internals.ns.selector("header__search")+t.internals.ns.selector("modal")+", "+t.internals.ns.selector("header__menu")+t.internals.ns.selector("modal")},X=function(e){function n(){e.apply(this,arguments)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"HeaderLinks"},n.prototype.init=function(){var e=this.queryParentSelector(Z.HEADER);this.toolsLinks=e.querySelector(Z.TOOLS_LINKS),this.menuLinks=e.querySelector(Z.MENU_LINKS);var n=this.toolsLinks.innerHTML.replace(/ +/g," "),i=this.menuLinks.innerHTML.replace(/ +/g," "),s=n.replace(/(<nav[.\s\S]*-translate [.\s\S]*) id="(.*?)"([.\s\S]*<\/nav>)/gm,'$1 id="$2-mobile"$3');if((s=s.replace(/(<nav[.\s\S]*-translate [.\s\S]*) aria-controls="(.*?)"([.\s\S]*<\/nav>)/gm,'$1 aria-controls="$2-mobile"$3'))!==i)switch(t.mode){case t.Modes.ANGULAR:case t.Modes.REACT:case t.Modes.VUE:t.inspector.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"+t.header.doc);break;default:this.menuLinks.innerHTML=s}},Object.defineProperties(n,i),n}(t.core.Instance),tt=function(e){function n(){e.apply(this,arguments)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={instanceClassName:{configurable:!0}};return i.instanceClassName.get=function(){return"HeaderModal"},n.prototype.init=function(){this.isResizing=!0},n.prototype.resize=function(){this.isBreakpoint(t.core.Breakpoints.LG)?this.unqualify():this.qualify()},n.prototype.qualify=function(){this.setAttribute("role","dialog");var t=this.element.getInstance("Modal");if(t){for(var e="",n=0,i=t.buttons;n<i.length;n+=1){var s=i[n];if(e=s.id||e,s.isPrimary&&e)break}this.setAttribute("aria-labelledby",e)}},n.prototype.unqualify=function(){var t=this.element.getInstance("Modal");t&&t.conceal(),this.removeAttribute("role"),this.removeAttribute("aria-labelledby")},Object.defineProperties(n,i),n}(t.core.Instance);t.header={HeaderLinks:X,HeaderModal:tt,HeaderSelector:Z,doc:"https://www.systeme-de-design.gouv.fr/elements-d-interface/composants/en-tete"},t.internals.register(t.header.HeaderSelector.BUTTONS,t.header.HeaderLinks),t.internals.register(t.header.HeaderSelector.MODALS,t.header.HeaderModal);var et={DISPLAY:t.internals.ns.selector("display"),RADIO_BUTTONS:'input[name="'+t.internals.ns("radios-theme")+'"]',FIELDSET:t.internals.ns.selector("fieldset")},nt=function(e){function n(){e.apply(this,arguments)}e&&(n.__proto__=e),n.prototype=Object.create(e&&e.prototype),n.prototype.constructor=n;var i={scheme:{configurable:!0}},s={instanceClassName:{configurable:!0}};return s.instanceClassName.get=function(){return"Display"},n.prototype.init=function(){if(this.radios=this.querySelectorAll(et.RADIO_BUTTONS),t.scheme){this.changing=this.change.bind(this);for(var e=0,n=this.radios;e<n.length;e+=1){n[e].addEventListener("change",this.changing)}this.addDescent(t.scheme.SchemeEmission.SCHEME,this.apply.bind(this)),this.ascend(t.scheme.SchemeEmission.ASK)}else this.querySelector(et.FIELDSET).setAttribute("disabled","")},i.scheme.get=function(){return this._scheme},i.scheme.set=function(e){if(this._scheme!==e&&t.scheme)switch(e){case t.scheme.SchemeValue.SYSTEM:case t.scheme.SchemeValue.LIGHT:case t.scheme.SchemeValue.DARK:this._scheme=e;for(var n=0,i=this.radios;n<i.length;n+=1){var s=i[n];s.checked=s.value===e}this.ascend(t.scheme.SchemeEmission.SCHEME,e)}},n.prototype.change=function(){for(var t=0,e=this.radios;t<e.length;t+=1){var n=e[t];if(n.checked)return void(this.scheme=n.value)}},n.prototype.apply=function(t){this.scheme=t},n.prototype.dispose=function(){for(var t=0,e=this.radios;t<e.length;t+=1){e[t].removeEventListener("change",this.changing)}},Object.defineProperties(n.prototype,i),Object.defineProperties(n,s),n}(t.core.Instance);t.display={Display:nt,DisplaySelector:et},t.internals.register(t.display.DisplaySelector.DISPLAY,t.display.Display)}();
//# sourceMappingURL=component.nomodule.min.js.map