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

react-custom-date-picker

v1.2.1

Published

React Date Picker, allowing for custom appearance, range picker, and highlighting the week

Downloads

110

Readme

React Custom Date Picker

Build

A simple date picker that is customizable.

Getting Started

Install

npm install react-custom-date-picker --save

or

yarn add react-custom-date-picker

Import

import DatePicker from 'react-custom-date-picker';

Dependencies

  • moment

Usage

This is the minimum requirement for using the react-custom-date-picker

Single Date Picker

import React, { Component } from 'react';
import DatePicker from 'react-custom-date-picker';

class App extends Component {
  state = {
    date: null,
  }

  handleDateChange = (date) => {
    this.setState({ date });
  }

  render() {
    return (
      <DatePicker
        date={this.state.date}
        handleDateChange={this.handleDateChange}
      />
    );
  }
}

export default App;

Custom Theming

import React, { Component } from 'react';
import DatePicker from 'react-custom-date-picker';

class App extends Component {
  state = {
    date: null,
  }

  handleDateChange = (date) => {
    this.setState({ date });
  }

  render() {
    return (
      <DatePicker
        color="#296b3e"
        date={this.state.date}
        errorColor="#c32c27"
        handleDateChange={this.handleDateChange}
        hoverWeek
        inputStyle={{
          borderRadius: 0,
        }}
        lightHeader
      />
    );
  }
}

export default App;

Date Range

import React, { Component } from 'react';
import DatePicker from 'react-custom-date-picker';

class App extends Component {
  state = {
    date: null,
    endDate: null,
  }

  handleDateChange = ([date, endDate]) => {
    this.setState({
      date,
      endDate,
    });
  }

  render() {
    return (
      <DatePicker
        date={this.state.date}
        endDate={this.state.endDate}
        handleDateChange={this.handleDateChange}
        range
      />
    );
  }
}

export default App;

Props

| Prop | Description | Type | Default | Required | | --- | --- | --- | --- | --- | | color | The primary color of the date picker | String | '#46b2e9' | No | | date | The date (or start date if using the 'range' prop) | Date Object | null | Yes | | endDate | The end date if using the 'range' prop | Date Object | null | Yes | | errorColor | The color displayed if date is invalid and using the 'required' prop | String | '#ff0000' | No | | errorMessage | The error message to display if there is an error | String | 'Invalid Date' | No | | forceError | How to generate an error without user blurring the input | Boolean | false | No | | handleDateChange | Used to control value of date (or array of two dates if using 'range' prop) | Function | n/a | Yes | | hoverWeek | Highlights entire week on hover | Boolean | false | No | | inputStyle | All CSS attributes for input DOM element available | Object | {} | No | | keepOpen | Prevent the calendar from closing on selection or outside click | Boolean | false | No | | lightHeader | Use white font for header and selected date (recommend if 'color' prop is a dark color) | Boolean | false | No | | maxDate | Set the max date allowed (as a string 'YYYY-MM-DD') | String | null | No | | minDate | Set the min date allowed (as a string 'YYYY-MM-DD') | String | null | No | | modal | Display the calendar in a modal view (does not work with the prop 'keepOpen') | Boolean | false | No | | placeholder | Placeholder text for input | String | 'Date (MM/DD/YYYY)' | No | | range | Allow user to select start date and end date | Boolean | false | No | | required | Displays error on blur if date is invalid | Boolean | false | No | | startOfWeek | Set the starting day of the week (0 = Sunday, 1 = Monday, etc.) | Number | 0 | No | | width | Set width of datepicker window | Number | 400 | No |