@types/webscopeio__react-textarea-autocomplete
Advanced tools
Comparing version 4.6.3 to 4.7.0
@@ -1,2 +0,2 @@ | ||
// Type definitions for @webscopeio/react-textarea-autocomplete 4.6 | ||
// Type definitions for @webscopeio/react-textarea-autocomplete 4.7 | ||
// Project: https://github.com/webscopeio/react-textarea-autocomplete | ||
@@ -12,4 +12,6 @@ // Definitions by: Michal Zochowski <https://github.com/michauzo> | ||
export type CaretPositionType = 'start' | 'end' | 'next' | number; | ||
type Component<P extends {}> = React.FunctionComponent<P> | React.ComponentClass<P>; | ||
export type CaretPositionType = "start" | "end" | "next" | number; | ||
export interface TextToReplaceType { | ||
@@ -21,5 +23,3 @@ text: string; | ||
export type DataProviderType<TItem> = (token: string) => | ||
| Promise<TItem[]> | ||
| TItem[]; | ||
export type DataProviderType<TItem> = (token: string) => Promise<TItem[]> | TItem[]; | ||
@@ -36,10 +36,12 @@ export interface ItemComponentProps<TItem> { | ||
/** | ||
* The component for rendering the item in suggestion list. It has selected and entity props provided by React Textarea Autocomplete. | ||
*/ | ||
component: React.SFC<ItemComponentProps<TItem>>; | ||
/** | ||
* Called after each keystroke to get data what the suggestion list should display (array or promise resolving array). | ||
*/ | ||
dataProvider: DataProviderType<TItem>; | ||
/** | ||
* The component for rendering the item in suggestion list. It has selected and entity props provided by React Textarea Autocomplete. | ||
*/ | ||
component: Component<ItemComponentProps<TItem>>; | ||
/** | ||
* Set this to true if you want to provide autocomplete for words (tokens) containing whitespace. | ||
@@ -49,2 +51,3 @@ * @default false | ||
allowWhitespace?: boolean; | ||
/** | ||
@@ -55,2 +58,3 @@ * Show autocomplete only if it's preceded by whitespace. Cannot be combined with allowWhitespace. | ||
afterWhitespace?: boolean; | ||
/** | ||
@@ -76,3 +80,6 @@ * (Optional for string based item. If the item is an object this method is required) This function defines text | ||
export interface TextareaProps<TItem> extends React.TextareaHTMLAttributes<HTMLTextAreaElement> { | ||
export type TextareaProps< | ||
TItem, | ||
CustomTextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> | ||
> = CustomTextAreaProps & { | ||
/** | ||
@@ -82,14 +89,13 @@ * Define triggers and their corresponding behavior. | ||
trigger: TriggerType<TItem>; | ||
/** | ||
* Gets data props which is already fetched (and displayed) suggestion. | ||
*/ | ||
loadingComponent: React.SFC; | ||
loadingComponent: Component<{ data: TItem[] | Promise<TItem[]> }>; | ||
/** | ||
* Listener called every time the textarea's caret position is changed. The listener is called with one attribute - caret position denoted by an integer number. | ||
*/ | ||
onCaretPositionChange?: (pos: number) => void; | ||
/** | ||
* Allows you to get React ref of the underlying textarea. | ||
*/ | ||
innerRef?: (ref: HTMLTextAreaElement) => void; | ||
/** | ||
@@ -100,8 +106,16 @@ * With default implementation it will scroll the dropdown every time when the item gets out of the view. | ||
scrollToItem?: boolean | ((container: HTMLDivElement, item: HTMLDivElement) => void); | ||
/** | ||
* When it's true autocomplete will close when use click outside. | ||
* @default false | ||
* Number of characters that user should type for trigger a suggestion. | ||
* @default 1 | ||
*/ | ||
closeOnClickOutside?: boolean; | ||
minChar?: number; | ||
/** | ||
* Listener called every time the textarea's caret position is changed. | ||
* The listener is called with one attribute - caret position denoted by an integer number. | ||
*/ | ||
onCaretPositionChange?: (pos: number) => void; | ||
/** | ||
* When it's true the textarea will move along with a caret as a user continues to type. | ||
@@ -111,11 +125,34 @@ * @default false | ||
movePopupAsYouType?: boolean; | ||
/** | ||
* Number of characters that user should type for trigger a suggestion. | ||
* @default 1 | ||
* Element which should prevent autocomplete to overflow. Defaults to body. | ||
*/ | ||
minChar?: number; | ||
boundariesElement?: string | HTMLElement; | ||
/** | ||
* What component use for as textarea. Default is textarea. (You can combine this with react-autosize-textarea for instance) | ||
*/ | ||
textAreaComponent?: Component<CustomTextAreaProps> | { component: Component<CustomTextAreaProps>; ref: string }; | ||
/** | ||
* When set to true the autocomplete will be rendered at the end of the <body> | ||
* @default false | ||
*/ | ||
renderToBody?: boolean; | ||
/** | ||
* Callback get called everytime item is highlighted in the list | ||
*/ | ||
onItemHighlighted?: (event: { currentTrigger: string; item: TItem | null }) => void; | ||
/** | ||
* Callback get called everytime item is selected | ||
*/ | ||
onItemSelected?: (event: { currentTrigger: string; item: TItem }) => void; | ||
/** | ||
* Styles of textarea | ||
*/ | ||
style?: React.CSSProperties; | ||
/** | ||
@@ -125,2 +162,3 @@ * Styles of list's wrapper. | ||
listStyle?: React.CSSProperties; | ||
/** | ||
@@ -130,14 +168,18 @@ * Styles of item's wrapper. | ||
itemStyle?: React.CSSProperties; | ||
/** | ||
* Styles of loader's wrapper. | ||
*/ | ||
loaderStyle?: React.CSSProperties; | ||
/** | ||
* Styles of textarea's container. | ||
*/ | ||
containerStyle?: React.CSSProperties; | ||
/** | ||
* Styles of loader's wrapper. | ||
*/ | ||
loaderStyle?: React.CSSProperties; | ||
/** | ||
* Styles of dropdown's wrapper. | ||
*/ | ||
dropdownStyle?: React.CSSProperties; | ||
/** | ||
@@ -147,2 +189,3 @@ * ClassNames of the textarea. | ||
className?: string; | ||
/** | ||
@@ -152,2 +195,3 @@ * ClassNames of the textarea's container. | ||
containerClassName?: string; | ||
/** | ||
@@ -157,2 +201,3 @@ * ClassNames of list's wrapper. | ||
listClassName?: string; | ||
/** | ||
@@ -162,2 +207,3 @@ * ClassNames of item's wrapper. | ||
itemClassName?: string; | ||
/** | ||
@@ -167,2 +213,3 @@ * ClassNames of loader's wrapper. | ||
loaderClassName?: string; | ||
/** | ||
@@ -172,3 +219,3 @@ * ClassNames of dropdown's wrapper. | ||
dropdownClassName?: string; | ||
} | ||
}; | ||
@@ -188,3 +235,6 @@ export interface TextareaState<TItem> { | ||
declare class ReactTextareaAutocomplete<TItem extends string | object> extends React.Component<TextareaProps<TItem>, TextareaState<TItem>> { | ||
declare class ReactTextareaAutocomplete< | ||
TItem extends string | object, | ||
CustomTextAreaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> = React.TextareaHTMLAttributes<HTMLTextAreaElement> | ||
> extends React.Component<TextareaProps<TItem, CustomTextAreaProps>, TextareaState<TItem>> { | ||
/** | ||
@@ -202,3 +252,3 @@ * Gets the current caret position in the textarea. | ||
*/ | ||
getSelectionPosition(): { selectionStart: number, selectionEnd: number }; | ||
getSelectionPosition(): { selectionStart: number; selectionEnd: number }; | ||
/** | ||
@@ -205,0 +255,0 @@ * Returns currently selected word. |
{ | ||
"name": "@types/webscopeio__react-textarea-autocomplete", | ||
"version": "4.6.3", | ||
"version": "4.7.0", | ||
"description": "TypeScript definitions for @webscopeio/react-textarea-autocomplete", | ||
@@ -24,4 +24,4 @@ "license": "MIT", | ||
}, | ||
"typesPublisherContentHash": "dc36a61f78aa5a0ff91de151271275bf347f72c23781ce79cd57ef12a1d7b2be", | ||
"typeScriptVersion": "3.2" | ||
"typesPublisherContentHash": "c4e5b0b5759c76ce030d475c030f45d8fe9eb8840377895e9cae99bf79c7d565", | ||
"typeScriptVersion": "3.5" | ||
} |
@@ -11,3 +11,3 @@ # Installation | ||
### Additional Details | ||
* Last updated: Fri, 25 Sep 2020 23:56:42 GMT | ||
* Last updated: Tue, 30 Mar 2021 13:01:11 GMT | ||
* Dependencies: [@types/react](https://npmjs.com/package/@types/react) | ||
@@ -14,0 +14,0 @@ * Global values: `ReactTextareaAutocomplete` |
9807
200