gadgets
Version:
Reusable React UI widgets - This is my widget library. There are many like it, but this one is mine...
66 lines (65 loc) • 2.33 kB
TypeScript
/**
* Generates elements that will be contained within a `List`. This resolved
* to the `<li>` tag. It uses the `Item` shared component.
*
* See the `List` component for screen and example usage.
*
* ## API
* #### Events
* - `onBlur(e: React.FocusEvent<HTMLLIElement>)` - Called when the ListItem
* loses focus.
* - `onClick(e: React.MouseEvent<HTMLLIElement>)` - Invoked when the ListItem
* is clicked by the mouse.
* - `onDoubleClick(e: React.MouseEvent<HTMLLIElement>)` Invoked when the
* ListItem is double clicked by the mouse.
* - `onSelection(title: string)` - When the ListItem is clicked this is also
* invoked to return the title string associated with this ListItem
*
* #### Styles
* - `ui-listitem` - A global style placed on the `<li>` element.
*
* #### Properties
* - `href={selectHandler: nilEvent}` - The parent List component passes this
* object to each child to share parent variables. It contains the following
* fields:
* - `selectHandler {(item: ListItem) => void}` - invoked by the child when
* it is selected to notify the parent that it was selected.
*
* @module ListItem
*/
import * as React from "react";
import { ItemProps, ItemState } from "../item/Item";
import { BaseComponent } from "../shared";
export interface ListItemHREF {
selectHandler: (item: ListItem) => void;
}
export interface ListItemProps extends ItemProps {
href?: ListItemHREF;
onBlur?: (e: React.FocusEvent<HTMLLIElement>) => void;
onClick?: (e: React.MouseEvent<HTMLLIElement>) => void;
onDoubleClick?: (e: React.MouseEvent<HTMLLIElement>) => void;
onSelection?: (title: string) => void;
}
export interface ListItemState extends ItemState {
toggleRipple: boolean;
}
export declare class ListItem extends BaseComponent<ListItemProps, ListItemState> {
static readonly defaultProps: ListItemProps;
private _delay;
private _preventClick;
private _timer;
constructor(props: ListItemProps);
readonly preventClick: boolean;
/**
* When an edit is concluded, this function is called to restore the pre-edit
* state.
*/
private deactivateEdit;
private handleBlur;
private handleClick;
private handleDoubleClick;
private handleKeyDown;
private handleKeyPress;
render(): JSX.Element;
}
export default ListItem;