# react-amazing-input

> React-component for control state HTMLInputElement

Latest version **1.1.1** (published 2019-05-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-amazing-input
pnpm add react-amazing-input
yarn add react-amazing-input
bun add react-amazing-input
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2019-05-26 |
| First published | 2019-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 450.7 KB |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| Author | Denis Pupyrev |
| Maintainers | adaptmen |

## Links

- npm: https://www.npmjs.com/package/react-amazing-input
- Repository: https://github.com/adaptmen/react-amazing-input
- npm.io page: https://npm.io/package/react-amazing-input

## Dependencies (8)

- [mobx](https://npm.io/package/mobx.md) ^5.9.4
- [react](https://npm.io/package/react.md) ^16.8.6
- [react-dom](https://npm.io/package/react-dom.md) ^16.8.6
- [mobx-react](https://npm.io/package/mobx-react.md) ^5.4.4
- [@types/react](https://npm.io/package/@types/react.md) ^16.8.18
- [core-decorators](https://npm.io/package/core-decorators.md) ^0.20.0
- [@types/react-dom](https://npm.io/package/@types/react-dom.md) ^16.8.4
- [webpack-dev-server](https://npm.io/package/webpack-dev-server.md) ^3.4.1

## Recent versions

- 1.1.1 (latest) — 2019-05-26
- 1.1.0 — 2019-05-26
- 1.0.10 — 2019-05-26
- 1.0.9 — 2019-05-26
- 1.0.8 — 2019-05-26
- 1.0.7 — 2019-05-26
- 1.0.6 — 2019-05-26
- 1.0.5 — 2019-05-26
- 1.0.4 — 2019-05-26
- 1.0.3 — 2019-05-26
- 1.0.2 — 2019-05-26
- 1.0.1 — 2019-05-25
- 1.0.0 — 2019-05-25

## README

# react-amazing-input

### Installation

```bash
    npm install react-amazing-input
```
or
```bash
    yarn add react-amazing-input
```

### Props

| Name           | Type                          | Description                           | Default    |
| ---------      | --------                      | ------------------------------------- | -------    |
| value?         | string                        | value of input                        | `null`     |
| focused?       | boolean                       | set focus state                       | `null`     |
| hidden?        | boolean                       | set hidden state                      | `null`     |
| hiddenStyle?   | CSSProperties                 | custom style for hidden state         | `null`     |
| style?         | CSSProperties                 | custom style for default              | `null`     |
| className?     | string                        | className for input                   | `null`     |
| onNativeFocus? | () => void                    | handle for onFocus                    | `null`     |
| onNativeBlur?  | () => void                    | handle for onBlur                     | `null`     |
| onInput?       | (inputValue: string) => void  | handle onInput                        | `null`     |
| onChange?      | (evt: any) => void            | handle onChange                       | `() => {}` |
| onTouchStart?  | (evt: any) => void            | handle onTouchStart                   | `null`     |
| onTouchEnd?    | (evt: any) => void            | handle onTouchEnd                     | `null`     |
| onTouchMove?   | (evt: any) => void            | handle onTouchMove                    | `null`     |
| onTouchCancel? | (evt: any) => void            | handle onTouchCancel                  | `null`     |
| onMouseDown?   | (evt: any) => void            | handle onMouseDown                    | `null`     |
| onMouseUp?     | (evt: any) => void            | handle onMouseUp                      | `null`     |
| onMouseMove?   | (evt: any) => void            | handle onMouseMove                    | `null`     |
| onKeyDown?     | (evt: any) => void            | handle onKeyDown                      | `null`     |
| onKeyUp?       | (evt: any) => void            | handle onKeyUp                        | `null`     |
| onKeyPress?    | (evt: any) => void            | handle onKeyPress                     | `null`     |


###Usage

```typescript jsx
import * as React from "react";
import {Component} from "react";
import {autobind} from "core-decorators";

import {Input} from "react-amazing-input";


interface AppState {
  value: string;
  inputFocused: boolean;
  inputHidden: boolean;
  enableControlState: boolean;
}

class App extends Component<{}, AppState> {

  constructor(props) {
    super(props);

    this.state = {
      value: "",
      inputFocused: false,
      inputHidden: false,
      enableControlState: true
    };
  }

  @autobind
  private onInput(str: string) {
    this.setState({value: str});
  }

  @autobind
  private onNativeFocusInput() {
    this.setState({inputFocused: true});
    console.log("Native focus");
  }

  @autobind
  private onNativeBlurInput() {
    this.setState({inputFocused: false});
    console.log("Native blur");
  }

  render() {
    
    const {value, enableControlState, inputHidden, inputFocused} = this.state;
    
    return (
      <div className={"App"}>
        <div>
          <h2>Input value:</h2>
          <h3>{value}</h3>
        </div>
        <Input onNativeFocus={this.onNativeFocusInput}
               onNativeBlur={this.onNativeBlurInput}
               onInput={this.onInput}
               focused={enableControlState ? inputFocused : null}
               hidden={inputHidden}
               value={value}/>
        <button onClick={() => this.setState({inputFocused: !inputFocused})}>Change focus</button>
        <button onClick={() => this.setState({inputHidden: !inputHidden})}>Change hidden</button>
        <button onClick={() => this.setState({value: "123"})}>Change value</button>
        <label>
          <input type='checkbox' checked={enableControlState} onClick={() => this.setState({enableControlState: !enableControlState})} />
          Enable control state
        </label>
      </div>
    );
  }

}
```

---
_Source: https://npm.io/package/react-amazing-input · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
