-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jordan Humphreys
committed
Feb 21, 2020
1 parent
53f2577
commit 8948638
Showing
3 changed files
with
47 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,12 @@ | ||
{ | ||
"name": "tribute", | ||
"description": "Native ES6 @mentions", | ||
"version": "4.1.1", | ||
"main": [ | ||
"dist/tribute.js", | ||
"dist/tribute.css" | ||
], | ||
"authors": [ | ||
"Jordan Humphreys <[email protected]>" | ||
], | ||
"version": "4.1.2", | ||
"main": ["dist/tribute.js", "dist/tribute.css"], | ||
"authors": ["Jordan Humphreys <[email protected]>"], | ||
"license": "MIT", | ||
"keywords": [ | ||
"mentions", | ||
"autocomplete", | ||
"fuzzy", | ||
"search" | ||
], | ||
"keywords": ["mentions", "autocomplete", "fuzzy", "search"], | ||
"homepage": "https://github.com/zurb/tribute", | ||
"moduleType": [], | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test" | ||
] | ||
"ignore": ["**/.*", "node_modules", "bower_components", "test"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,94 @@ | ||
// Type definitions for TributeJS v4.1.1 | ||
// Type definitions for TributeJS v4.1.2 | ||
// Project: https://github.com/zurb/tribute | ||
// Definitions by: Jordan Humphreys <https://github.com/mrsweaters/> | ||
|
||
export type TributeItem<T extends {}> = { | ||
index: number | ||
original: T | ||
score: number | ||
string: string | ||
} | ||
index: number; | ||
original: T; | ||
score: number; | ||
string: string; | ||
}; | ||
|
||
export type TributeSearchOpts = { | ||
pre: string | ||
post: string | ||
skip: boolean | ||
} | ||
pre: string; | ||
post: string; | ||
skip: boolean; | ||
}; | ||
|
||
export type TributeCollection<T extends {}> = { | ||
// symbol that starts the lookup | ||
trigger?: string | ||
trigger?: string; | ||
|
||
// element to target for @mentions | ||
iframe?: any | ||
iframe?: any; | ||
|
||
// class added in the flyout menu for active item | ||
selectClass?: string | ||
selectClass?: string; | ||
|
||
// class added in the flyout menu for active item | ||
containerClass?: string | ||
containerClass?: string; | ||
|
||
itemClass?: string | ||
itemClass?: string; | ||
|
||
// function called on select that returns the content to insert | ||
selectTemplate?: (item: TributeItem<T>) => string | ||
selectTemplate?: (item: TributeItem<T>) => string; | ||
|
||
// template for displaying item in menu | ||
menuItemTemplate?: (item: TributeItem<T>) => string | ||
menuItemTemplate?: (item: TributeItem<T>) => string; | ||
|
||
// template for when no match is found (optional), | ||
// If no template is provided, menu is hidden. | ||
noMatchTemplate?: () => string | ||
noMatchTemplate?: () => string; | ||
|
||
// specify an alternative parent container for the menu | ||
menuContainer?: Element | ||
menuContainer?: Element; | ||
|
||
// column to search against in the object (accepts function or string) | ||
lookup?: string | ((item: T, mentionText: string) => string) | ||
lookup?: string | ((item: T, mentionText: string) => string); | ||
|
||
// column that contains the content to insert by default | ||
fillAttr?: string | ||
fillAttr?: string; | ||
|
||
// array of objects to match | ||
values?: Array<T> | ((text: string, cb: (result: Array<T>) => void) => void) | ||
values?: Array<T> | ((text: string, cb: (result: Array<T>) => void) => void); | ||
|
||
// specify whether a space is required before the trigger character | ||
requireLeadingSpace?: boolean | ||
requireLeadingSpace?: boolean; | ||
|
||
// specify whether a space is allowed in the middle of mentions | ||
allowSpaces?: boolean | ||
allowSpaces?: boolean; | ||
|
||
// optionally specify a custom suffix for the replace text | ||
// (defaults to empty space if undefined) | ||
replaceTextSuffix?: string | ||
replaceTextSuffix?: string; | ||
|
||
//specify whether the menu should be positioned | ||
positionMenu?: boolean | ||
positionMenu?: boolean; | ||
|
||
//specify whether to put Tribute in autocomplete mode | ||
autocompleteMode?: boolean | ||
autocompleteMode?: boolean; | ||
|
||
// Customize the elements used to wrap matched strings within the results list | ||
searchOpts?: TributeSearchOpts | ||
} | ||
searchOpts?: TributeSearchOpts; | ||
}; | ||
|
||
export type TributeOptions<T> = TributeCollection<T> | { | ||
// pass an array of config objects | ||
collection: Array<TributeCollection<{ [key: string]: any }>> | ||
} | ||
export type TributeOptions<T> = | ||
| TributeCollection<T> | ||
| { | ||
// pass an array of config objects | ||
collection: Array<TributeCollection<{ [key: string]: any }>>; | ||
}; | ||
|
||
export default class Tribute<T extends {}> { | ||
constructor(options: TributeOptions<T>) | ||
constructor(options: TributeOptions<T>); | ||
|
||
isActive: boolean | ||
isActive: boolean; | ||
|
||
append(index: number, values: Array<T>, replace?: boolean): void | ||
append(index: number, values: Array<T>, replace?: boolean): void; | ||
|
||
appendCurrent(values: Array<T>, replace?: boolean): void | ||
appendCurrent(values: Array<T>, replace?: boolean): void; | ||
|
||
attach(to: Element): void | ||
attach(to: Element): void; | ||
|
||
detach(to: Element): void | ||
detach(to: Element): void; | ||
} |