UNPKG

@nent/core

Version:

Functional elements to add routing, data-binding, dynamic HTML, declarative actions, audio, video, and so much more. Supercharge static HTML files into web apps without script or builds.

75 lines (70 loc) 2.44 kB
/*! * NENT 2022 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-1829aebc.js'); const interfaces = require('./interfaces-1da33056.js'); const state = require('./state-246c735d.js'); require('./index-96f3ab3f.js'); const ViewNotFound = class { constructor(hostRef) { index.registerInstance(this, hostRef); /** * The title for this view. This is prefixed * before the app title configured in n-views * */ this.pageTitle = 'Not Found'; /** * Header height or offset for scroll-top on this * view. */ this.scrollTopOffset = 0; } async setPageTags(router) { if (router.hasExactRoute()) return; await router.setPageTags({ title: this.pageTitle, robots: 'nofollow', }); router.scrollTo(this.scrollTopOffset); } componentWillLoad() { const { router } = state.state; if (!router) { return; } this.transition = this.transition || (router === null || router === void 0 ? void 0 : router.transition); this.routeChangeStartSubscription = router.eventBus.on(interfaces.ROUTE_EVENTS.RouteChanged, async () => { index.forceUpdate(this); await this.setPageTags(router); }); this.routeMatchedSubscription = router.eventBus.on(interfaces.ROUTE_EVENTS.RouteMatchedExact, async () => { index.forceUpdate(this); await this.setPageTags(router); }); this.routeFinalizeSubscription = router.eventBus.on(interfaces.ROUTE_EVENTS.RouteChangeFinish, async () => { await this.setPageTags(router); index.forceUpdate(this); }); } render() { var _a; const hide = ((_a = state.state.router) === null || _a === void 0 ? void 0 : _a.hasExactRoute()) || false; return (index.h(index.Host, { hidden: hide, class: this.transition }, index.h("slot", null))); } async componentDidLoad() { await this.setPageTags(state.state.router); } disconnectedCallback() { var _a, _b, _c; (_a = this.routeChangeStartSubscription) === null || _a === void 0 ? void 0 : _a.call(this); (_b = this.routeMatchedSubscription) === null || _b === void 0 ? void 0 : _b.call(this); (_c = this.routeFinalizeSubscription) === null || _c === void 0 ? void 0 : _c.call(this); } get el() { return index.getElement(this); } }; ViewNotFound.style = ":host { display: block; }"; exports.n_view_not_found = ViewNotFound;