npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@khrtz/react-time-picker

v1.0.7

Published

React Time Picker

Downloads

3

Readme

react-time-picker

A carefully crafted time picker for React

Install

$ npm install @khrtz/react-time-picker --save

Usage

var TimePicker = require('./src')

var VALUE = '14:00:01'

var onChange = function(value){
    picker.setProps({value: value})
}

var picker = React.render(
    <TimePicker
        value={VALUE}
        onChange={onChange}
    />,
    document.getElementById('content')
)

For uncontrolled behavior, use defaultValue instead of value

The time picker can also be used on touch devices.

Properties

  • value: String - a time value - for controlled behavior
  • defaultValue: String - a time value - for uncontrolled behavior
  • onChange: Function(string) - function to be called on change

Formatting

The time picker can display time in multiple formats. For example, you can show hour, hour & minute, hour & minute & second, and all of these with or without AM/PM.

You can specify a format to decide which parts of the time picker to display

  • format: String - a format that dictates which parts of the time picker are displayed. Valid parts are:

    • H or HH - for hour and double digit hour
    • m or mm - for minute and double digit minute
    • s or ss - for second and double digit second
    • a or A - for meridian display

So you can decide what to display either by specifying a format or just use the appropriate formatting on the value you provide.

Examples

  • If you want to display only hour & minute, specify a value string with hour and minute (eg: 16:03)
  • If you want to display hour, minute & second, specify eg 16:45:21
  • If you want to display AM/PM, specify an hour format that contains AM/PM eg 10:45 PM

Overflowing

By default when minutes/seconds are incremented, and they overflow 59, the next amount is increased. You can also overflow hour to trigger a meridian change by using overflowHourToMeridian.

Increment steps

When time arrows are triggered, values are incremented with a certain amount - called step. The default step value is 1

  • step: Number
  • hourStep: Number - A step for incrementing hours (defaults to null). If not provided, step will be used when incrementing the hour
  • minuteStep: Number - A step for incrementing minutes (defaults to null). If not provided, step will be used when incrementing the minute
  • secondStep: Number - A step for incrementing seconds (defaults to null). If not provided, step will be used when incrementing the second

Styling props

The time picker comes with built-in styles, no dependencies on external css files.

  • style

By default, the timepicker is 200px in width and has padding 10px. You can easily change that:

<TimePicker style={{width: '100%', padding: 5}} />

Styles for time boxes (the div containing the input and the arrows)

  • boxStyle - style to be applied to all boxes (hour, minute, second, meridian)
  • hourStyle
  • minuteStyle
  • secondStyle
  • meridianStyle

Styles for time input fields

  • hourInputStyle
  • minuteInputStyle
  • secondInputStyle
  • meridianInputStyle

Other props

  • inputFactory: Function(props) - you can control how to render the time inputs, by using this function. It will be called with some props for the input:

    • props.timeName: String - the name of the input ('hour', 'minute', etc)
    • props.style - the style for the input
    • props.value
    • props.onChange
    • props.onFocus
    • props.onBlur

    Changing either onChange, onFocus or onBlur of the props passed in to inputFactory is not recommended. If you choose to change those, make sure you know what you're doing or you call the initial functions along with your own logic

  • showArrows: Boolean - decides whether to show arrows or not. Defaults to true

  • arrowStyle - style to be applied to all arrows

  • arrowUpStyle

  • arrowDownStyle

  • arrowOverStyle

  • arrowUpOverStyle

  • arrowDownOverStyle

  • arrowFactory

  • stepDelay: Number - defaults to 60. The amount of milliseconds between amount increments when mouse is down on an arrow

  • stopChangePropagation: Boolean - defaults to true. Stops the propagation of the change event on the inputs contained in the time picker. Needed so your onChange function will not get called multiple times, and with different arguments. Only modify this if you know what you're doing

  • normalizeStyle: Boolean - defaults to true. Uses react-style-normalizer to prefix style names when needed. In this case, all style props are prefixed (style, inputStyle, hourStyle, etc... )

Contributing

Check out the project, cd into it and do

$ npm install
$ npm run dev # to run webpack-dev-server
$ npm run serve # to run a web server to serve your files

Navigate to localhost:9091.

Change the sources in the src directory. When a change is detected, the browser is auto refreshed.

To make a new build, execute npm run build, which refreshes the lib folder (for use with npm) from sources found in src, and also creates a concatenated file for use in the browser (minified version as well).

Roadmap

See Roadmap

Changelog

See Changelog

License

MIT