Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add types declaration file #7

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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