@parsonic/share-button
Version:
Native share button web component
47 lines • 1.44 kB
TypeScript
/**
* @tagname share-button
*
* @attr {string} data-url - The URL of the item to share
* @attr {string} data-title - The title of the item to share
* @attr {string} data-text - The text of the share message
* @attr {string} data-share-event-name - Override for the name of the share event
* @attr {string} data-result-event-name - Override for the name of the result event
*
* @slot button - Slot for a custom button element
* @csspart button - Style the default button element
*
* @fires {CustomEvent<ShareData>} share - Event dispatched when the share button is pressed
* @fires {CustomEvent<SuccessResultDetail | ErrorResultDetail>} shareResult - Event dispatched when the share action is completed
*/
export default class ShareButton extends HTMLElement {
/**
* Defines the custom element with provided tag name if `navigator.share` is supported
*/
static register(tag?: string): void;
connectedCallback(): void;
}
export type SuccessResultDetail = {
/**
* - The result of the share action
*/
result: "success";
/**
* - The data being shared
*/
data: ShareData;
};
export type ErrorResultDetail = {
/**
* - The result of the share action
*/
result: "error";
/**
* - The data being shared
*/
data: ShareData;
/**
* - The error that occurred
*/
error: DOMException;
};
//# sourceMappingURL=ShareButton.d.ts.map