gadgets
Version:
Reusable React UI widgets - This is my widget library. There are many like it, but this one is mine...
65 lines (64 loc) • 2.18 kB
TypeScript
/**
* A multiline text editing component. It is a a contenteditable div. As text
* is added to the component the onUpdate callback is executed to pass the
* contents that have chnaged.
*
* ## Screen:
* <img src="https://github.com/jmquigley/gadgets/blob/master/images/textarea.png" width="80%" />
*
* ## Examples:
*
* ```javascript
* import {TextAra} from "gadgets";
*
* <TextArea
* maxRows={10}
* onUpdate={callback}
* value={initial text}
* />
* ```
*
* ## API
* #### Events
* - `onUpdate(text: string)` - Invoked when the text within the component is changed.
* The current text in the component is passed to the callback.
*
* #### Styles
* - `ui-textarea` - Placed on the `<div>` component that wraps the text component.
*
* #### Properties
* - `rows=5 {number}` - The number of lines displayed within the component.
* - `updateDelay=150 {number}` - The onUpdate function is called when the text is
* updated. This is a debounce delay to rate limit how often this function is
* called when input into the control is fast. The number is milliseconds.
* - `value=null {string}` - a string value that will overwrite the contents of
* the current component.
*
* @module TextArea
*/
import * as React from "react";
import { BaseComponent, BaseProps, BaseState } from "../shared";
export interface TextAreaProps extends BaseProps {
onChange?: (e: React.ChangeEvent<HTMLDivElement>) => void;
onUpdate?: (text: string) => void;
rows?: number;
updateDelay?: number;
value?: string;
}
export interface TextAreaState extends BaseState {
value: string;
}
export declare class TextArea extends BaseComponent<TextAreaProps, TextAreaState> {
static readonly defaultProps: TextAreaProps;
private _container;
private _debounceUpdate;
constructor(props: TextAreaProps);
private handleChange;
private handleRef;
static getDerivedStateFromProps(props: TextAreaProps, state: TextAreaState): any;
componentDidMount(): void;
componentDidUpdate(_prevProps: TextAreaProps, prevState: TextAreaState): void;
private updateContent;
render(): JSX.Element;
}
export default TextArea;