@ionic/core
Version:
Base components for Ionic
4 lines • 17.6 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(t,i,e,n){function r(t){return t instanceof e?t:new e((function(i){i(t)}))}return new(e||(e=Promise))((function(e,s){function u(t){try{a(n.next(t))}catch(t){s(t)}}function o(t){try{a(n["throw"](t))}catch(t){s(t)}}function a(t){t.done?e(t.value):r(t.value).then(u,o)}a((n=n.apply(t,i||[])).next())}))};var __generator=this&&this.__generator||function(t,i){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,r,s,u;return u={next:o(0),throw:o(1),return:o(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function o(t){return function(i){return a([t,i])}}function a(o){if(n)throw new TypeError("Generator is already executing.");while(u&&(u=0,o[0]&&(e=0)),e)try{if(n=1,r&&(s=o[0]&2?r["return"]:o[0]?r["throw"]||((s=r["return"])&&s.call(r),0):r.next)&&!(s=s.call(r,o[1])).done)return s;if(r=0,s)o=[o[0]&2,s.value];switch(o[0]){case 0:case 1:s=o;break;case 4:e.label++;return{value:o[1],done:false};case 5:e.label++;r=o[1];o=[0];continue;case 7:o=e.ops.pop();e.trys.pop();continue;default:if(!(s=e.trys,s=s.length>0&&s[s.length-1])&&(o[0]===6||o[0]===2)){e=0;continue}if(o[0]===3&&(!s||o[1]>s[0]&&o[1]<s[3])){e.label=o[1];break}if(o[0]===6&&e.label<s[1]){e.label=s[1];s=o;break}if(s&&e.label<s[2]){e.label=s[2];e.ops.push(o);break}if(s[2])e.ops.pop();e.trys.pop();continue}o=i.call(t,e)}catch(t){o=[6,t];r=0}finally{n=s=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:true}}};
/*!
* (C) Ionic http://ionicframework.com - MIT License
*/System.register(["./p-f11a9436.system.js","./p-e673a0a2.system.js","./p-455cd7cc.system.js","./p-f201b53a.system.js","./p-978bdf4c.system.js","./p-3855fef7.system.js","./p-0ec5b7cf.system.js"],(function(t,i){"use strict";var e,n,r,s,u,o,a,f,h,c,d,v,l,w,m,b,_;return{setters:[function(t){e=t.r;n=t.c;r=t.h;s=t.f;u=t.e},function(t){o=t.g},function(t){a=t.n;f=t.s},function(t){h=t.b;c=t.c},function(t){d=t.l;v=t.t;l=t.s;w=t.d;m=t.b;b=t.c},function(t){_=t.a},function(){}],execute:function(){var p=1;var g=2;var y=3;var k=function(){function t(t,i){this.component=t;this.params=i;this.state=p}t.prototype.init=function(t){return __awaiter(this,void 0,void 0,(function(){var i,e;return __generator(this,(function(n){switch(n.label){case 0:this.state=g;if(!!this.element)return[3,2];i=this.component;e=this;return[4,_(this.delegate,t,i,["ion-page","ion-page-invisible"],this.params)];case 1:e.element=n.sent();n.label=2;case 2:return[2]}}))}))};t.prototype._destroy=function(){a(this.state!==y,"view state must be ATTACHED");var t=this.element;if(t){if(this.delegate){this.delegate.removeViewFromDom(t.parentElement,t)}else{t.remove()}}this.nav=undefined;this.state=y};return t}();var j=function(t,i,e){if(!t){return false}if(t.component!==i){return false}return f(t.params,e)};var C=function(t,i){if(!t){return null}if(t instanceof k){return t}return new k(t,i)};var B=function(t){return t.map((function(t){if(t instanceof k){return t}if("component"in t){return C(t.component,t.componentProps===null?undefined:t.componentProps)}return C(t,undefined)})).filter((function(t){return t!==null}))};var E=":host{left:0;right:0;top:0;bottom:0;position:absolute;contain:layout size style;z-index:0}";var O=E;var S=t("ion_nav",function(){function t(t){e(this,t);this.ionNavWillLoad=n(this,"ionNavWillLoad",7);this.ionNavWillChange=n(this,"ionNavWillChange",3);this.ionNavDidChange=n(this,"ionNavDidChange",3);this.transInstr=[];this.gestureOrAnimationInProgress=false;this.useRouter=false;this.isTransitioning=false;this.destroyed=false;this.views=[];this.didLoad=false;this.delegate=undefined;this.swipeGesture=undefined;this.animated=true;this.animation=undefined;this.rootParams=undefined;this.root=undefined}t.prototype.swipeGestureChanged=function(){if(this.gesture){this.gesture.enable(this.swipeGesture===true)}};t.prototype.rootChanged=function(){if(this.root===undefined){return}if(this.didLoad===false){return}if(!this.useRouter){if(this.root!==undefined){this.setRoot(this.root,this.rootParams)}}};t.prototype.componentWillLoad=function(){this.useRouter=document.querySelector("ion-router")!==null&&this.el.closest("[no-router]")===null;if(this.swipeGesture===undefined){var t=h(this);this.swipeGesture=c.getBoolean("swipeBackEnabled",t==="ios")}this.ionNavWillLoad.emit()};t.prototype.componentDidLoad=function(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(e){switch(e.label){case 0:this.didLoad=true;this.rootChanged();t=this;return[4,i.import("./p-705fda69.system.js")];case 1:t.gesture=e.sent().createSwipeBackGesture(this.el,this.canStart.bind(this),this.onStart.bind(this),this.onMove.bind(this),this.onEnd.bind(this));this.swipeGestureChanged();return[2]}}))}))};t.prototype.connectedCallback=function(){this.destroyed=false};t.prototype.disconnectedCallback=function(){for(var t=0,i=this.views;t<i.length;t++){var e=i[t];d(e.element,w);e._destroy()}if(this.gesture){this.gesture.destroy();this.gesture=undefined}this.transInstr.length=0;this.views.length=0;this.destroyed=true};t.prototype.push=function(t,i,e,n){return this.insert(-1,t,i,e,n)};t.prototype.insert=function(t,i,e,n,r){return this.insertPages(t,[{component:i,componentProps:e}],n,r)};t.prototype.insertPages=function(t,i,e,n){return this.queueTrns({insertStart:t,insertViews:i,opts:e},n)};t.prototype.pop=function(t,i){return this.removeIndex(-1,1,t,i)};t.prototype.popTo=function(t,i,e){var n={removeStart:-1,removeCount:-1,opts:i};if(typeof t==="object"&&t.component){n.removeView=t;n.removeStart=1}else if(typeof t==="number"){n.removeStart=t+1}return this.queueTrns(n,e)};t.prototype.popToRoot=function(t,i){return this.removeIndex(1,-1,t,i)};t.prototype.removeIndex=function(t,i,e,n){if(i===void 0){i=1}return this.queueTrns({removeStart:t,removeCount:i,opts:e},n)};t.prototype.setRoot=function(t,i,e,n){return this.setPages([{component:t,componentProps:i}],e,n)};t.prototype.setPages=function(t,i,e){i!==null&&i!==void 0?i:i={};if(i.animated!==true){i.animated=false}return this.queueTrns({insertStart:0,insertViews:t,removeStart:0,removeCount:-1,opts:i},e)};t.prototype.setRouteId=function(t,i,e,n){var r=this;var s=this.getActiveSync();if(j(s,t,i)){return Promise.resolve({changed:false,element:s.element})}var u;var o=new Promise((function(t){return u=t}));var a;var f={updateURL:false,viewIsReady:function(t){var i;var e=new Promise((function(t){return i=t}));u({changed:true,element:t,markVisible:function(){return __awaiter(r,void 0,void 0,(function(){return __generator(this,(function(t){switch(t.label){case 0:i();return[4,a];case 1:t.sent();return[2]}}))}))}});return e}};if(e==="root"){a=this.setRoot(t,i,f)}else{var h=this.views.find((function(e){return j(e,t,i)}));if(h){a=this.popTo(h,Object.assign(Object.assign({},f),{direction:"back",animationBuilder:n}))}else if(e==="forward"){a=this.push(t,i,Object.assign(Object.assign({},f),{animationBuilder:n}))}else if(e==="back"){a=this.setRoot(t,i,Object.assign(Object.assign({},f),{direction:"back",animated:true,animationBuilder:n}))}}return o};t.prototype.getRouteId=function(){return __awaiter(this,void 0,void 0,(function(){var t;return __generator(this,(function(i){t=this.getActiveSync();if(t){return[2,{id:t.element.tagName,params:t.params,element:t.element}]}return[2,undefined]}))}))};t.prototype.getActive=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,this.getActiveSync()]}))}))};t.prototype.getByIndex=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){return[2,this.views[t]]}))}))};t.prototype.canGoBack=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){return[2,this.canGoBackSync(t)]}))}))};t.prototype.getPrevious=function(t){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(i){return[2,this.getPreviousSync(t)]}))}))};t.prototype.getLength=function(){return __awaiter(this,void 0,void 0,(function(){return __generator(this,(function(t){return[2,Promise.resolve(this.views.length)]}))}))};t.prototype.getActiveSync=function(){return this.views[this.views.length-1]};t.prototype.canGoBackSync=function(t){if(t===void 0){t=this.getActiveSync()}return!!(t&&this.getPreviousSync(t))};t.prototype.getPreviousSync=function(t){if(t===void 0){t=this.getActiveSync()}if(!t){return undefined}var i=this.views;var e=i.indexOf(t);return e>0?i[e-1]:undefined};t.prototype.queueTrns=function(t,i){return __awaiter(this,void 0,void 0,(function(){var e,n,r,s,u;return __generator(this,(function(o){switch(o.label){case 0:if(this.isTransitioning&&((e=t.opts)===null||e===void 0?void 0:e.skipIfBusy)){return[2,false]}r=new Promise((function(i,e){t.resolve=i;t.reject=e}));t.done=i;if(!(t.opts&&t.opts.updateURL!==false&&this.useRouter))return[3,2];s=document.querySelector("ion-router");if(!s)return[3,2];return[4,s.canTransition()];case 1:u=o.sent();if(u===false){return[2,false]}if(typeof u==="string"){s.push(u,t.opts.direction||"back");return[2,false]}o.label=2;case 2:if(((n=t.insertViews)===null||n===void 0?void 0:n.length)===0){t.insertViews=undefined}this.transInstr.push(t);this.nextTrns();return[2,r]}}))}))};t.prototype.success=function(t,i){if(this.destroyed){this.fireError("nav controller was destroyed",i);return}if(i.done){i.done(t.hasCompleted,t.requiresTransition,t.enteringView,t.leavingView,t.direction)}i.resolve(t.hasCompleted);if(i.opts.updateURL!==false&&this.useRouter){var e=document.querySelector("ion-router");if(e){var n=t.direction==="back"?"back":"forward";e.navChanged(n)}}};t.prototype.failed=function(t,i){if(this.destroyed){this.fireError("nav controller was destroyed",i);return}this.transInstr.length=0;this.fireError(t,i)};t.prototype.fireError=function(t,i){if(i.done){i.done(false,false,t)}if(i.reject&&!this.destroyed){i.reject(t)}else{i.resolve(false)}};t.prototype.nextTrns=function(){if(this.isTransitioning){return false}var t=this.transInstr.shift();if(!t){return false}this.runTransition(t);return true};t.prototype.runTransition=function(t){return __awaiter(this,void 0,void 0,(function(){var i,e,n,r,s,u;return __generator(this,(function(o){switch(o.label){case 0:o.trys.push([0,6,,7]);this.ionNavWillChange.emit();this.isTransitioning=true;this.prepareTI(t);i=this.getActiveSync();e=this.getEnteringView(t,i);if(!i&&!e){throw new Error("no views in the stack to be removed")}if(!(e&&e.state===p))return[3,2];return[4,e.init(this.el)];case 1:o.sent();o.label=2;case 2:this.postViewInit(e,i,t);n=(t.enteringRequiresTransition||t.leavingRequiresTransition)&&e!==i;if(n&&t.opts&&i){r=t.opts.direction==="back";if(r){t.opts.animationBuilder=t.opts.animationBuilder||(e===null||e===void 0?void 0:e.animationBuilder)}i.animationBuilder=t.opts.animationBuilder}s=void 0;if(!n)return[3,4];return[4,this.transition(e,i,t)];case 3:s=o.sent();return[3,5];case 4:s={hasCompleted:true,requiresTransition:false};o.label=5;case 5:this.success(s,t);this.ionNavDidChange.emit();return[3,7];case 6:u=o.sent();this.failed(u,t);return[3,7];case 7:this.isTransitioning=false;this.nextTrns();return[2]}}))}))};t.prototype.prepareTI=function(t){var i,e;var n;var r=this.views.length;(i=t.opts)!==null&&i!==void 0?i:t.opts={};(e=(n=t.opts).delegate)!==null&&e!==void 0?e:n.delegate=this.delegate;if(t.removeView!==undefined){a(t.removeStart!==undefined,"removeView needs removeStart");a(t.removeCount!==undefined,"removeView needs removeCount");var s=this.views.indexOf(t.removeView);if(s<0){throw new Error("removeView was not found")}t.removeStart+=s}if(t.removeStart!==undefined){if(t.removeStart<0){t.removeStart=r-1}if(t.removeCount<0){t.removeCount=r-t.removeStart}t.leavingRequiresTransition=t.removeCount>0&&t.removeStart+t.removeCount===r}if(t.insertViews){if(t.insertStart<0||t.insertStart>r){t.insertStart=r}t.enteringRequiresTransition=t.insertStart===r}var u=t.insertViews;if(!u){return}a(u.length>0,"length can not be zero");var o=B(u);if(o.length===0){throw new Error("invalid views to insert")}for(var f=0,h=o;f<h.length;f++){var c=h[f];c.delegate=t.opts.delegate;var d=c.nav;if(d&&d!==this){throw new Error("inserted view was already inserted")}if(c.state===y){throw new Error("inserted view was already destroyed")}}t.insertViews=o};t.prototype.getEnteringView=function(t,i){var e=t.insertViews;if(e!==undefined){return e[e.length-1]}var n=t.removeStart;if(n!==undefined){var r=this.views;var s=n+t.removeCount;for(var u=r.length-1;u>=0;u--){var o=r[u];if((u<n||u>=s)&&o!==i){return o}}}return undefined};t.prototype.postViewInit=function(t,i,e){var n,r,s;a(i||t,"Both leavingView and enteringView are null");a(e.resolve,"resolve must be valid");a(e.reject,"reject must be valid");var u=e.opts;var o=e.insertViews,f=e.removeStart,h=e.removeCount;var c;if(f!==undefined&&h!==undefined){a(f>=0,"removeStart can not be negative");a(h>=0,"removeCount can not be negative");c=[];for(var v=f;v<f+h;v++){var l=this.views[v];if(l!==undefined&&l!==t&&l!==i){c.push(l)}}(n=u.direction)!==null&&n!==void 0?n:u.direction="back"}var _=this.views.length+((r=o===null||o===void 0?void 0:o.length)!==null&&r!==void 0?r:0)-(h!==null&&h!==void 0?h:0);a(_>=0,"final balance can not be negative");if(_===0){console.warn("You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.",this,this.el);throw new Error("navigation stack needs at least one root page")}if(o){var p=e.insertStart;for(var g=0,y=o;g<y.length;g++){var l=y[g];this.insertViewAt(l,p);p++}if(e.enteringRequiresTransition){(s=u.direction)!==null&&s!==void 0?s:u.direction="forward"}}if(c&&c.length>0){for(var k=0,j=c;k<j.length;k++){var l=j[k];d(l.element,m);d(l.element,b);d(l.element,w)}for(var C=0,B=c;C<B.length;C++){var l=B[C];this.destroyView(l)}}};t.prototype.transition=function(t,i,e){return __awaiter(this,void 0,void 0,(function(){var n,r,s,u,o,a,f;var d=this;return __generator(this,(function(l){switch(l.label){case 0:n=e.opts;r=n.progressAnimation?function(t){if(t!==undefined&&!d.gestureOrAnimationInProgress){d.gestureOrAnimationInProgress=true;t.onFinish((function(){d.gestureOrAnimationInProgress=false}),{oneTimeCallback:true});t.progressEnd(0,0,0)}else{d.sbAni=t}}:undefined;s=h(this);u=t.element;o=i&&i.element;a=Object.assign(Object.assign({mode:s,showGoBack:this.canGoBackSync(t),baseEl:this.el,progressCallback:r,animated:this.animated&&c.getBoolean("animated",true),enteringEl:u,leavingEl:o},n),{animationBuilder:n.animationBuilder||this.animation||c.get("navAnimation")});return[4,v(a)];case 1:f=l.sent().hasCompleted;return[2,this.transitionFinish(f,t,i,n)]}}))}))};t.prototype.transitionFinish=function(t,i,e,n){var r=t?i:e;if(r){this.unmountInactiveViews(r)}return{hasCompleted:t,requiresTransition:true,enteringView:i,leavingView:e,direction:n.direction}};t.prototype.insertViewAt=function(t,i){var e=this.views;var n=e.indexOf(t);if(n>-1){a(t.nav===this,"view is not part of the nav");e.splice(n,1);e.splice(i,0,t)}else{a(!t.nav,"nav is used");t.nav=this;e.splice(i,0,t)}};t.prototype.removeView=function(t){a(t.state===g||t.state===y,"view state should be loaded or destroyed");var i=this.views;var e=i.indexOf(t);a(e>-1,"view must be part of the stack");if(e>=0){i.splice(e,1)}};t.prototype.destroyView=function(t){t._destroy();this.removeView(t)};t.prototype.unmountInactiveViews=function(t){if(this.destroyed){return}var i=this.views;var e=i.indexOf(t);for(var n=i.length-1;n>=0;n--){var r=i[n];var s=r.element;if(s){if(n>e){d(s,w);this.destroyView(r)}else if(n<e){l(s,true)}}}};t.prototype.canStart=function(){return!this.gestureOrAnimationInProgress&&!!this.swipeGesture&&!this.isTransitioning&&this.transInstr.length===0&&this.canGoBackSync()};t.prototype.onStart=function(){this.gestureOrAnimationInProgress=true;this.pop({direction:"back",progressAnimation:true})};t.prototype.onMove=function(t){if(this.sbAni){this.sbAni.progressStep(t)}};t.prototype.onEnd=function(t,i,e){var n=this;if(this.sbAni){this.sbAni.onFinish((function(){n.gestureOrAnimationInProgress=false}),{oneTimeCallback:true});var r=t?-.001:.001;if(!t){this.sbAni.easing("cubic-bezier(1, 0, 0.68, 0.28)");r+=o([0,0],[1,0],[.68,.28],[1,1],i)[0]}else{r+=o([0,0],[.32,.72],[0,1],[1,1],i)[0]}this.sbAni.progressEnd(t?1:0,r,e)}else{this.gestureOrAnimationInProgress=false}};t.prototype.render=function(){return r("slot",{key:"71e9b5d07fc90ca5534197a63a003a4154aabd59"})};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});Object.defineProperty(t,"watchers",{get:function(){return{swipeGesture:["swipeGestureChanged"],root:["rootChanged"]}},enumerable:false,configurable:true});return t}());S.style=O;var V=function(t,i,e,n,r){var s=t.closest("ion-nav");if(s){if(i==="forward"){if(e!==undefined){return s.push(e,n,{skipIfBusy:true,animationBuilder:r})}}else if(i==="root"){if(e!==undefined){return s.setRoot(e,n,{skipIfBusy:true,animationBuilder:r})}}else if(i==="back"){return s.pop({skipIfBusy:true,animationBuilder:r})}}return Promise.resolve(false)};var P=t("ion_nav_link",function(){function t(t){var i=this;e(this,t);this.onClick=function(){return V(i.el,i.routerDirection,i.component,i.componentProps,i.routerAnimation)};this.component=undefined;this.componentProps=undefined;this.routerDirection="forward";this.routerAnimation=undefined}t.prototype.render=function(){return r(u,{key:"9ba170d1b10e08e8a6b5e6a30d363871d455a0a9",onClick:this.onClick})};Object.defineProperty(t.prototype,"el",{get:function(){return s(this)},enumerable:false,configurable:true});return t}())}}}));