@nent/core
Version:
4 lines • 1.54 kB
JavaScript
/*!
* NENT 2022
*/
import{r as t,h as i,a as s}from"./index-916ca544.js";import{e as a}from"./index-f7016b94.js";import{R as n}from"./interfaces-3b78db83.js";import{s as e,o}from"./state-adf07580.js";import"./index-4bfabbbd.js";const r=class{constructor(i){t(this,i),this.route=null}get parentView(){return this.el.closest("n-view")}get parentViewPrompt(){return this.el.closest("n-view-prompt")}async componentWillLoad(){if(e.router)await this.setupRoute();else{const t=o("router",(async()=>{await this.setupRoute(),t()}))}}async setupRoute(){this.parentViewPrompt?this.setPage(this.parentViewPrompt.route):this.parentView?this.setPage(this.parentView.route):await this.subscribe()}async setPage(t){var i;this.route=await t.getNextRoute(),this.title=await(null===(i=this.route)||void 0===i?void 0:i.resolvePageTitle())}async subscribe(){var t,i;this.matchSubscription=a.on(n.RouteMatchedExact,(async({route:t})=>{await this.setPage(t)})),(null===(t=e.router)||void 0===t?void 0:t.exactRoute)&&await this.setPage(null===(i=e.router)||void 0===i?void 0:i.exactRoute)}render(){var t;const s=this.text||this.title;return i("n-view-link",{"link-class":this.linkClass,path:(null===(t=this.route)||void 0===t?void 0:t.path)||"",title:this.title,"active-class":"none",validate:!0},i("slot",{name:"start"}),s||i("slot",null),i("slot",{name:"end"}))}disconnectedCallback(){var t;null===(t=this.matchSubscription)||void 0===t||t.call(this)}get el(){return s(this)}};r.style="n-view-link-next { display: inline-block; }";export{r as n_view_link_next}