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-select-date

v0.1.2

Published

A React Calendar that consists of between single-date, multiple-date, range and slots booking features

Downloads

405

Readme

react-select-date

A React Calendar that consists of between single-date, multiple-date, range and slots booking features.Purely date calculated from JavaScript Date Object.

Live Demo: https://stoic-shirley-7fca42.netlify.app

Range and Multiple select

Single and Duel slots

Customizable DateField

Getting Started

Installation

Run npm i react-select-date

Usage

SingelDate

import Calendar from "react-select-date";

function MyComponent() {
  return (
      <Calendar 
        onSelect={(date) => console.log(date)}
      />
  );
}

export default MyComponent;

DateRange

import Calendar from "react-select-date";

function MyComponent() {
  return (
      <Calendar 
        onSelect={(date) => console.log(date)}
        selectDateType="range"
        // select-date color
        templateClr="blue"
      />
  );
}

export default MyComponent;

Multiple With DuelSlots

import Calendar from "react-select-date";

function MyComponent() {
  const duelSlotDates = [
      { date: "2021-07-02", totalSlot: "30", avaliableSlot: "4" },
      { date: "2021-07-10", totalSlot: "30", avaliableSlot: "5" },
      { date: "2021-7-15", totalSlot: "280", avaliableSlot: "160" },
      { date: "2021-07-07", totalSlot: "30", avaliableSlot: "14" },
    ]
  return (
      <Calendar
        onSelect={(date) => console.log(date)}
        selectDateType="multiple"
        duelSlotDates={duelSlotDates}
      />
  );
}

export default MyComponent;

Options

Property | type | Default Value | Description -------------------------------------|------------|------------------|----------------------------------------------------------------- selectDateType | String | single | defines the selection type of single,multiple or range onSelect | Func | | callback function for returns the selected date singleSlotDates | *Object[] | [] | defines the avilable slots duelSlotDates | *Object[] | [] | defines the avilable and total slots templateClr | String | green | defines the selecte date color(green or blue) disableCertainDates | *Object[] | [] | disables the specific dates disableDates | String | | disables the past or future dates disableDays | *Object[] | [] | disables the day minDate | String/Date Object | | defines minimum date. Disabled earlier dates maxDate | String/Date Object | | defines maximam date. Disabled later dates slotInfo | Boolean | true | show/hide visibility of slotInfo showDatelabel | Boolean | false | show/hide visibility of label for date input showDateInputField | Boolean | true | show/hide visibility of date input showSelectMonthArrow | Boolean | false | whether month select field can be editable and visibility of arrow showSelectYearArrow | Boolean | false | whether year select field can be editable and visibility of arrow showArrow | Boolean | true | show/hide visibility of left arrow and right arrow

Default value

Property | type | Example | Description -------------------------------------|------------|------------------|----------------------------------------------------------------- defaultValue(Single) | Object | { date: "2021-9-9" } | defines the default value for single select defaultValue(Multiple) | Array | [ "2021-8-15", "2021-08-01", "2021-08-20" ] | defines the default value for multiple select defaultValue(Range) | Object | { startDate: "2021-8-15", endDate: "2021-8-20" } | defines the default value for range select

About Calendar

This Calendar was developed using Hooks and Javascript date object without any dependencies. The calendar has options where users can choose between single-date, multiple-date, range and slots booking features.

Single-Date Select

The single-date selection is a fully controlled component that allows users to select a single date from the calendar table. The user can select the date from date-input after entering the valid date. On click of the Enter button inside the respective field or when focus is moved, it will trigger the selectDate Func. The date-input field will throw an error message if the date is not valid.The slotInfo props shows the colors of selected-Date and disabled-Date.

Multiple-Date Select

The multiple Date selection is a fully controlled component that allows users to select multiple dates. The functionality is same as single-date to select the dates.

DateRange

The dateRange is a fully controlled component that allows users to select a date range. The user can select the date range from either the date-input field or the calendar table. Selected dates can be controlled using onSelect props. The DateRange also manages internal state for partial dates that are manually entered(Although onSelect will not trigger until a date has been filled completely. In that case, date-input field will throw an error message if the date is not valid).

Slots

Slots booking is a fully controlled component that allows users to view the avilable and total slots. In slots booking, the user can change the type of selection through selectDateType props. The user can display only avilable slots by sending singleSlotDates value, In order to view avilable slots and total slots the user needs to send duelSlotDates value(It should be noted that user cannot send both the singleSlotDates and duelSlotDates at the same time).

// example slots values
singleSlotDates = {[ { date: "2021-07-03", avaliableSlot: "7" } ]}
duelSlotDates = {[ { date: "2021-07-02", totalSlot: "30", avaliableSlot: "4" } ]}

Overriding styles

Feel free to override the styles, can customize the calendar styles as you expect.

// Few Example:

// to change the disable number style
.cld_container .cld_disableDate{
  color: red;
}

// to change the selected date style
// if using templateClr = blue replace the "cld_greenHighlight" classname to "cld_blueHighlight"
.cld_container .cld_greenHighlight{
   background-color: #ff8100; 
}

// to change the selected disable date style
.cld_container .cld_disablebgColor{
   color: #ffffff;
   background: #ff9595;
}

// to change the calender background style
#root .cld_container{
  background-color: #fafad2;
}

Author

License

MIT