UNPKG

@tindtechnologies/universalviewer

Version:

The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎

2 lines (1 loc) 5.13 kB
import{a as y,e as c,f as g,i as d,l as p}from"./chunk-VNJCZCB4.js";import"./chunk-L67DAW3A.js";var f=function(r,e,t,s){return new(t||(t=Promise))(function(a,n){function l(i){try{h(s.next(i))}catch(o){n(o)}}function u(i){try{h(s.throw(i))}catch(o){n(o)}}function h(i){i.done?a(i.value):new t(function(o){o(i.value)}).then(l,u)}h((s=s.apply(r,e||[])).next())})},b=function(r,e){var t={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,a,n,l;return l={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(l[Symbol.iterator]=function(){return this}),l;function u(i){return function(o){return h([i,o])}}function h(i){if(s)throw new TypeError("Generator is already executing.");for(;t;)try{if(s=1,a&&(n=i[0]&2?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[i[0]&2,n.value]),i[0]){case 0:case 1:n=i;break;case 4:return t.label++,{value:i[1],done:!1};case 5:t.label++,a=i[1],i=[0];continue;case 7:i=t.ops.pop(),t.trys.pop();continue;default:if(n=t.trys,!(n=n.length>0&&n[n.length-1])&&(i[0]===6||i[0]===2)){t=0;continue}if(i[0]===3&&(!n||i[1]>n[0]&&i[1]<n[3])){t.label=i[1];break}if(i[0]===6&&t.label<n[1]){t.label=n[1],n=i;break}if(n&&t.label<n[2]){t.label=n[2],t.ops.push(i);break}n[2]&&t.ops.pop(),t.trys.pop();continue}i=e.call(r,t)}catch(o){i=[6,o],a=0}finally{s=n=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}},T=function(){function r(e){var t=this;y(this,e),this.transitioning=!1,this.useRouter=!1,this.onTabClicked=function(s){var a=s.detail,n=a.href,l=a.tab;if(t.useRouter&&n!==void 0){var u=document.querySelector("ion-router");u&&u.push(n)}else t.select(l)},this.ionNavWillLoad=d(this,"ionNavWillLoad",7),this.ionTabsWillChange=d(this,"ionTabsWillChange",3),this.ionTabsDidChange=d(this,"ionTabsDidChange",3)}return r.prototype.componentWillLoad=function(){return f(this,void 0,void 0,function(){var e;return b(this,function(t){switch(t.label){case 0:return this.useRouter||(this.useRouter=!!document.querySelector("ion-router")&&!this.el.closest("[no-router]")),this.useRouter?[3,2]:(e=this.tabs,[4,this.select(e[0])]);case 1:t.sent(),t.label=2;case 2:return this.ionNavWillLoad.emit(),[2]}})})},r.prototype.componentWillRender=function(){var e=this.el.querySelector("ion-tab-bar");if(e){var t=this.selectedTab?this.selectedTab.tab:void 0;e.selectedTab=t}},r.prototype.select=function(e){return f(this,void 0,void 0,function(){var t;return b(this,function(s){switch(s.label){case 0:return t=v(this.tabs,e),this.shouldSwitch(t)?[4,this.setActive(t)]:[2,!1];case 1:return s.sent(),[4,this.notifyRouter()];case 2:return s.sent(),this.tabSwitch(),[2,!0]}})})},r.prototype.getTab=function(e){return f(this,void 0,void 0,function(){return b(this,function(t){return[2,v(this.tabs,e)]})})},r.prototype.getSelected=function(){return Promise.resolve(this.selectedTab?this.selectedTab.tab:void 0)},r.prototype.setRouteId=function(e){return f(this,void 0,void 0,function(){var t,s=this;return b(this,function(a){switch(a.label){case 0:return t=v(this.tabs,e),this.shouldSwitch(t)?[4,this.setActive(t)]:[2,{changed:!1,element:this.selectedTab}];case 1:return a.sent(),[2,{changed:!0,element:this.selectedTab,markVisible:function(){return s.tabSwitch()}}]}})})},r.prototype.getRouteId=function(){return f(this,void 0,void 0,function(){var e;return b(this,function(t){return e=this.selectedTab&&this.selectedTab.tab,[2,e!==void 0?{id:e,element:this.selectedTab}:void 0]})})},r.prototype.setActive=function(e){return this.transitioning?Promise.reject("transitioning already happening"):(this.transitioning=!0,this.leavingTab=this.selectedTab,this.selectedTab=e,this.ionTabsWillChange.emit({tab:e.tab}),e.setActive())},r.prototype.tabSwitch=function(){var e=this.selectedTab,t=this.leavingTab;this.leavingTab=void 0,this.transitioning=!1,e&&t!==e&&(t&&(t.active=!1),this.ionTabsDidChange.emit({tab:e.tab}))},r.prototype.notifyRouter=function(){if(this.useRouter){var e=document.querySelector("ion-router");if(e)return e.navChanged("forward")}return Promise.resolve(!1)},r.prototype.shouldSwitch=function(e){var t=this.selectedTab;return e!==void 0&&e!==t&&!this.transitioning},Object.defineProperty(r.prototype,"tabs",{get:function(){return Array.from(this.el.querySelectorAll("ion-tab"))},enumerable:!0,configurable:!0}),r.prototype.render=function(){return c(g,{onIonTabButtonClick:this.onTabClicked},c("slot",{name:"top"}),c("div",{class:"tabs-inner"},c("slot",null)),c("slot",{name:"bottom"}))},Object.defineProperty(r.prototype,"el",{get:function(){return p(this)},enumerable:!0,configurable:!0}),Object.defineProperty(r,"style",{get:function(){return":host{left:0;right:0;top:0;bottom:0;display:-ms-flexbox;display:flex;position:absolute;-ms-flex-direction:column;flex-direction:column;width:100%;height:100%;z-index:0}.tabs-inner,:host{contain:layout size style}.tabs-inner{position:relative;-ms-flex:1;flex:1}"},enumerable:!0,configurable:!0}),r}(),v=function(r,e){var t=typeof e=="string"?r.find(function(s){return s.tab===e}):e;return t||console.error('tab with id: "'+t+'" does not exist'),t};export{T as ion_tabs};