Giter VIP home page Giter VIP logo

react-ts-timepicker's Introduction

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

Property Type Default value Description
value string / Date / null null The value of the input.
timeFormat string hh:mma moment.js like time format string. See below for more information.
name string timepicker The name of the input.
onChange function () => {} Function called when the user picks a valid time. Type of the value will be the same as value has.
step number 30 Step in minutes between two suggestions.
minTime string / null null Suggestions start time.
maxTime string / null null Suggestions end time. Without this prop suggestions max time equals one day.
includeMax boolean true Whether or not include suggestions max time.
hideOnScroll boolean false Whether or not hide suggestions on window scroll.
allowOnlySuggestions boolean false Allow on suggestions values to be entered to the input. Input value will be rounded to the nearest suggestion.
className string '' Class name of the wrapping div. Can be used for overriding default time picker styles.
inputClass string '' Class name of the input element.
appendTo string / null body Element 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

Input Example Description
H HH 0..23 Hours (24 hour time)
h hh 1..12 Hours (12 hour time used with a A.)
a A am pm Post or ante meridiem (Note the one character a p are also considered valid)
m mm 0..59 Minutes
s ss 0..59 Seconds

License

This project is licensed under the MIT License .

react-ts-timepicker's People

Contributors

0xhyperdust avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

vektornsk

react-ts-timepicker's Issues

Package doesn't contain type definitions

It looks like your build system is not generating typings file, so typescript users that want to install this lib can't really benefit from the fact that this library is written in ts.

image

I can look into that later in some free time - this is probably an easy change.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.