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

aeht-chakra-dayzed-datepicker

v0.0.7

Published

chakra + dayzed = datepicker

Downloads

77

Readme

A Simple Chakra Datepicker based on Dayzed.

npm version Downloads

Every individual component is using Chakra UI. So it should respect all Chakra UI Configs without problem.

The componenent itself has to use some date library

Highly recommend just copy/paste the source code from /src to customize however you want.

Install the dependency

Npm

npm i date-fns dayzed
npm i chakra-dayzed-datepicker

Yarn:

yarn add date-fns dayzed
yarn add chakra-dayzed-datepicker

Basic usage

Single

  const [date, setDate] = useState(new Date());
  
  <SingleDatepicker
    name="date-input"
    date={date}
    onDateChange={setDate}
  />

Range:

Note that this list will have one value during the selection process. Your system won't work if you try to control this directly as [startDate, endDate] because we'll try to set selectedDates to [intermediateSelection] and the length of the resulting selectedDates is meaningful to the datepicker.

  const [selectedDates, setSelectedDates] = useState<Date[]>([new Date(), new Date()]);
  
  <RangeDatepicker
    selectedDates={selectedDates}
    onDateChange={setSelectedDates}
  />

propsConfigs:

dateNavBtnProps extends from ButtonProps of Chakra-UI This allows you to override the default behavior however your want as long as supported by Chakra-UI.

dayOfMonthBtnProps = {
  defaultBtnProps,
  isInRangeBtnProp,
  selectedBtnProps,
  todayBtnProps
}

dayOfMonthBtnProps allows you to customzie date btn style based on the state. Style precedence: default < isInRange < seleted < today.

popoverCompProps might be useful when you want to setup some simple styles like text color globally

popoverCompProps = {
  popoverContentProps,
  popoverBodyProps
}

Example:

  propsConfigs={{
    dateNavBtnProps: {
      colorScheme: "blue",
      variant: "outline"
    },
    dayOfMonthBtnProps: {
      defaultBtnProps: {
        borderColor: "red.300",
        _hover: {
          background: 'blue.400',
        }
      },
      isInRangeBtnProps: {
        color: "yellow",
      },
      selectedBtnProps: {
        background: "blue.200",
        color: "green",
      },
      todayBtnProps: {
        background: "teal.400",
      }
    },
    inputProps: {
      size: "sm"
    },
    popoverCompProps: {
      popoverContentProps: {
        background: "gray.700",
        color: "white",
      },
    },
  }}

configs:

Non Chakra-related configurations :

  configs={{
    dateFormat: 'yyyy-MM-dd',
    dayNames: 'abcdefg'.split(''), // length of 7
    monthNames: 'ABCDEFGHIJKL'.split(''), // length of 12
    firstDayOfWeek: 2, // default is 0, the dayNames[0], which is Sunday if you don't specify your own dayNames,
  }}

other props:

Name |single/range | Type | Default value | Description ----------------------|--------------|------------------------|-------------------------|-------------- name |both | string | undefined | name attribute for <input /> element usePortal |both | boolean | undefined | to prevent parent styles from clipping or hiding content defaultIsOpen |both | boolean | false | open the date panel at the beginning closeOnSelect |both | boolean | true | close the date panel upon the complete selection minDate |both | Date | undefined | minimum date maxDate |both | Date | undefined | maximum date disabledDates |single | Set | undefined | for single datepicker only, uses startOfDay as comparison, e.g., disabledDates={new Set([startOfDay(new Date()).getTime()}

For version < [email protected]: dayOfMonthBtnProps extends from ButtonProps and has only selectedBg support,

  dayOfMonthBtnProps: {
    borderColor: "red.300",
    selectedBg: "blue.200",
    _hover: {
      bg: 'blue.400',
    }
  },