# react-simple-timefield

> Simple React time input field

Latest version **3.3.1** (published 2023-01-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-simple-timefield
pnpm add react-simple-timefield
yarn add react-simple-timefield
bun add react-simple-timefield
```

## 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 | 3.3.1 |
| Published | 2023-01-26 |
| First published | 2017-08-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 40.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 97 |
| Author | Anton Fisher |
| Maintainers | afschr |
| Keywords | react, time, timefield, timeinput, input |

## Links

- npm: https://www.npmjs.com/package/react-simple-timefield
- Repository: https://github.com/antonfisher/react-simple-timefield
- Homepage: https://github.com/antonfisher/react-simple-timefield#readme
- Issues: https://github.com/antonfisher/react-simple-timefield/issues
- npm.io page: https://npm.io/package/react-simple-timefield

## Dependencies (1)

- [@types/enzyme-adapter-react-16](https://npm.io/package/@types/enzyme-adapter-react-16.md) 1.0.5

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.3.1 (latest) — 2023-01-26
- 3.3.0 — 2023-01-26
- 3.2.5 — 2021-10-13
- 3.2.4 — 2021-10-13
- 3.2.3 — 2020-08-25
- 3.2.1 — 2020-08-25
- 3.2.0 — 2020-08-22
- 3.1.0 — 2020-08-22
- 3.0.0 — 2019-09-29
- 2.0.3 — 2019-04-10
- 2.0.2 — 2019-04-10
- 2.0.1 — 2018-11-23
- 2.0.0 — 2018-02-01
- 1.3.2 — 2017-09-12
- 1.3.1 — 2017-09-11
- … 6 more at https://npm.io/package/react-simple-timefield/versions

## README

# react-simple-timefield

Simple React time input field, check out [demo](https://antonfisher.com/react-simple-timefield/).

[![Build Status](https://travis-ci.org/antonfisher/react-simple-timefield.svg?branch=master)](https://travis-ci.org/antonfisher/react-simple-timefield)
[![Coverage Status](https://coveralls.io/repos/github/antonfisher/react-simple-timefield/badge.svg?branch=master)](https://coveralls.io/github/antonfisher/react-simple-timefield?branch=master)
[![npm](https://img.shields.io/npm/dt/react-simple-timefield.svg?colorB=brightgreen)](https://www.npmjs.com/package/react-simple-timefield)
[![npm](https://img.shields.io/npm/v/react-simple-timefield.svg?colorB=brightgreen)](https://www.npmjs.com/package/react-simple-timefield)
[![GitHub license](https://img.shields.io/github/license/antonfisher/react-simple-timefield.svg)](https://github.com/antonfisher/react-simple-timefield/blob/master/LICENSE)

[![Demo](docs/demo.gif)](https://antonfisher.com/react-simple-timefield/)

## Installation
```bash
npm install --save react-simple-timefield

#for React <16 use: npm install --save react-simple-timefield@1
```

## Usage
```jsx
import TimeField from 'react-simple-timefield';
...
<TimeField
    value={time}                       // {String}   required, format '00:00' or '00:00:00'
    onChange={(event, value) => {...}} // {Function} required
    input={<MyCustomInputElement />}   // {Element}  default: <input type="text" />
    inputRef={(ref) => {...}}          // {Function} input's ref
    colon=":"                          // {String}   default: ":"
    showSeconds                        // {Boolean}  default: false
/>
```

## Real world example
```jsx
import TimeField from 'react-simple-timefield';

class App extends React.Component {
  constructor(...args) {
    super(...args);

    this.state = {
      time: '12:34'
    };

    this.onTimeChange = this.onTimeChange.bind(this);
  }

  onTimeChange(event, time) {
    this.setState({time});
  }

  render() {
    const {time} = this.state;

    return (
      <TimeField value={time} onChange={this.onTimeChange} />
    );
  }
}
```

## Migrate version 2.x to version 3.x

There is a breaking change in version 3.
The `onChange` callback property will be called with two arguments.

```jsx
// Before:
<TimeField onChange={(value) => console.log(value)} />

// After:
<TimeField onChange={(event, value) => console.log(event, value)} />
```

## Contributing

#### Run demo:
For running demo locally, replace:
```javascript
import TimeField from '../';
// to
import TimeField from '../src';
```
in `demo/index.tsx` file.

```bash
# run development mode
cd demo
npm install
npm install --only=dev
npm run dev
```

#### Build:
```bash
npm install
npm install --only=dev
npm test
npm run format
npm run build
```

## License
MIT License. Free use and change.

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