3 lines
7.7 KiB
JavaScript
3 lines
7.7 KiB
JavaScript
/*! DSFR v1.11.2 | SPDX-License-Identifier: MIT | License-Filename: LICENSE.md | restricted use (see terms and conditions) */
|
|
!function(){"use strict";var t=window.dsfr,e=function(e){function i(){e.call(this,t.core.DisclosureType.SELECT)}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var s={list:{configurable:!0}},n={instanceClassName:{configurable:!0}};return n.instanceClassName.get=function(){return"TabButton"},i.prototype.handleClick=function(t){e.prototype.handleClick.call(this,t),this.focus()},i.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))},s.list.get=function(){return this.element.getAscendantInstance("TabsList","TabsGroup")},Object.defineProperties(i.prototype,s),Object.defineProperties(i,n),i}(t.core.DisclosureButton),i={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")},s="direction-start",n="direction-end",o="none",r=function(r){function a(){r.call(this,t.core.DisclosureType.SELECT,i.PANEL,e,"TabsGroup"),this._direction=o,this._isPreventingTransition=!1}r&&(a.__proto__=r),a.prototype=Object.create(r&&r.prototype),a.prototype.constructor=a;var c={direction:{configurable:!0},isPreventingTransition:{configurable:!0}},l={instanceClassName:{configurable:!0}};return l.instanceClassName.get=function(){return"TabPanel"},c.direction.get=function(){return this._direction},c.direction.set=function(t){if(t!==this._direction){switch(this._direction){case s:this.removeClass(i.PANEL_START);break;case n:this.removeClass(i.PANEL_END);break;case o:break;default:return}switch(this._direction=t,this._direction){case s:this.addClass(i.PANEL_START);break;case n:this.addClass(i.PANEL_END)}}},c.isPreventingTransition.get=function(){return this._isPreventingTransition},c.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)},a.prototype.translate=function(t,e){this.isPreventingTransition=e,this.direction=t},a.prototype.reset=function(){this.group&&this.group.retrieve(!0)},a.prototype._electPrimaries=function(t){var e=this;return this.group&&this.group.list?r.prototype._electPrimaries.call(this,t).filter((function(t){return e.group.list.node.contains(t.node)})):[]},Object.defineProperties(a.prototype,c),Object.defineProperties(a,l),a}(t.core.Disclosure),a="tab_keys_left",c="tab_keys_right",l="tab_keys_home",h="tab_keys_end",p={PRESS_KEY:t.internals.ns.emission("tab","press_key"),LIST_HEIGHT:t.internals.ns.emission("tab","list_height")},u=function(e){function i(){e.call(this,"TabPanel")}e&&(i.__proto__=e),i.prototype=Object.create(e&&e.prototype),i.prototype.constructor=i;var r={list:{configurable:!0},buttonHasFocus:{configurable:!0},isPreventingTransition:{configurable:!0}},u={instanceClassName:{configurable:!0}};return u.instanceClassName.get=function(){return"TabsGroup"},i.prototype.init=function(){e.prototype.init.call(this),this.listen("transitionend",this.transitionend.bind(this)),this.addAscent(p.PRESS_KEY,this.pressKey.bind(this)),this.addAscent(p.LIST_HEIGHT,this.setListHeight.bind(this)),this.isRendering=!0},i.prototype.getIndex=function(t){void 0===t&&(t=0),e.prototype.getIndex.call(this,t)},r.list.get=function(){return this.element.getDescendantInstances("TabsList","TabsGroup",!0)[0]},i.prototype.setListHeight=function(t){this.listHeight=t},i.prototype.transitionend=function(t){this.isPreventingTransition=!0},r.buttonHasFocus.get=function(){return this.members.some((function(t){return t.buttonHasFocus}))},i.prototype.pressKey=function(t){switch(t){case a:this.pressLeft();break;case c:this.pressRight();break;case l:this.pressHome();break;case h:this.pressEnd()}},i.prototype.pressRight=function(){this.buttonHasFocus&&(this.index<this.length-1?this.index++:this.index=0,this.focus())},i.prototype.pressLeft=function(){this.buttonHasFocus&&(this.index>0?this.index--:this.index=this.length-1,this.focus())},i.prototype.pressHome=function(){this.buttonHasFocus&&(this.index=0,this.focus())},i.prototype.pressEnd=function(){this.buttonHasFocus&&(this.index=this.length-1,this.focus())},i.prototype.focus=function(){this.current&&this.current.focus()},i.prototype.apply=function(){for(var t=0;t<this._index;t++)this.members[t].translate(s);this.current&&this.current.translate(o);for(var e=this._index+1;e<this.length;e++)this.members[e].translate(n);this.isPreventingTransition=!1},r.isPreventingTransition.get=function(){return this._isPreventingTransition},r.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)},i.prototype.render=function(){if(null!==this.current){this.node.scrollTop=0,this.node.scrollLeft=0;var t=Math.round(this.current.node.offsetHeight);this.panelHeight!==t&&(this.panelHeight=t,this.style.setProperty("--tabs-height",this.panelHeight+this.listHeight+"px"))}},Object.defineProperties(i.prototype,r),Object.defineProperties(i,u),i}(t.core.DisclosuresGroup),d=function(e){function s(){e.apply(this,arguments)}e&&(s.__proto__=e),s.prototype=Object.create(e&&e.prototype),s.prototype.constructor=s;var n={isScrolling:{configurable:!0}},o={instanceClassName:{configurable:!0}};return o.instanceClassName.get=function(){return"TabsList"},s.prototype.init=function(){this.listen("scroll",this.scroll.bind(this)),this.listenKey(t.core.KeyCodes.RIGHT,this.ascend.bind(this,p.PRESS_KEY,c),!0,!0),this.listenKey(t.core.KeyCodes.LEFT,this.ascend.bind(this,p.PRESS_KEY,a),!0,!0),this.listenKey(t.core.KeyCodes.HOME,this.ascend.bind(this,p.PRESS_KEY,l),!0,!0),this.listenKey(t.core.KeyCodes.END,this.ascend.bind(this,p.PRESS_KEY,h),!0,!0),this.isResizing=!0},s.prototype.focalize=function(t){var e=t.getRect(),i=this.getRect(),s=this.node.scrollLeft;e.left<i.left?this.node.scrollTo(s-i.left+e.left-16,0):e.right>i.right&&this.node.scrollTo(s-i.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())},s.prototype.apply=function(){this._isScrolling?(this.addClass(i.SHADOW),this.scroll()):(this.removeClass(i.SHADOW_RIGHT),this.removeClass(i.SHADOW_LEFT),this.removeClass(i.SHADOW))},s.prototype.scroll=function(){var t=this.node.scrollLeft,e=t<=16,s=this.node.scrollWidth-this.node.clientWidth-16,n=Math.abs(t)>=s,o="rtl"===document.documentElement.getAttribute("dir"),r=o?i.SHADOW_RIGHT:i.SHADOW_LEFT,a=o?i.SHADOW_LEFT:i.SHADOW_RIGHT;e?this.removeClass(r):this.addClass(r),n?this.removeClass(a):this.addClass(a)},s.prototype.resize=function(){this.isScrolling=this.node.scrollWidth>this.node.clientWidth+16;var t=this.getRect().height;this.setProperty("--tabs-list-height",t+"px"),this.ascend(p.LIST_HEIGHT,t)},s.prototype.dispose=function(){this.isScrolling=!1},Object.defineProperties(s.prototype,n),Object.defineProperties(s,o),s}(t.core.Instance);t.tab={TabPanel:r,TabButton:e,TabsGroup:u,TabsList:d,TabSelector:i,TabEmission:p},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)}();
|
|
//# sourceMappingURL=tab.nomodule.min.js.map
|