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.

71 lines (68 loc) 2.34 kB
/*! * NENT 2022 */ import { r as registerInstance, f as forceUpdate, h, H as Host, a as getElement } from './index-916ca544.js'; import { R as ROUTE_EVENTS } from './interfaces-3b78db83.js'; import { s as state } from './state-adf07580.js'; import './index-4bfabbbd.js'; const ViewNotFound = class { constructor(hostRef) { 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; if (!router) { return; } this.transition = this.transition || (router === null || router === void 0 ? void 0 : router.transition); this.routeChangeStartSubscription = router.eventBus.on(ROUTE_EVENTS.RouteChanged, async () => { forceUpdate(this); await this.setPageTags(router); }); this.routeMatchedSubscription = router.eventBus.on(ROUTE_EVENTS.RouteMatchedExact, async () => { forceUpdate(this); await this.setPageTags(router); }); this.routeFinalizeSubscription = router.eventBus.on(ROUTE_EVENTS.RouteChangeFinish, async () => { await this.setPageTags(router); forceUpdate(this); }); } render() { var _a; const hide = ((_a = state.router) === null || _a === void 0 ? void 0 : _a.hasExactRoute()) || false; return (h(Host, { hidden: hide, class: this.transition }, h("slot", null))); } async componentDidLoad() { await this.setPageTags(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 getElement(this); } }; ViewNotFound.style = ":host { display: block; }"; export { ViewNotFound as n_view_not_found };