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

@drskyjs/datepicker

v1.3.1

Published

A lightweight, customizable React datepicker component built with @drskyjs, offering seamless integration with modern React applications.

Downloads

2

Readme

Datepicker Project

The Datepicker component allows users to select a date, built using React and custom hooks to provide full date picking functionality. This component is perfect for integration into forms or user interfaces where precise date input is required.

Prerequisites

This section outlines the necessary tools and environments required to successfully use or contribute to the @drskyjs/datepicker project. Ensure that your development environment meets the following prerequisites: Development Environment

  • Node.js: Version 20.x or newer
  • npm: Version 10.x or newer

Installation

To use the Datepicker component in your project, start by installing it via npm:

npm install @drskyjs/datepicker

Using the Datepicker Component

function MyComponent() {
  const [date, setDate] = useState('');

  const updateDateState = (newDate) => {
    setDate(newDate);
  };

  return (
    <div>
      <Datepicker date={date} updateDateState={updateDateState} placeholder='Select a date' />
    </div>
  );
}

Using a Ref on the Input Element

If you need to attach a ref directly to the input element of the Datepicker, you should use the DatepickerWithRef component with the innerRef prop as follows:

function MyComponent() {
  const [date, setDate] = useState('');
  const inputRef = useRef(null);

  const updateDateState = (newDate) => {
    setDate(newDate);
  };

  return (
    <div>
      <Datepicker
        date={date}
        updateDateState={updateDateState}
        placeholder='Select a date'
        innerRef={inputRef}
      />
    </div>
  );
}

Props

The Datepicker component accepts the following props for customization:

  • date (string): The currently selected date.
  • updateDateState (function): Function to update the date state.
  • Calendar (component, optional): A custom Calendar component to replace the default one.
  • className, id, name, placeholder, pattern, title, required (string, optional): Standard attributes for the date input element.
  • innerRef (ref, optional): Reference to pass to the date input component for direct access.

Customizing the Calendar Component

You can pass a custom Calendar component as a prop to Datepicker. Your custom Calendar component should accept the same props as the default Calendar:

type CalendarProps = {
  date: string;
  onClickNewDate: (newDate: string) => void;
};

Exemple :

function DefaultCalendar({ date, onClickNewDate }: CalendarProps) {
  return (
    <Calendar date={date} onClickNewDate={onClickNewDate}>
      <div className={styles.header}>
        <Calendar.YearSelection />
        <Calendar.MonthSelection />
      </div>
      <Calendar.WeekDayLabels />
      <Calendar.Days />
    </Calendar>
  );
}