@exadel/esl
Version:
Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components
86 lines (85 loc) • 3.71 kB
TypeScript
import { ESLBaseElement } from '../../esl-base-element/core';
import type { ESLShareBaseAction } from './esl-share-action';
import type { ESLShareButtonConfig } from './esl-share-config';
export type { ESLShareButtonTagShape } from './esl-share-button.shape';
/**
* ESLShareButton
* @author Dmytro Shovchko
*
* ESLShareButton is a custom element to invoke a share actions, defined by {@link ESLShareBaseAction}
*/
export declare class ESLShareButton extends ESLBaseElement {
static is: string;
static observedAttributes: string[];
/** Creates an instance of the ESLShareButton */
static create<T extends typeof ESLShareButton>(this: T, buttonName?: string): InstanceType<T>;
/** Event to dispatch when {@link ESLShareButton} configuration is changed */
SHARE_CHANGED_EVENT: string;
/** Event to dispatch on {@link ESLShareButton} ready state */
SHARE_READY_EVENT: string;
/** Name of share action that occurs after button click */
action: string;
/** Link to share on a social network */
link: string;
/** String social network identifier (no spaces) */
name: string;
/** URL to share (current page URL by default) */
shareUrl: string;
/** Title to share (current document title by default) */
shareTitle: string;
/** Additional params to pass into a button (can be used by share actions) */
additional: Record<string, any>;
/** Marker to render default icon inside button on init */
defaultIcon: boolean;
/** Marker of availability of share button */
unavailable: boolean;
/** @readonly Ready state marker */
readonly ready: boolean;
/** @returns config of button specified by the name attribute */
get config(): ESLShareButtonConfig | undefined;
/** Gets a property from attribute, or from button config if not set attribute */
protected get(name: 'action' | 'link'): string;
protected get(name: 'additional'): Record<string, any>;
/** @returns an instance of {@link ESLShareBaseAction} assigned to the button */
protected get actionInstance(): ESLShareBaseAction | null;
/** @returns name of action assigned to the button */
get shareAction(): string;
/** @returns additional params assigned to the button */
get shareAdditional(): Record<string, any>;
/** @returns link to share on social network */
get shareLink(): string;
/** @returns title to share */
get titleToShare(): string;
/** @returns URL to share */
get urlToShare(): string;
protected attributeChangedCallback(attrName: string, oldVal: string, newVal: string): void;
protected connectedCallback(): void;
/** Initializes the button */
protected init(force?: boolean): void;
/** Sets initial a11y attributes */
protected initA11y(): void;
/** Initializes the button content */
protected initIcon(): void;
/** Does an action to share */
share(): void;
/** Updates on button action change */
protected updateAction(): void;
/** Updates on button name change */
protected updateName(): void;
/** Gets attribute from the element or closest parent,
* returns fallback value in the case when an element with attribute not found */
protected getShareAttr(name: string, fallback: string): string;
protected _onClick(e: MouseEvent): void;
protected _onKeydown(e: KeyboardEvent): void;
protected _onConfigChange(): void;
/** Actions on complete init and ready component */
private onReady;
}
declare global {
export interface ESLLibrary {
ShareButton: typeof ESLShareButton;
}
export interface HTMLElementTagNameMap {
'esl-share-button': ESLShareButton;
}
}