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.

47 lines (41 loc) 1.33 kB
/*! * NENT 2022 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-1829aebc.js'); const appShareCss = ":host{display:inline-block;cursor:pointer}"; const ContentShare = class { constructor(hostRef) { index.registerInstance(this, hostRef); } componentWillLoad() { if (!this.url) { let url = document.location.href; const canonicalElement = document.querySelector('link[rel=canonical]'); if (canonicalElement) { url = canonicalElement.href; } this.url = url; } } /** * Manual share method for more complex scenarios * @param data */ async share(data) { if (navigator === null || navigator === void 0 ? void 0 : navigator.share) { await navigator.share({ title: (data === null || data === void 0 ? void 0 : data.title) || this.headline || document.title, text: (data === null || data === void 0 ? void 0 : data.text) || this.text, url: (data === null || data === void 0 ? void 0 : data.url) || this.url, }); } } render() { return (index.h(index.Host, { onClick: async () => await this.share() }, index.h("slot", null))); } get el() { return index.getElement(this); } }; ContentShare.style = appShareCss; exports.n_app_share = ContentShare;