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

ez-react-date-input

v1.0.1

Published

A ReactJS date input that is NOT a date-picker

Downloads

10

Readme

ez-react-date-input

"It's an input, not a picker!"

...not that I have anything against date pickers, but I just wanted something simple looking that could serve its purpose on small phone screens too. And then I remembered nothing is simple. So if this helps someone else, then awesome.

Usage

npm install --save ez-react-date-input

import {
    DateInput,
    DateInputWithLabel
} from 'ez-react-date-input';

<DateInput
id="myDateInput"
className="myDateInputClass"
invalidColor="#d65151"

value="Aug 22, 2004"
inputFormat="MMM DD, YYYY"
onChange={customHandleChange}
name="myFormName"

outputFormat="YYYY-MM-DD"
formFormat="YYYY-MM-DD"

minYear={2004}
maxYear={2004}

valueOnMount={false}
validateFunc={customValidate}
/>

<DateInputWithLabel 
{/*^Everything from DateInput */}
className=""
id=""
labelText="from"
/>

Important stuff

  • If 'value' is set then onChange must update the source of 'value'. Otherwise, value will overwrite input changes.
  • Default input and output formats are 'YYYY-MM-DD'.
/* onChange will get this object */
{
    value: /*2004-08-22*/,
    isValid: /*true*/,
    name: /*myFormName*/,

    year: /*2005*/,
    month: /*03*/,
    date: /*20*/
}

References

props

<DateInput>

Children classNames are "date-input date", "date-input month", "date-input year", and "hidden-form-value"

  • id - Given to wrapper. (id) + ("-date", "-month", "-year) is given to the inputs for label handling.

  • className - Given to wrapper, appended onto "date-input-wrapper"

  • invalidColor - Must be a css string color value(hex, rgb(), 'orange'). Applied to input font if they're invalid.

  • value - Date value to be parsed, then initialized into inputs

  • onChange - Passed an object on each input change

  • name - Form name for hidden input

The 'format' props take any strings that can be passed into moment.format All default to "YYYY-MM-DD"

  • inputFormat - Format for parsing props.value

  • outputFormat - Format for the returned (results).value into onChange

  • formFormat - Format to store in formInput

  • minYear - Minimum allowed year

  • maxYear - Maximum allowed year

  • valueOnMount - When 'true', the onChange function will be run on component mount. If no value is passed in to set initial date, will default to the present date.

  • validateFunc - Recieves a moment object built from the current state values as final 'isValid' check, before onChange result. Must return true if valid, false if not.

<DateInputWithLabel>
  • ^All the props from DateInput
  • id - Given to container label. Inner input will get (id)+"-input"
  • className - Given to container label, appended to "date-input-label-wrapper ". Inner input will get (className)+"-input"
  • labelText - Placed before the string output.

Default classNames

<DateInput />
  • date-input-wrapper - Main wrapper
Input children classNames
  • date-input date - "date input <input type="text">"
  • date-input month - "month select list <select>"
  • date-input year - "year input <input type="text">"
<DateInputWithLabel>
  • date-input-label-wrapper - Main label wrapper
  • date-output-wrapper - Wraps label text <span> and date output <span>
  • date-label-text - <span> Holding label text
  • date-value-output - <span> With result of date input change

"What's with the 'ez'?"

react-date-input was taken, that's it. No snark intended.