@georapbox/clipboard-copy-element
Version:
A custom element that implements the Clipboard API to copy text content from elements or input values to the clipboard.
98 lines • 3.78 kB
TypeScript
/**
* Represents a value that may be of type T, or null.
*/
export type Nullable<T> = T | null;
/**
* @summary A custom element for copying text to the clipboard.
* @documentation https://github.com/georapbox/clipboard-copy-element#readme
*
* @tagname clipboard-copy - This is the default tag name, unless overridden by the `defineCustomElement` method.
* @extends HTMLElement
*
* @property {string} value - The value to be copied to clipboard.
* @property {string} from - The CSS selector of the element to copy from.
* @property {boolean} disabled - Whether the copy to clipboard button is disabled.
* @property {number} feedbackDuration - The duration for displaying the success or error status.
*
* @attribute {string} value - Reflects the value property.
* @attribute {string} from - Reflects the from property.
* @attribute {boolean} disabled - Reflects the disabled property.
* @attribute {number} feedback-duration - Reflects the feedbackDuration property.
*
* @slot copy - The default slot for the copy button.
* @slot success - The slot for the success status message.
* @slot error - The slot for the error status message.
*
* @csspart button - The button element.
* @csspart button--success - The button element when the copy operation is successful.
* @csspart button--error - The button element when the copy operation fails.
* @csspart button--disabled - The button element when the disabled attribute is set.
*
* @fires clipboard-copy-success - Dispatched when the copy operation is successful.
* @fires clipboard-copy-error - Dispatched when the copy operation fails.
*
* @method defineCustomElement - Static method. Defines a custom element with the given name.
*/
export class ClipboardCopy extends HTMLElement {
static get observedAttributes(): string[];
/**
* Defines a custom element with the given name.
* The name must contain a dash (-).
*
* @param {string} [elementName='clipboard-copy'] - The name of the custom element.
* @example
*
* ClipboardCopy.defineCustomElement('my-clipboard-copy');
*/
static defineCustomElement(elementName?: string | undefined): void;
/**
* Lifecycle method that is called when attributes are changed, added, removed, or replaced.
*
* @param {string} name - The name of the attribute.
* @param {string} oldValue - The old value of the attribute.
* @param {string} newValue - The new value of the attribute.
*/
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
/**
* Lifecycle method that is called when the element is added to the DOM.
*/
connectedCallback(): void;
/**
* Lifecycle method that is called when the element is removed from the DOM.
*/
disconnectedCallback(): void;
set value(value: string);
/**
* The value to be copied to clipboard.
*
* @type {string}
* @attribute value - Reflects the value property.
*/
get value(): string;
set from(value: string);
/**
* The CSS selector of the element to copy from.
*
* @type {string}
* @attribute from - Reflects the from property.
*/
get from(): string;
set disabled(value: boolean);
/**
* Whether the copy to clipboard button is disabled.
*
* @type {boolean}
* @attribute disabled - Reflects the disabled property.
*/
get disabled(): boolean;
set feedbackDuration(value: number);
/**
* The duration for displaying the success or error status.
*
* @type {number}
* @attribute feedback-duration - Reflects the feedbackDuration property.
*/
get feedbackDuration(): number;
#private;
}
//# sourceMappingURL=clipboard-copy.d.ts.map