Skip to content

Commit

Permalink
docs: add types declaration file (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
geopic authored Nov 16, 2020
1 parent eeb758a commit 4163495
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
70 changes: 70 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -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<SplitTypeOptions>

/**
* 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<HTMLElement>} A collection of elements
* - {Array<HTMLElement | ArrayLike<HTMLElement>>} A nested array of elements
* @param [options] Settings for the SplitType instance
*/
constructor(
target:
| string
| HTMLElement
| ArrayLike<HTMLElement>
| Array<HTMLElement | ArrayLike<HTMLElement>>,
options?: Partial<SplitTypeOptions>
)

/**
* 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<SplitTypeOptions>): void

/**
* Restores target elements to their original text content. It also clears
* cached data associated with the split text nodes.
*/
revert(): void
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}",
Expand Down

0 comments on commit 4163495

Please sign in to comment.