Options
All
  • Public
  • Public/Protected
  • All
Menu

The chat input, by default, provides a simple text input component. However, an array of IAction interfaces can be provided that can extend the input to provide many types of inputs flows.

The default operation of the input component is to provide a way for the user to enter text and send it. The text is provided to the onInput callback function for processing. The send button can be customised by overriding the SendButtonComponent property, or setting the static Input.SendButtonComponent variable to override it application wide.

Most chat input require more than just text input. The chat input provides an extensible actions interface to allow completely custom input methods to be implemented. Multiple actions can be provided to the input element. All actions must implement a promise that returns some user input. The resolved user input is routed through the same onInput callback function that the text is routed through. This makes it easy to construct control flows for various user inputs. Optionally, the action can provide a React Native component that is rendered instead of the default text input. This allows complete control of the user experience whilst providing input to the chat application.

example
```ts import * as React from 'react'; import { Alert, Text, View } from 'react-native';

import { IInputMutable, InputText, isIInputText as isIInputText } from '@ef-carbon/input'; import { IInputActionImmutable, Input, InputAction, KeyboardSpacer } from '@ef-carbon/react-native-chat';

export interface IProps { }

export class MyComponent extends React.PureComponent { render(): React.ReactNode { * return ; }

private readonly handleInput = async (data: IInputMutable): Promise => { const text = isIInputText(data) ? data.text : 'Unknown...'; return new Promise(resolve => Alert.alert( 'Input', text, [ { text: 'OK', onPress: resolve }, ], { cancelable: false }, )); } } `

Type parameters

  • SS

Hierarchy

Index

Constructors

constructor

Properties

Static Optional SendIconComponent

SendIconComponent: SendIconComponent = undefined

Accessors

actions

disabled

  • get disabled(): boolean

fadeDelay

  • get fadeDelay(): number

fadeDuration

  • get fadeDuration(): number

fadeEasing

  • get fadeEasing(): EasingFunction | undefined

focused

  • get focused(): boolean

placeholder

  • get placeholder(): string

provides

  • get provides(): ReadonlySet<InputType>
  • Determines the inputs that the component can provide. The component can always support text input and extra inputs can be supported by adding actions.

    Returns ReadonlySet<InputType>

Methods

Optional UNSAFE_componentWillMount

  • UNSAFE_componentWillMount(): void

Optional UNSAFE_componentWillReceiveProps

  • UNSAFE_componentWillReceiveProps(nextProps: Readonly<IProps>, nextContext: any): void

Optional UNSAFE_componentWillUpdate

  • UNSAFE_componentWillUpdate(nextProps: Readonly<IProps>, nextState: Readonly<IState>, nextContext: any): void

blur

  • blur(): void

clear

  • clear(): void

Optional componentDidCatch

  • componentDidCatch(error: Error, errorInfo: ErrorInfo): void
  • Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.

    Parameters

    • error: Error
    • errorInfo: ErrorInfo

    Returns void

componentDidMount

  • componentDidMount(): void

componentDidUpdate

  • componentDidUpdate(__namedParameters: object): void
  • Parameters

    • __namedParameters: object
      • next: undefined | Text | Audio | Video | Image | Iterable<Type> | IResponsesOptions

    Returns void

Optional componentWillMount

  • componentWillMount(): void

Optional componentWillReceiveProps

  • componentWillReceiveProps(nextProps: Readonly<IProps>, nextContext: any): void

Optional componentWillUnmount

  • componentWillUnmount(): void
  • Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as cancelled network requests, or cleaning up any DOM elements created in componentDidMount.

    Returns void

Optional componentWillUpdate

  • componentWillUpdate(nextProps: Readonly<IProps>, nextState: Readonly<IState>, nextContext: any): void

focus

  • focus(): void

Optional getSnapshotBeforeUpdate

  • getSnapshotBeforeUpdate(prevProps: Readonly<IProps>, prevState: Readonly<IState>): SS | null
  • Runs before React applies the result of render to the document, and returns an object to be given to componentDidUpdate. Useful for saving things such as scroll position before render causes changes to it.

    Note: the presence of getSnapshotBeforeUpdate prevents any of the deprecated lifecycle events from running.

    Parameters

    Returns SS | null

isDisabled

  • isDisabled(): boolean

isFocused

  • isFocused(): boolean

render

  • render(): React.ReactNode

Optional shouldComponentUpdate

  • shouldComponentUpdate(nextProps: Readonly<IProps>, nextState: Readonly<IState>, nextContext: any): boolean
  • Called to determine whether the change in props and state should trigger a re-render.

    Component always returns true. PureComponent implements a shallow comparison on props and state and returns true if any props or states have changed.

    If false is returned, Component#render, componentWillUpdate and componentDidUpdate will not be called.

    Parameters

    • nextProps: Readonly<IProps>
    • nextState: Readonly<IState>
    • nextContext: any

    Returns boolean