0.1.2 • Published 5 years ago

react-ts-timepicker v0.1.2

Weekly downloads
36
License
MIT
Repository
-
Last release
5 years ago

React TS Timepicker

npm version dependencies Build Status Coverage Status

This is a lightweight and easy to use time picker without dependencies for React, written in Typescript and thoroughly covered by unit tests.

Demo

https://codesandbox.io/s/52ll738ljk

Installation

Install plugin with npm:

$ npm install react-ts-timepicker

Or yarn:

$ yarn add react-ts-timepicker

Compatibility

React 15.6+

Basic usage

import React, { Component } from 'react';
import TimePicker from 'react-ts-timepicker';

class App extends Component {
  state = {
    value: '10:00',
  }
 
  onChange = value => {
    this.setState({ value })
  }
 
  render() {
    return (
      <div>
        <TimePicker
          onChange={this.onChange}
          value={this.state.value}
        />
      </div>
    );
  }
}

Configuration

PropertyTypeDefault valueDescription
valuestring / Date / nullnullThe value of the input.
timeFormatstringhh:mmamoment.js like time format string. See below for more information.
namestringtimepickerThe name of the input.
onChangefunction() => {}Function called when the user picks a valid time. Type of the value will be the same as value has.
stepnumber30Step in minutes between two suggestions.
minTimestring / nullnullSuggestions start time.
maxTimestring / nullnullSuggestions end time. Without this prop suggestions max time equals one day.
includeMaxbooleantrueWhether or not include suggestions max time.
hideOnScrollbooleanfalseWhether or not hide suggestions on window scroll.
allowOnlySuggestionsbooleanfalseAllow on suggestions values to be entered to the input. Input value will be rounded to the nearest suggestion.
classNamestring''Class name of the wrapping div. Can be used for overriding default time picker styles.
inputClassstring''Class name of the input element.
appendTostring / nullbodyElement where the suggestions are appended. Takes either string to use as a selector or null to append suggestions to time picker wrapper itself.

Time formats

InputExampleDescription
H HH0..23Hours (24 hour time)
h hh1..12Hours (12 hour time used with a A.)
a Aam pmPost or ante meridiem (Note the one character a p are also considered valid)
m mm0..59Minutes
s ss0..59Seconds

License

This project is licensed under the MIT License .

0.1.2

5 years ago

0.1.1

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago