@nent/core
Version:
43 lines (39 loc) • 1.27 kB
JavaScript
/*!
* NENT 2022
*/
import { r as registerInstance, h, H as Host, a as getElement } from './index-916ca544.js';
const appShareCss = ":host{display:inline-block;cursor:pointer}";
const ContentShare = class {
constructor(hostRef) {
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 (h(Host, { onClick: async () => await this.share() }, h("slot", null)));
}
get el() { return getElement(this); }
};
ContentShare.style = appShareCss;
export { ContentShare as n_app_share };