diff --git a/lib/index.d.ts b/lib/index.d.ts new file mode 100644 index 0000000..6993956 --- /dev/null +++ b/lib/index.d.ts @@ -0,0 +1,70 @@ +declare module 'split-type' { + type SplitTypeOptions = { + absolute: boolean + tagName: string + lineClass: string + wordClass: string + charClass: string + splitClass: string + types: string + split: string + } + + export default class SplitType { + /** + * An array of the split line elements in the splitType instance + */ + lines: HTMLElement[] | null + + /** + * An array of the split word elements in the splitType instance + */ + words: HTMLElement[] | null + + /** + * An array of the split character elements + */ + chars: HTMLElement[] | null + + /** + * Get the default settings for all SplitType calls, or set new ones. + * + * If setting: the value should be object containing specific settings to + * override. The value will be merged with the existing defaults object. + */ + static defaults: Partial + + /** + * Creates a new `SplitType` instance + * + * @param target The target elements to split. can be one of: + * - {string} A css selector + * - {HTMLElement} A single element + * - {ArrayLike} A collection of elements + * - {Array>} A nested array of elements + * @param [options] Settings for the SplitType instance + */ + constructor( + target: + | string + | HTMLElement + | ArrayLike + | Array>, + options?: Partial + ) + + /** + * Splits the text in all target elements. This method is called + * automatically when a new SplitType instance is created. It can also be + * called manually to re-split text with new options. + * @param options + */ + split(options: Partial): void + + /** + * Restores target elements to their original text content. It also clears + * cached data associated with the split text nodes. + */ + revert(): void + } +} diff --git a/package.json b/package.json index 6f9df33..ac7694e 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.2.2", "description": "A javascript library that splits plain text into individual lines, words, and characters.", "main": "dist/index.js", + "types": "lib/index.d.ts", "unpkg": "umd/index.min.js", "files": [ "umd/*.{js,ts}",