import{r as registerInstance,h}from"./index-15028158.js";var min=function(t){return function(a,e){return a===e||t.compare(a,e)<1?a:e}};var max=function(t){return function(a,e){return a===e||t.compare(a,e)>-1?a:e}};var clamp=function(t){var a=min(t);var e=max(t);return function(t,i){return function(l){return e(a(l,i),t)}}};var Eq={equals:function(t,a){return t===a}};var Ord={equals:Eq.equals,compare:function(t,a){return t<a?-1:t>a?1:0}};var defaultTabListCss="stencila-tab-list.sc-stencila-tab-list-default{display:block}.sc-stencila-tab-list-default-h ul.sc-stencila-tab-list-default,stencila-tab-list.sc-stencila-tab-list-default ul.sc-stencila-tab-list-default,ul[role=tablist].sc-stencila-tab-list-default{background-color:#e9eaf1;background-color:var(--color-neutral-50,#e9eaf1);display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;margin:0;padding:0}";var tabListMaterialCss="stencila-tab-list.sc-stencila-tab-list-material{display:block}.sc-stencila-tab-list-material-h ul.sc-stencila-tab-list-material,ul[role=tablist].sc-stencila-tab-list-material{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;margin:0;padding:0}";var TabList=function(){function t(t){var a=this;registerInstance(this,t);this.activeTabIndex=0;this.onKeyboardNavigateTabs=function(t){var e=t.key==="ArrowRight"?1:t.key==="ArrowLeft"?-1:0;var i=clamp(Ord)(0,a.tabs.length-1);a.selectTab(i(a.activeTabIndex+e))};this.clickHandler=function(t,e){return function(i){var l;i.preventDefault();a.selectTab(e);(l=t.onClick)===null||l===void 0?void 0:l.call(t,i)}}}t.prototype.selectTab=function(t){this.activeTabIndex=t};t.prototype.render=function(){var t=this;return h("ul",{role:"tablist",onKeyDown:this.onKeyboardNavigateTabs},this.tabs.map((function(a,e){return h("stencila-tab",{isSelected:a.isSelected===true||a.isSelected===undefined&&e===t.activeTabIndex,label:a.label,onClick:t.clickHandler(a,e),tabIndex:e===t.activeTabIndex?0:-1})})))};return t}();TabList.style={default:defaultTabListCss,material:tabListMaterialCss};export{TabList as stencila_tab_list};
//# sourceMappingURL=stencila-tab-list.entry.js.map