@exadel/esl
Version:
Exadel Smart Library (ESL) is the lightweight custom elements library that provide a set of super-flexible components
90 lines (89 loc) • 4.56 kB
TypeScript
import { SyntheticEventTarget } from '../../esl-utils/dom/events/target';
import type { PropertyProvider } from '../../esl-utils/misc/functions';
/** The definition of the sharing button */
export interface ESLShareButtonConfig {
/** Name of the share action, which is performed after the button is pressed */
action: string;
/** HTML content of the share icon */
icon?: string;
/**
* URL link (with placeholders) to share. Can contain the following placeholders:
* - `{u}` or `{url}` - URL to share (`shareUrl` property on the {@link ESLShareButton} instance)
* - `{t}` or `{title}` - title to share (`shareTitle` property on the {@link ESLShareButton} instance)
*/
link: string;
/** String identifier of the button (no spaces) */
name: string;
/** Button title */
title: string;
/** Additional params to pass into a button */
additional?: Record<string, any>;
}
/** The definition of share buttons groups (named sets of share buttons) */
export interface ESLShareGroupConfig {
/** Name of the group. The group can be accessed with the `group:` prefix in the component configuration */
name: string;
/** A list of button names separated by space */
list: string;
}
/** Object containing {@link ESLShareButtonConfig} and {@link ESLShareGroupConfig} definitions */
export interface ESLShareConfigInit {
/** List of share buttons configurations */
buttons?: ESLShareButtonConfig[];
/** List of share buttons groups configurations */
groups?: ESLShareGroupConfig[];
}
/** Class for managing share buttons configurations */
export declare class ESLShareConfig extends SyntheticEventTarget {
/** @returns ESLShareConfig shared instance */
static get instance(): ESLShareConfig;
/**
* Updates the configuration with either a {@link ESLShareConfigInit} object or provider function.
* Every button and group specified in the new config will be added to the current configuration.
* @returns ESLShareConfig instance
*/
static set(cfg: ESLShareConfigInit | PropertyProvider<ESLShareConfigInit>): ESLShareConfig;
/**
* Updates the configuration with promise resolved to {@link ESLShareConfigInit} or promise provider function.
* Every button and group specified in the new config will be added to the current configuration.
* @returns Promise<ESLShareConfig> instance
*/
static set(provider: Promise<Partial<ESLShareConfig>> | PropertyProvider<Promise<ESLShareConfigInit>>): Promise<ESLShareConfig>;
/** Updates items configuration from the list with the specified partial config */
static update(query: string, changes: Partial<ESLShareButtonConfig>): ESLShareConfig;
/** Appends single button or group to current configuration */
static append(cfg: ESLShareButtonConfig | ESLShareGroupConfig | ESLShareButtonConfig[] | ESLShareGroupConfig[]): ESLShareConfig;
protected readonly _groups: Map<string, string>;
protected readonly _buttons: Map<string, ESLShareButtonConfig>;
protected constructor();
/** @returns list of all available groups */
get groups(): ESLShareGroupConfig[];
/** @returns list of all available buttons */
get buttons(): ESLShareButtonConfig[];
/** Normalize list string by removing groups and extra whitespaces */
protected resolve(query: string): string[];
/**
* Selects the buttons for the given list and returns their configuration.
* @returns config of buttons
*/
get(query: string): ESLShareButtonConfig[];
/** Clears the configuration */
clear(): ESLShareConfig;
/**
* Gets the group of buttons configuration.
* @returns config of group
*/
getGroup(name: string): ESLShareGroupConfig | undefined;
/**
* Gets the button configuration.
* @returns config of button
*/
getButton(name: string): ESLShareButtonConfig | undefined;
/** Updates the configuration with a {@link ESLShareButtonConfig} or {@link ESLShareGroupConfig} */
protected add(config: ESLShareButtonConfig | ESLShareGroupConfig): void;
/** Updates the configuration with a {@link ESLShareButtonConfig}(s) or {@link ESLShareGroupConfig}(s) */
append(config: ESLShareButtonConfig | ESLShareGroupConfig | ESLShareButtonConfig[] | ESLShareGroupConfig[]): ESLShareConfig;
/** Updates items configuration from the list with the specified partial config */
update(query: string, changes: Partial<ESLShareButtonConfig>): ESLShareConfig;
protected _onUpdate(): void;
}