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.

66 lines (61 loc) 1.88 kB
/*! * NENT 2022 */ import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client'; const appShareCss = ":host{display:inline-block;cursor:pointer}"; const ContentShare = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement { constructor() { super(); this.__registerHost(); this.__attachShadow(); } 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 (h(Host, { onClick: async () => await this.share() }, h("slot", null))); } get el() { return this; } static get style() { return appShareCss; } }, [1, "n-app-share", { "headline": [1], "text": [1], "url": [1025], "share": [64] }]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["n-app-share"]; components.forEach(tagName => { switch (tagName) { case "n-app-share": if (!customElements.get(tagName)) { customElements.define(tagName, ContentShare); } break; } }); } const NAppShare = ContentShare; const defineCustomElement = defineCustomElement$1; export { NAppShare, defineCustomElement };