@tamagui/react-native-web-lite
Version:
React Native for Web
41 lines (40 loc) • 1.21 kB
JavaScript
import { invariant } from "@tamagui/react-native-web-internals";
class Share {
static share(content, options = {}) {
return invariant(
typeof content == "object" && content !== null,
"Content to share must be a valid object"
), invariant(
typeof content.url == "string" || typeof content.message == "string",
"At least one of URL and message is required"
), invariant(
typeof options == "object" && options !== null,
"Options must be a valid object"
), invariant(
!content.title || typeof content.title == "string",
"Invalid title: title should be a string."
), window.navigator.share !== void 0 ? window.navigator.share({
title: content.title,
text: content.message,
url: content.url
}) : Promise.reject(new Error("Share is not supported in this browser"));
}
/**
* The content was successfully shared.
*/
static get sharedAction() {
return "sharedAction";
}
/**
* The dialog has been dismissed.
* @platform ios
*/
static get dismissedAction() {
return "dismissedAction";
}
}
var Share_default = Share;
export {
Share_default as default
};
//# sourceMappingURL=index.js.map