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-calendar-value

v1.1.3

Published

A React Package used to show/pick/set values on particular Dates on Calendar

Downloads

5

Readme

React Calendar Value

React Calendar Value is a versatile and customizable calendar component for managing date selections and values in React applications.

DatePicker

DateRangePicker

Installation

You can install the React Calendar Value package using npm or yarn.

Using npm:

npm install react-calendar-value

Using yarn:

yarn add react-calendar-value

Once installed, you can import the component in your React application and start using it.

Usage

Note

The value of the Dates should be in this format only


const data = [
    {"24-02-2024": "56000"},
    {"12-03-2024": "62000"},
    {"03-04-2024": "58000"},
    {"18-04-2024": "54000"},
    {"05-05-2024": "59000"},
    {"19-05-2024": "57000"},
    {"23-05-2024": "55000"},
    {"15-02-2024": "53000"},
    {"07-03-2024": "57000"},
    {"29-03-2024": "60000"},
    {"10-04-2024": "54000"}
];

// Format = {"dd-mm-yyyy" : value};

1. DatePicker

Import the DatePicker use it in your React application:

import React, { useEffect, useState } from "react";
import DatePicker from "react-calendar-value";
import { data } from "./Data";

export default function App() {
  // State variables for managing the visibility of the calendar, selected date, and messages
  let [show, setShow] = useState(false);
  let [selectedDate , SetSelectedDate] = useState(new Date());
  let [messages , setMessages] = useState(null);

  // Update the messages when the selected date changes
  useEffect(() => {
    if(selectedDate){
      setMessages(selectedDate.toLocaleDateString("en-US", {
        weekday: "short",
        year: "numeric",
        month: "short",
        day: "numeric",
      }));
    } else {
      setMessages(null);
    }
  }, [selectedDate]);

  return (
    <div>
      {/* Title */}
      <div>Date Picker</div>
      
      {/* Button to toggle the visibility of the calendar */}
      <button onClick={() => setShow(!show)}>Show Calendar</button>
      
      {/* DatePicker component */}

      <DatePicker

        // Mandatory
        show={show} // Boolean indicating whether to show the calendar
        setShow={setShow} // Function to toggle the visibility of the calendar
        CalenderValues={data} // Array of objects containing date-value pairs for calendar values
        selectedDate={selectedDate} // Currently selected date
        setSelectedDate={SetSelectedDate} // Function to set the selected date
        HeadingMessage={messages} // Message to display as the heading in the calendar
        
        // Optional
        closeWhenClickOutside={false} // Boolean indicating whether to close the calendar when clicking outside of it
        showCloseButton={true} // Boolean indicating whether to show the close button in the calendar
        disableDatesBeforeSelectedDate={false} // Boolean indicating whether to disable dates before the selected date
        numberOfMonthsToShow={3} // Number of months to show in the calendar
        DisableBeforeDates={true} // Boolean indicating whether to disable dates before today
        DisableBeforeMonths={true} // Boolean indicating whether to disable dates before the current month
        showBackgroundDull={true} // Boolean indicating whether to show a dull background when the calendar is open
      />
    </div>
  );
}

2. DateRangePicker

Import the DateRangePicker use it in your React application:

import React, { useEffect, useState } from "react";
import DateRangePicker from "react-calendar-value";

export default function App() {

  // State variables for managing the visibility of the calendar and selected dates
  const [show, setShow] = useState(false);
  const [selectedDate1, setSelectedDate1] = useState(new Date());
  const [selectedDate2, setSelectedDate2] = useState("");

  // Format the selected date for display in the heading message
  const formatSelectedDate = (date) => {
    if (!date) return "";
    const options = { year: "numeric", month: "short", day: "numeric" };
    return date.toLocaleDateString("en-US", options);
  };

  return (
    <div>

      <div>Date Range Picker</div>

      {/* Button to toggle the visibility of the calendar */}
      <button onClick={() => setShow(!show)}>Show Calendar</button>

      {/* DateRangePicker component */}
      <DateRangePicker

        // Mandatory
        show={show} // Boolean indicating whether to show the calendar
        setShow={setShow} // Function to toggle the visibility of the calendar
        selectedDate1={selectedDate1} // Start date of the selected date range
        setSelectedDate1={setSelectedDate1} // Function to set the start date
        selectedDate2={selectedDate2} // End date of the selected date range
        setSelectedDate2={setSelectedDate2} // Function to set the end date
        CalenderValues={data} // Array of objects containing date-value pairs for calendar values

        // Optional
        showCloseButton={true} // Boolean indicating whether to show the close button in the calendar
        closeWhenClickOutside={false} // Boolean indicating whether to close the calendar when clicking outside of it
        disableDatesBeforeSelectedDate={true} // Boolean indicating whether to disable dates before the selected date
        HeadingMessage={`"${formatSelectedDate(selectedDate1) === "" ? '________' : `${formatSelectedDate(selectedDate1)}`}" To "${formatSelectedDate(selectedDate2) === "" ? '________' : `${formatSelectedDate(selectedDate2)}`}"`} // Message to display as the heading in the calendar
        numberOfMonthsToShow={4} // Number of months to show in the calendar
        DisableBeforeDates={true} // Boolean indicating whether to disable dates before today
        DisableBeforeMonths={true} // Boolean indicating whether to disable dates before the current month
        showBackgroundDull={true} // Boolean indicating whether to show a dull background when the calendar is open
      />
    </div>
  );
}

Contributing

Contributions, bug reports, and feature requests are welcome. Feel free to open an issue or submit a pull request on the GitHub repository.

License

This project is licensed under the MIT License.