p-3535d6b5.entry.js 4.1 KB

1234
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. import{r as t,h as i,e as s,f as e,c as a}from"./p-66a5d6a8.js";import{a as o}from"./p-f08a92cc.js";import{d as n}from"./p-17e21141.js";import"./p-94551927.js";const h=class{constructor(i){t(this,i),this.loaded=!1,this.active=!1,this.delegate=void 0,this.tab=void 0,this.component=void 0}async componentWillLoad(){this.active&&await this.setActive()}async setActive(){await this.prepareLazyLoaded(),this.active=!0}changeActive(t){t&&this.prepareLazyLoaded()}prepareLazyLoaded(){if(!this.loaded&&null!=this.component){this.loaded=!0;try{return o(this.delegate,this.el,this.component,["ion-page"])}catch(t){n("[ion-tab] - Exception in prepareLazyLoaded:",t)}}return Promise.resolve(void 0)}render(){const{tab:t,active:e,component:a}=this;return i(s,{key:"c36c113e74e12b58459df9e3b546ad4856187e90",role:"tabpanel","aria-hidden":e?null:"true","aria-labelledby":`tab-button-${t}`,class:{"ion-page":void 0===a,"tab-hidden":!e}},i("slot",{key:"0d7821dac70ba7a12edfb3331988f3df1566cc1a"}))}get el(){return e(this)}static get watchers(){return{active:["changeActive"]}}};h.style=":host(.tab-hidden){display:none !important}";const r=class{constructor(i){t(this,i),this.ionNavWillLoad=a(this,"ionNavWillLoad",7),this.ionTabsWillChange=a(this,"ionTabsWillChange",3),this.ionTabsDidChange=a(this,"ionTabsDidChange",3),this.transitioning=!1,this.onTabClicked=t=>{const{href:i,tab:s}=t.detail;if(this.useRouter&&void 0!==i){const t=document.querySelector("ion-router");t&&t.push(i)}else this.select(s)},this.selectedTab=void 0,this.useRouter=!1}async componentWillLoad(){if(this.useRouter||(this.useRouter=!(!this.el.querySelector("ion-router-outlet")&&!document.querySelector("ion-router")||this.el.closest("[no-router]"))),!this.useRouter){const t=this.tabs;t.length>0&&await this.select(t[0])}this.ionNavWillLoad.emit()}componentWillRender(){const t=this.el.querySelector("ion-tab-bar");t&&(t.selectedTab=this.selectedTab?this.selectedTab.tab:void 0)}async select(t){const i=c(this.tabs,t);return!!this.shouldSwitch(i)&&(await this.setActive(i),await this.notifyRouter(),this.tabSwitch(),!0)}async getTab(t){return c(this.tabs,t)}getSelected(){return Promise.resolve(this.selectedTab?this.selectedTab.tab:void 0)}async setRouteId(t){const i=c(this.tabs,t);return this.shouldSwitch(i)?(await this.setActive(i),{changed:!0,element:this.selectedTab,markVisible:()=>this.tabSwitch()}):{changed:!1,element:this.selectedTab}}async getRouteId(){var t;const i=null===(t=this.selectedTab)||void 0===t?void 0:t.tab;return void 0!==i?{id:i,element:this.selectedTab}:void 0}setActive(t){return this.transitioning?Promise.reject("transitioning already happening"):(this.transitioning=!0,this.leavingTab=this.selectedTab,this.selectedTab=t,this.ionTabsWillChange.emit({tab:t.tab}),t.active=!0,Promise.resolve())}tabSwitch(){const t=this.selectedTab,i=this.leavingTab;this.leavingTab=void 0,this.transitioning=!1,t&&i!==t&&(i&&(i.active=!1),this.ionTabsDidChange.emit({tab:t.tab}))}notifyRouter(){if(this.useRouter){const t=document.querySelector("ion-router");if(t)return t.navChanged("forward")}return Promise.resolve(!1)}shouldSwitch(t){return void 0!==t&&t!==this.selectedTab&&!this.transitioning}get tabs(){return Array.from(this.el.querySelectorAll("ion-tab"))}render(){return i(s,{key:"20b97196d78c1b3f3faf31618a8a2347e087f06b",onIonTabButtonClick:this.onTabClicked},i("slot",{key:"b0823fbae6e47743cfd12c376b365ad7e32cec7c",name:"top"}),i("div",{key:"eaffd7e4d69ab9489a387e3bbb36e3bab72203a0",class:"tabs-inner"},i("slot",{key:"20bb66a2937e3ec473aa59c4075ce581b5411677"})),i("slot",{key:"1529dd361f050f52074f51c73b3982ba827dc3a5",name:"bottom"}))}get el(){return e(this)}},c=(t,i)=>{const s="string"==typeof i?t.find((t=>t.tab===i)):i;return s||n(`[ion-tabs] - Tab with id: "${s}" does not exist`),s};r.style=":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%;contain:layout size style;z-index:0}.tabs-inner{position:relative;-ms-flex:1;flex:1;contain:layout size style}";export{h as ion_tab,r as ion_tabs}